Your properties at the top are confused and other properties missing. Buffers for indicator calculations should always come last after plotting buffer types.
try this:
#property indicator_chart_window #property indicator_buffers 9 #property indicator_plots 3 #property indicator_label1 "SuperTrend" #property indicator_type1 DRAW_COLOR_LINE #property indicator_color1 clrGreen, clrRed #property indicator_width1 3 #property indicator_label2 "Above line" #property indicator_type2 DRAW_LINE #property indicator_color2 clrSkyBlue #property indicator_style2 STYLE_DOT #property indicator_width2 1 #property indicator_label3 "Below line" #property indicator_type3 DRAW_LINE #property indicator_color3 clrYellow #property indicator_style3 STYLE_DOT #property indicator_width3 1 input int Periode=10; input double Multiplier=3; input int AboveLine=100; input int BelowLine=100; input bool Show_Filling=false; // Show as DRAW_FILLING double Filled_a[]; double Filled_b[]; double SuperTrend[]; double ColorBuffer[]; double Atr[]; double Up[]; double Down[]; double Middle[]; double trend[]; double AboveLineBuffer[]; double BelowLineBuffer[]; double ST_UpBuffer[]; double ST_DownBuffer[]; int atrHandle; int OnInit() { SetIndexBuffer(0, SuperTrend, INDICATOR_DATA); SetIndexBuffer(1, ColorBuffer, INDICATOR_COLOR_INDEX); SetIndexBuffer(2, AboveLineBuffer, INDICATOR_DATA); SetIndexBuffer(3, BelowLineBuffer, INDICATOR_DATA); SetIndexBuffer(4, Atr, INDICATOR_CALCULATIONS); SetIndexBuffer(5, Up, INDICATOR_CALCULATIONS); SetIndexBuffer(6, Down, INDICATOR_CALCULATIONS); SetIndexBuffer(7, Middle, INDICATOR_CALCULATIONS); SetIndexBuffer(8, trend, INDICATOR_CALCULATIONS); atrHandle = iATR(_Symbol, _Period, Periode); IndicatorSetInteger(INDICATOR_DIGITS, _Digits); return INIT_SUCCEEDED; } int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time[], const double &open[], const double &high[], const double &low[], const double &close[], const long &tick_volume[], const long &volume[], const int &spread[]) { if (rates_total <= 0) return 0; int to_copy = (prev_calculated > rates_total || prev_calculated < 0) ? rates_total : rates_total - prev_calculated + 1; if (IsStopped()) return 0; if (CopyBuffer(atrHandle, 0, 0, to_copy, Atr) <= 0) { Print("Getting ATR failed! Error", GetLastError()); return 0; } int first = (prev_calculated == 0) ? Periode : prev_calculated - 1; for (int i = first; i < rates_total; i++) { if (IsStopped()) break; if (i < Periode) continue; // Prevent access before enough data Middle[i] = (high[i] + low[i]) / 2; Up[i] = Middle[i] + (Multiplier * Atr[i]); Down[i] = Middle[i] - (Multiplier * Atr[i]); if (i > 0) { if (close[i] > Up[i - 1]) trend[i] = 1; else if (close[i] < Down[i - 1]) trend[i] = -1; else trend[i] = trend[i - 1]; } else { trend[i] = 1; } if (trend[i] > 0 && Down[i] < Down[i - 1]) Down[i] = Down[i - 1]; if (trend[i] < 0 && Up[i] > Up[i - 1]) Up[i] = Up[i - 1]; SuperTrend[i] = (trend[i] > 0) ? Down[i] : Up[i]; ColorBuffer[i] = (trend[i] > 0) ? 0.0 : 1.0; double pointValue = _Point; AboveLineBuffer[i] = SuperTrend[i] + (AboveLine * pointValue); BelowLineBuffer[i] = SuperTrend[i] - (BelowLine * pointValue); } ChartRedraw(); return rates_total; }
this accounts for 2 buffers and 1 plot:
SetIndexBuffer(0, SuperTrend, INDICATOR_DATA); SetIndexBuffer(1, ColorBuffer, INDICATOR_COLOR_INDEX);
this accounts for 1 buffer and 1 plot:
SetIndexBuffer(2, AboveLineBuffer, INDICATOR_DATA);
this accounts for 1 buffer and 1 plot:
SetIndexBuffer(3, BelowLineBuffer, INDICATOR_DATA);
this adds 5 more buffers:
SetIndexBuffer(4, Atr, INDICATOR_CALCULATIONS); SetIndexBuffer(5, Up, INDICATOR_CALCULATIONS); SetIndexBuffer(6, Down, INDICATOR_CALCULATIONS); SetIndexBuffer(7, Middle, INDICATOR_CALCULATIONS); SetIndexBuffer(8, trend, INDICATOR_CALCULATIONS);
so you have 9 buffers and 3 plots in total

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
The supertrend indicator is supposed to plot lines certain points/pips above and below the supertrend signal.
Working Supertrend indicator and Daily Open (Indicator that plots lines certain points/pips above and below the daily open.) indicator files attached.
I was hoping to apply the line plotting function to supertrend signal instead of daily open.
Working Supertrend and Daily Open indicators attached.