This script is designed as a visual indicator for trading platforms to help identify market momentum and price trends by analyzing the relationship between "up" moves and "down" moves over specific periods. Instead of just looking at the current price, it filters out market noise to provide a smoother representation of how the market is behaving.
How the Logic Works
1. Data Collection (The Foundation) The tool begins by scanning past price data over a set number of bars. It looks specifically at individual candles to determine if they closed higher or lower than they opened.
- It calculates the total "strength" of all positive moves (bullish).
- It calculates the total "strength" of all negative moves (bearish).
By separating these two types of movements, the script creates a foundation of what the market is doing independently of overall price direction.
2. Smoothing and Averaging Once the raw strengths are identified, the script performs a secondary analysis. It takes those values and averages them over a smaller, specific window (determined by the "tr" parameter). This step ensures that sudden, insignificant spikes in price don't cause erratic jumps in the indicator; it focuses on the consistent flow of the market rather than momentary volatility.
3. Momentum Calculation The core intelligence of this script lies in how it combines these values. It aggregates the bullish and bearish strengths into a single unified value. It then applies a series of complex mathematical weights (coefficients) to this sum.
Think of this like a "momentum filter": it weighs the most recent data more heavily than older data to give you a real-time sense of whether the current trend is accelerating or exhausting itself.
4. Visual Output The final result is plotted as a continuous line on a separate window in your trading platform.
- When the line moves upward, it suggests that positive price action (bullish strength) is dominating the timeframe.
- When the line moves downward, it indicates that negative price action (bearish strength) is prevailing.
Summary for Traders
Essentially, this tool acts as a "filter" for market sentiment. It ignores the distractions of minor price fluctuations and instead highlights the underlying push and pull of the market. By observing the direction and velocity of the resulting line, traders can get a clearer picture of whether the current trend has enough strength to continue or if it is beginning to lose steam.
//+------------------------------------------------------------------+
//| B&WImp-T01.mq4 |
//| 30.08.2006 Translated on MT4 by Oleg Golozubov aka Maloma |
//+------------------------------------------------------------------+
#property copyright " Copyright © 2006, HomeSoft-Tartan Corp."
#property link " spiky@transkeino.ru - http:\\www.fxexpert.ru"
#property indicator_separate_window
#property indicator_color1 Lime
#property indicator_buffers 1
#include <stdlib.mqh>
extern double mBar=300;
extern int per=96;
extern double tr=3;
extern double t3_period=8;
extern double b=0.7;
double Buffer[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0, DRAW_LINE, STYLE_SOLID);
SetIndexBuffer(0, Buffer);
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
double impr[300];
double impb[300];
double e1=0;
double e2=0;
double e3=0;
double e4=0;
double e5=0;
double e6=0;
double c1=0;
double c2=0;
double c3=0;
double c4=0;
double n=0;
double w1=0;
double w2=0;
double b2=0;
double b3=0;
int shift=0;
double imppr=0;
double imppb=0;
int i=0;
double sipr=0;
double sipb=0;
double null=0;
double sum=0;
double t3=0;
b2=b*b;
b3=b2*b;
c1=-b3;
c2=(3*(b2+b3));
c3=-3*(2*b2+b+b3);
c4=(1+3*b+b3+3*b2);
n=t3_period;
if(n<1) n=1;
n=1+0.5*(n-1);
w1=2/(n+1);
w2=1-w1;
for(shift=Bars-1;shift>=0 ;shift--) Buffer[shift]=0;
null=0.00001;
for(shift=mBar;shift>=per;shift--)
{
imppr=0;
imppb=0;
for(i=shift;i>=shift-per;i--)
{
if(Close[i]>Open[i]) imppr=imppr+(Close[i]-Open[i]);
if(Close[i]<Open[i]) imppb=imppb+(Close[i]-Open[i]);
}
imppr=MathRound(imppr/Point);
imppb=MathRound(imppb/Point);
if(imppr==0) imppr=0.0001;
if(imppb==0) imppb=0.0001;
impr[shift-per]=imppr;
impb[shift-per]=imppb;
}
for(shift=mBar-per;shift>=0;shift--)
{
sipr=0;
sipb=0;
for(i=shift;i>=shift-tr ;i--)
{
sipr=sipr+impr[shift];
sipb=sipb+impb[shift];
}
sipr=MathRound((sipr/tr));
sipb=MathRound((sipb/tr));
sum=sipr+sipb;
e1=w1*sum+w2*e1;
e2=w1*e1+w2*e2;
e3=w1*e2+w2*e3;
e4=w1*e3+w2*e4;
e5=w1*e4+w2*e5;
e6=w1*e5+w2*e6;
t3=c1*e6+c2*e5+c3*e4+c4*e3;
if(t3==0) t3=0.0001;
if(t3!=0) Buffer[shift]=t3;
}
return(0);
}
//+------------------------------------------------------------------+
Comments