KiS_Avg
Download scriptThis tool is designed to provide a clear visual and numerical overview of the price action within a single trading day. Rather than focusing on complex predictive patterns, it simplifies the market's movement by identifying three fundamental data points for every day: the highest price reached, the lowest price reached, and the average midpoint between those two extremes.
How the Logic Works
The script scans through historical price data to organize information based on daily cycles. Every time a new trading day begins, the tool resets its internal tracking to capture the specific boundaries of that day's movement. It constantly monitors the "High" and "Low" prices as they occur:
- Daily High: The highest point the price touched during the current session.
- Daily Low: The lowest point the price touched during the current session.
- Daily Average: The mathematical midpoint between that day's high and low.
Visual Representation
On your trading chart, the script draws three distinct lines to represent these values:
- A line representing the Maximum price reached for the day.
- A line representing the Minimum price reached for the day.
- A central line representing the Average price of the day.
By observing these lines together, you can see the "trading range" or "volatility corridor" for any given day at a glance.
Real-Time Data Display
In addition to the visual lines on the chart, the script provides a live data readout in the corner of your screen. This text summary updates automatically and gives you specific metrics for the current day, including:
- The High, Low, and Average prices.
- The Width: The total distance (in points) between the day's high and low.
- Distance from Average to Open/Close: This tells you exactly how far the current price is moving away from the daily midpoint relative to where the day started and where it currently stands.
Essentially, this tool helps traders quickly understand the "boundaries" of the current day’s price action and measure how far the market has stretched from its middle point.
//+------------------------------------------------------------------+
//| KiS_max_min_Avg.mq4 |
//+------------------------------------------------------------------+
/*[[
Name := KiS_max_min_Avg
Author := KCBT
Link := http://www.kcbt.ru/forum/index.php?
]]*/
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 MediumOrchid
#property indicator_color2 Aqua
#property indicator_color3 MediumOrchid
//---- indicator buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
SetIndexBuffer(0, ExtMapBuffer1);
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(1, ExtMapBuffer2);
SetIndexStyle(1, DRAW_LINE);
SetIndexBuffer(2, ExtMapBuffer3);
SetIndexStyle(2, DRAW_LINE);
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
Comment("");
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int shift, i, CurDay, BarCount;
double DayMax, DayMin;
double DayOpen, DayClose, Avg;
for (shift=Bars-1; shift>=0; shift--) {
if (CurDay != TimeDay(Time[shift])) {
for (i=BarCount; i>=0; i--) {
ExtMapBuffer1[shift+i] = DayMax;
ExtMapBuffer2[shift+i] = (DayMax+DayMin)/2;
ExtMapBuffer3[shift+i] = DayMin;
}
CurDay = TimeDay(Time[shift]);
BarCount = 0;
DayMax = 0;
DayMin = 1000; //Çàðàíåå áîëüøå, ÷òîá óìåíüøèëñÿ â ïðîöåññå
DayOpen = Open[shift];
}
if (DayMax < High[shift]) {DayMax = High[shift];}
if (DayMin > Low[shift]) {DayMin = Low[shift];}
BarCount = BarCount + 1;
}
// ýòî äîðèñîâêà ïîñëåäíåãî, íåçàâåðøåííîãî åùå, äíÿ
for (i=BarCount; i>=0; i--) {
ExtMapBuffer1[shift+i] = DayMax;
ExtMapBuffer2[shift+i] = (DayMax+DayMin)/2;
ExtMapBuffer3[shift+i] = DayMin;
}
DayClose = Close[0];
Avg = (DayMax+DayMin)/2; //ñðåäíÿÿ çà òåêóùèé äåíü
Comment("Max:", DayMax," Min:", DayMin, "\n", "Avg:", Avg, " Width:", (DayMax-DayMin)/Point,"\n","From Avg to Open:",MathRound(MathAbs(Avg-DayOpen)/Point),"\n","From Avg to Close:",MathRound(MathAbs(Avg-DayClose)/Point));
return(0);
}
//+------------------------------------------------------------------+
Comments