Author: ��� ����� �. aka KimIV
id

This tool is designed to help traders visualize potential price boundaries on a daily basis by analyzing historical market behavior. Rather than just showing where the price has been, it attempts to project where the price might go next based on established mathematical patterns of past trading sessions.

How the Logic Works

Historical Analysis The script looks back at a specific number of previous days (determined by the user) to understand how those trading sessions developed. For each of these past days, it identifies four key data points: the opening price, the highest price reached, the lowest price reached, and the closing price.

Calculating the Price "Center" The core logic relies on identifying the balance point of a trading day. Depending on whether a previous day ended higher or lower than it started, the script applies a specific formula to find a weighted average. This calculation balances the high and low extremes against the opening and closing prices to determine a "pivot" or equilibrium point for that day's movement.

Projecting Future Ranges By calculating these balance points for past days, the tool can then project expected boundaries for the current or upcoming session. It calculates two primary levels:

  • Upper Projection: An estimated ceiling based on the historical distance between the calculated center and the previous low.
  • Lower Projection: An estimated floor based on the historical distance between the calculated center and the previous high.

Visual Forecasting One of the primary features of this script is its ability to project these ranges into the future. If enabled, it creates visual "rays" on your chart. These lines extend from the current price action forward, providing a roadmap of potential support and resistance levels for the next trading session. This allows traders to see at a glance where the market might face significant pressure or find stability based on historical volatility patterns.

Summary of Key Features

  • Dynamic Calculations: Adjusts its math automatically depending on whether the previous day’s price action was bullish, bearish, or neutral.
  • Timeframe Optimization: Specifically calibrated for daily data to ensure that the "Daily Range" logic remains consistent.
  • Visual Guidance: Uses distinct colors and dotted lines to differentiate between historical projections and future forecasts, keeping the chart clean and readable.
Price Data Components
Series array that contains close prices for each bar
9 Views
0 Downloads
0 Favorites
id
//+------------------------------------------------------------------+ 
//| i-DRProjections.mq4 | 
//| Êèì Èãîðü Â. aka KimIV | 
//| http://www.kimiv.ru | 
//| 27.08.2005 v.0.0 ïî ïðîñüáå $anto$'à | 
//| Èíäèêàòîð Daily Range Projections | 
//| Ïðîãíîçèðîâàíèå äíåâíûõ äèàïàçîíîâ öåí | 
//| Àâòîð èäåè Òîìàñ Äåìàðê | 
//| 29.08.2005 v.0.1 Äîðàáîòêà Aleks78 | 
//+------------------------------------------------------------------+ 
#property copyright "Êèì Èãîðü Â. aka KimIV" 
#property link "http://www.kimiv.ru" 

#property indicator_chart_window 
#property indicator_buffers 2 
#property indicator_color1 LightBlue 
#property indicator_color2 LightSalmon 

//------- Âíåøíèå ïàðàìåòðû ------------------------------------------ 
extern int NumberOfDay = 10; // Êîëè÷åñòâî äíåé 
extern bool ShowTomorrow = True; // Ïîêàçûâàòü çàâòðà 

//------- Áóôåðû èíäèêàòîðà ------------------------------------------ 
double MaxDay[]; 
double MinDay[]; 

//+------------------------------------------------------------------+ 
//| Custom indicator initialization function | 
//+------------------------------------------------------------------+ 
void init() { 
if (ShowTomorrow) { 
ObjectCreate("LineHi", OBJ_TREND, 0, 0,0, 0,0); 
ObjectCreate("LineLo", OBJ_TREND, 0, 0,0, 0,0); 
} 

SetIndexBuffer(0, MaxDay); 
SetIndexStyle (0, DRAW_LINE, STYLE_SOLID, 1); 
SetIndexBuffer(1, MinDay); 
SetIndexStyle (1, DRAW_LINE, STYLE_SOLID, 1); 
Comment(""); 
} 

//+------------------------------------------------------------------+ 
//| Custor indicator deinitialization function | 
//+------------------------------------------------------------------+ 
void deinit() { 
ObjectDelete("LineHi"); 
ObjectDelete("LineLo"); 
Comment(""); 
} 

//+------------------------------------------------------------------+ 
//| Custom indicator iteration function | 
//+------------------------------------------------------------------+ 
int start() { 
double po, ph, pl, pc, x; 
double MaxDay1, MinDay1, OpenDay1, CloseDay1; //+++ 
int currDay, i=0, j=0; 

if (Period()>240) { 
Comment("Èíäèêàòîð i-DRProjections íå ïîääåðæèâàåò ÒÔ áîëåå Í4 !"); 
return; 
} 

while (i<=NumberOfDay) { 
if (currDay!=TimeDay(Time[j])) { 
po = iOpen (NULL, 1440, i+1); 
ph = iHigh (NULL, 1440, i+1); 
pl = iLow (NULL, 1440, i+1); 
pc = iClose(NULL, 1440, i+1); 
if (pc<po) x = (ph + pl + pc + pl) / 2; 
if (pc>po) x = (ph + pl + pc + ph) / 2; 
if (pc==po) x = (ph + pl + pc + pc) / 2; 
i++; 
} 
currDay = TimeDay(Time[j]); 
MaxDay[j] = x - pl; 
MinDay[j] = x - ph; 
j++; 
} 

//++++++++++++++++++++++++++++++++++++++++++++++++ 
if (ShowTomorrow) { 
MaxDay1 = MarketInfo(Symbol(),MODE_HIGH); 
MinDay1 = MarketInfo(Symbol(),MODE_LOW); 
OpenDay1 = iOpen (NULL, 1440, 0); 
CloseDay1 = Bid; 

if (CloseDay1<OpenDay1) x = (MaxDay1 + MinDay1 + CloseDay1 + MinDay1) / 2; 
if (CloseDay1>OpenDay1) x = (MaxDay1 + MinDay1 + CloseDay1 + MaxDay1) / 2; 
if (CloseDay1==OpenDay1) x = (MaxDay1 + MinDay1 + CloseDay1 + CloseDay1) / 2; 

ObjectSet("LineHi",OBJPROP_TIME1, Time[1]); 
ObjectSet("LineLo",OBJPROP_TIME1, Time[1]); 
ObjectSet("LineHi",OBJPROP_PRICE1, x - MinDay1); 
ObjectSet("LineLo",OBJPROP_PRICE1, x - MaxDay1); 
ObjectSet("LineHi",OBJPROP_TIME2, CurTime()); 
ObjectSet("LineLo",OBJPROP_TIME2, CurTime()); 
ObjectSet("LineHi",OBJPROP_PRICE2, x - MinDay1); 
ObjectSet("LineLo",OBJPROP_PRICE2, x - MaxDay1); 
ObjectSet("LineHi",OBJPROP_COLOR, indicator_color1); 
ObjectSet("LineLo",OBJPROP_COLOR, indicator_color2); 
ObjectSet("LineHi",OBJPROP_RAY, True); 
ObjectSet("LineLo",OBJPROP_RAY, True); 
ObjectSet("LineHi",OBJPROP_STYLE, STYLE_DOT); 
ObjectSet("LineLo",OBJPROP_STYLE, STYLE_DOT); 
} 
//++++++++++++++++++++++++++++++++++++++++++++++++ 
} 
//+------------------------------------------------------------------+

Comments