fxnewsbolttun
Download scriptThis script is designed as a technical analysis tool for the MetaTrader platform, specifically built to identify and highlight significant price "peaks" (supply points) and "troughs" (demand points) on a trading chart. It automates the process of scanning historical price data to find key structural levels where the market has shown clear turning points.
Core Logic and Functionality
The script operates by analyzing the relationship between high and low prices across consecutive candles (bars) on your chart. Instead of just looking at any price movement, it uses a specific set of criteria to ensure that only the most significant "pivot" points are captured.
1. Identification of Supply Zones (High Points) The tool scans backward from the current price to find local maxima. To qualify as a significant high point, the script checks if:
- The current candle's high is higher than the highs of the candles immediately preceding it and following it.
- The high is also greater than the closing price of an earlier candle in the sequence.
- The high is higher than any other high point already identified during the current scan.
This logic ensures that the script ignores minor fluctuations and only "locks onto" major peaks where the price reversed downward.
2. Identification of Demand Zones (Low Points) Similarly, the tool performs a mirror analysis to find significant local minima. A price point is flagged as a demand zone if:
- The current candle's low is lower than the lows of the candles immediately preceding it and following it.
- The low is also lower than the closing price of an earlier candle in the sequence.
- The low is lower than any other low point already identified during the current scan.
This allows the tool to pinpoint major "floors" where the price reacted by moving upward.
3. Dynamic Scanning and Updates The script includes a "Step Back" feature, allowing it to look into a specific depth of historical data to find these points. It is designed to be reactive; every time a new candle forms or the timeframe changes, the script refreshes its calculations to ensure the identified peaks and troughs are current.
Visual Representation
While the logic handles the mathematical "heavy lifting," the final result provides the user with clear visual markers:
- Supply Lines: High points are associated with specific colors (defaulting to Blue) and widths, helping traders visualize where overhead resistance may exist.
- Demand Lines: Low points are highlighted in contrasting colors (defaulting to Red), marking areas where potential support may be found.
Summary for the Trader
In simple terms, this script acts as an automated "scout." It combs through the price history to find the most prominent high and low marks—the "landmarks" of the market—and marks them clearly on your chart. This helps you identify historical zones of interest where the price has historically struggled to break through or bounce off in the past.
#property indicator_chart_window
extern int StepBack=0;
extern bool Qw1=True;
extern bool Qw2=True;
extern bool Qw3=True;
extern color UpLineColor = Blue;
extern int UpLnWidth = 1;
extern color DnLineColor = Red;
extern int DnLnWidth = 1;
extern color MarkColor = Blue;
extern int MarkNumber = 217;
int i=1,NP=0,D=0,
iB_Up=0,iB_Dn=0,
S1=0,
S2=0,
UpLev=0,
DownLev=0,
iP_Up=0,
iP_Dn=0,
value=0,
CurPeriod=0,
shift=0;
datetime nTime=0;
double UpV=0,
DownV=0,
iP=0,
target = 0,
UpP[2]={0,0},
DownP[2]={0,0},
PP1=0,PP2=0,PP3=0;
int DownBT[2]={0,0}, // Bar Time
UpBT[2]={0,0},
UpB[2]={0,0}, // Bar Num
DownB[2]={0,0};
string buff_str = "";
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//---- TODO: add your code here
Comment(" ");
ObjectsDeleteAll();
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int Target_Style[4] = {STYLE_DASH,STYLE_DASH,STYLE_DASH,STYLE_SOLID},
Target_LW[4] = { 1, 1, 1, 2 },
i=0,ic=0;
color Target_Color[4] = {DimGray,MediumSpringGreen,SeaGreen,Blue},
Target_Up_Color[4] = {DimGray,MediumSpringGreen,SeaGreen,Blue},
Target_Dn_Color[4] = {Magenta,Orange,Yellow,Red};
double target[4];
//---- TODO: add your code here
if ( (nTime!=Time[0]) || (CurPeriod!=Period()) ) {
UpP[0] = 0;
UpP[1] = 0;
}
//=================================================
//******** Ïîèñê îïîðíûõ òî÷åê ïðåäëîæåíèÿ ********
//=================================================
for(i=2+StepBack,D=2,NP=0; (NP<D)&&(i<Bars); i++) {//Begin
if (High[i]!= High[i+1]) {
if( (High[i]>High[i+1] && High[i]>High[i-1] && High[i]>Close[i+2] )
&& High[i]> UpP[0] ) {
UpB[NP] = i;
UpBT[NP] = Time[i];
UpP[NP] = High[i];
NP++;
}
}
if (High[i]== High[i+1]) {
if ( (High[i]>High[i+2] && High[i]>High[i-1] && High[i]>Close[i+3] ) && High[i]> UpP[0] ) {
UpB[NP] = i;
UpBT[NP] = Time[i];
UpP[NP] = High[i];
NP++;
}
}
if(i == (Bars-2) ) {
UpB[NP] = i;
UpBT[NP] = Time[i];
UpP[NP] = High[i];
break;
}
}//for(i=2+StepBack,D=2,NP=0; NP<D; ) {//End;
//=================================================
//********** Ïîèñê îïîðíûõ òî÷åê ñïðîñà ***********
//=================================================
DownP[0] = 1000000000;
DownP[1] = 1000000000;
for(i=2+StepBack,D=2,NP=0; (NP<D)&&(i<Bars); i++) {//Begin
if (Low[i]!= Low[i+1]) {
if ( (Low[i]<Low[i+1] && Low[i]<Low[i-1] && Low[i]<Close[i+2] ) && Low[i]< DownP[0] ){
DownB[NP] = i;
DownBT[NP]= Time[i];
DownP[NP] = Low[i];
NP++;
}
//i++;
}
if (Low[i]== Low[i+1]) {
if ( (Low[i]<Low[i+2] && Low[i]<Low[i-1] && Low[i]<Close[i+3] ) && Low[i]< DownP[0] ){
DownB[NP] = i;
DownBT[NP]= Time[i];
DownP[NP] = Low[i];
NP++;
}
//i++;
}
if (i == (Bars-2) ) {
DownB[NP] = i;
DownBT[NP]= Time[i];
DownP[NP] = Low[i];
break;
}
}
}
Comments