[i]3MAsame
Download scriptThis script is designed to provide traders with a comprehensive visual overview of long-term market trends by consolidating data from multiple timeframes into a single view. Instead of forcing a user to switch back and forth between different charts (such as Weekly, Daily, and Hourly), this tool automatically calculates and displays several Moving Averages simultaneously on the current chart.
How the Logic Works
The core functionality of the script relies on "Multi-Timeframe Analysis." It scans various periods of market history to identify where the price is heading in the long run. Specifically, it pulls data from the following four distinct intervals:
- Weekly Perspective: It calculates a 4-period Simple Moving Average based on weekly data to show the broadest trend.
- Daily Perspective: It tracks a 20-period Simple Moving Average using daily data to capture the medium-term momentum.
- 4-Hour Perspective: It uses a much longer 120-period (20x6) average of the 4-hour candles to smooth out minor fluctuations.
- Hourly Perspective: It incorporates a very long 480-period (20x24) average of hourly data to identify the deepest underlying trend.
Visual Representation
The script handles these four different data sets by assigning each one to its own dedicated line on your chart. Because each line represents a different timeframe, they move at different speeds:
- Some lines will appear relatively flat and steady, representing the "big picture" (Weekly and Daily trends).
- Other lines will be more reactive to recent price changes, representing shorter-term sentiment (Hourly and 4-Hour trends).
Purpose for the Trader
By displaying all four of these averages at once, the script allows you to see "confluence." When multiple lines from different timeframes align in the same direction, it signals a strong trend. Conversely, if the lines are crossing one another or moving in opposite directions, it highlights market indecision or a potential reversal. It essentially acts as a multi-layered filter, helping you stay aligned with the dominant market flow across all major trading horizons.
/*-----------------------------+
| |
| 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 4
#property indicator_color1 Red
#property indicator_color2 White
#property indicator_color3 Aqua
#property indicator_color4 LightGreen
//---- buffers
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, Buffer1);
SetIndexStyle(1,DRAW_LINE);
SetIndexBuffer(1, Buffer2);
SetIndexStyle(2,DRAW_LINE);
SetIndexBuffer(2, Buffer3);
SetIndexStyle(3,DRAW_LINE);
SetIndexBuffer(3, Buffer4);
return(0);
}
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
int i;
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 ma1, ma2, ma3, ma4;
double p=Point();
while(pos>=0)
{
ma4= iMA(Symbol(),PERIOD_W1,4 ,0,PRICE_OPEN,MODE_SMA,pos);
ma3= iMA(Symbol(),PERIOD_D1,20 ,0,PRICE_OPEN,MODE_SMA,pos);
ma2= iMA(Symbol(),PERIOD_H4,20*6 ,0,PRICE_OPEN,MODE_SMA,pos);
ma1= iMA(Symbol(),PERIOD_H1,20*24 ,0,PRICE_OPEN,MODE_SMA,pos);
Buffer4[pos]=ma4;
Buffer3[pos]=ma3;
Buffer2[pos]=ma2;
Buffer1[pos]=ma1;
pos--;
}
return(0);
}
//+------------------------------------------------------------------+
Comments