//+------------------------------------------------------------------+ //| SMI Color.mq4 | //| Copyright © 2005, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #property copyright "Copyright © 2005, MetaQuotes Software Corp." #property link "http://www.metaquotes.net" #property indicator_separate_window #property indicator_buffers 3 #property indicator_color1 Yellow #property indicator_color2 Green #property indicator_color3 Red #property indicator_width1 2 #property indicator_width2 2 #property indicator_width3 2 #property indicator_level1 0 #property indicator_level2 60 #property indicator_level3 -60 //---- input parameters extern int Period_Q =10; extern int Period_R =3; 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_BufferFLAT[]; double SMI_BufferUP[]; double SMI_BufferDOWN[]; double SMI_Buffer[]; double EMA2_SM; double EMA2_HQ; // double EMA_HQ[]; // double EMA_SM[]; // double SM_Buffer[]; // double HQ_Buffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators IndicatorBuffers(4); IndicatorDigits(Digits + 1); //---- drawing settings SetIndexBuffer(0,SMI_BufferFLAT); // FLAT SMI SetIndexBuffer(1,SMI_BufferUP); // UP SMI SetIndexBuffer(2,SMI_BufferDOWN); // DOWN SMI // line => dot changes /* SetIndexStyle(0,DRAW_LINE,STYLE_SOLID); SetIndexStyle(1,DRAW_LINE,STYLE_SOLID); SetIndexStyle(2,DRAW_LINE,STYLE_SOLID); */ SetIndexStyle(0,DRAW_ARROW); SetIndexStyle(1,DRAW_ARROW); SetIndexStyle(2,DRAW_ARROW); SetIndexArrow(0,159); SetIndexArrow(1,159); SetIndexArrow(2,159); //---- //---- SetIndexBuffer(3,SMI_Buffer); //---- name for DataWindow and indicator subwindow label IndicatorShortName("SMI("+Period_Q+","+Period_R+","+Period_S+","+Signal+")"); SetIndexLabel(0,"SMI_FLAT"); SetIndexLabel(1,"SMI_UP"); SetIndexLabel(2,"SMI_DOWN"); //---- initialization done 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-Period_Q-counted_bars; limit=Bars-Period_Q; for (i=limit-Period_R-Period_S;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); // Color Handling if(SMI_Buffer[i+1] > SMI_Buffer[i]) { SMI_BufferUP[i] = EMPTY_VALUE ; SMI_BufferFLAT[i] = EMPTY_VALUE ; SMI_BufferDOWN[i] = SMI_Buffer[i] ; } else if(SMI_Buffer[i+1] < SMI_Buffer[i]) { SMI_BufferDOWN[i] = EMPTY_VALUE ; SMI_BufferFLAT[i] = EMPTY_VALUE ; SMI_BufferUP[i] = SMI_Buffer[i] ; } else { SMI_BufferUP[i] = EMPTY_VALUE ; SMI_BufferDOWN[i] = EMPTY_VALUE ; SMI_BufferFLAT[i] = SMI_Buffer[i] ; } } //---- TODO: add your code here //---- return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Indicator Curves created:
Implements a curve of type DRAW_LINE
Implements a curve of type DRAW_ARROW
Indicators Used:
Custom Indicators Used:
SMI_Helper
Order Management characteristics:
Other Features: