if Price > XAverage( Price, Length ) then
Counter = Counter + 1 else Counter = 0;
if CurrentBar > ConfirmBars and Counter = ConfirmBars then
Buy ( !( "EMACrossLE" ) ) next bar at market;
But the problem is that even if ConfirmBars=0 and Price > XAverage, the code doesnt trigger the Buy Order. It only triggers if the market crosses under and over the XAverage..(?).
It was supposed to trigger the order once the two conditions were filled: Price>XAverage and Counter=ConfirmBars , but it only triggers if Price crosses up the XAverage.
Can you help answer these questions from other members on futures io?
first of all it would be useful to see the code completely,
I suppose Price, Length and ConfirmBars are inputs and counter is a variable.
In this case setting ConfirmBars to 0 should never trigger the buy signal,
it should be set to 1 as minimum...
I believe I found the problem. I just add "=" to the condition if CurrentBar >= ConfirmBars, and now it works accordingly:
if Price > XAverage( Price, Length ) then
Counter = Counter + 1 else Counter = 0;
if CurrentBar >= ConfirmBars and Counter = ConfirmBars then
Buy ( !( "EMACrossLE" ) ) next bar at market;