Author:
ma_shift

This technical indicator is designed to provide traders with a multi-layered visual representation of price trends by calculating and plotting several different types of moving averages simultaneously. Rather than relying on a single line, it creates a sophisticated "map" of price action using two distinct primary datasets that are processed in different ways.

Core Logic Overview

The script functions by analyzing two main categories of data:

1. High/Low Range Analysis (Primary Layer) The first part of the logic focuses on the extreme points of price movement. It calculates moving averages based specifically on the "Highs" and "Lows" of each candle. This allows you to see the outer boundaries of price volatility. By tracking both the high and low extremes independently, the indicator provides a visual representation of the price "envelope" or the range in which the market is currently fluctuating.

2. Weighted Trend Analysis (Secondary Layer) The second part of the logic focuses on a more centralized trend line. It calculates a moving average based on a secondary price point (such as the Close) over a different timeframe. This represents the "core" momentum of the asset.

Unique Visual Features

What sets this script apart from a standard moving average is how it displays the data:

  • Time Shifts: The script applies specific "shifts" to the secondary trend lines. This means that instead of seeing three identical lines stacked on top of each other, the indicator offsets them horizontally across the chart. This creates a visual "echo" or a trailing effect, allowing you to see how the trend has evolved over a sequence of bars rather than just its current position.
  • Multi-Source Comparison: By plotting high/low averages alongside a shifted central average, the tool helps traders visualize the relationship between extreme volatility (the outer boundaries) and the core price trend (the inner movement).

Summary for Traders

Essentially, this tool acts as a visual diagnostic for market structure. It doesn't just tell you where the price is; it shows you:

  • The volatile boundaries of the current market range.
  • The core momentum of the trend.
  • A historical "trail" of that momentum through the use of horizontal shifts, helping to identify if the trend is accelerating, slowing down, or beginning to rotate.
Indicators Used
Moving average indicator
14 Views
0 Downloads
0 Favorites
ma_shift
//+------------------------------------------------------------------+
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+
//2009fxtsd
#property copyright ""
#property link      ""

#property indicator_chart_window
#property indicator_buffers    6
#property indicator_color1     Blue
#property indicator_color2     Blue
#property indicator_color3     DodgerBlue
#property indicator_color4     Tomato
#property indicator_color5     Red
#property indicator_color6     Maroon

//#property indicator_width1     2
//#property indicator_width2     2
#property indicator_width3     2
#property indicator_width5     2

#property indicator_style1     4
#property indicator_style2     4


#property indicator_style4     2
#property indicator_style6     2



extern int period1      = 2;
extern int method1      = 0;
extern int price1       = 0;


extern int period2      = 3;
extern int method2      = 0;
extern int price2       = 0;

extern int shift2a      = 5;
extern int shift2b      = 7;
extern int shift2c      = 9;


double buffer1[];
double buffer2[];
double buffer3[];
double buffer4[];
double buffer5[];
double buffer6[];

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+

int init()
{
      IndicatorBuffers(6); 

   
   SetIndexBuffer(0,buffer1);
   SetIndexBuffer(1,buffer2);
   SetIndexBuffer(2,buffer3);
   SetIndexBuffer(3,buffer4);
   SetIndexBuffer(4,buffer5);
   SetIndexBuffer(5,buffer6);

   SetIndexShift(3,shift2a);
   SetIndexShift(4,shift2b);
   SetIndexShift(5,shift2c);


   IndicatorShortName("ma shift " +period2);  
   SetIndexLabel(0,"ma1hi");
   SetIndexLabel(1,"ma1lo");
   SetIndexLabel(2,"ma1");
   SetIndexLabel(3,"ma2 "+period2+" shift a "+shift2a);
   SetIndexLabel(4,"ma2 "+period2+" shift b "+shift2b);
   SetIndexLabel(5,"ma2 "+period2+" shift c "+shift2c);



   return(0);
}
int deinit()
{
   return(0);
}

//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+



int start()
{
   int counted_bars=IndicatorCounted();
   int limit,i;
   
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
           limit=Bars-counted_bars;


   for(i=limit; i>=0; i--)
   {

     buffer1[i]  = iMA(NULL, 0, period1, 0,method1 , PRICE_HIGH, i); 
     buffer2[i]  = iMA(NULL, 0, period1, 0,method1 , PRICE_LOW, i); 
 
     buffer3[i]  = iMA(NULL, 0, period1, 0,method1 , price1, i); 
 
     buffer4[i]  = iMA(NULL, 0, period2, 0,method2 , price2, i); 
     buffer5[i]  = iMA(NULL, 0, period2, 0,method2 , price2, i); 
     buffer6[i]  = iMA(NULL, 0, period2, 0,method2 , price2, i); 
 
   
  }
   
   return(0);
}


Comments