syst_Mrs V traffic lights 04
Download scriptThis script is designed to function as a visual trend-following and momentum indicator for the MetaTrader platform. Its primary goal is to provide traders with clear "traffic light" signals—visual cues that indicate whether current market conditions favor an upward (Long) or downward (Short) movement based on several technical filters.
Core Technical Logic
The script evaluates market data by combining four main technical indicators to determine the strength and direction of a trend:
- Momentum & Velocity (MACD & Stochastic): The logic looks for a confirmation of momentum. It checks if the MACD (Moving Average Convergence Divergence) is increasing/decreasing and if the Stochastic Oscillator is moving in a corresponding upward or downward direction.
- Relative Strength (RSI): The Relative Strength Index (RSI) is used to measure the speed and change of price movements.
- Smoothing Filter (Moving Average of RSI): Unlike standard tools that just look at the raw RSI, this script applies a Moving Average to the RSI itself. It then compares the current RSI value against this smoothed average to determine if the relative strength is gaining or losing steam.
- Price Position (EMA Filters): The script utilizes Exponential Moving Averages (EMAs) of different periods (specifically a "fast" 5-period and a "slow" 34-period). These are used as structural boundaries to confirm that the price is trading in the correct zone relative to historical averages.
Signal Filtering Options
The script is unique because it offers several different "modes" or filters. You can choose how strict you want the logic to be before a signal appears:
- All Signals: The most inclusive mode. It triggers based on the core momentum and RSI filters without requiring specific price positions relative to the EMAs.
- Price Above/Below Filters: These options require the current market price to be physically above or below specific moving averages (the 5-period shift or the 34-period average) before a signal is valid. This ensures that "Buy" signals only occur in an uptrend and "Sell" signals only occur in a downtrend.
- EMA Crossings: One specific mode focuses on the relationship between the two moving averages themselves, triggering signals when the fast average crosses over the slow average.
Visual Representation
The script translates these complex mathematical checks into a visual histogram:
- Upward Signals: When all conditions for a "Long" position are met, the indicator highlights a higher level (Line Height 1).
- Downward Signals: When all conditions for a "Short" position are met, the indicator highlights a high level on the opposite side (Line Height 3).
- Neutral/No Signal: When conditions are not met, the indicator remains at a minimal height, allowing traders to easily identify only the moments of high-probability opportunity.
//+------------------------------------------------------------------+
//| 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);
}
//+------------------------------------------------------------------+
Comments