Icho-Trend_v1

Download script
Icho-Trend_v1

The Trend Manager is a visual trading tool designed to help market participants identify directional momentum by comparing price action across two different time offsets. It simplifies complex market data into a clear, histogram-based visual guide that categorizes the current trend as either Bullish (Buy), Bearish (Sell), or Neutral.

How the Logic Works

The core functionality of this script relies on calculating "Spans"—essentially average price points derived from a specific look-back period. Here is the step-by-step breakdown of the logic:

1. Data Collection (The Look-Back Period) The tool looks at a predetermined number of previous bars (defined by the user as the TM_Period). For every point on the chart, it scans this specific window of time to identify the highest price reached and the lowest price touched.

2. Calculating the Spans From those high and low points, the tool calculates a midpoint value. It creates two distinct versions of this calculation:

  • Span A: The current midpoint based on the most recent look-back period.
  • Span B: The midpoint from a previous point in time (determined by the TM_Shift).

3. Trend Identification The tool then compares these two values against each other to determine the market's "bias":

  • Buy Signal: If the current midpoint (Span A) is higher than the shifted midpoint (Span B), it indicates upward momentum, and the trend is categorized as a Buy.
  • Sell Signal: If the current midpoint (Span A) is lower than the shifted midpoint (Span B), it indicates downward momentum, and the trend is categorized as a Sell.
  • Neutral: If both midpoints are exactly equal, the tool considers the market to be in a neutral state.

Visual Representation

The script renders these calculations on your chart as colored histograms. By visualizing the relationship between the current price action and its historical counterpart, the Trend Manager allows you to see at a glance whether the market's "center of gravity" is moving upward or downward.

Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
Icho-Trend_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

// Trend Manager.mq4
// Based on indicator sold at traderstradingsystem.com

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue

extern int TM_Period = 7;
extern int TM_Shift = 2;

double SpanA_Buffer[];
double SpanB_Buffer[];
int a_begin;

int init()
{
   a_begin=TM_Shift;
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID);
   SetIndexBuffer(0,SpanB_Buffer);
   SetIndexDrawBegin(0,TM_Period+a_begin-1);
   SetIndexLabel(0,"TM_Period+");
   SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID);
   SetIndexBuffer(1,SpanA_Buffer);
   SetIndexDrawBegin(1,TM_Period+a_begin-1);
   SetIndexLabel(1,"TM_Period");

   return(0);
}

int start()
{
   int    i,k;
   int    counted_bars=IndicatorCounted();
   double high,low,price;
   string sColor;
   
   if(Bars<=TM_Period) return(0);
   if(counted_bars<1)
   {
      for(i=1;i<=TM_Period;i++) 
      {
         SpanA_Buffer[Bars-i]=0;
         SpanB_Buffer[Bars-i]=0;
      }
   }
   
   // JUSTIN NOTES
   // BASICALLY, I THINK THE FORMULA IS TO GO BACK 7 BARS, SUM THE HIGH LOW, DIVIDE BY 2
   // THEN GET THAT SAME VALUE, BUT 2 BARS PREVIOUSLY, IF THE FIRST VALUE IS GREATER IT'S A BUY
   // OTHER WISE IT'S A SELL, IF EQUAL, NEAUTRAL

   i=Bars-TM_Period;
   if(counted_bars>TM_Period) i=Bars-counted_bars-1;
   while(i>=0)
   {
      high=High[i]; low=Low[i]; k=i-1+TM_Period;
      while(k>=i)
      {
         price=High[k];
         if(high<price) high=price;
         price=Low[k];
         if(low>price)  low=price;
         k--;
      }
      SpanA_Buffer[i]  = (high+low)/2.0;
      SpanB_Buffer[i]  = SpanA_Buffer[i+TM_Shift];
      
      //Print("Span A Buffer[", i, "] = ", (high+low)/2.0);
      //Print("Span B Buffer[", i, "] = ", SpanA_Buffer[i+TM_Shift]);

      //Print("Span A Price = ", SpanA_Buffer[Bars-TM_Period], " -- Span B Price = ", SpanB_Buffer[Bars-TM_Period]);
      
      if ( SpanA_Buffer[i] > SpanB_Buffer[i] )
      {
         sColor = "BUY";
      }
      else if ( SpanA_Buffer[i] < SpanB_Buffer[i] )
      {
         sColor = "SELL";
      }
      else
      {
         sColor = "NEUTRAL";
      }     
      
      
      Print(sColor, " -- Bar = ", i, " -- Span A Price (Blue) = ", SpanA_Buffer[i], " -- Span B Price (Red) = ", SpanB_Buffer[i]);
      
      i--;
   }
   
   return(0);
}

Comments