PDA

View Full Version : How to get highest and lowest price on the current chart (screen) ?



blaidd drwg
06-17-2014, 01:07 PM
Hi,
how to get highest and lowest price on the current chart (screen) ?
Is there a way to convert time and price on chart to pixels on screen ?

Hassan-HS
06-17-2014, 06:18 PM
Hello,



how to get highest and lowest price on the current chart (screen) ?


You can loop over all bars to know the highest/lowest price, check the following example...




Dim Highest
Highest=GetHigh(0,Clng(1))
for i=1 to bars(0)
if GetHigh(0,Clng(i)) > Highest then
Highest=GetHigh(0,Clng(i))
end if
Next


to know about vtl function please visit this page (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/2567), and you can read this course (http://www.hybrid-solutions.com/VTL%20Course.pdf)that will help you.




Is there a way to convert time and price on chart to pixels on screen ?


No,that is illogical

blaidd drwg
06-17-2014, 10:17 PM
Well, it's not enough.
bars(0) returns (in my case) 463 candles on sceen there are about 200 candles (in my case),
so if I take highest form 0 to bars(0) it's some times out of range (out of screen).
How to find the highest point on screen ?
I mean substitue of WindowPriceMax() from MQL4.

Or better how to write equivalent of mql4:
double top=WindowPriceMax();
double bottom=WindowPriceMin();
datetime left=Time[WindowFirstVisibleBar()];
int right_bound=WindowFirstVisibleBar()-WindowBarsPerChart();

Hassan-HS
06-18-2014, 07:17 AM
Hello,



bars(0) This should return the count of the bars that exist in the current chart, please check the Data Window (http://www.hybrid-solutions.com/support/index.php?/Knowledgebase/Article/View/2368/0/data-window) tab and make sure that you scroll the chart to the last bar, and that you preview the chart that the script attached into.

So you can use the function that i sent it to you in the previous post, i'm sure of that.

Note:

Current Chart: The chart that include this sign.

347