Using IndexBuffers: how to get arrows above high / below low so that they don't overlap the candle wick

Back to topics list To post a new topic, please log in or register
avatar
6
user3822 2016.07.21 22: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?

avatar
13001
WHRoeder 2016.07.22 03: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.



avatar
6
user3822 2016.07.26 17: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?

avatar
13001
WHRoeder 2016.07.26 18:46 #
 
They are type& (reference) not const type& they are output variables.
Back to topics list  

To add comments, please log in or register