The Stopreversal Mt4 script is a specialized technical analysis tool designed to identify specific price action patterns and potential trend reversals in real-time. Its primary purpose is to help traders spot "breakout" moments where the market moves from one state to another, providing visual cues and alerts for potential entry points.
Core Logic Overview
The script functions by tracking a dynamic "Stop Level." Instead of looking at simple price movements in isolation, it analyzes the relationship between the current closing price and the previous significant price point.
Here is a breakdown of how the logic operates:
1. Tracking Price Momentum The tool constantly evaluates whether the market is moving upward, downward, or staying flat relative to a reference point. It updates its internal "Stop Level" based on four distinct scenarios:
- Stagnant Movement: If the price remains unchanged, the level holds steady.
- Downward Pressure: If prices are consistently dropping, it adjusts the level downward (factoring in a small buffer).
- Upward Pressure: If prices are consistently rising, it adjusts the level upward.
- Directional Shifts: If the price shifts direction suddenly, the tool recalculates the new level immediately to accommodate the new trend.
2. Identifying Reversal Signals The script triggers a signal when a specific "breakout" occurs:
- Buying Opportunity: When the price moves above the established Stop Level while the previous bar showed a downward movement, the script identifies a potential shift toward an uptrend.
- Selling Opportunity: Conversely, if the price drops below the Stop Level while the previous bar showed upward movement, it identifies a potential shift toward a downtrend.
3. Visual and Audible Alerts To ensure traders don't miss these moments, the script provides two layers of notification:
- On-Chart Visualization: It paints colored bars (Blue for buying opportunities and Red for selling opportunities) directly on the chart to highlight where these reversals are occurring.
- Real-Time Notifications: If the user has enabled alerts, the script will trigger a pop-up message ("Look for Buying/Selling opportunity soon") exactly when these conditions are met, specifically timed to coordinate with 5-minute intervals.
Summary for the Trader
Essentially, this script acts as an automated "scout." It monitors the market's momentum and waits for the exact moment price breaks through a calculated resistance or support level. By doing this, it filters out minor market noise and highlights only the significant movements where a trend change is likely to occur.
//+------------------------------------------------------------------
//| Stopreversal Mt4.mq4
//|
//|
//| Conversion only Dr. Gaines
//| dr_richard_gaines@yahoo.com
//| modifications by Emsjoflo joel@emsjoflo.com
//|
//+------------------------------------------------------------------
#property copyright " emsjoflo"
#property link "automaticforec.invisionzone.com"
#property indicator_chart_window
#include <stdlib.mqh>
#property indicator_buffers 4
#property indicator_color1 Lime
#property indicator_width1 2
#property indicator_color2 Red
#property indicator_width2 2
#property indicator_color3 DodgerBlue
#property indicator_color4 Tomato
extern double nPips = 0.004;
extern bool Send5MinuteAlert = true;
int LastTradeTime;
double ExtHistoBuffer[];
double ExtHistoBuffer2[];
double BlueBar[],RedBar[];
void SetLoopCount(int loops)
{
}
void SetIndexValue(int shift, double value)
{
ExtHistoBuffer[shift] = value;
}
void SetIndexValue2(int shift, double value)
{
ExtHistoBuffer2[shift] = value;
}
int init()
{
SetIndexStyle(0, DRAW_ARROW, STYLE_SOLID);
SetIndexArrow(0, 233);
SetIndexBuffer(0, ExtHistoBuffer);
SetIndexStyle(1, DRAW_ARROW, STYLE_SOLID);
SetIndexArrow(1, 234);
SetIndexBuffer(1, ExtHistoBuffer2);
SetIndexStyle(2,DRAW_HISTOGRAM,0,2);
SetIndexBuffer(2,BlueBar);
SetIndexStyle(3,DRAW_HISTOGRAM,0,2);
SetIndexBuffer(3,RedBar);
return(0);
}
int start()
{
//+------------------------------------------------------------------
//| Local variables
//+------------------------------------------------------------------
int shift = 0;
double cnt = 0;
double TrStopLevel = 0;
double PREV = 0;
double pass = 0;
SetLoopCount(0);
// loop from first bar to current bar (with shift=0)
for(shift=Bars-2;shift>=0 ;shift--){
if( (Close[shift] == PREV) )
{
TrStopLevel=PREV;
}
else
{
if( (Close[shift+1])<PREV && (Close[shift]<PREV) )
{
TrStopLevel=MathMin(PREV,Close[shift]*(1+nPips));
}
else
{
if( ((Close[shift+1])>PREV) && (Close[shift]>PREV) )
{
TrStopLevel=MathMax(PREV,Close[shift]*(1-nPips));
}
else
{
if( (Close[shift]>PREV) )
{
TrStopLevel=Close[shift]*(1-nPips);
}
else TrStopLevel=Close[shift]*
(1+nPips);
}
}
}
if( Close[shift] > TrStopLevel && Close[shift+1]<PREV && PREV !=
0 )
{
if (CurTime() -iTime(NULL,0,1)==iTime(NULL,0,1)-iTime(NULL,0,2)-300
&& CurTime() -iTime(NULL,0,1)>=(iTime(NULL,0,2)-iTime(NULL,0,3)-300)
&& CurTime() -iTime(NULL,0,2)>=(iTime(NULL,0,1)-iTime(NULL,0,3)-300)
&& Send5MinuteAlert) Alert("Look for Buying opportunity soon");
RedBar[shift]=Low[shift];
BlueBar[shift]=High[shift];
//SetOrder(OP_BUY,1,ask,2,0,ask+TakeProfit*Point,blue);
//Alert("buy");
SetIndexValue(shift, TrStopLevel);
}
if( Close[shift] < TrStopLevel && Close[shift+1]>PREV && PREV !=
0 )
{
if ((CurTime() -iTime(NULL,0,1))==(iTime(NULL,0,1)-iTime(NULL,0,2)-300)
&& (CurTime() -iTime(NULL,0,1))>=(iTime(NULL,0,2)-iTime(NULL,0,3)-300)
&& (CurTime() -iTime(NULL,0,2))>=(iTime(NULL,0,1)-iTime(NULL,0,3)-300)
&& Send5MinuteAlert)Alert("Look for Selling opportunity soon");
BlueBar[shift]=Low[shift];
RedBar[shift]=High[shift];
//SetOrder(OP_SELL,1,bid,2,0,bid-TakeProfit*Point,Red);
SetIndexValue2(shift, TrStopLevel);
//Alert("Sell");
}
PREV=TrStopLevel;
//Alert(TrStopLevel);
}
return(0);
}
Comments