KiS_Avg(1)
Download scriptThis tool is designed to provide a clear visual summary of price action within a single trading day. It identifies the extreme boundaries of market movement—specifically the highest and lowest prices reached—and calculates the mathematical center between them.
How the Logic Works
The script scans your historical price data and organizes it based on calendar days. Every time a new day begins, the tool resets its tracking to capture the specific highs and lows for that 24-hour period. As the market moves throughout the day, the script continuously monitors every price tick to ensure it captures the absolute peak and the lowest valley reached.
Visual Data Representation
The indicator plots three distinct lines on your chart to help you visualize these boundaries:
- The Upper Bound: A line representing the highest price reached during the current day.
- The Lower Bound: A line representing the lowest price reached during the current day.
- The Midpoint (Average): A central line calculated by finding the exact halfway point between that day's high and low.
Real-Time Dashboard
In addition to the visual lines, the tool provides a live text summary on your screen. This summary updates automatically to give you quick statistics at a glance:
- Price Extremes: Displays the current daily High, Low, and Average price.
- Volatility Measurement: It calculates the total "Width" of the day's trading range (the distance between the high and the low).
- Distance Analysis: It measures how far the current market price is from the daily average in terms of points. It shows two specific distances:
- The distance from the Average to the day's Opening price.
- The distance from the Average to the current Closing (current) price.
By using this logic, you can easily see where the "fair value" center of the day sits and how aggressively the price is swinging away from that center 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","Îò Avg äî Open:",MathRound(MathAbs(Avg-DayOpen)/Point),"\n","Îò Avg äî Close:",MathRound(MathAbs(Avg-DayClose)/Point));
return(0);
}
//+------------------------------------------------------------------+
Comments