_Amplitude_allHistAvg

Download script
Author: Copyright � 2005, komposter

This script is designed as a technical analysis tool for trading platforms that visualizes the "amplitude" or the range of price movement over time. Instead of showing simple price points, it breaks down the anatomy of individual price candles to provide a comprehensive view of market volatility and sentiment.

The logic functions by calculating five distinct types of averages across the entire available history of the chart:

Core Movement Metrics

  • High-Low Average: This tracks the total distance covered by each candle from its highest point to its lowest point. It represents the overall "reach" or volatility of the market.
  • Open-Close Average: This measures the size of the actual "body" of the candle. It helps distinguish between the actual movement that resulted in a price fix versus the movement that was merely "noise."

Shadow and Rejection Metrics

The script further analyzes the "wicks" or shadows (the parts of the candle that do not result in a final price change), categorizing them into:

  • Up-Shadow Average: Measures the distance between the high of the candle and the closing price (during upward moves) or the opening price (during downward moves).
  • Down-Shadow Average: Measures the distance between the low of the candle and the opening price (during upward moves) or the closing price (during downward moves).
  • Summed Shadow Average: A combined metric that adds both the upper and lower shadows together, providing a complete picture of price rejection at both ends of the range.

Dynamic Visual Presentation

Beyond just calculating numbers, the script provides a real-time dashboard on the chart:

  1. Historical Averaging: The logic doesn't just look at the current candle; it continuously accumulates and averages these values over the total history, allowing users to see how current volatility compares to long-term trends.
  2. On-Screen Dashboard: The script automatically creates a text-based information panel on the chart. This display shows the most recent average values for High-Low, Open-Close, Up-Shadow, and Down-Shadow, allowing traders to see these key metrics at a glance without having to manually interpret the lines on the graph.
  3. Customizable Positioning: The script includes specific settings to adjust where this information panel appears on your screen, ensuring it stays out of the way of your primary price action while remaining easily accessible.

In summary, this tool translates complex price action into five digestible averages, helping traders understand not just how far the price moved, but how much of that move was "real" body movement versus "rejected" shadow movement.

11 Views
0 Downloads
0 Favorites
_Amplitude_allHistAvg
//+------------------------------------------------------------------+
//|                                              	Amplitude_All.mq4 |
//|                                      Copyright © 2005, komposter |
//|                                      mailto:komposterius@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, komposter"
#property link      "mailto:komposterius@mail.ru"

#property indicator_separate_window
#property indicator_minimum 0
#property  indicator_buffers 5
#property  indicator_color1  Chartreuse
#property  indicator_color2  Green
#property  indicator_color3  Blue
#property  indicator_color4  Red
#property  indicator_color5  SlateGray
#property indicator_width2 2
#property indicator_style5 2


//---- EASY TO READ indicator parameters  

extern bool  show.info       = true;
extern int   win             = 1;
extern int price.x.offset    = 250;  //250
extern int price.y.offset    = -160; //-190
//+------------------------------------------------------------------+ 


double buf0[]; //High-Low Average
double buf1[]; //Body Average
double buf2[]; //Up_Shadow Average
double buf3[]; //Down_Shadow Average
double buf4[]; //Summ_Shadow Average

int init()
{
//	IndicatorShortName( "Amplitude(All history average)   -   " );

	IndicatorShortName( "Ampltd(allHistAvg)HL,OC,(Hwg,Lwg)H+Lwg" );

	IndicatorDigits ( 2 );

	SetIndexBuffer ( 0 , buf0 );
	SetIndexStyle ( 0 , DRAW_LINE, STYLE_DOT );
	SetIndexDrawBegin ( 0 , 0 );
	SetIndexLabel( 0 , "High-Low");

	SetIndexBuffer ( 1 , buf1 );
	SetIndexStyle ( 1 , DRAW_LINE, STYLE_DOT );
	SetIndexDrawBegin ( 1 , 0 );
	SetIndexLabel( 1 , "Open-Close");

	SetIndexBuffer ( 2 , buf2 );
	SetIndexStyle ( 2 , DRAW_LINE, STYLE_DOT );
	SetIndexDrawBegin ( 2 , 0 );
	SetIndexLabel( 2 , "Up_Shadow");

	SetIndexBuffer ( 3 , buf3 );
	SetIndexStyle ( 3 , DRAW_LINE, STYLE_DOT );
	SetIndexDrawBegin ( 3 , 0 );
	SetIndexLabel( 3 , "Down_Shadow");

	SetIndexBuffer ( 4 , buf4 );
	SetIndexStyle ( 4 , DRAW_LINE, STYLE_DOT );
	SetIndexDrawBegin ( 4 , 0 );
	SetIndexLabel( 4 , "Summ_Shadow");

return(0);
}

int start()
{
	int counted_bars=IndicatorCounted();
	if ( counted_bars < 0 ) { Print( "Indicator Error (Counted bars < 0)!" ); return(-1); }
	if ( Bars < 100 ) { Print( "Indicator Error (bars < 100)!" ); return(-1); }
	int limit = Bars - 1;

	double buf_tmp = 0.0, buf_tmp1 = 0.0, buf_tmp2 = 0.0, buf_tmp3 = 0.0, buf_tmp4 = 0.0;
	int bars = Bars, z, z1, z2, z3, z4;
	double high, low, close, open, point = Point;

	for ( int i = limit; i >= 0; i -- )
	{
		high = High[i]; low = Low[i]; close = Close[i]; open = Open[i];

		buf_tmp += ( high - low ) / point;
		buf0[i] = buf_tmp / ( bars - i + z );
		if ( ( high - low ) / point == 0 ) z --;

		buf_tmp1 += MathAbs( ( close - open ) ) / point;
		buf1[i] = buf_tmp1 / ( bars - i + z1 );
		if ( MathAbs( ( close - open ) ) / point  == 0 ) z1 --;

		if ( close - open >= 0 )
		{
			buf_tmp2 += ( high - close ) / point;
			buf2[i] = buf_tmp2 / ( bars - i + z2 );
			if ( ( high - close ) / point  == 0 ) z2 --;

			buf_tmp3 += ( open - low ) / point;
			buf3[i] = buf_tmp3 / ( bars - i + z3 );
			if ( ( open - low ) / point  == 0 ) z3 --;
		}
		else
		{
			buf_tmp2 += ( high - open ) / point;
			buf2[i] = buf_tmp2 / ( bars - i + z2 );
			if ( ( high - open ) / point  == 0 ) z2 --;

			buf_tmp3 += ( close - low ) / point;
			buf3[i] = buf_tmp3 / ( bars - i + z3 );
			if ( ( close - low ) / point  == 0 ) z3 --;
		}
		buf4[i] = buf2[i] + buf3[i];
	}




//+------------------------------------------------------------------+ 
if (show.info) {    

//int win  = WindowFind("_Amplitude_AHArsAvt"); 
   
int tDig = Digits ;
   
string tLabl = "AHA" ;

string tMain =  DoubleToStr( buf0[0] , tDig ) ;  
string tTopL =  DoubleToStr( buf2[0] , tDig ) ; 
string tBotL =  DoubleToStr( buf3[0] , tDig ) ; 
string tTopR =  DoubleToStr( buf1[0] , tDig ) ; 
string tBotR =  DoubleToStr( buf4[0] , tDig ) ; 

color cLabl =  Gray ;
color cMain =  Chartreuse ;   
color cTopL =  Blue ; 
color cBotL =  Crimson  ; 
color cTopR =  Red ; 
color cBotR =  SlateGray ;


   ObjectCreate("AHA_LB", OBJ_LABEL, win, 0, 0);// main LABEL
   ObjectSetText("AHA_LB", tLabl , 30, "Arial Bold", cLabl );
   ObjectSet("AHA_LB", OBJPROP_CORNER, 0);
   ObjectSet("AHA_LB", OBJPROP_XDISTANCE, 760+price.x.offset);
   ObjectSet("AHA_LB", OBJPROP_YDISTANCE, 160+price.y.offset);
 
   ObjectCreate("AHA_TL", OBJ_LABEL, win, 0, 0);// top left LABEL
   ObjectSetText("AHA_TL", tTopL , 15, "Arial Bold", cTopL );
   ObjectSet("AHA_TL", OBJPROP_CORNER, 0);
   ObjectSet("AHA_TL", OBJPROP_XDISTANCE, 770+price.x.offset);
   ObjectSet("AHA_TL", OBJPROP_YDISTANCE, 197+price.y.offset);
   
   ObjectCreate("AHA_BL", OBJ_LABEL, win, 0, 0);//HiLow LABEL
   ObjectSetText("AHA_BL", tBotL , 15, "Arial Bold", cBotL );
   ObjectSet("AHA_BL", OBJPROP_CORNER, 0);
   ObjectSet("AHA_BL", OBJPROP_XDISTANCE, 770+price.x.offset);
   ObjectSet("AHA_BL", OBJPROP_YDISTANCE, 260+price.y.offset);                 
                     
   ObjectCreate("AHA_MN", OBJ_LABEL, win, 0, 0);//HiLow LABEL
   ObjectSetText("AHA_MN", tMain , 40, "Arial Bold", cMain );
   ObjectSet("AHA_MN", OBJPROP_CORNER, 0);
   ObjectSet("AHA_MN", OBJPROP_XDISTANCE, 800+price.x.offset); // 765
   ObjectSet("AHA_MN", OBJPROP_YDISTANCE, 210+price.y.offset); 
           
 
   ObjectCreate("AHA_TR", OBJ_LABEL, win, 0, 0);
   ObjectSetText("AHA_TR", tTopR , 15, "Arial Bold", cTopR );
   ObjectSet("AHA_TR", OBJPROP_CORNER, 0);
   ObjectSet("AHA_TR", OBJPROP_XDISTANCE, 860+price.x.offset);
   ObjectSet("AHA_TR", OBJPROP_YDISTANCE, 197+price.y.offset);
                 
   ObjectCreate("AHA_BR", OBJ_LABEL, win, 0, 0);
   ObjectSetText("AHA_BR", tBotR , 15, "Arial Bold", cBotR );
   ObjectSet("AHA_BR", OBJPROP_CORNER, 0);
   ObjectSet("AHA_BR", OBJPROP_XDISTANCE, 860+price.x.offset);
   ObjectSet("AHA_BR", OBJPROP_YDISTANCE, 260+price.y.offset);    
    
 
//+------------------------------------------------------------------+  
   WindowRedraw();    
} 

return(0);
}



Comments