//+------------------------------------------------------------------+ //| Second Indicator.mq5 | //| Author: Santiago Cruz | //| https://www.mql5.com/en/users/algo-trader/ | //+------------------------------------------------------------------+ #property copyright "Santiago Cruz, AlgoNet Inc." #property link "https://www.mql5.com/en/users/algo-trader/" #property version "1.00" #property indicator_separate_window #property indicator_buffers 8 #property indicator_plots 2 //--- plot TSI_line #property indicator_label1 "TSI main line" #property indicator_type1 DRAW_LINE #property indicator_color1 clrRed #property indicator_style1 STYLE_SOLID #property indicator_width1 3 #property indicator_applied_price PRICE_CLOSE //--- plot TSI_signal line #property indicator_label2 "TSI signal line" #property indicator_type2 DRAW_LINE #property indicator_color2 clrBlue #property indicator_style2 STYLE_DASH #property indicator_width2 1 #include //--- input parameters input int ema1=25; input int ema2=13; //--- input parameters for the signal line input int sMAp = 10; input ENUM_MA_METHOD MAmode = MODE_EMA; //--- indicator buffers double TSI_mlineBuffer[], TSI_slineBuffer[], MomBuffer[], AbsMomBuffer[], EMA_MomBuffer[], EMA_EMAMomBuffer[], EMA_AbsMomBuffer[], EMA_EMAAbsMomBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,TSI_mlineBuffer,INDICATOR_DATA); SetIndexBuffer(1,TSI_slineBuffer,INDICATOR_DATA); SetIndexBuffer(2,MomBuffer,INDICATOR_CALCULATIONS); SetIndexBuffer(3,AbsMomBuffer,INDICATOR_CALCULATIONS); SetIndexBuffer(4,EMA_MomBuffer,INDICATOR_CALCULATIONS); SetIndexBuffer(5,EMA_EMAMomBuffer,INDICATOR_CALCULATIONS); SetIndexBuffer(6,EMA_AbsMomBuffer,INDICATOR_CALCULATIONS); SetIndexBuffer(7,EMA_EMAAbsMomBuffer,INDICATOR_CALCULATIONS); //Bar starting point PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,ema1+ema2-1); PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,ema1+ema2+sMAp); //Set the accuracy of displaying indicator values IndicatorSetInteger(INDICATOR_DIGITS,2); string shortname; StringConcatenate(shortname,"TSI(",ema1,",",ema2,")"); //Set a name to show in the seperate window PlotIndexSetString(0,PLOT_LABEL,shortname); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const int begin, const double &price[]) { //If the size of the rates total is too small ...stop the program if(rates_total