Datetime as anchor points?

 

I am creating a rectangle with the highest and the lowest price session for the period.

I can easily do it with ihigh and ilow for the Y axis (Vertical)

But how can I set up the value datetime for the X axis (horizontal?)

I have studied the script of the example on how to create the rectangle sadly it does not specify how to use time like 7 to 9 pm broker time (x - axis coordinates).

Any advice on how I do it? thanks.

 
toksis :

I am creating a rectangle with the highest and the lowest price session for the period.

I can easily do it with ihigh and ilow for the Y axis (Vertical)

But how can I set up the value datetime for the X axis (horizontal?)

I have studied the script of the example on how to create the rectangle sadly it does not specify how to use time like 7 to 9 pm broker time (x - axis coordinates).

Any advice on how I do it? thanks.

See the help for the OBJ_RECTANGLE graphic object. Pay special attention to the code that creates the rectangle:

//+------------------------------------------------------------------+
//| Create rectangle by the given coordinates                        |
//+------------------------------------------------------------------+
bool RectangleCreate(const long            chart_ID=0,        // chart's ID
                     const string          name="Rectangle",  // rectangle name
                     const int             sub_window=0,      // subwindow index 
                     datetime              time1=0,           // first point time
                     double                price1=0,          // first point price
                     datetime              time2=0,           // second point time
                     double                price2=0,          // second point price
                     const color           clr=clrRed,        // rectangle color
                     const ENUM_LINE_STYLE style=STYLE_SOLID, // style of rectangle lines
                     const int             width=1,           // width of rectangle lines
                     const bool            fill=false,        // filling rectangle with color
                     const bool            back=false,        // in the background
                     const bool            selection=true,    // highlight to move
                     const bool            hidden=true,       // hidden in the object list
                     const long            z_order=0)         // priority for mouse click

the variables 'time1' and 'time2' are the time coordinates.

 
Vladimir Karputov #:

See the help for the OBJ_RECTANGLE graphic object. Pay special attention to the code that creates the rectangle:

the variables 'time1' and 'time2' are the time coordinates.

Yes i know that but what is the value of time1 if time1 is 7:30 pm? How does it look like? how to initialise?
 
toksis # but what is the value of time1 if time1 is 7:30 pm? How does it look like?

A rectangle has two coordinates. Each has a time and a price. Your question is meaningless.

A Human has weight and hight. What does two feet look like?

 
William Roeder #:

A rectangle has two coordinates. Each has a time and a price. Your question is meaningless.

A Human has weight and hight. What does two feet look like?

Maybe you have a sample of how time1 and time2 looks like for time 1 = 7:30  and time2 is 9:00?  Sorry i am new to this....
 

Read here: https://www.mql5.com/en/docs/basis/types/integer/datetime

For example TimeCurrent - (TimeCurrent() % 86400) will give you 00:00 of the current day.

Documentation on MQL5: Language Basics / Data Types / Integer Types / Datetime Type
Documentation on MQL5: Language Basics / Data Types / Integer Types / Datetime Type
  • www.mql5.com
Datetime Type - Integer Types - Data Types - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
toksis # :
Maybe you have a sample of how time1 and time2 looks like for time 1 = 7:30  and time2 is 9:00?  Sorry i am new to this....

Today like a fan or tomorrow I will make such an indicator. The indicator will set two dates. Between these dates, the indicator will draw a rectangle. The rectangle is drawn by the maximum and minimum between these dates.

 
toksis #:
Yes i know that but what is the value of time1 if time1 is 7:30 pm? How does it look like? how to initialise?
It won't be a problem. You can either give it an exact bar time or not, the graphical object won't care.
Exept maybe if the value doesn't exist due to some holiday or similar circumstance, this one I don't know.
 
toksis # :

version "1.000". I must say right away that this version is not optimal. But it's good for an example.

Files:
 
Vladimir Karputov #:

version "1.000". I must say right away that this version is not optimal. But it's good for an example.

this similar to mt4? I am using mt4
 
toksis #:
this similar to mt4? I am using mt4
No.  You are on a forum dedicated to MQL5, you write in one of the main sections - that's why you received an answer to MQL5.  For the old terminal there is a special section (https://www.mql5.com/en/forum/mql4)
Reason: