[i]2MAsame
Download scriptThis custom indicator is designed to provide traders with a multi-timeframe perspective of market trends by overlaying several smoothed price averages directly onto the current trading chart. Instead of looking at just one timeframe, it allows you to visualize how different intervals—ranging from 30 minutes to one week—are moving simultaneously.
How the Logic Works
The primary goal of this script is to provide "contextual awareness." It accomplishes this by pulling data from five distinct timeframes and displaying them as separate lines on your screen. Here is the breakdown of how it processes that information:
- Multi-Timeframe Integration: The script automatically calculates a Simple Moving Average (SMA) for five different periods: 30 Minutes, 1 Hour, 4 Hours, Daily (D1), and Weekly (W1).
- Standardized Calculation: To ensure consistency across all these timeframes, the indicator uses a consistent "2-period" moving average based on the opening price of each candle. This means it is looking for very immediate, short-term trends within each specific timeframe.
- Visual Overlay: Rather than requiring you to switch back and forth between different charts to see what the "big picture" looks like, the script places all five averages onto your active chart.
Key Benefits for the User
- Trend Alignment: By viewing these lines together, you can quickly identify if the short-term momentum (30m/1h) is moving in the same direction as the long-term trend (Daily/Weekly).
- Reduced Chart Clutter: It consolidates five different sources of data into a single visual display, allowing for faster decision-making.
- Unified View: The indicator serves as a "summary" tool, helping you see where current price action sits in relation to broader market cycles without needing to open multiple windows.
/*-----------------------------+
| |
| Shared by www.Aptrafx.com |
| |
+------------------------------*/
//+------------------------------------------------------------------+
//| 5 Min RSI 12-period qual INDICATOR |
//+------------------------------------------------------------------+
#property copyright "Ron T"
#property link "http://www.lightpatch.com"
#property indicator_chart_window
#property indicator_buffers 5
#property indicator_color1 Red
#property indicator_color2 White
#property indicator_color3 Aqua
#property indicator_color4 LightGreen
#property indicator_color5 DodgerBlue
//---- buffers
double Buffer0[];
double Buffer1[];
double Buffer2[];
double Buffer3[];
double Buffer4[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//|------------------------------------------------------------------|
int init()
{
// 233 up arrow
// 234 down arrow
// 159 big dot
// 158 little dot
// 168 open square
// 120 box with X
SetIndexStyle(0,DRAW_LINE);
SetIndexBuffer(0, Buffer0);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1, Buffer1);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2, Buffer2);
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3, Buffer3);
SetIndexStyle(4,DRAW_LINE);
SetIndexBuffer(4, Buffer4);
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
int i;
for( i=0; i<Bars; i++ ) Buffer0[i]=0;
for( i=0; i<Bars; i++ ) Buffer1[i]=0;
for( i=0; i<Bars; i++ ) Buffer2[i]=0;
for( i=0; i<Bars; i++ ) Buffer3[i]=0;
for( i=0; i<Bars; i++ ) Buffer4[i]=0;
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int pos=Bars-100; // leave room for moving average periods
int ctr=0;
double ma0, ma1, ma2, ma3, ma4;
double p=Point();
while(pos>=0)
{
// so we're on a HOURLY chart, and we're going to calculate
// every tick for H1, every 4th tick for H4 and
// every 24th tick for D1
ma0= iMA(Symbol(),PERIOD_M30,2 ,0,PRICE_OPEN,MODE_SMA,pos);
ma1= iMA(Symbol(),PERIOD_H1 ,2 ,0,PRICE_OPEN,MODE_SMA,pos);
ma2= iMA(Symbol(),PERIOD_H4 ,2 ,0,PRICE_OPEN,MODE_SMA,pos);
ma3= iMA(Symbol(),PERIOD_D1 ,2 ,0,PRICE_OPEN,MODE_SMA,pos);
ma4= iMA(Symbol(),PERIOD_W1 ,2 ,0,PRICE_OPEN,MODE_SMA,pos);
Buffer0[pos]=ma0;
Buffer1[pos]=ma1;
Buffer2[pos]=ma2;
Buffer3[pos]=ma3;
Buffer4[pos]=ma4;
pos--;
}
return(0);
}
//+------------------------------------------------------------------+
Comments