MultiTrend
Download scriptThis script is designed as a technical analysis tool that identifies potential reversal points in price action by detecting "exhaustion" and trend changes. Rather than simply looking at whether the price is going up or down, it analyzes how far the current price has stretched away from its recent historical range to predict where the market might turn around.
Core Logic Overview
The tool operates by constantly measuring the "elasticity" of the market. It calculates a dynamic range based on recent high and low prices and compares the current price against a calculated boundary. When the price pushes too far beyond these boundaries, the script signals that the movement may be overextended.
How it Works Step-by-Step:
- Dynamic Range Calculation: The script looks back at a specific number of candles (determined by market volatility) to find the highest and lowest prices reached in that period. It then establishes a "normal" range for the current price movement.
- Boundary Detection: Based on these high and low points, the script creates two invisible boundaries: an upper ceiling and a lower floor. The distance of these boundaries from the highs and lows is controlled by a sensitivity setting.
- Overextension Identification:
- If the price opens significantly below the lower boundary, it suggests the market is being oversold or has dropped too quickly.
- If the price opens significantly above the upper boundary, it suggests the market is overbought or has climbed too aggressively.
- Signal Validation: The script doesn't just fire a signal every time the price hits a limit. It performs a "look-back" check to ensure that a movement in the opposite direction has actually begun. It verifies that the trend has flipped before confirming a signal.
- Visual Output: Once a confirmed reversal is detected, the script places visual markers (arrows) on the chart. One color indicates a potential move upward (bullish), and the other indicates a potential move downward (bearish).
Summary for the User
In simple terms, this tool helps you identify "rubber band" effects in trading. When the price stretches too far in one direction, the script detects that the move is becoming unsustainable and highlights moments where the market is likely to snap back in the opposite direction.
//+--------------------------------------------------------------------+
//| MultiTrend_Signal_KVN.mq4 |
//| Vladimir Korykin |
//| koryvladimir@inbox.ru |
//+--------------------------------------------------------------------+
#property copyright "Vladimir Korykin"
#property link "koryvladimir@inbox.ru"
//----
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 Yellow
//----
extern int K=48;
extern double Kstop=0.5;
extern int Kperiod=150;
extern int PerADX=14;
extern int CountBars=2800;
//----
double ind0[];
double ind1[];
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int init()
{
SetIndexStyle(0,DRAW_ARROW,EMPTY,2);
SetIndexArrow(0,218);
SetIndexBuffer(0,ind0);
SetIndexEmptyValue(0,0.0);
SetIndexStyle(1,DRAW_ARROW,EMPTY,2);
SetIndexArrow(1,217);
SetIndexBuffer(1,ind1);
SetIndexEmptyValue(1,0.0);
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int deinit()
{
return(0);
}
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
int start()
{
int loopbegin=0, SSP=0, i1=0, MyBars=0;
double Range=0,AvgRange=0;
double smin=0, smax=0, SsMax=0, SsMin=0,val1=0,val2=0,value3=0;
int table1[], table2[];
double Table_value2[];
//----
ArrayResize(Table_value2, Bars);
ArrayResize(table1, Bars);
ArrayResize(table2, Bars);
//----
bool first=true;
if (first)
{
loopbegin=CountBars+1;
MyBars=loopbegin;
if (loopbegin < 0) return(0);
first=false;
}
for(int i=loopbegin; i>=0; i--)
{
// SSP=MathCeil(Kperiod/iADX(NULL, 0, PerADX, PRICE_CLOSE, MODE_MAIN, 1));
SSP=MathCeil(Kperiod/iADX(NULL, 0, PerADX, PRICE_OPEN, MODE_MAIN, 1));
Range=0;
AvgRange=0;
for(i1=i; i1<=i+SSP; i1++)
AvgRange=AvgRange+MathAbs(High[i1]-Low[i1]);
Range=AvgRange/(SSP+1);
SsMax=High[Highest(NULL,0,MODE_HIGH,SSP,i)];
SsMin=Low[Lowest(NULL,0,MODE_LOW,SSP,i)];
smin=SsMin+(SsMax-SsMin)*K/100;
smax=SsMax-(SsMax-SsMin)*K/100;
table1[i]=i;
// Table_value2[i]=Close[i];
Table_value2[i]=Open[i];
table2[i]=0;
val1=0;
val2=0;
value3=0;
// if (Close[i]<smin)
if (Open[i]<smin)
{
i1=1;
table2[i]=-1;
while(table2[i+i1]>-1 && table2[i+i1]<1 && Table_value2[i+i1]>0)
i1=i1+1;
if (table2[i+i1]==1)
{
value3=High[i]+Range*Kstop;
val1=value3;
}
}
// if (Close[i]>smax)
if (Open[i]>smax)
{
i1=1;
table2[i]=1;
while(table2[i+i1]>-1 && table2[i+i1]<1 && Table_value2[i+i1]>0)
i1=i1+1;
if (table2[i+i1]==-1)
{
value3=Low[i]-Range*Kstop;
val2=value3;
}
}
ind0[i]=val1;
ind1[i]=val2;
loopbegin=loopbegin+1;
if (MyBars<Bars && i==0)
{
for(i1=72; i1>=2; i1--)
{
table1[i1]=table1[i1-1];
Table_value2[i1]=Table_value2[i1-1];
table2[i1]=table2[i1-1];
}
MyBars=MyBars+1;
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments