Trying to create a rectangle over different market sessions.

 


Any help would be sighlty appreciated.

void OnStart()



  {
  
    datetime Session_Begins = TimeDay (D'2021.06.07 02:00');
    datetime Session_Ends = TimeDay (D'2021.06.07 11:30');
  
   string OpenTime=TimeToStr(Session_Begins,TIME_SECONDS);
   string CloseTime=TimeToStr(Session_Ends,TIME_SECONDS);
   
   //int LondonHigh=iHighest(_Symbol,_Period,MODE_HIGH,Session_Ends,Session_Begins);   
   //int LondonLow=iLowest(_Symbol,_Period,MODE_LOW,Session_Ends,Session_Begins);     
   
   int LondonHigh=iHighest(_Symbol,_Period,MODE_HIGH,CloseTime,OpenTime);   
   int LondonLow=iLowest(_Symbol,_Period,MODE_LOW,CloseTime,OpenTime);     
   
   
  
   ObjectCreate ("Rectangle", OBJ_RECTANGLE, 0, Time[Session_Begins],High[LondonHigh],Time[Session_Ends],Low[LondonLow]);
   ObjectSetInteger(0,"Rectangle",OBJPROP_COLOR,clrGray);
   ObjectSetInteger(0,"Rectangle",OBJPROP_BACK,true);
 
   
  }
 

Help with what?

State your problem if you want help.

Check the documentation for what iHighest and iLowest returns.

Time[Session_Begins]

Time[Session_Ends]

Time[] needs a bar index

 datetime Session_Begins = TimeDay (D'2021.06.07 02:00');

I don't know what you expect from this????


Please edit your post and use the code button (Alt+S) when pasting code.

EDIT your original post, please do not just post the code correctly in a new post.


Topics concerning MT4 and MQL4 have their own section.

In future please post in the correct section.

I have moved your topic to the MQL4 and Metatrader 4 section.

 
  1. Help you with what? You haven't stated a problem, you stated a want. Show us your attempt (using the CODE button) and state the nature of your problem.
              No free help 2017.04.21

  2. Please edit your (original) post and use the CODE button (Alt-S)! (For large amounts of code, attach it.)
              General rules and best pratices of the Forum. - General - MQL5 programming forum 2019.05.06
              Messages Editor

  3. int LondonHigh=iHighest(_Symbol,_Period,MODE_HIGH,CloseTime,OpenTime);   
    int LondonLow=  iLowest(_Symbol,_Period,MODE_LOW,CloseTime,OpenTime);  

    Perhaps you should read the manual. What are the last two parameters in iHighest vs. what you are passing.
       How To Ask Questions The Smart Way. 2004
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.