Say you have an indicator with 2 buffers, the 2nd one is calculated on the 1st. The scale of the first is much larger and you're not interested in displaying its values. So you could use #property indicator_maximum but that's not good because the values of the 2nd buffer change if you change the time frame. You could also limit the number of buffers: #property indicator_buffers 2 change that to 1, but that doesn't work because if you change the order of the buffers in SetIndexBuffer, then you it doesn't display anything since the first one needs to be calculated first and the second buffer is calculated on the first. Any other solutions in this particular scenario?
- Indicator not visible in strategy tester
- Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes
- Any rookie question, so as not to clutter up the forum. Professionals, don't pass by. Nowhere without you - 6.
Yes,
use #property indicator_buffers 1
then in the init write IndicatorBuffers(2);
assign a second array to the buffer index.
Note, the first buffer will be drawn, the second not.
here is an example:
#property indicator_separate_window #property indicator_buffers 4 #property indicator_color1 Green #property indicator_color2 Black #property indicator_color3 Blue #property indicator_color4 Red //---- buffers double signal[]; double main[]; double diffup[]; double diffdo[]; double ma[]; double maf[]; int init() { //---- indicators IndicatorBuffers(6); SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,5); SetIndexBuffer(0,signal); SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,3); SetIndexBuffer(1,main); SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,3); SetIndexBuffer(2,diffup); SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID,3); SetIndexBuffer(3,diffdo); SetIndexBuffer(4,ma); SetIndexBuffer(5,maf); //---- return(0); }
2 buffers with different scale, don't draw 1st, but 2nd is calculated on 1st.
Like zzuegg said: don't draw 2nd and the 1st is calculated on the 2nd
WHRoeder:
2 buffers with different scale, don't draw 1st, but 2nd is calculated on 1st.
Like zzuegg said: don't draw 2nd and the 1st is calculated on the 2nd
Thanks guys, that works.

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register