This tool is designed to identify and visualize significant trend reversal points on a trading chart. Its primary purpose is to filter out minor market noise and highlight the specific moments when price action shifts from an upward movement to a downward movement, or vice versa.
Core Logic and Functionality
The script operates by constantly monitoring the "highs" and "lows" of price action over time. It establishes a memory of these significant points to understand the current direction of the market. Here is how the logic flows:
1. Trend Tracking The tool maintains an internal sense of whether the market is currently in an "Up" trend or a "Down" trend. It updates these boundaries dynamically as new highs and lows are formed on the chart.
2. Identifying Reversal Conditions Unlike simple indicators that react to every small price movement, this script uses a specific threshold (defined by the user as the "ReversPoint"). For a reversal to be confirmed, the price must move significantly enough against the current trend to exceed this predefined distance from the recent peak or valley.
- In an Upward Trend: If the price drops below the previous high by more than the designated number of points, the script identifies a potential shift to a downward trend.
- In a Downward Trend: If the price climbs above the previous low by more than the designated number of points, the script identifies a potential shift back to an upward trend.
3. Precision Marking When these specific reversal conditions are met, the tool calculates the exact point where the momentum began to shift. Instead of just marking the current candle, it looks back at the price action to place a visual marker (a yellow section) at the historical peak or valley that triggered the change.
4. Visual Output The result is a clean set of markers on your chart that pinpoint major turning points. By focusing only on movements that exceed your "ReversPoint" requirement, the tool helps traders ignore minor fluctuations and focus on substantial structural changes in market direction.
//+------------------------------------------------------------------+
//| RPoint.mq4 |
//| Copyright © 2004, Poul_Trade_Forum |
//| Aborigen |
//| http://forex.kbpauk.ru/ |
//+------------------------------------------------------------------+
#property copyright "Poul Trade Forum"
#property link "http://forex.kbpauk.ru/"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_color1 Yellow
//---- input parameters
extern int ReversPoint=50;
//---- buffers
double RBuffer[];
int Trend=1,InTrend,ttime;
double Points,Last_High, Last_Low;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
string short_name;
Points = MarketInfo (Symbol(), MODE_POINT);
//---- indicator line
SetIndexStyle(0,DRAW_SECTION,EMPTY,1,Yellow);
SetIndexBuffer(0,RBuffer);
SetIndexEmptyValue(0,0);
//---- name for DataWindow and indicator subwindow label
short_name="RPoint";
IndicatorShortName(short_name);
SetIndexLabel(0,short_name);
//----
SetIndexDrawBegin(0,100);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted(),i,shift;
//---- TODO: add your code here
i=(Bars-counted_bars)-1;
for (shift=i; shift>=0;shift--)
{
if (Time[shift]!=ttime) InTrend=InTrend+1;
ttime=Time[shift];
RBuffer[shift]=0;
if (High[shift+1]>Last_High && Trend==1) InTrend=1;
if (Low[shift+1]<Last_Low && Trend==0) InTrend=1;
if (High[shift+1]>Last_High) Last_High=High[shift+1];
if (Low[shift+1]<Last_Low) Last_Low=Low[shift+1];
if (Trend==1 && Low[shift+1]<Last_High-ReversPoint*Points && InTrend>1)
{
Trend=0;
RBuffer[shift+InTrend]=High[shift+InTrend];
Last_High=Low[shift+1];
Last_Low=Low[shift+1];
InTrend=1;
}
if (Trend==0 && High[shift+1]>Last_Low+ReversPoint*Points && InTrend>1)
{
Trend=1;
RBuffer[shift+InTrend]=Low[shift+InTrend];
Last_Low=High[shift+1];
Last_High=High[shift+1];
InTrend=1;
}
//----
}
return(0);
}
//+------------------------------------------------------------------+
Comments