ind_aMU_v1
Download scriptThis script is a custom technical analysis tool designed for the MetaTrader trading platform. Its primary purpose is to provide traders with a visual representation of price trends by calculating and displaying two distinct Moving Averages simultaneously on a single chart.
Core Functionality
The logic operates by analyzing historical price data to create two "smooth" lines that help identify the general direction of the market:
- Fast Trend Identification: The script calculates a "Fast" Moving Average based on a shorter period (defaulting to 12 bars). This line is more responsive and reacts quickly to recent price fluctuations.
- Slow Trend Identification: The script simultaneously calculates a "Slow" Moving Average based on a longer period (defaulting to 21 bars). This line provides a broader perspective of the market's momentum, filtering out minor "noise."
By plotting both lines on your chart, the tool allows you to see the relationship between short-term and long-term price movements at a glance.
Visual Interface Features
Beyond the raw data analysis, the script includes several user-interface elements to enhance the trading experience:
- Dynamic Labeling: The script automatically generates an on-screen text label upon loading. This serves as a signature or identification tag for the indicator within the workspace.
- Animated Branding: The tool features a unique visual element where specific colored letters (Y, T, and G) are displayed on the chart. These labels are programmed to cycle through different color schemes automatically. This provides a dynamic aesthetic experience while keeping the branding visible on the interface.
Customization Options
The logic is built with flexibility in mind. While it functions automatically out of the box, it includes several parameters that allow users to adjust the behavior without modifying the underlying code:
- Time Periods: You can change how many candles/bars are used to calculate the Fast and Slow averages.
- Shift: You can move the lines forward or backward on the chart to align them with specific price points.
- Smoothing Methods: Users can choose different mathematical methods (such as Simple, Exponential, etc.) to determine how the averages are calculated.
- Price Source: The user can define whether the averages are based on the closing price, opening price, or other specific price types.
//+------------------------------------------------------------------+
//| ind_aMU.mq4 |
//| Yuriy Tokman (YTG) |
//| yuriytokman@gmail.com |
//+------------------------------------------------------------------+
#property copyright "Yuriy Tokman (YTG)"
#property link "yuriytokman@gmail.com"
#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 Green
#property indicator_color2 Red
extern int period_fast = 12;
extern int period_slow = 21;
extern int ma_shift = 0;
extern int ma_method = 0;
extern int applied_price = 0;
double B0[];
double B1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
SetIndexStyle(0, 4);
SetIndexBuffer(0, B0);
SetIndexStyle(1, 4);
SetIndexBuffer(1, B1);
GetAvtor();
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
//----
int limit , i;GetYTG();
int counted_bars=IndicatorCounted();
if(counted_bars<0) return(-1);
if(counted_bars>0) counted_bars--;
limit=Bars-counted_bars;
for(i=0; i<limit; i++){
B0[i] = iMA(Symbol(),0,period_fast,ma_shift,ma_method,applied_price,i);
B1[i] = iMA(Symbol(),0,period_slow,ma_shift,ma_method,applied_price,i);
}
//----
return(0);
}
//+------------------------------------------------------------------+
//----+
void Label(string name_label,string text_label,int corner = 2,int x = 3,int y = 15,int font_size = 10,string font_name = "Arial",color text_color = Lime, bool fon = false )
{
if (ObjectFind(name_label)!=-1) ObjectDelete(name_label);
ObjectCreate(name_label,OBJ_LABEL,0,0,0,0,0);
ObjectSet(name_label,OBJPROP_CORNER,corner);
ObjectSet(name_label,OBJPROP_XDISTANCE,x);
ObjectSet(name_label,OBJPROP_YDISTANCE,y);
ObjectSetText(name_label,text_label,font_size,font_name,text_color);//OBJPROP_BACK
ObjectSet(name_label,OBJPROP_BACK,fon);
}
//----+
void GetAvtor()
{
string char1[256]; int i;
for (i = 0; i < 256; i++) char1[i] = CharToStr(i);
string txtt =
char1[209]+char1[238]+char1[226]+char1[229]+char1[242]+char1[237]+char1[232]+char1[234]
+char1[232]+char1[32]+char1[193]+char1[197]+char1[209]+char1[207]+char1[203]+char1[192]
+char1[210]+char1[205]+char1[206]+char1[58]+char1[32]+char1[104]+char1[116]+char1[116]
+char1[112]+char1[58]+char1[47]+char1[47]+char1[121]+char1[116]+char1[103]+char1[46]
+char1[99]+char1[111]+char1[109]+char1[46]+char1[117]+char1[97];
Label("label",txtt,2,10,15,15);
}
//----+
void GetYTG()
{
static int count = 0;
count++;if(count>2)count = 0;
color color_Y = Red;
color color_T = Lime;
color color_G = Blue;
if(count==1){color_Y = Crimson;color_T = LimeGreen;color_G = DodgerBlue;}
if(count==2){color_Y = OrangeRed;color_T = ForestGreen;color_G = RoyalBlue;}
Label("ytg_Y","Y" ,3,40,20,25,"Arial Black",color_Y);
Label("ytg_T","T" ,3,25,5,25,"Arial Black",color_T);
Label("ytg_G","G" ,3,13,32,25,"Arial Black",color_G);
}
//----+
Comments