Chart Price Max/Min
Returns the maximal value of the vertical scale of the specified subwindow of the current chart |
||
Returns the minimal value of the vertical scale of the specified subwindow of the current chart |
Chart maximum |
||
Chart minimum |
#define WINDOW_MAIN 0 void GetChartLimits(int&iLeft, int&iRight, double&top, double&bot,int iW=0){ /* MT4 build 445: In the tester (visual mode,) on the first tick, these * routines return left=100, right=37 (depends on default bar scaling.) * This is what the chart looks like when you maximize it while it is * generating the FXT file. On ticks after that, it appears like the * left/right are correct but the hi/lo are one tick behind the displayed * chart. On the start of a new bar, the hi/lo can be off when a recent * extreme drops off but the scale hasn't resized. I tried calling * WindowRedraw() first but that did not change results. I don't know * about live charts. */ top = WindowPriceMax(iW); iLeft = WindowFirstVisibleBar(); bot = WindowPriceMin(iW); iRight = iLeft-WindowBarsPerChart(); if(top-bot < pips2dbl) top = bot+pips2dbl; // Avoid scroll bug / div0 if(iRight < 0) iRight = 0; // Chart is shifted. } // GetChartLimits //////////////////////////////////////////////////////////////////////////////// int iLeft,iRight; double top,bot; GetChartLimits(iLeft, iRight, top, bot);
Pre-build 600 Post-build 600
Hi, thanks for the previous answer. How do we get the maximum and minimum prices of a second chart, not the chart on which the EA is run? E.g.:
long first_chart = ChartID(); long second_chart = ChartOpen("EURUSD", PERIOD_H1); // 1st style of function call for ChartGetDouble() Print(ChartGetDouble(first_chart, CHART_PRICE_MIN), " ", ChartGetDouble(first_chart, CHART_PRICE_MAX)); // prints correct values ChartSetInteger(second_chart,CHART_BRING_TO_TOP,0,true); // doesn't make a difference Print(ChartGetDouble(second_chart, CHART_PRICE_MIN), " ", ChartGetDouble(second_chart, CHART_PRICE_MAX)); // prints 0 0 // 2nd style of function call for ChartGetDouble() double p; Print(ChartGetDouble(second_chart, CHART_PRICE_MAX, 0, p)); Print(p); // prints 1 (successful data retrieval) then 0 // Checking chart IDs Print(first_chart, " ", second_chart); Print(ChartID()); // despite bringing 2nd chart to the top, the 1st chart is still selected
I try to open a second chart and print its maximum and minimum prices but see 0s. I also try the second style of function call but still see a 0. Maybe my call syntax is incorrect?
It feels like the second chart isn't somehow selected, hence my attempt to bring it to the top, but ChartID() remains attached to the first chart.