How to show VLine during strategy test

 

In MT4, I can show VLine when doing the strategy test. Now with MT5, seem the ChartWindow does not exist when doing the strategy test, so the VLine cannot be displayed.

    ObjectCreate(0, s, OBJ_VLINE, 0, t, 0);
    ObjectSetInteger(0,s, OBJPROP_COLOR, vcolor);

This does not work during strategy test. Can anyone help me ?


Thanks

Documentation on MQL5: Standard Constants, Enumerations and Structures / Objects Constants / Object Types
  • www.mql5.com
Standard Constants, Enumerations and Structures / Objects Constants / Object Types - Documentation on MQL5
 
Does anybody know?
 
yzhou88:
Does anybody know?

You'll should provide more details in your code (and format as such).

For example, are you Initiating a chart window of your own? Have you tried that? Code will tell. Those 2 lines alone do not describe the context well enough.

 
Lugner:

You'll should provide more details in your code (and format as such).

For example, are you Initiating a chart window of your own? Have you tried that? Code will tell. Those 2 lines alone do not describe the context well enough.

Thank you for your reply. The code goes like this:

void OnInit()

{

       avg_handle = iAMA(_Symbol,_Period,ama_period, ama_fast_period, ama_slow_period, 0,PRICE_WEIGHTED);
             
       long id = ChartID();
       if(id <= 0)
       {
           id = ChartOpen(_Symbol, _Period);
       }
       if(id != 0)

       {

       //--------------the following code does not work during simulation ------------------------

        ObjectCreate(id, "start", OBJ_VLINE, 0, TimeCurrent(), 0);

        ObjectSetInteger(id,"start", OBJPROP_COLOR, Yellow);


           ChartIndicatorAdd(0,0,avg_handle);

           ChartSetInteger(0,CHART_SHOW_PERIOD_SEP,1);

       }

}

Please help. Thanks!