AvalsLevels

Download script
Author: Copyright � 2006, �������� �������
AvalsLevels

This script is designed as a visual trading indicator that identifies key price boundaries on a chart. Instead of simply showing every peak and valley, it uses a specific logical flow to filter out "noise" and highlight significant structural levels where the market might encounter resistance or support.

How the Logic Works

The core objective of the script is to distinguish between minor price fluctuations and significant structural shifts. It achieves this by analyzing the direction of price movement (Up or Down) and comparing current price action against historical highs and lows.

1. Trend Detection and Filtering The logic begins by checking if a candle closed higher or lower than it opened.

  • When the market is moving in an Upward trend, the script looks for significant "lows" to serve as potential support zones.
  • When the market is moving in a Downward trend, the script focuses on finding "highs" that represent potential resistance.

2. Dynamic Level Identification The script maintains a memory of historical price points (tops and bottoms). It uses a "cleanup" process where it constantly compares new price data against these saved levels:

  • If a new price point is higher than a previous recorded "top," the older top is discarded because it is no longer relevant to the current market structure.
  • Conversely, if a new low is lower than a previous recorded "bottom," the old bottom is removed.
  • This ensures that the indicator only displays the most relevant, prominent boundaries currently active in the price action.

3. The "Speed" Threshold (Significance Filter) A key feature of this logic is the SpeedLineMin parameter. Before the script officially adds a new level to your chart, it calculates the distance between the current price and the nearest recent peak/valley.

  • A level is only registered if the price has moved a significant enough distance (the "Speed") away from that point.
  • This prevents the chart from being cluttered with every tiny movement, ensuring that only substantial structural shifts are highlighted.

Visual Output

The results are displayed on your chart as two distinct dashed lines:

  • Blue Dashed Lines: Represent dynamic support levels identified during upward movements.
  • Red Dashed Lines: Represent dynamic resistance levels identified during downward movements.

In summary, this tool acts as a structural map of the market. It automatically "cleans" out insignificant price data and only plots significant boundaries that meet your specific criteria for distance and trend direction.

Miscellaneous
Implements a curve of type %1
13 Views
0 Downloads
0 Favorites
AvalsLevels
//+------------------------------------------------------------------+
//|                                                  AvalsLevels.mq4 |
//|                               Copyright © 2006, Âÿ÷åñëàâ Ñóâîðîâ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Âÿ÷åñëàâ Ñóâîðîâ"

#property indicator_chart_window
#property indicator_buffers 2

#property indicator_color1 Blue 
#property indicator_style2 STYLE_DASH
#property indicator_color3 Red
#property indicator_style4 STYLE_DASH

double topband2[]; 
double botband2[]; 
double pogreha=5;

//---- input parameters
extern int       SpeedLineMin=5;
int init()
  {
   IndicatorBuffers(2); 
    
   SetIndexBuffer(0,topband2); 
   SetIndexStyle(0, DRAW_LINE, STYLE_DASH, 1, Blue); 
   SetIndexDrawBegin(0,3); 
   SetIndexLabel(0,"SPEEDUP");  

   SetIndexBuffer(1,botband2); 
   SetIndexStyle(1, DRAW_LINE, STYLE_DASH, 1, Red); 
   SetIndexDrawBegin(1,3); 
   SetIndexLabel(1,"SPEEDDOWN");  
   
//---- indicators
//----
   return(0);
  }
int start()
  {
  double Max=High[Highest(NULL,0,MODE_HIGH,Bars-1,0)];  
  int Basis,sh;
  bool sign;
  double d1,Dist;
   int i=iBars(NULL,PERIOD_D1);
   double Maxx=High[iHighest(NULL,PERIOD_D1,MODE_HIGH,i,0)];  
   double tops[]; 
   double bots[];     
   int   counted_bars=IndicatorCounted(); 
   double lasttop=High[counted_bars];
   double lastbot=Low[counted_bars];
   ArrayResize(tops,0);   
   ArrayResize(bots,0);   

   lasttop=High[counted_bars];
   lastbot=Low[counted_bars];
  
   i=Bars-IndicatorCounted();
   while (i>=0){     
     Basis=i;
     if (Close[i]>=Open[i]){         //UP
       sign=false;
       while((i>=0) && (!sign)){
         while ((ArraySize(tops)>0) && (High[i]>=tops[ArraySize(tops)-1])) ArrayResize(tops,ArraySize(tops)-1);
         while ((ArraySize(bots)>0) && (Low[i]<=bots[ArraySize(bots)-1])) ArrayResize(bots,ArraySize(bots)-1);         
         topband2[i]=tops[ArraySize(tops)-1];
         if (topband2[i]==0) topband2[i]=Max;
         botband2[i]=bots[ArraySize(bots)-1];
         i--;
         if ((High[i]>High[i+1]) && (Low[i]>Low[i+1]) && (Close[i]>Open[i])) sign=false; else sign=true;         
       }//while
       d1= MathMin(High[Basis+1],High[Basis+2]);
       d1= MathMin(d1,High[Basis]);       
       Dist=(High[i+1]-d1)/Point;
       if (Dist>=SpeedLineMin) {
         ArrayResize(bots,ArraySize(bots)+1);
         bots[ArraySize(bots)-1]=d1;         
       }//if       
     } else {
       sign=false;
       while((i>=0) && (!sign)){
         while ((ArraySize(tops)>0) && (High[i]>=tops[ArraySize(tops)-1])) ArrayResize(tops,ArraySize(tops)-1);
         while ((ArraySize(bots)>0) && (Low[i]<=bots[ArraySize(bots)-1])) ArrayResize(bots,ArraySize(bots)-1);         
         topband2[i]=tops[ArraySize(tops)-1];
         if (topband2[i]==0) topband2[i]=Max;
         botband2[i]=bots[ArraySize(bots)-1];
         i--;
         if ((Low[i]<Low[i+1]) && (High[i]<High[i+1]) && (Close[i]<Open[i])) sign=false; else sign=true;         
       }//while
       d1=0;
       d1= MathMax(Low[Basis+1],Low[Basis+2]);
       d1= MathMax(d1,Low[Basis]);       
       Dist=(d1-Low[i+1])/Point;
       if (Dist>=SpeedLineMin) {
         ArrayResize(tops,ArraySize(tops)+1);
         tops[ArraySize(tops)-1]=d1;         
       }//if            
     }            
   }//while   
   return(0);
  }
int deinit()
{ 
  return(0);  
}
  
//+------------------------------------------------------------------+

Comments