continuation_v1
Download scriptThis indicator is designed to provide visual insights into market momentum by analyzing price movement trends over a specific period. Rather than just looking at where the price is currently sitting, it focuses on the "flow" of the market—identifying whether the current trend is gaining strength or losing steam based on historical accumulation.
Core Logic and Mechanics
The script operates by breaking down price action into two distinct directions: upward movements (gains) and downward movements (losses). It processes these movements using a multi-layered calculation approach:
1. Dynamic Price Tracking The tool examines the closing price of each bar relative to the previous one. If the price closes higher, it registers that specific increase as a positive value. If it closes lower, it records the decrease as a negative value. By doing this, the script filters out "noise" and focuses purely on the net change in price direction.
2. Cumulative Data Aggregation Beyond just recording individual changes, the logic creates cumulative totals. It tracks the running sum of gains and losses over a user-defined timeframe (controlled by the Depth parameter). This allows the indicator to see the "big picture" of how much momentum has been built up in one direction versus the other over a sustained period.
3. Momentum Comparison The final output is generated by performing a cross-comparison between these accumulated totals:
- The First Component: It compares the total strength of recent upward moves against the accumulated downward pressure from previous periods.
- The Second Component: It compares the total strength of recent downward moves against the accumulated upward pressure from previous periods.
Visual Representation
The results are plotted as two separate lines on a dedicated window below your main price chart. These lines represent the "net" momentum of the market:
- Trend Continuity: When one line trends significantly above the other, it indicates that the current direction (upward or downward) has sufficient momentum to potentially continue its path.
- Momentum Shifts: Sudden moves in these lines can signal when the price is beginning to exhaust its current trend and may be preparing for a reversal or a period of consolidation.
By using this tool, traders can better visualize whether a move is backed by significant historical strength or if the market is struggling to maintain its current trajectory.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| 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