continuation

Download script
Author: Copyright � 2005, MetaQuotes Software Corp.
continuation

This tool is designed to analyze price movement trends by isolating and quantifying the momentum of "upward" versus "downward" price changes over a specific period. Instead of simply looking at the raw price, it focuses on the cumulative energy behind consecutive price movements.

Core Logic Overview

The script operates by breaking down market activity into two distinct components: positive gains (increases in price) and negative losses (decreases in price). It treats these two directions as independent forces to determine which side is gaining more strength over time.

How it Works

To achieve this, the logic follows a three-step process:

1. Directional Filtering The script scans the historical price data bar by bar. For every move, it identifies if the price went up or down.

  • If the price rose, it records that specific amount of growth and ignores any downward movement for that moment.
  • If the price fell, it records the amount of the drop and ignores any upward movement.

2. Cumulative Tracking Once the individual moves are identified, the script performs a "running total" calculation. It creates a cumulative history of all upward gains and a separate cumulative history of all downward losses. This allows the tool to see not just what happened in the last minute, but how much total momentum has been built up over a larger window of time (defined by the user's depth setting).

3. Momentum Comparison Finally, the indicator calculates the "tension" between these two cumulative forces. It subtracts the total accumulated downward energy from the current upward activity, and vice versa.

Visual Representation

The results are displayed as two separate lines:

  • One line represents the net strength of the positive trend relative to the negative momentum.
  • The other line represents the net strength of the negative trend relative to the positive momentum.

By observing these lines, a user can visually identify which market force is dominating. When one line moves significantly higher while the other stays low or drops, it suggests that the current price action is being driven by a sustained, continuous trend in one specific direction.

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

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Blue
//---- indicator parameters
extern int ExtDepth=20;

//---- indicator buffers
double ExtMapBuffer[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(2);
//---- drawing settings
   SetIndexStyle(0,DRAW_LINE);
   SetIndexStyle(1,DRAW_LINE);
//---- indicator buffers mapping
   SetIndexBuffer(0,ExtMapBuffer);
   SetIndexBuffer(1,ExtMapBuffer2);
 
//---- indicator short name
   IndicatorShortName("continuation("+ExtDepth+"),");
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int start()
  {
   int    shift,shiftt;
   double k_n[],k_p[],ch_p,ch_n,cff_p,cff_n;
   double CF_p[],CF_n[],Change_p[],Change_n[];

   for(shift=Bars-ExtDepth; shift>=0; shift--)
     
     {
   if (Close[shift] > Close[shift+1])
   { Change_p[shift] = Close[shift]- Close[shift+1];
  CF_p[shift]= Change_p[shift] + CF_p[shift+1];
   Change_n[shift] = 0;
   CF_n[shift]= 0;
   }
    else
  { Change_p[shift] = 0;
  	CF_p[shift] = 0;
   Change_n[shift]  = Close[shift+1]- Close[shift];
   CF_n[shift] = Change_n[shift]+ CF_n[shift+1];
   }
  }
for(shiftt=shift+ExtDepth; shiftt>=shift; shiftt--)
     
     {
      ch_p= Change_p[shiftt+shift]+ch_p ;
      ch_n= Change_n[shiftt+shift]+ch_n ;
      cff_p=  CF_p[shiftt+shift]+cff_p; 
      cff_n=  CF_n[shiftt+shift]+ cff_n;
     }
 
 ExtMapBuffer[shift]=ch_p-cff_n; 
 ExtMapBuffer2[shift]=ch_n-cff_p;

   return(0);
  }

  
    
 

Comments