This indicator is designed to provide traders with a visual "channel" on their trading charts, helping to identify price boundaries based on historical trends. Instead of showing every minute movement, the tool focuses on calculating specific reference points once per day to maintain a clear and organized view of the market.
Core Logic and Functionality
Daily Synchronization The script is programmed to perform its primary calculations at a specific time each day (defaulting to midnight). By anchoring the data to a daily reset, it ensures that the visual boundaries remain consistent throughout the trading day rather than fluctuating wildly with every tiny price tick.
Trend Analysis (Moving Average) At the designated time, the tool looks back at a set number of previous days to calculate an Exponential Moving Average (EMA). This average serves as the "heart" of the indicator, representing the core trend of the price action. Because it is an exponential average, it gives slightly more importance to recent price data while still smoothing out the overall movement.
Dynamic Boundary Creation Once the daily moving average is established, the script calculates two outer boundaries based on a user-defined percentage:
- The Upper Bound: This is calculated by adding a specific percentage to the moving average.
- The Lower Bound: This is calculated by subtracting that same percentage from the moving average.
Visual Representation
On your chart, these calculations result in three distinct lines:
- The Center Line: Represents the smoothed trend (the EMA).
- The Upper Channel: Represents the "ceiling" based on your chosen volatility percentage.
- The Lower Channel: Represents the "floor" based on your chosen volatility percentage.
Summary for the User
In simple terms, this script draws a " коридор" (corridor) around the price. It automatically updates every day to reflect the current market trend and creates a visual zone that helps traders see where the price is sitting in relation to its recent history. By adjusting the period length and the percentage variable, you can make this corridor wider or narrower to suit different trading styles.
//+------------------------------------------------------------------+
//| Epsilon.mq4 |
//| Copyright © 2008, Commercial Credit & Commerce Inc. |
//| http://www.creditbanc.net |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, Commercial Credit & Commerce Inc."
#property link "http://www.creditbanc.net"
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 White
#property indicator_color2 Red
#property indicator_color3 Red
//---- input parameters
extern string Start_Time = "00:00";//Time to adjust moving average (1time per day)
extern int Ema_Period=10;// Length of moving average in days
extern double Cycle1_Var=1;// percent above and below moving average
//---- internal Global Variables
double ema;
double cycle1_high;
double cycle1_low;
//---- buffers
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
int pos, i;
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0,ExtMapBuffer1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1,ExtMapBuffer2);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2,ExtMapBuffer3);
SetIndexStyle(3,DRAW_LINE);
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
if (Bars <= Ema_Period) return(0);
if (counted_bars < 0) return (-1);
if (counted_bars > 0) counted_bars--;
pos = Bars - counted_bars - Ema_Period;
//----
for (i=pos; i>=0; i--)
{
if(TimeToStr(iTime(NULL,0,i), TIME_MINUTES) == Start_Time) // only perform ema calculation at 00:01
{
Sleep(60000);
ema = iMA(NULL, 0, Ema_Period, 0, MODE_EMA, PRICE_CLOSE, i); // calculate 10 day ema
cycle1_high = (ema + (ema * (Cycle1_Var / 100))); //Add percent to ema
cycle1_low =(ema - (ema * (Cycle1_Var / 100))); // subtract percent from ema
}
ExtMapBuffer1[i] = ema; // draw ema
ExtMapBuffer2[i] = cycle1_high; // draw cycle1 high (ema + percent)
ExtMapBuffer3[i] = cycle1_low; // draw cycle1 low (ema - percent)
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments