Download MetaTrader 5
To add comments, please log in or register
Interested in the Market activity? Come and track!
user3822
22
user3822 2016.07.21 20:00 

Hi everyone,

I just finished learning how to use IndexBuffers and made my first indicator. However, there's one slight annoyance: the arrows drawn overlap the candle's high/low. I would like it so that for an arrow at the low, to have spacing between the low and the arrow, and for the arrow at the high, to have spacing between the high and the arrow.

Can someone please advise as to how to best go about this? Or would I have to use a crude method, such as adding / subtracting pips?

whroeder1
13596
whroeder1 2016.07.22 01:27  
The amount you'd have to add depends the scale of the chart.
  1. Add 1% of the chart using
                                                             #define WINDOW_MAIN 0
    void     GetChartLimits(int&iLeft, int&iRight, double&top, double&bot,int iW=0){
       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.
    }
    
  2. Convert 10 pixels to pips via ChartXYToTimePrice - Chart Operations - MQL4 Reference and add that.
user3822
22
user3822 2016.07.26 15:31  
WHRoeder:
The amount you'd have to add depends the scale of the chart.
  1. Add 1% of the chart using
  2. Convert 10 pixels to pips via ChartXYToTimePrice - Chart Operations - MQL4 Reference and add that.



So I've been reading this and it has me bugged, but I think I get it now.

When I call for the GetChartLimits function, I didn't know where I'd get values to input into the function. But after reading more closely, it seems that the values don't matter (i.e., they can be 0 for the int and 0.0 for the double) because the proper values are converted within the function (i.e., top = WindowPriceMax(iW);).

Am I correct in my statement?

whroeder1
13596
whroeder1 2016.07.26 16:46  
They are type& (reference) not const type& they are output variables.
/
To add comments, please log in or register