Calculate the Range where your mouse is.

 

Hi, I have been trying to extract the high and low (found on the bottom of MT4 when your mouse is a bar) to calculate the range of the bar and comment it on the chart itself.


Anyone can point me to the right direction how this can be done?


Thanks & Rgds

Nelson

 
you have to write an indicator which creates text objects with ObjectCreate on every bar.
 

Edit: you can ignore the following. see my last post instead :)


If you want it to display only where you mouse is hovering, then thats not possible. BUT you can:

instead, create a vertical line object that you drag to the bar you want to calculate.

give it a special name. you can have the indicator create(if it isnt already created) this line and a text label object for displaying the info.

then write the indicator to locate that vertical line.

use ObjectGet to get the time of line.

use iBarShift to convert that time to a shift.

then use that shift to do something like: MathAbs(High[shift]-Low[shift])/Point) to get your range.


Finally, display that info by setting it into the text label object.


If you can't handle this, there might be code like this out there already, so maybe search for it in the codebase. If not, ask someone to help you out further.

 

OR,(I just came to my senses), use the ATR indicator, set the Period to 1 and every bars range will be displayed in the Data Window. easy.

No chance of getting it displayed on the chart on mouse over though. But the Data Window is close enough, no?

Reason: