test3
Download scriptThe Large Close Swings Indicator is a specialized visual tool designed to help traders identify significant price movements by monitoring the relationship between the opening and closing prices of each candle on a trading chart.
Core Functionality
The primary purpose of this script is to highlight specific "swings" or price shifts that exceed a pre-defined threshold. Rather than looking at every minor fluctuation in the market, the indicator filters out noise to pinpoint moments where there is a substantial difference between where a candle started and where it finished.
How the Logic Works
The script monitors each candle on your chart and performs the following calculations:
- Price Variance Detection: For every historical candle, the tool calculates the difference between the Opening Price and the Closing Price.
- Threshold Filtering: The user can set a specific "Swing" value (a minimum distance). The indicator will only react if the price move is larger than this specific amount.
- Directional Identification:
- Bearish Swings: If a candle opens high and closes significantly lower (exceeding your chosen threshold), the script marks that point on the chart with a specific visual icon (Red). This indicates a strong downward movement during that period.
- Bullish Swings: If a candle opens low and closes significantly higher (exceeding your chosen threshold in the opposite direction), the script marks that point with a different visual icon (White). This indicates a strong upward movement.
Practical Application for Traders
By using this indicator, you can quickly scan through historical data to identify high-momentum zones. Instead of manually measuring every candle, the tool automatically places markers on the chart whenever a "large" price swing occurs. This allows you to see at a glance where significant volatility has taken place, helping you identify potential trend reversals or strong directional momentum in the market.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| Large Close Swings Indicator.mq4 |
//+------------------------------------------------------------------+
#property copyright "Ron T"
#property link "http://www.lightpatch.com/forex"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 White
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
//----
int ExtCountedBars=0;
// indicator parameters
extern double Swing=0.0010;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//|------------------------------------------------------------------|
int init()
{
SetIndexStyle(0,DRAW_ARROW);
SetIndexBuffer(0, ExtMapBuffer1);
SetIndexArrow(0,226);
SetIndexStyle(1,DRAW_ARROW);
SetIndexBuffer(1, ExtMapBuffer2);
SetIndexArrow(1,225);
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
double sum=0;
double oldsum=0;
double change=0;
int i;
int pos=Bars-ExtCountedBars-1;
if(Bars<=10) return(0);
ExtCountedBars=IndicatorCounted();
// check for possible errors
if (ExtCountedBars<0) return(-1);
// last counted bar will be recounted
if (ExtCountedBars>0) ExtCountedBars--;
while(pos>=0)
{
change=Open[pos]-Close[pos];
if (change>Swing)
{
ExtMapBuffer1[pos]=Close[pos];
ExtMapBuffer2[pos]=0;
}
if (change<(Swing*(-1)))
{
ExtMapBuffer1[pos]=0;
ExtMapBuffer2[pos]=Close[pos];
}
pos--;
}
//---- zero initial bars
// if(ExtCountedBars<1)
// {
// for(i=1;i<MA_Period;i++) ExtMapBuffer1[Bars-i]=0;
// for(i=1;i<MA_Period;i++) ExtMapBuffer2[Bars-i]=0;
// }
return(0);
}
//+------------------------------------------------------------------+
Comments