yefekt
Download scriptThis indicator is designed to provide traders with a visual representation of price momentum and directional strength by analyzing the relationship between current price action and recent historical ranges. Unlike standard moving averages that simply smooth out price, this tool focuses on the "weight" of price movement relative to the volatility of the surrounding bars.
Core Logic Overview
The script operates by calculating a dynamic ratio. To do this, it performs two primary types of analysis:
1. Cumulative Range Calculation The indicator first establishes a baseline by measuring the total price movement (the distance between the highest high and lowest low) over a specific window of five consecutive bars. This creates a "sum of volatility" that serves as the denominator for its calculations. By doing this, the script understands how much the market has been moving overall during that period.
2. Relative Positioning Analysis Simultaneously, the script looks at the relationship between the current price and the high/low points from four bars ago. It determines where the price currently sits in relation to that previous range. By dividing this specific distance by the total volatility calculated in the first step, it produces a normalized value.
Visual Output and Behavior
The final output is presented as a histogram in a separate window, categorized into two distinct visual components:
- Directional Momentum: The tool determines whether the price is trending upward or downward based on whether the calculated ratio is positive or negative.
- Dynamic Switching:
- When the logic detects a positive trend, it illuminates a specific histogram (Lime color) to signify bullish momentum.
- When the logic detects a negative trend, it switches to a different histogram (Red color) to signify bearish momentum.
Summary for the Trader
Essentially, this script filters out minor market "noise" by comparing current price action against a 5-bar volatility window. It tells you not just if the price is moving, but whether the current move is significant enough relative to recent history to be considered a trend change, providing a clear visual cue for entering or exiting positions based on momentum shifts.
//+------------------------------------------------------------------+
//| Web: Y(Efekt).mq4 |
//| MNS777 |
//| mns777.ru@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Mns777"
#property link ""
//----
#property indicator_separate_window
#property indicator_buffers 6
#property indicator_minimum -1
#property indicator_maximum 1
//----
#property indicator_color5 Lime
#property indicator_color6 Red
//---- òîëùèíà èíäèêàòîðíûõ ëèíèé
#property indicator_width5 3
#property indicator_width6 3
//---- ïàðàìåòðû ãîðèçîíòàëüíûõ óðîâíåé èíäèêàòîðà
#property indicator_level1 0
#property indicator_level2 0.5
#property indicator_level3 -0.5
//---- Âíåøíèå ïàðàìåòðû
//---- Áóôåðû èíäèêàòîðà
double IndexBuffer[];
double IndexBar[];
double Buf1[];
double Buf2[];
double ExtBuffer1[];
double ExtBuffer2[];
//---- Ïåðåìåííûå
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexBuffer(0,IndexBuffer);
SetIndexStyle(0,DRAW_NONE);
SetIndexBuffer(1,IndexBar);
SetIndexStyle(1,DRAW_NONE);
SetIndexBuffer(2,Buf1);
SetIndexStyle(2,DRAW_NONE);
SetIndexBuffer(3,Buf2);
SetIndexStyle(3,DRAW_NONE);
//
SetIndexBuffer(4,ExtBuffer1);
SetIndexStyle(4,DRAW_HISTOGRAM);
SetIndexBuffer(5,ExtBuffer2);
SetIndexStyle(5,DRAW_HISTOGRAM);
//
IndicatorShortName("Y(Efekt)");
SetIndexLabel(0,NULL);
SetIndexLabel(1,"Y(Efekt)");
SetIndexLabel(2,NULL);
SetIndexLabel(3,NULL);
SetIndexLabel(4,NULL);
SetIndexLabel(5,NULL);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int limit,i,a;
int counted_bars=IndicatorCounted();
double current,X1;
datetime TimeBar;
//---- ïðîâåðêà íà âîçìîæíûå îøèáêè
if(counted_bars<0) return(-1);
//---- ïîñëåäíèé ïîñ÷èòàííûé áàð áóäåò ïåðåñ÷èòàí
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
//---- îñíîâíîé öèêë
//----
for(i=limit;i>=0;i--)
{
//Çàäàíèå çíà÷åíèé èíäåêñà èíäèêàòîðà
X1=(High[i]-Low[i+4]);
IndexBuffer[i]=(High[i]-Low[i])+(High[i+1]-Low[i+1]) +(High[i+2]-Low[i+2]) +(High[i+3]-Low[i+3]) +(High[i+4]-Low[i+4]) ;
if(High[i] > Low[i+4] )IndexBar[i]=X1/IndexBuffer[i];
if(Low[i] < High[i+4] )IndexBar[i]=(Low[i] - High[i+4] )/IndexBuffer[i];
}
//---- dispatch values between 2 buffers
bool up=true;
for(i=limit-1; i>=0; i--)
{
current=IndexBar[i];
if(current>0) up=true;
if(current<0) up=false;
if(!up)
{
ExtBuffer2[i]=current;
ExtBuffer1[i]=0.0;
}
else
{
ExtBuffer1[i]=current;
ExtBuffer2[i]=0.0;
}
IndexBar[i]=current;
}
//---- done
return(0);
}
//+------------------------------------------------------------------+
Comments