//+------------------------------------------------------------------+ //| SMI_v2.mq4 | //| Copyright © 2005, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //| | //| Modified to use SMI_Helper | //+------------------------------------------------------------------+ #property copyright "Copyright © 2005, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 White #property indicator_color2 Red #property indicator_level1 0 //---- input parameters extern int Period_Q=15; extern int Period_R=50; extern int Period_S=5; extern int Signal=3; extern int method =1; // O MODE_SMA 1 MODE_EMA 2 MODE_SMMA 3 MODE_LWMA //---- buffers double SMI_Buffer[]; double Signal_Buffer[]; double EMA2_SM; double EMA2_HQ; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators // IndicatorBuffers(8); SetIndexStyle(0,DRAW_LINE); SetIndexBuffer(0,SMI_Buffer); SetIndexStyle(1,DRAW_LINE); SetIndexBuffer(1,Signal_Buffer); SetIndexLabel(0,"SMI"); SetIndexLabel(1,"Signal SMI"); IndicatorShortName("SMI("+Period_Q+","+Period_R+","+Period_S+","+Signal+")"); //---- return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- TODO: add your code here //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); int limit; int i; // double Median_Q[]; if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; // limit=Bars-counted_bars; limit=Bars; for (i=limit-Period_R-Period_S-Signal;i>=0;i--) { EMA2_SM = iCustom(NULL,0,"SMI_Helper",Period_Q, Period_R, Period_S, Signal,method,0,i); EMA2_HQ = iCustom(NULL,0,"SMI_Helper",Period_Q, Period_R, Period_S, Signal,method,1,i); SMI_Buffer[i]=100*EMA2_SM/0.5/EMA2_HQ; } for (i=limit;i>=0;i--) { Signal_Buffer[i]=iMAOnArray(SMI_Buffer,0,Signal,0,method,i); } //---- TODO: add your code here //---- return(0); } //+------------------------------------------------------------------+