CloseOnTheLimit_Reverse

Download script
Author: Scriptong
CloseOnTheLimit_Reverse

This script functions as a visual trading tool designed to identify specific price action patterns on your charts. Its primary purpose is to highlight potential reversal zones or "exhaustion" points by analyzing the relationship between consecutive candles and market volatility.

How the Logic Works

The script scans the chart history to identify two distinct types of price movements:

1. Identifying Upward Momentum Shifts The tool looks for instances where a candle closes significantly higher than the peak of the previous two candles (adjusted by a small, user-defined buffer). When this specific condition is met, the script calculates a target level based on the current candle's high price. It then projects a visual marker downward, using a calculation based on the Average True Range (ATR)—a standard measure of market volatility—to place the mark at a specific distance below the price.

2. Identifying Downward Momentum Shifts Conversely, the script monitors for instances where a candle closes significantly lower than the bottom of the preceding two candles. When this occurs, it identifies the current candle's low price and projects a visual marker upward. Similar to the upward logic, this marker is placed at a specific distance above the price using volatility data to ensure the placement is proportional to the current market activity.

Visual Representation

The script communicates these findings through two distinct types of markers on your chart:

  • Blue Markers: These appear when the downward momentum conditions are met, highlighting potential areas of interest relative to local lows.
  • Red Markers: These appear when the upward momentum conditions are met, highlighting potential areas of interest relative to local highs.

By using the Average True Range (ATR) as a base for these markers, the script ensures that the visual signals are "normalized." This means that during periods of high volatility, the markers will be spaced further apart, while during calm markets, they will sit closer to the price action, helping traders maintain a consistent perspective regardless of market conditions.

Indicators Used
Indicator of the average true range
Miscellaneous
Implements a curve of type %1
8 Views
0 Downloads
0 Favorites
CloseOnTheLimit_Reverse
//+------------------------------------------------------------------+
//|                                              CloseOnTheLimit.mq4 |
//|                                                        Scriptong |
//|                                                scriptong@mail.ru |
//+------------------------------------------------------------------+
#property copyright "Scriptong"
#property link      "scriptong@mail.ru"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Blue
#property indicator_color2 Red
//---- input parameters
extern int       Bit=1;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,217);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexEmptyValue(0,0.0);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,218);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexEmptyValue(1,0.0);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
//----
   int limit = Bars-counted_bars;
   
   for(int i = limit; i>=0; i--)
    {
     if(Close[i+1] > High[i+2]+Bit*Point)
       ExtMapBuffer2[i] = High[i] + iATR(Symbol(), 0, 100, i)/2;
     if(Close[i+1] < Low[i+2]-Bit*Point)
       ExtMapBuffer1[i] = Low[i] - iATR(Symbol(), 0, 100, i)/2;
    }
//----
   return(0);
  }
//+------------------------------------------------------------------+

Comments