//+------------------------------------------------------------------+ //| Mrs V traffic lights 04 with filters and configurable ema.mq4 | //| | //| | //+------------------------------------------------------------------+ //mod //#property copyright "Wolfe" //#property link "xxxxwolfe@gmail.com" #property indicator_separate_window #property indicator_minimum 7 #property indicator_maximum 100 #property indicator_buffers 4 #property indicator_color3 DodgerBlue #property indicator_color4 Tomato #property indicator_width1 2 #property indicator_width2 2 #property indicator_width3 4 #property indicator_width4 4 //extern int RSI_Timeframe=0;//0=current chart,1=m1,5=m5,15=m15,30=m30,60=h1,240=h4,etc... //extern int RSI_Period = 8; //extern int RSI_Applied_Price = 0;//0=close, 1=open, 2=high, 3=low, 4=(high+low)/2, 5=(high+low+close)/3, 6=(high+low+close+close)/4 //extern int MA1_Period = 8; //extern int MA1_Method = 0;// 0=SMA, 1=EMA, 2=SMMA, 3=LWMA extern int fast_ema=5; extern int fast_ema_shift = 3; extern int slow_ema = 34; extern int Line_width = 4; extern int Line_height1 = 60; extern int Line_height2 = 3; extern int Line_height3 = 60; extern int Line_height4 = 2; extern string note1 = "choose only 1 of the following options"; extern bool All_signals = true; extern bool Five_shift_and_34cross =false; extern bool PAaboveFive_shift_and_34 =false; extern bool PAaboveOnly_34 = false; extern bool PAaboveOnly_5_shift = false; double MA1_Array[],RSI[]; double SignalUp[]; double SignalDown[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators setting SetIndexBuffer(0,RSI); SetIndexStyle(0,DRAW_NONE,STYLE_SOLID,2); IndicatorShortName("MrsV TL 04"); // string short_name = ""; // IndicatorShortName(short_name); IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)-4); SetIndexBuffer(1,MA1_Array); SetIndexStyle(1,DRAW_NONE,STYLE_SOLID,2); SetIndexBuffer(2,SignalUp); SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,Line_width); SetIndexBuffer(3,SignalDown); SetIndexStyle(3,DRAW_HISTOGRAM,STYLE_SOLID,Line_width); return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); if(counted_bars<0) return(-1); if(counted_bars>0) counted_bars--; int limit=Bars-counted_bars; //int limit = Bars - IndicatorCounted() - 1; //---- indicator calculation for(int i=limit; i>=0; i--) { RSI[i]= iRSI(NULL,0,8,0,i); } for(i=limit; i>=0; i--) { MA1_Array[i] = iMAOnArray(RSI,0,8,0,0,i); } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //=================FOR ALL SIGNALS OPTION====================== if(All_signals == true) { //======= going long===================== for(i=limit; i>=0; i--) if ( (iMACD(NULL,0,12,26,1,0,0,i)>iMACD(NULL,0,12,26,1,0,0,i+1)) && (iStochastic(NULL,0,5,3,3,0,0,0,i) > iStochastic(NULL,0,5,3,3,0,0,1,i)) && iRSI(NULL,0,8,0,i) > iMAOnArray(RSI,0,8,0,0,i) // && // iMA(NULL,0,slow_ema,0,1,0,i) < iMA(NULL,0,fast_ema,fast_ema_shift,1,0,i) // && // Close[i]>iMA(NULL,0,fast_ema,fast_ema_shift,1,0,i) ) SignalUp[i]=Line_height1; else SignalUp[i]=Line_height2; //======= going short===================== for(i=limit; i>=0; i--) if ( (iMACD(NULL,0,12,26,1,0,0,i)<iMACD(NULL,0,12,26,1,0,0,i+1)) && (iStochastic(NULL,0,5,3,3,0,0,0,i) < iStochastic(NULL,0,5,3,3,0,0,1,i)) && iRSI(NULL,0,8,0,i) < iMAOnArray(RSI,0,8,0,0,i) // && // iMA(NULL,0,slow_ema,0,1,0,i) > iMA(NULL,0,fast_ema,fast_ema_shift,1,0,i) // && // Close[i]<iMA(NULL,0,fast_ema,fast_ema_shift,1,0,i) ) SignalDown[i]=Line_height3; else SignalDown[i]=Line_height4; } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //=================FOR PAaboveFive_shift_and_34 OPTION====================== if(PAaboveFive_shift_and_34 == true) { //======= going long===================== for(i=limit; i>=0; i--) if ( (iMACD(NULL,0,12,26,1,0,0,i)>iMACD(NULL,0,12,26,1,0,0,i+1)) && (iStochastic(NULL,0,5,3,3,0,0,0,i) > iStochastic(NULL,0,5,3,3,0,0,1,i)) && iRSI(NULL,0,8,0,i) > iMAOnArray(RSI,0,8,0,0,i) // && // iMA(NULL,0,slow_ema,0,1,0,i) < iMA(NULL,0,fast_ema,fast_ema_shift,1,0,i) && Close[i]>iMA(NULL,0,fast_ema,fast_ema_shift,1,0,i) && Close[i]>iMA(NULL,0,slow_ema,0,1,0,i) ) SignalUp[i]=Line_height1; else SignalUp[i]=Line_height2; //======= going short===================== for(i=limit; i>=0; i--) if ( (iMACD(NULL,0,12,26,1,0,0,i)<iMACD(NULL,0,12,26,1,0,0,i+1)) && (iStochastic(NULL,0,5,3,3,0,0,0,i) < iStochastic(NULL,0,5,3,3,0,0,1,i)) && iRSI(NULL,0,8,0,i) < iMAOnArray(RSI,0,8,0,0,i) // && // iMA(NULL,0,slow_ema,0,1,0,i) > iMA(NULL,0,fast_ema,fast_ema_shift,1,0,i) && Close[i]<iMA(NULL,0,fast_ema,fast_ema_shift,1,0,i) && Close[i]< iMA(NULL,0,slow_ema,0,1,0,i) ) SignalDown[i]=Line_height3; else SignalDown[i]=Line_height4; } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //=================FOR Five_shift_and_34 OPTION====================== if(Five_shift_and_34cross == true) { //======= going long===================== for(i=limit; i>=0; i--) if ( (iMACD(NULL,0,12,26,1,0,0,i)>iMACD(NULL,0,12,26,1,0,0,i+1)) && (iStochastic(NULL,0,5,3,3,0,0,0,i) > iStochastic(NULL,0,5,3,3,0,0,1,i)) && iRSI(NULL,0,8,0,i) > iMAOnArray(RSI,0,8,0,0,i) && iMA(NULL,0,slow_ema,0,1,0,i) < iMA(NULL,0,fast_ema,fast_ema_shift,1,0,i) // && // Close[i]>iMA(NULL,0,fast_ema,fast_ema_shift,1,0,i) ) SignalUp[i]=Line_height1; else SignalUp[i]=Line_height2; //======= going short===================== for(i=limit; i>=0; i--) if ( (iMACD(NULL,0,12,26,1,0,0,i)<iMACD(NULL,0,12,26,1,0,0,i+1)) && (iStochastic(NULL,0,5,3,3,0,0,0,i) < iStochastic(NULL,0,5,3,3,0,0,1,i)) && iRSI(NULL,0,8,0,i) < iMAOnArray(RSI,0,8,0,0,i) && iMA(NULL,0,slow_ema,0,1,0,i) > iMA(NULL,0,fast_ema,fast_ema_shift,1,0,i) // && // Close[i]<iMA(NULL,0,fast_ema,fast_ema_shift,1,0,i) ) SignalDown[i]=Line_height3; else SignalDown[i]=Line_height4; } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //=================FOR Only_5_shift OPTION====================== if(PAaboveOnly_5_shift == true) { //======= going long===================== for(i=limit; i>=0; i--) if ( (iMACD(NULL,0,12,26,1,0,0,i)>iMACD(NULL,0,12,26,1,0,0,i+1)) && (iStochastic(NULL,0,5,3,3,0,0,0,i) > iStochastic(NULL,0,5,3,3,0,0,1,i)) && iRSI(NULL,0,8,0,i) > iMAOnArray(RSI,0,8,0,0,i) // && // iMA(NULL,0,slow_ema,0,1,0,i) < iMA(NULL,0,fast_ema,fast_ema_shift,1,0,i) && Close[i]>iMA(NULL,0,fast_ema,fast_ema_shift,1,0,i) ) SignalUp[i]=Line_height1; else SignalUp[i]=Line_height2; //======= going short===================== for(i=limit; i>=0; i--) if ( (iMACD(NULL,0,12,26,1,0,0,i)<iMACD(NULL,0,12,26,1,0,0,i+1)) && (iStochastic(NULL,0,5,3,3,0,0,0,i) < iStochastic(NULL,0,5,3,3,0,0,1,i)) && iRSI(NULL,0,8,0,i) < iMAOnArray(RSI,0,8,0,0,i) // && // iMA(NULL,0,slow_ema,0,1,0,i) > iMA(NULL,0,fast_ema,fast_ema_shift,1,0,i) && Close[i]<iMA(NULL,0,fast_ema,fast_ema_shift,1,0,i) ) SignalDown[i]=Line_height3; else SignalDown[i]=Line_height4; } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ //=================FOR Only_34 OPTION====================== if(PAaboveOnly_34 == true) { //======= going long===================== for(i=limit; i>=0; i--) if ( (iMACD(NULL,0,12,26,1,0,0,i)>iMACD(NULL,0,12,26,1,0,0,i+1)) && (iStochastic(NULL,0,5,3,3,0,0,0,i) > iStochastic(NULL,0,5,3,3,0,0,1,i)) && iRSI(NULL,0,8,0,i) > iMAOnArray(RSI,0,8,0,0,i) // && // iMA(NULL,0,slow_ema,0,1,0,i) < iMA(NULL,0,fast_ema,fast_ema_shift,1,0,i) && Close[i]>iMA(NULL,0,slow_ema,0,1,0,i) ) SignalUp[i]=Line_height1; else SignalUp[i]=Line_height2; //======= going short===================== for(i=limit; i>=0; i--) if ( (iMACD(NULL,0,12,26,1,0,0,i)<iMACD(NULL,0,12,26,1,0,0,i+1)) && (iStochastic(NULL,0,5,3,3,0,0,0,i) < iStochastic(NULL,0,5,3,3,0,0,1,i)) && iRSI(NULL,0,8,0,i) < iMAOnArray(RSI,0,8,0,0,i) // && // iMA(NULL,0,slow_ema,0,1,0,i) > iMA(NULL,0,fast_ema,fast_ema_shift,1,0,i) && Close[i]<iMA(NULL,0,slow_ema,0,1,0,i) ) SignalDown[i]=Line_height3; else SignalDown[i]=Line_height4; } //---- return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Series array that contains close prices for each bar
Indicator Curves created:
Implements a curve of type DRAW_NONE
Implements a curve of type DRAW_HISTOGRAM
Indicators Used:
Relative strength index
Moving average indicator
MACD Histogram
Stochastic oscillator
Custom Indicators Used:
Order Management characteristics:
Other Features: