Stop_reversal_mod1
Download scriptThis tool is designed to identify specific price action patterns known as "stop reversals." It functions by monitoring the flow of market prices to detect moments where a trend might be exhausted or where "stops" (protective orders placed by other traders) are likely to be triggered, potentially leading to a sudden change in direction.
Core Logic and Market Monitoring
The script works by constantly tracking the relationship between the current market price and a calculated "Stop Level." It continuously evaluates whether the market is moving in a consistent direction or if it is behaving in a way that suggests a reversal.
To determine these movements, the logic follows these primary rules:
- Dynamic Stop Level Calculation: The script automatically updates a reference level based on previous prices. If the price moves consistently downward, the tool calculates a new threshold. If it moves upward, it adjusts the threshold in the opposite direction. It also includes a small buffer (defined by the "nPips" setting) to ensure that minor market "noise" doesn't trigger false signals.
- Trend Persistence: By remembering the previous price levels, the script can distinguish between a standard market fluctuation and a significant move that is pushing toward a potential reversal point.
Signal Identification
The indicator looks for two specific scenarios where a reversal is likely:
- Buying Opportunities: If the current price rises above the calculated Stop Level, but the previous bar showed a downward move, the script identifies this as a potential "Buy" setup. This suggests that sellers may be exhausted and the price is ready to head upward.
- Selling Opportunities: Conversely, if the current price drops below the Stop Level after a previous upward move, the script identifies a potential "Sell" setup, suggesting that buyers are exhausted and the price may fall.
Notifications and Visuals
To keep the user informed in real-time without requiring constant manual monitoring, the script includes several automated features:
- Visual Cues: It plots specific markers (histograms) on your chart to highlight where these reversal levels are occurring.
- Smart Alerts: The script can trigger an immediate pop-up alert on your screen when a signal is detected.
- Email Notifications: It can send automated emails providing details on the potential setup, including which currency pair or asset is being monitored and what type of trade (Buy or Sell) it is anticipating.
- Time-Based Filtering: There is a specific logic integrated to manage alerts based on how much time remains before a candle closes, helping to ensure you are notified at the most relevant moments for your trading timeframe.
//+------------------------------------------------------------------
//| 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 SendAlert = true;
extern bool SendEmail = true;
extern int AlertMinutesB4Close =30;
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)-AlertMinutesB4Close*60)
&& CurTime() -iTime(NULL,0,1)>=(iTime(NULL,0,2)-iTime(NULL,0,3)-AlertMinutesB4Close*60)
&& CurTime() -iTime(NULL,0,2)>=(iTime(NULL,0,1)-iTime(NULL,0,3)-AlertMinutesB4Close*60))
{
if(SendAlert) Alert("Look for Buying opportunity soon");
if(SendEmail) SendMail("Possible Buy setup on "+Symbol(),"Stop Reversal Indicator is anticipating a Buy setup on "+Symbol()+Period()+"in "+AlertMinutesB4Close+" minutes");
}
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)-AlertMinutesB4Close*60)
&& (CurTime() -iTime(NULL,0,1))>=(iTime(NULL,0,2)-iTime(NULL,0,3)-AlertMinutesB4Close*60)
&& (CurTime() -iTime(NULL,0,2))>=(iTime(NULL,0,1)-iTime(NULL,0,3)-AlertMinutesB4Close*60))
{
if (SendAlert)Alert("Look for Selling opportunity soon");
if(SendEmail) SendMail("Possible Sell setup on "+Symbol(),"Stop Reversal Indicator is anticipating a Sellz setup on "+Symbol()+Period()+"in "+AlertMinutesB4Close+" minutes");
}
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