Obtain 'Period' and 'Price' when a line exits off the edge of a chart?

 

Greetings,


  I am new to MQL5 and I am not sure if the following is possible.  If I draw some 'Trend' lines on a chart (using 'ObjectCreate') and have them extend out to the edge of chart boundaries (using ' OBJPROP_RAY_RIGHT') is it possible to obtain the 'TIME PERIOD' AND 'PRICE' for the drawn line at the point where it EXTENDS OFF THE CHART BOUNDARY...?  The drawn lines in question will generally extend off to the Right edge, the Top edge, or the Bottom edge of the chart.

  I seek this information because I need to determine if drawn lines on the chart are 'overlapping' when they exit off the chart edge...and the only way I can think to calculate this information is to somehow get the PERIOD AND PRICE data at the point of exit.

  I have some image examples to illustrate what I mean.  Please note in each image there are 4 drawn lines.  There are 2 Blue lines and 2 Yellow lines.  I consider the lines to be 'overlapping' (at the edge where they exit the chart) when the different colored lines 'lie within' each other.  Therefore if the lines (at the edge where they exit the chart) are not the same color (such as 'blue' followed by 'yellow' OR 'yellow' followed by 'blue') then they 'lie within' each other.  If the line colors (at the edge where they exit the chart) are the same color (such as 'blue' followed by 'blue' OR 'yellow' followed by 'yellow') then they do NOT 'lie within' each other. 

The following images should make this more clear:



  As previously mentioned I do not know of a way to determine this information unless the PERIOD and PRICE information at the point of EXIT off the chart edge can be figured.  Any suggestions GREATLY appreciated.

Documentation on MQL5: Constants, Enumerations and Structures / Indicator Constants / Drawing Styles
Documentation on MQL5: Constants, Enumerations and Structures / Indicator Constants / Drawing Styles
  • www.mql5.com
Drawing Styles - Indicator Constants - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
Files:
within_1.jpg  286 kb
within_2.jpg  290 kb
within_3.jpg  298 kb
without_1.jpg  293 kb
without_2.jpg  297 kb
without_3.jpg  289 kb
without_4.jpg  293 kb
 
pangit68: is it possible to obtain the 'TIME PERIOD' AND 'PRICE' for the drawn line at the point where it EXTENDS OFF THE CHART BOUNDARY...? 
  1. There is no such thing as "TIME_PERIOD". Read the time of bar zero.
  2. Perhaps you should read the manual. ObjectGetValueByTime - Object Functions - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
       How To Ask Questions The Smart Way. (2004)
          How To Interpret Answers.
             RTFM and STFW: How To Tell You've Seriously Screwed Up.

 

Greetings,

  Thank you for your reply.  Perhaps I should have referred to plots along the X and Y axis, with time measured along the horizontal X axis and price along the vertical Y axis.

  I see for any drawn line in a chart all the prices along that line are given by 'hovering' the cursor at any point along the line...is it possible to retrieve these values (the prices along the line) programmatically?

  Not sure why you stated to read the time of bar zero, since for any given drawn line the bar where the line exits the chart is unknown.  I had a look at "ObjectGetValueByTime" previously and that is my issue, how can I supply that command with the proper parameter for 'time' as is required?

 
pangit68 #:   I see for any drawn line in a chart all the prices along that line are given by 'hovering' the cursor at any point along the line...is it possible to retrieve these values (the prices along the line) programmatically?

  Not sure why you stated to read the time of bar zero, since for any given drawn line the bar where the line exits the chart is unknown.  I had a look at “ObjectGetValueByTime" previously and that is my issue, how can I supply that command with the proper parameter for 'time' as is required?

  1. Asked and answered.
  2. The right most bar is bar zero. That is where the line exits the chart.
  3. What part of “read the time of bar zero” was unclear?
 

Thank you for the reply.

Actually a great many, if not most of drawn lines do not exit off the right side of the chart at bar zero.  Many will exit off the top or bottom and do not come close to the right edge.  The images I attached clearly indicate that.  That is why I stated "Not sure why...bar zero".  The time of bar zero is of no use if a line exits off the top or bottom edge at some other bar, correct?

It seems the "ObjectGetValueByTime" function is only useful if I know that 'exit bar'...from what I can understand of it.

I located this post "https://stackoverflow.com/questions/57326973/how-to-get-line-coordinates-on-chart-in-mql5" and will give it a try tomorrow.  However I don't think that will solve my issue since it seems it may only return information for the 2 plots of the drawn line...not where the line exits off the edge.  I am beginning to think it is not possible to get that information where the line exits off the chart edge(s).

How to get line coordinates on chart in MQL5?
How to get line coordinates on chart in MQL5?
  • 2019.08.02
  • Mehrdad Mehrdad 11 2 2 bronze badges
  • stackoverflow.com
I want to get coordinates of begin and end of a trendline(or other type of lines) that user draw on a chart. I use callback function. This function called when user do some changes on chart, like draw a trendline. When user draw a line...
 
pangit68 #: attached clearly indicate that.  That is why I stated "Not sure why...bar zero".  The time of bar zero is of no use if a line exits off the top or bottom edge at some other bar, correct?

No. Reduce the price scale by dragging, the line wax still there, just off-screen.

 

Thank you for your response.

I don't suppose there is some other method that might enable to determine where the lines lie as they leave the chart edge boundaries?  I realize that is unlikely...just a 'stab in the dark'.

 
pangit68 #: I don't suppose there is some other method that might enable to determine where the lines lie as they leave the chart edge boundaries?  I realize that is unlikely...just a 'stab in the dark'.
  1. There are no boundaries top and bottom, just the right edge.
  2. Read the top price, get the time (ObjectGetTimeByValue) where the line reaches it.
              Chart Price Max/Min - MQL4 programming forum (2017)
 

Greetings Mr. Roeder,

  Just wanted to thank you for your earlier suggestions, based upon your input I believe I have this problem solved.  I will continue to do some more testing however I believe it is functioning as I had intended.  Thanks again. 

Reason: