Stop_reversal_mod_v1

Download script
Author: emsjoflo
Stop_reversal_mod_v1

The Stopreversal Mt4 indicator is designed to identify specific price action shifts that suggest a potential reversal in the market trend. Rather than relying on simple lagging averages, the logic focuses on tracking "breakout" levels and monitoring how the price reacts to them in real-time.

Core Logic & Functionality

The script operates by continuously scanning historical and current price data to establish a dynamic threshold, referred to as a Stop Level. Here is how the logic flows:

1. Dynamic Threshold Tracking The tool monitors the relationship between the current closing prices and the previous price points. It calculates a specific level (the Stop Level) based on several conditions:

  • If the price is moving consistently in one direction, the tool adjusts the threshold to account for that momentum.
  • It incorporates a small buffer (defined by the user as "nPips") to ensure that minor market noise doesn't trigger false signals; it looks for significant movement beyond these calculated levels.

2. Reversal Detection The primary goal of the script is to detect "Stop Reversals." This happens when the price moves past a previously established level but then shows a specific type of reaction:

  • Buying Opportunities: The logic looks for instances where the price crosses above the Stop Level following a downward move. When this specific pattern occurs, the indicator identifies a potential shift toward an upward trend.
  • Selling Opportunities: Conversely, the script monitors for instances where the price falls below the Stop Level after an upward move, signaling a potential shift toward a downward trend.

3. Visual Indicators and Alerts To make this data actionable for the user, the script provides several visual and auditory cues:

  • On-Chart Mapping: The tool draws specific bars (Blue and Red) on the chart to highlight exactly where these reversal conditions have been met.
  • Real-Time Notifications: If the "5-Minute Alert" feature is enabled, the script monitors the timing of the candles. If a reversal pattern is detected within a specific time window, it will trigger an automated alert message on your screen.

Summary for the Trader

Essentially, this tool acts as a "momentum tracker." It identifies where traders might be placing their stop-loss orders and watches for the moment those stops are hit in a way that suggests the trend is changing. By highlighting these "Stop Reversals" visually on your chart and providing alerts, it helps you spot potential entry points before the rest of the market fully reacts to the new direction.

Miscellaneous
Implements a curve of type %1
12 Views
0 Downloads
0 Favorites
Stop_reversal_mod_v1
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/

//+------------------------------------------------------------------
//|                                            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