Activity_indic_1

Download script
Author: Copyright � 2008, MetaQuotes Software Corp.
Activity_indic_1

This technical indicator is designed to analyze market price action by combining volume data with specific price points from past candles. It functions by calculating moving averages of the "body" and "extremes" of the price bars, weighted by the trading activity (volume) occurring during those periods.

Core Logic and Functionality

The script works by evaluating three specific types of price movement to provide a clearer picture of market momentum:

1. Price Body Analysis The indicator looks at the difference between the opening and closing prices. It calculates the "body" of the candles over a user-defined period, factoring in the volume of those trades. This helps identify the core strength or weakness of the price movement regardless of temporary spikes.

2. High and Low Extremes The logic also tracks the highest and lowest points reached during specific timeframes. By calculating the difference between these extremes and the previous candles' prices—weighted by volume—the script highlights how aggressively the price is reaching for new highs or lows.

3. Volume Weighting A key feature of this script is that it does not treat all price movements equally. It incorporates "Volume" as a multiplier. This means that a large price move on low volume is treated differently than a large price move on high volume, allowing the indicator to differentiate between significant market trends and minor fluctuations.

Key Parameters

  • Moving Average Period (ma_p1): This determines the length of the time window used to smooth out the data. A higher number will result in smoother lines, while a lower number will make the indicator more sensitive to recent price changes.
  • Candle Back (Candle_back): This defines how many previous candles the script looks back at to aggregate volume and price data for its calculations.

Visual Output

The script is designed to display these calculations in a separate window below the main price chart. It creates multiple data buffers (lines), though currently, it focuses on calculating three primary metrics:

  • The weighted price body movement.
  • The weighted high-price extremes.
  • The weighted low-price extremes.

By observing these lines, a user can see whether the market is trending with significant volume support or if the current price action is lacking the underlying strength to sustain a move.

Miscellaneous
Implements a curve of type %1
8 Views
0 Downloads
0 Favorites
Activity_indic_1
//+------------------------------------------------------------------+
//|                                             Activity_indic_1.mq4 |
//|                      Copyright © 2008, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link      "http://www.metaquotes.net"

#property indicator_separate_window
#property indicator_buffers 7
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 Aqua
#property indicator_color4 Orange
#property indicator_color5 Brown
#property indicator_color6 SeaGreen
#property indicator_color7 Gray
//---- input parameters
extern int       ma_p1  = 8;
//extern int       Flt_Per= 3;
extern int       Candle_back = 2;
//extern int       Hystory= 120;
//---- buffers
double ExtMapBuffer1[]; // ht
double ExtMapBuffer2[]; // bl
double ExtMapBuffer3[]; // co
double ExtMapBuffer4[]; // hc
double ExtMapBuffer5[]; // lc
double ExtMapBuffer6[]; // ho
double ExtMapBuffer7[]; // lo
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_LINE,EMPTY,2);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE,EMPTY,2);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexStyle(2,DRAW_LINE,EMPTY,2);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexStyle(3,DRAW_LINE,EMPTY,2);
   SetIndexBuffer(3,ExtMapBuffer4);
   SetIndexStyle(4,DRAW_LINE,EMPTY,2);
   SetIndexBuffer(4,ExtMapBuffer5);
   SetIndexStyle(5,DRAW_LINE,EMPTY,2);
   SetIndexBuffer(5,ExtMapBuffer6);
   SetIndexStyle(6,DRAW_LINE,EMPTY,2);
   SetIndexBuffer(6,ExtMapBuffer7);
//----

for ( int i = Bars - 1 ; i >= 0 ; i -- )
   {
       ExtMapBuffer1[i] = 0 ; // ht
       ExtMapBuffer2[i] = 0 ; // bl
       ExtMapBuffer3[i] = 0 ; // co
       ExtMapBuffer4[i] = 0 ; // hc
       ExtMapBuffer5[i] = 0 ; // lc
       ExtMapBuffer6[i] = 0 ; // ho
       ExtMapBuffer7[i] = 0 ; // lo
      
   }
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    i,j,k,limit,counted_bars=IndicatorCounted();
//----
   
   if ( ma_p1 < 1 ) ma_p1 = 1 ;

   if ( Candle_back < 1 ) Candle_back = 1 ;
   
   if (counted_bars<0) return(-1);
//---- last counted bar will be recounted
   if (counted_bars>0) counted_bars--;

   limit = Bars - counted_bars;
   
   for ( i = limit ; i >= 0 ; i -- )
   {
       /*
       if ( Open[i+j] > Close[i+j] ) ExtMapBuffer1[i] = ( ExtMapBuffer1[i+1] * ma_p1 - (High[i+ma_p1] - Open[i+ma_p1])*Volume[i+ma_p1] + (High[i] - Open[i])*Volume[i] ) / ma_p1 ; // ht
       else  ExtMapBuffer1[i] = ( ExtMapBuffer1[i+1] * ma_p1 - (High[i+ma_p1] - Close[i+ma_p1])*Volume[i+ma_p1] + (High[i] - Close[i])*Volume[i] ) / ma_p1 ; // ht

       if ( Open[i+ma_p1] < Close[i+ma_p1] ) ExtMapBuffer2[i] = ( ExtMapBuffer2[i+1] * ma_p1 - (High[i+ma_p1] - Open[i+ma_p1])*Volume[i+ma_p1] + (High[i] - Open[i])*Volume[i] ) / ma_p1 ; // ht
       else  ExtMapBuffer2[i] = ( ExtMapBuffer2[i+1] * ma_p1 - (High[i+ma_p1] - Close[i+ma_p1])*Volume[i+ma_p1] + (High[i] - Close[i])*Volume[i] ) / ma_p1 ; // ht
       */
       int volvi = 0 ;
       int volvo = 0 ;
       for ( j = 0 ; j < Candle_back ; j ++ ) volvi += Volume[i+j] ;
       for ( j = 0 ; j < Candle_back ; j ++ ) volvo += Volume[i+ma_p1+j] ;
       
       ExtMapBuffer1[i] = 0 ; // ht
       ExtMapBuffer2[i] = 0 ; // bl
       ExtMapBuffer3[i] = ( ExtMapBuffer3[i+1] * ma_p1 - (Close[i+ma_p1] - Open[i+Candle_back+ma_p1])*volvo + (Close[i] - Open[i+Candle_back])*volvi ) / ma_p1 ; // co
       ExtMapBuffer4[i] = ( ExtMapBuffer4[i+1] * ma_p1 - (High[i+ma_p1] - Close[i+Candle_back+ma_p1])*volvo + (High[i] - Close[i+Candle_back])*volvi ) / ma_p1 ; // hc
       ExtMapBuffer5[i] = ( ExtMapBuffer5[i+1] * ma_p1 - (Low[i+ma_p1] - Close[i+Candle_back+ma_p1])*volvo + (Low[i] - Close[i+Candle_back])*volvi ) / ma_p1 ;  // lc
       ExtMapBuffer6[i] = 0 ; // ho
       ExtMapBuffer7[i] = 0 ; // lo
      
/*
   if ( i < limit - Flt_Per )
      for ( j = Flt_Per-1 ; j >= 0 ; j -- )
         {
         ExtMapBuffer1[i] += ExtMapBuffer1[i+j] / Flt_Per ;
         ExtMapBuffer2[i] += ExtMapBuffer2[i+j] / Flt_Per ;
         ExtMapBuffer3[i] += ExtMapBuffer3[i+j] / Flt_Per ;
         ExtMapBuffer4[i] += ExtMapBuffer4[i+j] / Flt_Per ;
         ExtMapBuffer5[i] += ExtMapBuffer5[i+j] / Flt_Per ;
         ExtMapBuffer6[i] += ExtMapBuffer6[i+j] / Flt_Per ;
         ExtMapBuffer7[i] += ExtMapBuffer7[i+j] / Flt_Per ;
         }
*/

   }


//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments