tradebreakout
Download scriptThe TradeBreakOut indicator is a visual tool designed to help traders identify specific price momentum shifts by monitoring how the current market price compares to recent historical highs and lows. Instead of looking at simple price movements, it focuses on "breakout" logic—calculating the percentage difference between where the price is now and where it has been over a set period of time.
How the Logic Works
The indicator analyzes the market by looking back at a specific number of previous candles (determined by the "Period" setting). It essentially seeks to identify two distinct types of movements:
- Resistance Breakouts: The tool monitors the highest price reached during that look-back period. If the current price rises significantly above those previous highs, it signals potential upward momentum.
- Support Breakouts: Conversely, it monitors the lowest price reached during that same period. If the current price drops significantly below those previous lows, it signals potential downward momentum.
Visual Representation
The indicator produces two distinct lines on a separate window below your main chart:
- The Green Line: This represents the relationship between the current price and the historical highs (Resistance). When this line crosses above the zero mark, it serves as a signal that the price is breaking out toward the upside.
- The Red Line: This represents the relationship between the current price and the historical lows (Support). When this line crosses below the zero mark, it indicates the price is breaking out toward the downside.
Key Customizations
Users have the flexibility to choose how the "price" is measured based on their trading style:
- Close Price: The calculation is based on the final closing price of each candle, which is often preferred by traders looking for confirmed movements.
- High/Low Price: The calculation uses the absolute highest and lowest points reached during a candle's duration, which can be useful for capturing extreme volatility or "wick" movements.
By converting these complex historical comparisons into two simple lines, the indicator allows traders to quickly see when the market is moving outside of its recent established boundaries, potentially providing earlier entry signals for trend reversals or continuations.
//+------------------------------------------------------------------+
//| TradeBreakOut.mq4 |
//| Copyright © 2013, Andriy Moraru |
//+------------------------------------------------------------------+
#property copyright ""
#property link "http://www.earnforex.com"
/*
Red line crossing 0 from above is a support breakout signal.
Green line crossing 0 from below is a resistance breakout signal.
*/
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_width1 1
#property indicator_color1 Green
#property indicator_color2 Red
//---
extern int L=50; // Period
extern int PriceType=1; // 0 - Close, 1 - High/Low
//--- Buffers
double TBR_R[],TBR_S[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
IndicatorBuffers(2);
SetIndexBuffer(0,TBR_R);
SetIndexBuffer(1,TBR_S);
//---
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1);
SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,1);
//---
SetIndexDrawBegin(0,L);
SetIndexDrawBegin(1,L);
//---
SetIndexEmptyValue(0,EMPTY_VALUE);
SetIndexEmptyValue(1,EMPTY_VALUE);
//---
IndicatorDigits(Digits);
//---
IndicatorShortName("TBR("+L+")");
//---
return(0);
}
//+------------------------------------------------------------------+
//| TradeBreakOut |
//+------------------------------------------------------------------+
int start()
{
if(Bars <= L) return(0);
//---
int counted_bars=IndicatorCounted();
if(counted_bars>0) counted_bars--;
//--- Skip calculated bars
int end=Bars-counted_bars;
//--- Cannot calculate bars that are too close to the end. There won't be enough bars to calculate ArrayMin/Max
if(Bars-end<=L) end=Bars -(L+1);
//---
for(int i=0; i<end; i++)
{
if(PriceType==0) // Close
{
TBR_R[i] = (Close[i] - Close[ArrayMaximum(Close, L, i + 1)]) / Close[ArrayMaximum(Close, L, i + 1)];
TBR_S[i] = (Close[i] - Close[ArrayMinimum(Close, L, i + 1)]) / Close[ArrayMinimum(Close, L, i + 1)];
}
else if(PriceType==1) // High/Low
{
TBR_R[i] = (High[i] - High[ArrayMaximum(High, L, i + 1)]) / High[ArrayMaximum(High, L, i + 1)];
TBR_S[i] = (Low[i] - Low[ArrayMinimum(Low, L, i + 1)]) / Low[ArrayMinimum(Low, L, i + 1)];
}
}
//---
return(0);
}
//+------------------------------------------------------------------+
Comments