VR---MOVING-AVERAGE
Download scriptThis script is a specialized technical analysis tool designed for the MetaTrader platform. Its primary purpose is to visualize trend data by plotting three distinct Moving Averages on your trading chart simultaneously, providing a multi-layered view of market momentum.
Core Functionality
The indicator works by calculating and displaying three separate moving average lines. By observing these lines together, traders can better identify the direction of the market, potential trend reversals, and areas of support or resistance. Each line is customizable in terms of its period (how much historical data it looks at), the type of price it tracks, and its visual appearance (color and thickness).
Dynamic Time Scaling
One of the unique features of this script is its intelligent adaptation to different timeframes. It includes a logic system that automatically scales the moving average periods based on the chart you are currently viewing (such as 1-minute, 15-minute, hourly, or daily charts).
Instead of using a static number for the calculation, the script identifies your current timeframe and applies a multiplier. This ensures that the moving averages remain relevant and visually consistent whether you are looking at "the big picture" on a daily chart or trying to capture fast movements on a minute-by-minute basis.
Key Components
- Multi-Layered Analysis: By displaying three lines (often configured as Short, Medium, and Long terms), the tool helps traders see different perspectives of the price action at once.
- Visual Customization: Each of the three averages can be toggled on or off individually. You can also choose specific colors for each to clearly distinguish between fast-moving data and slower, long-term trends.
- Automatic Adjustment: The script handles the heavy lifting of math conversions behind the scenes, ensuring that the "Time Factor" aligns correctly with the chart's candles without requiring manual recalculations by the user.
Summary for Traders
This tool serves as a dynamic trend-following indicator. It simplifies market analysis by automatically scaling three moving averages to fit your chosen timeframe, allowing you to see where the price is heading in the short term versus where it is heading over the long term, all while maintaining visual clarity on your trading screen.
//===========================================================================================================================//
// Author VOLDEMAR227 site WWW.TRADING-GO.RU SKYPE: TRADING-GO e-mail: TRADING-GO@List.ru
//===========================================================================================================================//
#property copyright "Copyright © 2012, WWW.TRADING-GO.RU ."
#property link "http://WWW.TRADING-GO.RU"
//===========================================================================================================================//
#property indicator_chart_window
#property indicator_buffers 3
extern string VR = "http://WWW.TRADING-GO.RU";
extern string Moving_Average = "Settings";
extern int Time_ = 1440;
extern bool MA1 = true;
extern int Ma1_period = 8 ;
extern int Ma1_price = 2 ;
extern int Ma1_metod = 1 ;
extern color Ma1_color = Red ;
extern bool MA2 = true;
extern int Ma2_period = 30 ;
extern int Ma2_price = 1 ;
extern int Ma2_metod = 1 ;
extern color Ma2_color = Green ;
extern bool MA3 = true;
extern int Ma3_period = 66 ;
extern int Ma3_price = 3 ;
extern int Ma3_metod = 1 ;
extern color Ma3_color = Black ;
double ExtBuffer0[];
double ExtBuffer1[];
double ExtBuffer2[];
int start()
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
ObjectCreate ("R", OBJ_LABEL, 0, 0, 0 );
ObjectSet ("R", OBJPROP_CORNER,2 );
ObjectSet ("R", OBJPROP_XDISTANCE,10);
ObjectSet ("R", OBJPROP_YDISTANCE,10);
ObjectSetText("R", "WWW.TRADING-GO.RU",10, "Arial", Red);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
SetIndexStyle (0,DRAW_LINE,1,2,Ma1_color);
SetIndexBuffer(0, ExtBuffer0 );
SetIndexLabel (0,"ExtBuffer0");
SetIndexStyle (1,DRAW_LINE,1,2,Ma2_color);
SetIndexBuffer(1, ExtBuffer1 );
SetIndexLabel (1,"ExtBuffer1");
SetIndexStyle (2,DRAW_LINE,1,2,Ma3_color);
SetIndexBuffer(2, ExtBuffer2 );
SetIndexLabel (2,"ExtBuffer2");
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
int t=0;
int c=0;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
if (WindowExpertName()=="VR---MOVING-AVERAGE")
{
int counted_bars=IndicatorCounted();
if(counted_bars > 0) {counted_bars--;}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
int limit = Bars - counted_bars - 1;
for(int x = limit; x >= 0; x--)
{
if (Period()==10080){t=Period() ; c=Time_/10080;}
if (Period()==1440 ){t=Period() ; c=Time_/1440 ;}
if (Period()==240 ){t=Period() ; c=Time_/240 ;}
if (Period()==60 ){t=Period() ; c=Time_/60 ;}
if (Period()==30 ){t=Period() ; c=Time_/30 ;}
if (Period()==15 ){t=Period() ; c=Time_/15 ;}
if (Period()==5 ){t=Period() ; c=Time_/5 ;}
if (Period()==1 ){t=Period() ; c=Time_/1 ;}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
if (MA1 == true){ExtBuffer0[x]=iMA(NULL,t,Ma1_period*c,0,Ma1_metod,Ma1_price,x);}
if (MA2 == true){ExtBuffer1[x]=iMA(NULL,t,Ma2_period*c,0,Ma1_metod,Ma2_price,x);}
if (MA3 == true){ExtBuffer2[x]=iMA(NULL,t,Ma3_period*c,0,Ma1_metod,Ma3_price,x);}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
}
}
else
{
Comment("Wrong name of the indicator");
}
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~//
Comments