FlatTrend SMC modified
Download scriptThis tool is designed to provide traders with a visual representation of market momentum and trend direction by combining three distinct technical analysis methods into a single indicator window. Rather than relying on just one signal, it layers different types of market data—moving averages, volatility indicators, and trailing stops—to help identify clear "buy" or "sell" zones.
How the Logic Works
The script evaluates the market based on three primary visual signals represented by different colors:
1. Trend Strength (Lime Green) The indicator constantly monitors three different Moving Averages (short-term, medium-term, and long-term). When these three averages are stacked in a specific upward sequence, the tool recognizes a confirmed bullish trend. This serves as a primary filter to ensure that the market is moving in a sustained direction before considering other signals.
2. Bearish Pressure (Red) The script looks for specific "sell" conditions by combining two different data points:
- Parabolic SAR: A trailing stop indicator used to identify potential reversals.
- ADX Momentum: It compares the current strength of the trend against its previous state. If the price falls below the Parabolic SAR and the momentum indicators show a specific shift, the tool flags a bearish signal.
3. Neutral/Flat Market (Gold) The indicator is designed to recognize when the market is neither showing a strong upward trend nor a clear downward reversal. If both the bullish trend conditions and the bearish pressure signals are absent, the tool highlights these areas in gold. This helps traders identify "flat" markets where price action might be consolidating or moving sideways.
User Experience
The script automatically adjusts its calculations based on the timeframe you choose (ranging from 1-minute charts to monthly views). By providing these three distinct colors, it allows you to see at a glance whether the market is currently trending upward, facing downward pressure, or simply remaining neutral.
//+------------------------------------------------------------------+
//| FlatTrend.mq4 |
//| Kirk Sloan |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Kirk Sloan"
#property link "http://www.metaquotes.net"
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 1
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 LimeGreen
#property indicator_color3 Gold
//---- input parameters
extern int Minutes=5;
extern int MA1Val = 8;
extern int MA1Type = 0;
extern int MA2Val = 18;
extern int MA2Type = 0;
extern int MA3Val = 24;
extern int MA3Type = 0;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double Ma;
double hhigh, llow;
double Psar;
double PADX,NADX;
string TimeFrameStr;
double MA1,MA2,MA3;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,1,Red);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,1, LimeGreen);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_HISTOGRAM,STYLE_SOLID,1, Gold);
SetIndexBuffer(2,ExtMapBuffer3);
switch(Minutes)
{
case 1 : TimeFrameStr="Period_M1"; break;
case 5 : TimeFrameStr="Period_M5"; break;
case 15 : TimeFrameStr="Period_M15"; break;
case 30 : TimeFrameStr="Period_M30"; break;
case 60 : TimeFrameStr="Period_H1"; break;
case 240 : TimeFrameStr="Period_H4"; break;
case 1440 : TimeFrameStr="Period_D1"; break;
case 10080 : TimeFrameStr="Period_W1"; break;
case 43200 : TimeFrameStr="Period_MN1"; break;
default : TimeFrameStr="Current Timeframe"; Minutes=0;
}
IndicatorShortName("Flat Trend SMC ("+TimeFrameStr+")");
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
for (int i = 0; i < 300; i++){
ExtMapBuffer1[i]=0;
ExtMapBuffer2[i]=0;
ExtMapBuffer3[i]=0;
MA1=iMA(NULL,Minutes,MA1Val,0,MODE_SMA,PRICE_CLOSE,i);
MA2=iMA(NULL,Minutes,MA2Val,0,MODE_SMA,PRICE_CLOSE,i);
MA3=iMA(NULL,Minutes,MA3Val,0,MODE_SMA,PRICE_CLOSE,i);
PADX=iADX(NULL,Minutes,14 ,PRICE_CLOSE,1,i);
NADX=iADX(NULL,Minutes,14 ,PRICE_CLOSE,2,i);
Psar = iSAR(NULL,Minutes,0.02,0.2,i) ;
if(MA1>MA2 && MA2>MA3)ExtMapBuffer2[i] = 1;
if(Psar > iClose(NULL, Minutes,i) && NADX > PADX)
{ExtMapBuffer1[i] = 1;}
if(ExtMapBuffer1[i] == 0 && ExtMapBuffer2[i] == 0)
{ExtMapBuffer3[i] = 1;}
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments