//+------------------------------------------------------------------+ //| xSuperTrend.mq5 | //| Copyright 2020, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2020, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.001" #property indicator_chart_window #property indicator_buffers 3 #property indicator_plots 3 //--- plot UpTrend #property indicator_label1 "UpTrend" #property indicator_type1 DRAW_LINE #property indicator_color1 clrBlue #property indicator_style1 STYLE_SOLID #property indicator_width1 1 //--- plot SuperTrend #property indicator_label2 "SuperTrend" #property indicator_type2 DRAW_LINE #property indicator_color2 clrOrange #property indicator_style2 STYLE_SOLID #property indicator_width2 1 //--- plot DownTrend #property indicator_label3 "DownTrend" #property indicator_type3 DRAW_LINE #property indicator_color3 clrRed #property indicator_style3 STYLE_SOLID #property indicator_width3 1 //--- input parameters input int Inp_ma_period = 10; // Super Trend: averaging period input double Inp_multiplier = 3.0; // Super Trend: multiplier //--- indicator buffers double UpTrendBuffer[]; double SuperTrendBuffer[]; double DownTrendBuffer[]; //--- int handle_iATR; // variable for storing the handle of the iATR indicator //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,UpTrendBuffer,INDICATOR_DATA); SetIndexBuffer(1,SuperTrendBuffer,INDICATOR_DATA); SetIndexBuffer(2,DownTrendBuffer,INDICATOR_DATA); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ 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[]) { //--- //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+