Download MetaTrader 5

Draw rectangle each day

To add comments, please log in or register
SE11XU
7
SE11XU  

I am having trouble getting my EA to draw a rectangle, can you please help.


Objective: At a given time each day draw a rectangle between two set times.

I have written the below code, it executes but the rectangle does not seem to ever draw. suggestions?

void OnTick()
  {
  
  //Only run once a day at london open
  if (thisDay != DayOfYear() && LondonOpen = Hour()) {
      thisDay = DayOfYear();
      
      // Hardcoded for this post only.
      double high = 1.1200;
      double low = 1.1100;
            
      string date = TimeToStr(Time[0],TIME_DATE);
      ObjectCreate(ChartID(), "AsiaSession_" + date, OBJ_RECTANGLE, 0, TimeCurrent() - 50000, high, TimeCurrent(), low);
      ObjectSet("AsiaSession_" + date, OBJPROP_FILL, boxColor);
   }
}
Alain Verleyen
Moderator
31192
Alain Verleyen  
SE11XU:

I am having trouble getting my EA to draw a rectangle, can you please help.


Objective: At a given time each day draw a rectangle between two set times.

I have written the below code, it executes but the rectangle does not seem to ever draw. suggestions?

Check the return value of ObjectCreate() and debug your code.
To add comments, please log in or register