TrendStrengthOpen

Download script
Author: ][aoc 2006
TrendStrengthOpen

The TrendStrength indicator is designed to provide traders with a visual representation of the underlying momentum and direction of a market's price movement. Rather than looking at raw price action, which can often be noisy and erratic, this tool calculates the "strength" of a trend by comparing different historical averages simultaneously.

How it Works

The logic operates by analyzing several Moving Averages (MA) at various intervals. It takes a primary short-term average as a baseline and measures how far away other longer-term averages are from that baseline.

Specifically, the script performs the following steps:

  • Baseline Calculation: It identifies a core average price over a very short period.
  • Comparative Analysis: It then calculates nine additional averages across a wide range of timeframes (spanning from 10 to 90 units).
  • Variance Measurement: For each of these timeframes, the tool calculates the difference between the short-term baseline and the longer-term average. This helps determine if the price is "pulling away" from its historical mean or staying close to it.
  • Averaging the Strength: Finally, the script adds all of these differences together and divides them by nine to create a single, unified value.

What this means for the user

The resulting line on your chart represents the aggregate trend strength.

  • Positive Values: When the indicator moves above the zero line, it suggests that the short-term price momentum is stronger than the long-term average, indicating a bullish trend.
  • Negative Values: When the indicator moves below the zero line, it suggests that the price is lagging behind or moving lower than the longer-term historical averages, indicating a bearish trend.
  • Stability: Because this tool averages multiple different timeframes into one single value, it aims to provide a smoother, more reliable picture of market direction than looking at a single moving average alone. It helps identify when a trend is gaining significant "weight" or losing steam.
Indicators Used
Moving average indicator
Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
TrendStrengthOpen
//+------------------------------------------------------------------+ 
//|                                                TrendStrength.mq4 | 
//|                                                        Xaoc 2006 | 
//|                                             http://forex.xcd.ru/ | 
//+------------------------------------------------------------------+ 
#property copyright "][aoc 2006" 
#property link      "http://forex.xcd.ru/" 

#property indicator_separate_window 
#property indicator_buffers 1 

#property indicator_color1 Orange 
#property indicator_level1 0
//#property indicator_maximum 0.02
//#property indicator_minimum -0.02

double TS[];


//+------------------------------------------------------------------+ 
//| Custom indicator initialization function                         | 
//+------------------------------------------------------------------+ 
int init() 
  { 
   IndicatorBuffers(1);  

   IndicatorShortName("TrendStrength"); 
    
   SetIndexBuffer(0,TS); 
   SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 1, Orange); 
   SetIndexDrawBegin(0,2); 
   SetIndexLabel(0,"TS");   
  } 
  
  
//+------------------------------------------------------------------+ 
//| Custor indicator deinitialization function                       | 
//+------------------------------------------------------------------+ 
int deinit() 
  { 
  } 
  
  
//+------------------------------------------------------------------+ 
//| Custom indicator iteration function                              | 
//+------------------------------------------------------------------+ 
int start() 
  { 
   int    shift,counted_bars=IndicatorCounted(); 
   double ma0, ma1, ma2, ma3, ma4, ma5, ma6, ma7, ma8, ma9, tmp; 
               

     if(counted_bars<0) return(-1); 
     if(counted_bars>0) counted_bars--; 

   shift=Bars-1; 
   while(shift>=0) 
     {
   tmp=    iMA(NULL,0, 5,0,MODE_SMA,PRICE_OPEN,shift);     
   ma1=tmp-iMA(NULL,0,10,0,MODE_SMA,PRICE_OPEN,shift); 
   ma2=tmp-iMA(NULL,0,20,0,MODE_SMA,PRICE_OPEN,shift); 
   ma3=tmp-iMA(NULL,0,30,0,MODE_SMA,PRICE_OPEN,shift); 
   ma4=tmp-iMA(NULL,0,40,0,MODE_SMA,PRICE_OPEN,shift);  
   ma5=tmp-iMA(NULL,0,50,0,MODE_SMA,PRICE_OPEN,shift);
   ma6=tmp-iMA(NULL,0,60,0,MODE_SMA,PRICE_OPEN,shift);
   ma7=tmp-iMA(NULL,0,70,0,MODE_SMA,PRICE_OPEN,shift);
   ma8=tmp-iMA(NULL,0,80,0,MODE_SMA,PRICE_OPEN,shift);
   ma9=tmp-iMA(NULL,0,90,0,MODE_SMA,PRICE_OPEN,shift);         
         
   TS[shift]=(ma1+ma2+ma3+ma4+ma5+ma6+ma7+ma8+ma9)/9;
        
     shift--;
     } 
         
  } 

Comments