Momentum-Multi.mod

Download script
Author: Copyright ?2004, MetaQuotes Software Corp.
Momentum-Multi.mod

The Momentum-Multi indicator is a specialized technical analysis tool designed to help traders visualize market trends by tracking the "speed" and "strength" of price movements across multiple timeframes simultaneously.

Core Concept: Multi-Layered Momentum

Instead of looking at just one perspective of the market, this script calculates eight different momentum values at once. Each value represents a different look-back period (ranging from very short-term to longer-term durations). By plotting all eight of these calculations on a single chart, the tool allows you to see how the market is behaving across various layers of time—from immediate price fluctuations to broader, sustained trends.

How It Works

The indicator operates based on the following logic:

  • Simultaneous Calculations: The script takes the current closing price and compares it against previous prices over eight distinct intervals. These intervals are customizable (e.g., periods of 5, 7, 9, 11, 14, 17, 20, and 23).
  • Normalized Baseline: To make the data easier to read and interpret, the script applies a standardized adjustment to each momentum value. This ensures that all eight lines are scaled consistently relative to a zero-baseline, making it easier to identify when prices are moving above or below average expectations.
  • Visual Differentiation: Each of the eight momentum layers is assigned a unique color. This allows you to distinguish between different timeframes at a glance. For example, you can quickly see if the short-term "fast" momentum is diverging from the long-term "slow" momentum.

Practical Application for Traders

For a user watching the charts, this tool provides a high-level overview of market dynamics:

  1. Trend Confirmation: When all eight lines move in the same direction, it suggests a strong, unified trend across multiple time horizons.
  2. Divergence Detection: If the shorter-term lines begin to move in one direction while the longer-term lines remain steady or move in the opposite direction, it can signal a potential shift in momentum or a weakening of the current trend.
  3. Market Stability: By observing how tightly clustered these eight lines are, traders can gauge whether the market is experiencing high volatility (wide spread between lines) or consolidated stability (lines moving closely together).

In summary, this script transforms raw price data into a multi-layered visual map, helping you see not just where the price is going, but the strength and consistency of that movement across different timeframes.

Indicators Used
Momentum indicator
Miscellaneous
Implements a curve of type %1
11 Views
0 Downloads
0 Favorites
Momentum-Multi.mod
//+------------------------------------------------------------------+
//|                                          Momentum-Multi.mq4 v1.0 |
//|                      Copyright ?2004, MetaQuotes Software Corp. |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
#property copyright "Copyright ?2004, MetaQuotes Software Corp."
#property link      "http: //www.metaquotes.net/"

#property indicator_separate_window
#property indicator_buffers 8
#property indicator_color1 Red
#property indicator_color2 Orange
#property indicator_color3 Gold
#property indicator_color4 Lime
#property indicator_color5 Aqua
#property indicator_color6 DodgerBlue
#property indicator_color7 MediumPurple
#property indicator_color8 Silver

#property indicator_level1 0
#property indicator_levelcolor LightSlateGray

#define INDICATOR_VERSION "v1.0.mod"

//---- input parameters
extern int MomPeriod1 = 5;
extern int MomPeriod2 = 7;
extern int MomPeriod3 = 9;
extern int MomPeriod4 = 11;
extern int MomPeriod5 = 14;
extern int MomPeriod6 = 17;
extern int MomPeriod7 = 20;
extern int MomPeriod8 = 23;

//---- buffers
double MomBuffer1[];
double MomBuffer2[];
double MomBuffer3[];
double MomBuffer4[];
double MomBuffer5[];
double MomBuffer6[];
double MomBuffer7[];
double MomBuffer8[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init() {
    string short_name;
//---- indicator line
    SetIndexStyle( 0, DRAW_LINE );
    SetIndexStyle( 1, DRAW_LINE );
    SetIndexStyle( 2, DRAW_LINE );
    SetIndexStyle( 3, DRAW_LINE );
    SetIndexStyle( 4, DRAW_LINE );
    SetIndexStyle( 5, DRAW_LINE );
    SetIndexStyle( 6, DRAW_LINE );
    SetIndexStyle( 7, DRAW_LINE );
    SetIndexBuffer( 0, MomBuffer1 );
    SetIndexBuffer( 1, MomBuffer2 );
    SetIndexBuffer( 2, MomBuffer3 );
    SetIndexBuffer( 3, MomBuffer4 );
    SetIndexBuffer( 4, MomBuffer5 );
    SetIndexBuffer( 5, MomBuffer6 );
    SetIndexBuffer( 6, MomBuffer7 );
    SetIndexBuffer( 7, MomBuffer8 );
//---- name for DataWindow and indicator subwindow label
    short_name = "Momentum-Multi " + INDICATOR_VERSION + "(" + MomPeriod1 + "," + MomPeriod2 + "," + MomPeriod3 + "," + MomPeriod4 + "," + MomPeriod5 + "," + MomPeriod6 + "," + MomPeriod7 + "," + MomPeriod8 + ")";
    IndicatorShortName( short_name );
    SetIndexLabel( 0, "Momentum-Multi(" + MomPeriod1 + ")" );
    SetIndexLabel( 1, "Momentum-Multi(" + MomPeriod2 + ")" );
    SetIndexLabel( 2, "Momentum-Multi(" + MomPeriod3 + ")" );
    SetIndexLabel( 3, "Momentum-Multi(" + MomPeriod4 + ")" );
    SetIndexLabel( 4, "Momentum-Multi(" + MomPeriod5 + ")" );
    SetIndexLabel( 5, "Momentum-Multi(" + MomPeriod6 + ")" );
    SetIndexLabel( 6, "Momentum-Multi(" + MomPeriod7 + ")" );
    SetIndexLabel( 7, "Momentum-Multi(" + MomPeriod8 + ")" );
//----
    SetIndexDrawBegin( 0, MomPeriod1 );
    SetIndexDrawBegin( 1, MomPeriod2 );
    SetIndexDrawBegin( 2, MomPeriod3 );
    SetIndexDrawBegin( 3, MomPeriod4 );
    SetIndexDrawBegin( 4, MomPeriod5 );
    SetIndexDrawBegin( 5, MomPeriod6 );
    SetIndexDrawBegin( 6, MomPeriod7 );
    SetIndexDrawBegin( 7, MomPeriod8 );
//----
    return( 0 );
}

//+------------------------------------------------------------------+
//| Momentum                                                         |
//+------------------------------------------------------------------+
int start() {
    int counted_bars = IndicatorCounted();
    
    // Check for errors
    if ( counted_bars < 0 ) {
        return( -1 );
    }

    // Last bar will be recounted
    if ( counted_bars > 0 ) {
        counted_bars--;
    }
    
    // Get the upper limit
    int limit = Bars - counted_bars;
    
    for ( int ictr = 0; ictr < limit; ictr++ ) {
        MomBuffer1[ictr] = iMomentum( NULL, 0, MomPeriod1, PRICE_CLOSE, ictr ) - 100.0;
        MomBuffer2[ictr] = iMomentum( NULL, 0, MomPeriod2, PRICE_CLOSE, ictr ) - 100.0;
        MomBuffer3[ictr] = iMomentum( NULL, 0, MomPeriod3, PRICE_CLOSE, ictr ) - 100.0;
        MomBuffer4[ictr] = iMomentum( NULL, 0, MomPeriod4, PRICE_CLOSE, ictr ) - 100.0;
        MomBuffer5[ictr] = iMomentum( NULL, 0, MomPeriod5, PRICE_CLOSE, ictr ) - 100.0;
        MomBuffer6[ictr] = iMomentum( NULL, 0, MomPeriod6, PRICE_CLOSE, ictr ) - 100.0;
        MomBuffer7[ictr] = iMomentum( NULL, 0, MomPeriod7, PRICE_CLOSE, ictr ) - 100.0;
        MomBuffer8[ictr] = iMomentum( NULL, 0, MomPeriod8, PRICE_CLOSE, ictr ) - 100.0;
    }
    return( 0 );
}

//+------------------------------------------------------------------+

Comments