MaEnv_02B_v2
Download scriptThis technical tool is designed to provide traders with a visual map of market zones based on smoothed price averages and mathematical proportions. Instead of simply showing a single moving average line, this script creates a multi-layered "environment" or corridor that helps identify potential support and resistance levels dynamically.
Core Logic Overview
The script operates through a three-step process to generate its visuals:
1. The Base Average (Trend Identification) The foundation of the tool is a custom weighted moving average. Rather than relying on just one timeframe or calculation, it combines three different "Linear Weighted Moving Averages" (using periods of 30, 50, and 100). By calculating these three averages and taking their mean, the script creates a stabilized "middle ground." This helps filter out minor market noise while maintaining an accurate representation of the primary price trend.
2. Mathematical Expansion (Zone Creation) Once the base average is established, the script projects four distinct levels both above and below that center line. These levels are calculated using specific numerical multipliers (6.18, 16.18, 26.18, and 36.18). These numbers are inspired by Fibonacci-style proportions, which many traders believe represent natural "equilibrium" points in financial markets.
3. Visual Mapping The result is a symmetrical "envelope" or "ribbon" displayed on your chart. Because these levels are tied directly to the weighted moving average:
- When the trend moves up, the entire corridor shifts upward with it.
- When the trend moves down, the corridor follows downward.
How to Interpret the Visuals
The script generates a series of lines that act as "boundaries." The area between these lines represents the price environment. Traders can use these boundaries to visualize:
- Volatility Zones: How far the price is currently deviating from its weighted average.
- Support and Resistance: Identifying areas where the price might stall or reverse when it hits one of the outer "bands."
- Trend Strength: Observing whether the price is consistently staying within the inner bands or breaking out toward the outer boundaries.
/*-------------------------------------------------------------------+
| MaEnv_02B.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
//----------------------------
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 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;
//------------------------------------------------------------
aquaUp1[i] = yMA[i] + 6.18 * Point;
aquaDn1[i] = yMA[i] - 6.18 * Point;
aquaUp2[i] = yMA[i] + 16.18 * Point;
aquaDn2[i] = yMA[i] - 16.18 * Point;
aquaUp3[i] = yMA[i] + 26.18 * Point;
aquaDn3[i] = yMA[i] - 26.18 * Point;
aquaUp4[i] = yMA[i] + 36.18 * Point;
aquaDn4[i] = yMA[i] - 36.18 * Point;
}
return(0);
}
//+------------------------------------------------------------------+
Comments