alphatrendspotter_free

Download script
Author: Copyright 2015, andyismail.net
alphatrendspotter_free

The AlphaTrendSpotter is a technical analysis tool designed to identify and visualize market trends by analyzing price action across multiple timeframes simultaneously. Rather than relying on a single data point, it synchronizes information from short-term, daily, and weekly perspectives to filter out market "noise" and provide clearer directional signals.

Core Logic & Methodology

The script operates on the principle of Multi-Timeframe Confluence. It evaluates three distinct layers of data to ensure that a trade signal is supported by the broader market context:

  1. Immediate Trend (Current Chart): It monitors very recent price movements using smoothed averages and volatility indicators to determine the immediate "mood" of the market.
  2. Daily Momentum (Higher Timeframe): It looks at the daily cycle to ensure that short-term movements align with the day's primary trajectory.
  3. Weekly Structural Trend (Macro Timeframe): It identifies the long-term trend, ensuring that any potential trade is moving in the same direction as the weekly momentum.

How the Signals are Generated

To produce a reliable "Spot," the tool performs a rigorous multi-step verification:

  • Moving Average Alignment: The script calculates several Exponential Moving Averages (EMAs) based on specific user-defined periods. For a trend to be confirmed, these averages must stack in a specific order—essentially proving that the current price is consistently trending above or below the historical average across all three timeframes.
  • Volatility Filtering: It incorporates Parabolic SAR (Stop and Reverse) indicators. This helps the tool distinguish between a steady trend and a volatile price swing, ensuring that the "trend" isn't just a temporary spike.
  • Confluence Check: A signal is only triggered when the requirements for all three layers (Immediate, Daily, and Weekly) are met simultaneously. If the daily trend is up but the weekly trend is down, the tool will withhold a signal to prevent trading against a major market shift.

Visual Representation on the Chart

The script communicates its findings through a color-coded histogram system:

  • Bullish Signal (Green): This appears when all data points—short-term price action, daily momentum, and weekly trends—align in an upward direction.
  • Bearish Signal (Red): This appears when all data points align in a downward direction.
  • Neutral/No Signal (Orange): If the data is conflicting (e.g., the market is sideways or the different timeframes are pointing in opposite directions), the tool remains neutral to warn the user of a lack of clear trend.

By combining these elements, the AlphaTrendSpotter acts as a sophisticated filter, aiming to highlight high-probability trend continuations while ignoring minor price fluctuations that do not have broader market support.

Indicators Used
Moving average indicatorParabolic Stop and Reverse system
Miscellaneous
Implements a curve of type %1
14 Views
0 Downloads
0 Favorites
alphatrendspotter_free
ÿþ//+------------------------------------------------------------------+

//|                                            AlphaTrendSpotter.mq4 |

//|                                     Copyright 2015, Andy Ismail. |

//|                                        http://www.fbsbroker.com  |

//+------------------------------------------------------------------+

#property copyright "Copyright 2015, andyismail.net"

#property link      "fbsbroker.com"

#property version   "1.10"

#property strict

#property indicator_separate_window

#property indicator_buffers 4

#property indicator_color1 Black

#property indicator_color2 Green

#property indicator_color3 Red

#property indicator_color4 Orange

#property indicator_levelwidth 4

//--- input parameters



input int         MaPeriod1=5;   // Daily Periode

int               MaPeriod11=1;  // Weekly Periode

int               MaPeriod2=MaPeriod1; // High Price Periode

int               MaPeriod3=MaPeriod1; // Low Price Periode 



int TrendPower=2;

string tpower="D";



//Buffers

double Buffer1[];

double Buffer2[];

double Buffer3[];

double Buffer4[];

//+------------------------------------------------------------------+

//| Custom indicator initialization function                         |

//+------------------------------------------------------------------+

int OnInit()

  {

//--- indicator buffers mapping

   if(TrendPower>1){tpower="W";}

   IndicatorDigits(Digits);

   IndicatorShortName("ATS (" + IntegerToString(MaPeriod1)+","+IntegerToString(MaPeriod11)+","+tpower+")");

   SetIndexStyle(0,DRAW_NONE);

   SetIndexBuffer(0,Buffer1);

   SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,4);

   SetIndexBuffer(1,Buffer2);

   SetIndexStyle(2,DRAW_HISTOGRAM,EMPTY,4);

   SetIndexBuffer(2,Buffer3);

   SetIndexStyle(3,DRAW_HISTOGRAM,EMPTY,4);

   SetIndexBuffer(3,Buffer4);

//---

   return(INIT_SUCCEEDED);

  }

//+------------------------------------------------------------------+

//| Custom indicator iteration function                              |

//+------------------------------------------------------------------+

int OnCalculate(const int rates_total,

                const int prev_calculated,

                const datetime &time[],

                const double &open[],

                const double &high[],

                const double &low[],

                const double &close[],

                const long &tick_volume[],

                const long &volume[],

                const int &spread[])

  {

//---

   int    countedBars=prev_calculated;

  double ma10, ma20, ma30;

   double ma1, ma2, ma3;

   double ma1w, ma2w, ma3w;

   double sar0, sar, sarw;

//----

   if(Bars<MaPeriod3)return(0);

   

   for(int i=Bars-countedBars-1; i>=0; i--){

      Buffer1[i]=0;

      

      ma10 = iMA(NULL,0,3,0,MODE_EMA,PRICE_CLOSE,i-1);

      ma20 = iMA(NULL,0,MaPeriod2,0,MODE_EMA,PRICE_HIGH,i);

      ma30 = iMA(NULL,0,MaPeriod3,0,MODE_EMA,PRICE_LOW,i);

   

      ma1 = iMA(NULL,1440,3,0,MODE_EMA,PRICE_OPEN,i-1);

      ma2 = iMA(NULL,1440,MaPeriod2,0,MODE_EMA,PRICE_HIGH,i);

      ma3 = iMA(NULL,1440,MaPeriod3,0,MODE_EMA,PRICE_LOW,i);

      

       ma1w = iMA(NULL,10080,MaPeriod11,0,MODE_EMA,PRICE_CLOSE,i-1);

      ma2w = iMA(NULL,10080,MaPeriod11,0,MODE_EMA,PRICE_HIGH,i);

      ma3w = iMA(NULL,10080,MaPeriod11,0,MODE_EMA,PRICE_LOW,i);

      

      sar0 = iSAR(NULL,0,0.02,0.2,i);

      sar = iSAR(NULL,1440,0.02,0.2,i);

      sarw = iSAR(NULL,10080,0.02,0.2,i);

    

    if (TrendPower==2){ 

      if(ma10>ma20 && ma10>ma30 && ma10>sar0 && ma1>ma2 && ma1>ma3 && ma1w>=ma2w && ma1>sar && ma1w>sarw){

         Buffer1[i]+=1;

      }else if( ma10<ma20 && ma10<ma30 && ma10<sar0 &&  ma1<ma2 && ma1<ma3 && ma1w<=ma3w && ma1<sar && ma1w<sarw){

         Buffer1[i]-=1;

      }      

         }

      if(Buffer1[i]>0){

         Buffer2[i]=2;

         Buffer3[i]=EMPTY_VALUE;

         Buffer4[i]=EMPTY_VALUE;

      }else if(Buffer1[i]<0){

         Buffer2[i]=EMPTY_VALUE;

         Buffer3[i]=2;

         Buffer4[i]=EMPTY_VALUE;

      }else{

         Buffer2[i]=EMPTY_VALUE;

         Buffer3[i]=EMPTY_VALUE;

         Buffer4[i]=1;

      }

   }

//--- return value of prev_calculated for next call

   return(rates_total);

  }

//+------------------------------------------------------------------+

Comments