MaEnv_02B_v3a
Download scriptThis script is designed as a technical analysis tool for the MetaTrader platform, specifically intended to help traders visualize potential support and resistance zones based on moving averages and Fibonacci-inspired proportions.
Core Logic Overview
The indicator works by establishing a central "average" price line and then projecting multiple upper and lower boundaries around that center point. Here is a breakdown of how it processes this information:
1. Establishing the Baseline (Moving Average) Instead of relying on a single simple average, the script calculates a customized moving average. It takes three different weighted averages (covering 30, 50, and 100 periods) and combines them into one unified baseline. This helps smooth out market "noise" while maintaining a representative view of the current price trend.
2. Dynamic Scaling (The "Boris Koeff") One of the unique features of this script is its ability to adapt to different timeframes automatically. It includes a specific logic gate that identifies which chart period you are viewing (e.g., 5-minute charts vs. daily charts). Depending on the timeframe, it assigns a multiplier value. This ensures that the plotted boundaries expand or contract appropriately so they don't look too crowded on small timeframes or too wide on large ones.
3. Boundary Projection Once the baseline and the timeframe multiplier are established, the script projects four distinct sets of "zones" above and below the baseline. These zones are calculated using specific numerical coefficients:
- Zone 1: The closest boundaries to the moving average.
- Zone 2: A wider set of boundaries.
- Zone 3: A broader range.
- Zone 4: The outermost extreme boundaries.
4. Precision Adjustments To ensure accuracy across different types of currency pairs or assets, the script automatically detects the decimal precision of your broker (e.g., whether a price has 4 digits or 5 digits). It adjusts its calculations in real-time to ensure that the plotted lines appear at the correct price levels regardless of the specific asset being traded.
Summary for the Trader
In practical terms, this script provides you with a "channel" of visual cues. The moving average acts as your center of gravity, while the eight surrounding lines represent different layers of potential market reactions. By watching how price interacts with these varying levels of expansion, traders can better visualize areas where the market might encounter resistance (ceiling) or support (floor).
/*-------------------------------------------------------------------+
| MaEnv_02B_v3a.mq4 |
| Copyright © 2010 |
| basisforex@gmail.com |
+-------------------------------------------------------------------*/
#property copyright "Copyright © 2010, basisforex@gmail.com"
#property link "basisforex@gmail.com"
//------------------------------
#property indicator_chart_window
#property indicator_buffers 8
#property indicator_color1 Yellow
#property indicator_color2 Yellow
#property indicator_color3 Aqua
#property indicator_color4 Aqua
#property indicator_color5 Blue
#property indicator_color6 Blue
#property indicator_color7 Red
#property indicator_color8 Red
//----------------------------
int BorisKoeff;
double aquaUp1[];
double aquaDn1[];
double aquaUp2[];
double aquaDn2[];
double aquaUp3[];
double aquaDn3[];
double aquaUp4[];
double aquaDn4[];
double yMA[];
//--------------
int init()
{
IndicatorBuffers(8);
//-----
SetIndexStyle(0, DRAW_LINE);
SetIndexBuffer(0, aquaUp1);
SetIndexDrawBegin(0, 0);
//-----
SetIndexStyle(1, DRAW_LINE);
SetIndexBuffer(1, aquaDn1);
SetIndexDrawBegin(1, 0);
//-------------------------
SetIndexStyle(2, DRAW_LINE);
SetIndexBuffer(2, aquaUp2);
SetIndexDrawBegin(2, 0);
//-----
SetIndexStyle(3, DRAW_LINE);
SetIndexBuffer(3, aquaDn2);
SetIndexDrawBegin(3, 0);
//-------------------------
SetIndexStyle(4, DRAW_LINE);
SetIndexBuffer(4, aquaUp3);
SetIndexDrawBegin(4, 0);
//-----
SetIndexStyle(5, DRAW_LINE);
SetIndexBuffer(5, aquaDn3);
SetIndexDrawBegin(5, 0);
//-------------------------
SetIndexStyle(6, DRAW_LINE);
SetIndexBuffer(6, aquaUp4);
SetIndexDrawBegin(6, 0);
//-----
SetIndexStyle(7, DRAW_LINE);
SetIndexBuffer(7, aquaDn4);
SetIndexDrawBegin(7, 0);
//-------------------------
return(0);
}
//+------------------------------------------------------------------+
int GetBorisKoeff()
{
if(Period() <= 5) return(1);
else if(Period() <= 15) return(2);
else if(Period() <= 30) return(3);
else if(Period() <= 60) return(4);
else if(Period() <= 240) return(8);//5);
else if(Period() <= 1440) return(14);//7);
else if(Period() <= 10080) return(20);//9);
else return(25);//15);
}
//+------------------------------------------------------------------+
int start()
{
int limit;
int counted_bars = IndicatorCounted();
if(counted_bars < 0) return(-1);
if(counted_bars > 0) counted_bars--;
limit = Bars - counted_bars;
//-----
ArrayResize(yMA, Bars);
ArrayInitialize(yMA, 0.0);
//-----
for(int i = limit; i >= 0; i--)
{
yMA[i]=(iMA(NULL, 0, 30, 0, MODE_LWMA, PRICE_WEIGHTED, i) +
iMA(NULL, 0, 50, 0, MODE_LWMA, PRICE_WEIGHTED, i) +
iMA(NULL, 0, 100, 0, MODE_LWMA, PRICE_WEIGHTED, i)) / 3;
//--------------------------------------------------------------
int Boril = GetBorisKoeff();
if(Digits == 4 || Digits == 2) aquaUp1[i] = yMA[i] + 6.18 * Point * Boril;
if(Digits == 5 || Digits == 3) aquaUp1[i] = yMA[i] + 61.8 * Point * Boril;
if(Digits == 4 || Digits == 2) aquaDn1[i] = yMA[i] - 6.18 * Point * Boril;
if(Digits == 5 || Digits == 3) aquaDn1[i] = yMA[i] - 61.8 * Point * Boril;
if(Digits == 4 || Digits == 2) aquaUp2[i] = yMA[i] + 16.18 * Point * Boril;
if(Digits == 5 || Digits == 3) aquaUp2[i] = yMA[i] + 161.8 * Point * Boril;
if(Digits == 4 || Digits == 2) aquaDn2[i] = yMA[i] - 16.18 * Point * Boril;
if(Digits == 5 || Digits == 3) aquaDn2[i] = yMA[i] - 161.8 * Point * Boril;
if(Digits == 4 || Digits == 2) aquaUp3[i] = yMA[i] + 26.18 * Point * Boril;
if(Digits == 5 || Digits == 3) aquaUp3[i] = yMA[i] + 261.8 * Point * Boril;
if(Digits == 4 || Digits == 2) aquaDn3[i] = yMA[i] - 26.18 * Point * Boril;
if(Digits == 5 || Digits == 3) aquaDn3[i] = yMA[i] - 261.8 * Point * Boril;
if(Digits == 4 || Digits == 2) aquaUp4[i] = yMA[i] + 36.18 * Point * Boril;
if(Digits == 5 || Digits == 3) aquaUp4[i] = yMA[i] + 361.8 * Point * Boril;
if(Digits == 4 || Digits == 2) aquaDn4[i] = yMA[i] - 36.18 * Point * Boril;
if(Digits == 5 || Digits == 3) aquaDn4[i] = yMA[i] - 361.8 * Point * Boril;
}
return(0);
}
//+------------------------------------------------------------------+
Comments