KiS_max_min_Avg_Monday Fixed
Download scriptThis tool is designed to provide a visual and statistical summary of daily price movements on your trading chart. Instead of just showing you the current price, it analyzes the "boundaries" of each trading day to help you understand the overall range and middle ground of the market's activity.
How the Logic Works
The script scans through historical price data and organizes it by calendar day (excluding weekends). For every day shown on your chart, it performs three main actions:
1. Identifying Price Boundaries The tool constantly tracks the highest price reached (Maximum) and the lowest price reached (Minimum) during a specific trading day. It establishes these "walls" to define the total territory the market covered from start to finish.
2. Calculating the Equilibrium Point Once it knows the High and the Low of the day, it calculates the Average (Midpoint). This is the mathematical center between the daily extremes. By plotting this, you can see where the "balance" of the day sits relative to where the price started and ended.
3. Dynamic Visual Updates As each new candle forms, the script updates these values in real-time. It ensures that as the price moves, the High, Low, and Midpoint lines adjust instantly so you can see the current range expanding or contracting as the market evolves.
On-Screen Information
In addition to drawing these lines on your chart, the tool provides a data summary in a text box (comment) on your screen. This gives you four key pieces of information at a glance:
- Max & Min: The absolute highest and lowest points reached so far today.
- Avg: The calculated midpoint of the current day's range.
- Width: The total distance between the High and Low, converted into price points.
- Distance to Open/Close: It calculates exactly how far the current average is from the day's opening price and the most recent closing price.
Summary for Traders
Essentially, this script helps you visualize "price territory." It allows you to see at a glance how much of the daily range has been covered, where the center of gravity for the day lies, and how far the current price is drifting from that central average.
//+------------------------------------------------------------------+
//| KiS_max_min_Avg.mq4 |
//| Monday Fixed by TaXiRaN |
//+------------------------------------------------------------------+
/*[[
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 (TimeDayOfWeek(Time[shift])!=0){
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