MultiStochastics
Download scriptThe MultiStochastics indicator is designed to provide traders with a comprehensive overview of market momentum across multiple timeframes simultaneously. Rather than forcing you to switch between different charts to see what is happening on various scales, this tool consolidates that information into a single visual window.
Core Functionality
The primary logic of this script is to fetch and display "Stochastic Oscillator" data for seven different time periods. The Stochastic Oscillator is a common technical analysis tool used to determine if an asset is overbought or oversold based on past price action.
By aggregating these various timeframes, the indicator allows you to see:
- Short-term momentum: Such as 1-minute (M1) and 5-minute (M5) charts.
- Medium-term trends: Including 15-minute (M15), 30-minute (M30), and 1-hour (H1) scales.
- Long-term movements: Covering 4-hour (H4) and Daily (D1) periods.
How It Works for the User
The script operates as follows:
- Multi-Layer Visualization: The indicator creates seven distinct lines on your chart. Each line corresponds to a specific timeframe, allowing you to see how the momentum of a small time unit relates to the larger trend of the day or week.
- Customizable Visibility: You have the flexibility to turn specific timeframes on or off using simple toggle switches. If you only care about high-level trends, you can disable the smaller timeframes; if you are a scalper, you can focus on the faster ones.
- Adjustable Parameters: For every timeframe enabled, the script allows you to define unique settings (such as K period, D period, and Slowing factor). This means you can fine-tune the sensitivity of each individual line to suit your specific trading strategy.
- Real-Time Updating: The logic automatically calculates these values in real-time as new price data arrives, ensuring that all seven lines update instantly to reflect current market conditions.
Practical Application
In a practical trading environment, this tool serves as a "consensus" map. For example, if the Daily and 4-hour lines are moving upward while the 15-minute and 30-minute lines are dipping, it may indicate a minor pullback within a larger bull market. By viewing all these data points at once, traders can make more informed decisions about whether to enter a trade based on the alignment of multiple timeframes.
//+------------------------------------------------------------------+
//| MultiStochastics.mq4 |
//| wskanaan |
//| http://www.metaquotes.net |
//+------------------------------------------------------------------+
#property copyright "wskanaan"
#property link "http://www.metaquotes.net"
#property indicator_separate_window
#property indicator_buffers 7 // Number of buffers
#property indicator_color1 Blue // Color of the 1st line
#property indicator_color2 Red
#property indicator_color3 Green
#property indicator_color4 Yellow
#property indicator_color5 Orange
#property indicator_color6 Indigo
#property indicator_color7 Violet
#property indicator_level1 10
#property indicator_level2 20
#property indicator_level3 50
#property indicator_level4 80
#property indicator_level5 90
#property indicator_minimum 0
#property indicator_maximum 100
double Buf_0[], Buf_1[], Buf_2[], Buf_3[], Buf_4[], Buf_5[], Buf_6[];
extern bool UseM1Stochastic = true;
extern int M1K = 14;
extern int M1D = 3;
extern int M1Slowing = 3;
extern bool UseM5Stochastic = true;
extern int M5K = 14;
extern int M5D = 3;
extern int M5Slowing = 3;
extern bool UseM15Stochastic = true;
extern int M15K = 14;
extern int M15D = 3;
extern int M15Slowing = 3;
extern bool UseM30Stochastic = true;
extern int M30K = 14;
extern int M30D = 3;
extern int M30Slowing = 3;
extern bool UseH1Stochastic = true;
extern int H1K = 14;
extern int H1D = 3;
extern int H1Slowing = 3;
extern bool UseH4Stochastic = true;
extern int H4K = 14;
extern int H4D = 3;
extern int H4Slowing = 3;
extern bool UseDayStochastic = true;
extern int DayK = 14;
extern int DayD = 3;
extern int DaySlowing = 3;
//+------------------------------------------------------------------+
//| Creates the array of pair symbols to check |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicators
//----
SetIndexBuffer(0,Buf_0); // Assigning an array to a buffer
SetIndexStyle (0,DRAW_LINE,STYLE_SOLID,1);// Line style
SetIndexLabel (0,"M1");
SetIndexBuffer(1,Buf_1); // Assigning an array to a buffer
SetIndexStyle (1,DRAW_LINE,STYLE_SOLID,1);// Line style
SetIndexLabel (1,"M5");
SetIndexBuffer(2,Buf_2); // Assigning an array to a buffer
SetIndexStyle (2,DRAW_LINE,STYLE_SOLID,1);// Line style
SetIndexLabel (2,"M15");
SetIndexBuffer(3,Buf_3); // Assigning an array to a buffer
SetIndexStyle (3,DRAW_LINE,STYLE_SOLID,1);// Line style
SetIndexLabel (3,"M30");
SetIndexBuffer(4,Buf_4); // Assigning an array to a buffer
SetIndexStyle (4,DRAW_LINE,STYLE_SOLID,1);// Line style
SetIndexLabel (4,"H1");
SetIndexBuffer(5,Buf_5); // Assigning an array to a buffer
SetIndexStyle (5,DRAW_LINE,STYLE_SOLID,1);// Line style
SetIndexLabel (5,"H4");
SetIndexBuffer(6,Buf_6); // Assigning an array to a buffer
SetIndexStyle (6,DRAW_LINE,STYLE_SOLID,1);// Line style
SetIndexLabel (6,"D1");
return;
}
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function |
//+------------------------------------------------------------------+
int deinit()
{
//----
//----
return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function |
//+------------------------------------------------------------------+
int start()
{
int counted_bars=IndicatorCounted();
//----
int Limit = Bars - counted_bars;
for(int x = 0; x < Limit; x++)
{
if(UseM1Stochastic) { Buf_0[x] = iStochastic(Symbol(), PERIOD_M1, M1K, M1D, M1Slowing, MODE_SMA, 0, MODE_MAIN, x); }
if(UseM5Stochastic) { Buf_1[x] = iStochastic(Symbol(), PERIOD_M5, M5K, M5D, M5Slowing, MODE_SMA, 0, MODE_MAIN, x); }
if(UseM15Stochastic) { Buf_2[x] = iStochastic(Symbol(), PERIOD_M15, M15K, M15D, M15Slowing, MODE_SMA, 0, MODE_MAIN, x); }
if(UseM30Stochastic) { Buf_3[x] = iStochastic(Symbol(), PERIOD_M30, M30K, M30D, M30Slowing, MODE_SMA, 0, MODE_MAIN, x); }
if(UseH1Stochastic) { Buf_4[x] = iStochastic(Symbol(), PERIOD_H1, H1K, H1D, M1Slowing, MODE_SMA, 0, MODE_MAIN, x); }
if(UseH4Stochastic) { Buf_5[x] = iStochastic(Symbol(), PERIOD_H4, H4K, H4D, H4Slowing, MODE_SMA, 0, MODE_MAIN, x); }
if(UseDayStochastic) { Buf_6[x] = iStochastic(Symbol(), PERIOD_D1, DayK, DayD, DaySlowing, MODE_SMA, 0, MODE_MAIN, x); }
}
//----
return(0);
}
//+------------------------------------------------------------------+
Comments