SmPriceBend-T01
Download scriptThis technical tool, known as PriceBend-T01, is designed to analyze market price movements by identifying changes in momentum and the "curvature" of price trends. Instead of looking at raw price data alone, it focuses on how the velocity of the price shifts over time, helping traders visualize whether a trend is accelerating, slowing down, or reversing.
How the Logic Works
The script operates through a multi-step mathematical process to filter out market noise and highlight significant price behavior:
1. Measuring Price Momentum The tool starts by calculating a simple moving average of the closing prices over a specific timeframe (defined by the user). It then compares the current moving average against the previous one. The difference between these two values represents the immediate "bend" or slope of the price movement.
2. Smoothing and Weighting Raw price data can be erratic. To make the information more readable, the script applies a smoothing algorithm. It uses a weighted calculation that gives importance to recent price movements while blending them with historical data. This prevents the indicator from reacting too wildly to minor, insignificant price fluctuations (market "noise").
3. Trend Acceleration Analysis The core logic goes beyond just seeing if the price is going up or down; it looks for the rate of change in that movement. By applying a specific mathematical coefficient to the smoothed data, the script identifies the underlying trajectory of the market. This helps distinguish between a strong, healthy trend and a weakening one that is losing steam.
4. Signal Generation The final step converts these complex calculations into two distinct visual outputs:
- Trend Mapping: The first output provides a continuous line that represents the calculated momentum.
- Directional Trigger: The second output acts as a binary signal. It evaluates the result of the mathematical formula: if the momentum is positive, it triggers an "Up" state; if it is negative, it triggers a "Down" state.
Summary for the User
In simple terms, this script acts like a sophisticated "speedometer" and "compass" combined. It looks at how fast the price is moving and, more importantly, how that speed is changing. By smoothing out the jumps in the market, it provides a clearer picture of the prevailing trend, helping you see where the momentum is heading before the actual price makes its next major move.
//+------------------------------------------------------------------+
//| MQL to MQ4 by Maloma SmPriceBend-T01.mq4 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, HomeSoft-Tartan Corp."
#property link "spiky@sinet.spb.ru"
//----
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Gold
#property indicator_color2 Red
//---- indicator parameters
extern int mBar=3000;
extern int per=21;
extern int t3_period=6;
extern double b=0.7;
extern double up=1;
extern double um=-1;
//---- indicator buffers
double Buffer1[];
double Buffer2[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
//---- indicator buffers mapping
SetIndexBuffer(0,Buffer1);
SetIndexBuffer(1,Buffer2);
//---- drawing settings
SetIndexStyle(0,DRAW_LINE,EMPTY,2);
SetIndexArrow(0,217);
SetIndexStyle(1,DRAW_LINE,EMPTY,2);
SetIndexArrow(1,218);
//----
SetIndexEmptyValue(0,0.0);
SetIndexEmptyValue(1,0.0);
//---- name for DataWindow
SetIndexLabel(0,"1st");
SetIndexLabel(1,"2nd");
//---- initialization done
IndicatorShortName("PriceBend-T01");
return(0);
}
double e1,e2,e3,e4,e5,e6,c1,c2,c3,c4,n,w1,w2,b2,b3;
double matwo,manul,bend,trig=0.0001,t3_21,t3_120;
int shift;
bool ft=true;
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
if (ft)
{
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;
ft=false;
}
//----
for(shift=mBar;shift>=0;shift--)
{
matwo=iMA(Symbol(),0,per,0,MODE_SMA,PRICE_CLOSE,shift+2);
manul=iMA(Symbol(),0,per,0,MODE_SMA,PRICE_CLOSE,shift);
//----
bend=(manul-matwo)/Point;
//----
e1=w1*bend + 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_21=c1*e6 + c2*e5 + c3*e4 + c4*e3;
//----
if (t3_21==0) t3_21=0.0001;
Buffer1[shift]=t3_21;
//n120=(n120nul-n120two)/point;
//if n120=0 then n120=0.0001;
if (t3_21>0) {trig=up;} else {trig=um;}
Buffer2[shift]=trig;
}
}
//+------------------------------------------------------------------+
Comments