Simple expected result with ea tester did not show up

 

Hi,



I try to understand MQL4 and the working of the tester. I have some simple code which I expected to draw (lots of) arrows on the chart. But it only draws one arrow. Maybe I do not know how the tester activates the start() routine or the code is not correct.



The code to draw up arrows:

int start()
{
//----
int arrowCounter;
if((High[1] > High[2]) && (Low[1]>Low[2]))
{
ObjectCreate("Up "+arrowCounter, OBJ_ARROW, 0, Time[1],Low[1]- 10 * Point);
ObjectSet("Up "+arrowCounter, OBJPROP_ARROWCODE, 241);
ObjectSet("Up "+arrowCounter, OBJPROP_COLOR, Green);
arrowCounter++;
}

//----
return(0);
}



This is the only code I added after running the wizard.



What should I do to make it draw an up arrow after each if ((High[1] > High[2]) && (Low[1]>Low[2])) for a new bar is valid?



Thanks for any help

 

Using the code that you show, arrowCounter is always initialized to 0 after start() and then incremented to 1.

All chart objects must have a unique name.

 
phy:

Using the code that you show, arrowCounter is always initialized to 0 after start() and then incremented to 1.

All chart objects must have a unique name.

Thanks phy, your remark led me to define the arrowCounter as static int arrowcounter. Now it works.

 
Very good.
Reason: