FlatTrend_SMC_modified
Download scriptThis tool is designed to analyze market trends by identifying specific momentum shifts and price actions. It operates as a visual indicator that provides three distinct signals (represented as histograms) to help traders understand whether the current market environment is trending upward, showing signs of reversal, or remaining neutral.
Core Logic Overview
The script works by processing historical price data over a user-defined timeframe (ranging from 1-minute charts up to monthly views). It continuously monitors three different technical layers: moving averages, trend oscillators, and parabolic price action filters.
How the Signals are Calculated
1. The Bullish Trend Signal (Green) The indicator identifies a strong upward trend by looking at three different Simple Moving Averages (SMAs) of varying lengths. If these averages align in a specific "stacked" order—where the fastest average is above the middle one, and the middle one is above the slowest—the tool recognizes this as a confirmed bullish momentum.
2. The Reversal/Pressure Signal (Red) This logic focuses on identifying potential turning points or shifts in momentum. It combines two different types of data:
- Parabolic SAR: A technical indicator used to identify the "top" or "bottom" of a price move.
- ADX Oscillator: It compares the current strength of the trend against its previous state to see if momentum is accelerating or decelerating. When the Parabolic SAR indicates a ceiling and the ADX shows a specific shift in pressure, the tool highlights this as a potential change in the market's direction.
3. The Neutral/Baseline Signal (Gold) This serves as a "base" signal. If the market does not meet the specific requirements for a strong bullish trend AND does not trigger the specific conditions for a reversal, the indicator marks the area as neutral. This helps traders identify periods of consolidation where no clear direction is established.
Summary for Traders
In practical terms, this script filters out market noise by requiring multiple technical conditions to be met simultaneously before signaling a trend. Instead of relying on just one price movement, it validates the "health" of the market using:
- Alignment: Are the averages moving together?
- Momentum: Is the strength of the move increasing or decreasing?
- Price Action: Has the price hit a technical resistance point?
//+------------------------------------------------------------------+
//| 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=30;
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