stopd_levels_mtf

Download script
Author: Copyright 2013, Lawrence Chan
stopd_levels_mtf

The STOPD Levels MTF indicator is a sophisticated technical analysis tool designed to project significant price levels on your trading charts based on historical price volatility. Rather than relying on standard fixed percentages, it calculates "levels" by analyzing the actual range of movement within specific preceding timeframes.

Core Logic and Functionality

The primary purpose of this script is to identify the extreme highs and lows of a completed period (such as a Day, Week, Month, Quarter, or Year) and use that distance to project seven distinct horizontal levels onto your current chart.

1. Dynamic Range Identification The script continuously monitors the "High" and "Low" prices of the market. It identifies the total vertical distance (the range) covered during a specific timeframe. For example, if the tool is set to a Daily timeframe, it looks at how far the price traveled from its highest point to its lowest point during the previous day.

2. Multi-Timeframe Awareness One of the key features of this script is its ability to adapt to different market cycles. Depending on your settings, it can automatically detect and calculate boundaries for:

  • Daily (D)
  • Weekly (W)
  • Monthly (M)
  • Quarterly (Q)
  • Yearly (Y)

When the script detects a "Period Break" (for instance, when a new day begins or a new month starts), it captures the data from the period that just closed to determine the scale for the upcoming periods.

3. Level Projection Once the range of the previous period is established, the script calculates seven specific levels based on custom percentages. These levels are relative to the starting point (the Low) and the total range (the distance between High and Low).

For instance, if you have set a level at 50.0, the script identifies the exact price point that represents the halfway mark of that previous period's movement. By projecting these lines onto your current chart, it provides a visual roadmap of where key support and resistance zones may lie.

Visual Representation

The script renders seven distinct lines on your chart, organized by color to help differentiate between various types of levels:

  • Blue Lines: Typically represent primary interior levels (like 100%, 50%, and 0%).
  • Orange Lines: Represent outer boundary levels (such as 150% or -50%).
  • Red Lines: Highlight extreme volatility boundaries (such as 200% or -100%).

Summary for the Trader

This tool is designed to help you visualize "zones of interest" by looking at historical behavior. Instead of guessing where a price might turn, it uses the magnitude of previous market swings to plot out potential areas of significance, allowing you to see how current price action relates to the volatility of the past.

Miscellaneous
Implements a curve of type %1
9 Views
0 Downloads
0 Favorites
stopd_levels_mtf
//+------------------------------------------------------------------+
//|                                             STOPD Levels MTF.mq4 |
//|                                    Copyright 2013, Lawrence Chan |
//|                                    http://www.daytradingbias.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2013, Lawrence Chan"
#property link      "http://www.daytradingbias.com"

#property indicator_chart_window
#property indicator_buffers 7
#property indicator_color1 Blue
#property indicator_color2 Blue
#property indicator_color3 Blue
#property indicator_color4 Orange
#property indicator_color5 Orange
#property indicator_color6 Red
#property indicator_color7 Red
//--- input parameters
extern string    Timeframe="D";
extern double    L1=100.0;
extern double    L2=50.0;
extern double    L3=0.0;
extern double    L4=150.0;
extern double    L5=-50.0;
extern double    L6=200.0;
extern double    L7=-100.0;
//--- buffers
double L1Buffer[];
double L2Buffer[];
double L3Buffer[];
double L4Buffer[];
double L5Buffer[];
double L6Buffer[];
double L7Buffer[];
//-- local vars
double L1v,L2v,L3v,L4v,L5v,L6v,L7v;
double LastHigh,LastLow,R;
bool PeriodBreak,Ready;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,L1Buffer);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(1,L2Buffer);
   SetIndexStyle(2,DRAW_LINE);
   SetIndexBuffer(2,L3Buffer);
   SetIndexStyle(3,DRAW_LINE);
   SetIndexBuffer(3,L4Buffer);
   SetIndexStyle(4,DRAW_LINE);
   SetIndexBuffer(4,L5Buffer);
   SetIndexStyle(5,DRAW_LINE);
   SetIndexBuffer(5,L6Buffer);
   SetIndexStyle(6,DRAW_LINE);
   SetIndexBuffer(6,L7Buffer);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----

//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int counted_bars=IndicatorCounted();
   int limit,i;

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

   limit=Bars-counted_bars-1;
   if(counted_bars==0) limit-=2;

   if(counted_bars==0) 
     {
      LastHigh= High [limit+1];
      LastLow = Low [limit+1];
      Ready=false;
     }

   for(i=limit; i>=0; i--)
     {
      if(High[i+1]>LastHigh)
         LastHigh=High[i+1];

      if(Low[i+1]<LastLow)
         LastLow=Low[i+1];

      if(Timeframe=="D") 
        {
         PeriodBreak=TimeDay(Time[i])!=TimeDay(Time[i+1]);
           } else if(Timeframe=="W") {
         PeriodBreak=TimeDayOfWeek(Time[i])<TimeDayOfWeek(Time[i+1]);
           } else if(Timeframe=="M") {
         PeriodBreak=TimeMonth(Time[i])!=TimeMonth(Time[i+1]);
           } else if(Timeframe=="Q") {
         PeriodBreak=MathFloor((TimeMonth(Time[i])-1)/3)!=MathFloor((TimeMonth(Time[i+1])-1)/3);
           } else if(Timeframe=="Y") {
         PeriodBreak=TimeYear(Time[i])!=TimeYear(Time[i+1]);
           } else {
         PeriodBreak=false;
        }

      if(PeriodBreak)
        {
         R=LastHigh-LastLow;
         L1v = LastLow + R * L1 / 100;
         L2v = LastLow + R * L2 / 100;
         L3v = LastLow + R * L3 / 100;
         L4v = LastLow + R * L4 / 100;
         L5v = LastLow + R * L5 / 100;
         L6v = LastLow + R * L6 / 100;
         L7v = LastLow + R * L7 / 100;

         LastHigh= High [i];
         LastLow = Low [i];

         Ready=true;
        }

      if(Ready) 
        {
         L1Buffer[i] = L1v;
         L2Buffer[i] = L2v;
         L3Buffer[i] = L3v;
         L4Buffer[i] = L4v;
         L5Buffer[i] = L5v;
         L6Buffer[i] = L6v;
         L7Buffer[i] = L7v;
        }
     }

   return(0);
  }

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

Comments