Download MetaTrader 5

OBJ_BUTTON does not work on the Strategy Tester?

To add comments, please log in or register
marcelo marques pereira
101
marcelo marques pereira  

Hi Guys!

I just coded a "Buy button" in my EA using the feature "OBJ_BUTTON"

ObjectCreate(0,aux_Button_name,OBJ_BUTTON,0,xposition,yposition);

and put it into the "OnChartEvent"  for when I click on it, the EA issues an order.. It works on Demo/Live ,  however when I run it over the Strategy Tester it remains pressed and and does not issue any order..

Does anyone know how to make it works  with the Strategy Tester?

 

Many thanks

honest_knave
Moderator
2334
honest_knave  

A workaround I have used in the past is to check the button state each tick:

ObjectGetInteger(0,aux_Button_name,OBJPROP_STATE)

 If it is true, run what ever you need then reset the button state to false using:

ObjectSetInteger(0,aux_Button_name,OBJPROP_STATE,false);

 

You can use IsVisualMode() to avoid unnecessary processing under normal operation.

marcelo marques pereira
101
marcelo marques pereira  
honest_knave:

A workaround I have used in the past is to check the button state each tick:

 If it is true, run what ever you need then reset the button state to false using:

 

You can use IsVisualMode() to avoid unnecessary processing under normal operation.

 

Thank you  honest_knave

thaI did that before and it does work ..howecer it consumes more processor  right? :  ) but it works for sure! : )

Thanks a million for replying my post, and have a nice weekend! 

To add comments, please log in or register