FlatTrend SMC modified_v1

Download script
Author: Kirk Sloan
FlatTrend SMC modified_v1

The Flat Trend SMC is a technical analysis tool designed to help traders visualize market direction and momentum by analyzing price history through several layers of filtering. Instead of relying on a single data point, the script combines three different types of financial indicators—Moving Averages, ADX (Average Directional Index), and Parabolic SAR—to provide a clearer picture of whether the market is trending or remaining stagnant.

How the Logic Works

The indicator operates by monitoring three distinct conditions simultaneously. These conditions are displayed on your chart as colored histograms:

1. Upward Trend Identification (Lime Green) The script first looks for a "bullish" sequence using three different Moving Averages. If the fastest average is above the middle average, and the middle average is above the slowest average, it signifies a consistent upward trend. When this specific alignment occurs, the indicator highlights a positive trend in Lime Green.

2. Bearish Momentum Detection (Red) To identify downward pressure, the script looks at two different factors:

  • Parabolic SAR: It checks if the current price has fallen below the Parabolic SAR level.
  • ADX Strength: It compares the momentum of the market over recent periods to see if the "downward" energy is increasing. If both conditions are met—meaning the price is struggling and the downward momentum is strengthening—the indicator signals this with a Red highlight.

3. Neutral/Flat Market Detection (Gold) The script also includes logic to identify "flat" or non-trending markets. If neither the upward trend conditions nor the downward momentum conditions are triggered, the indicator labels the price action as neutral. This is represented by the Gold highlight, alerting the trader that there may be insufficient movement to justify a trend-based trade.

Key Features

  • Multi-Timeframe Flexibility: The tool can be adjusted to monitor various timeframes, from 1-minute intervals up to monthly charts, allowing you to see trends on different scales.
  • Visual Clarity: By separating these three states into distinct colors (Red, Lime Green, and Gold), the script allows you to instantly see where the market stands without having to manually calculate complex moving averages or momentum shifts.
  • Comprehensive Filtering: By requiring multiple conditions to be met before changing a color (such as requiring both ADX and Parabolic SAR for a red signal), the script helps filter out "noise" and reduces false signals that occur in choppy markets.
Price Data Components
Series array that contains close prices for each bar
Indicators Used
Moving average indicatorMovement directional indexParabolic Stop and Reverse system
Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
FlatTrend SMC modified_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------+
//|                                                    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