_2523MTF_Stochastic_sh1 15.5.3.3 Turq
Download scriptThe MTF Stochastic indicator is a technical analysis tool designed to provide traders with a multi-timeframe view of market momentum. Unlike standard indicators that only show data for the specific chart you are currently viewing, this script allows you to overlay Stochastic Oscillator data from higher (or different) timeframes directly onto your current trading screen.
Core Functionality
The primary purpose of this indicator is to bridge the gap between different time horizons. For example, if you are analyzing a fast-moving 1-minute chart, this tool enables you to see the "big picture" by pulling in Stochastic data from larger periods (such as the 15-minute, 1-hour, or Daily charts) without having to switch back and forth between different windows.
Key Technical Features
- Multi-Timeframe Synchronization: The script automatically calculates and maps historical data from a selected higher timeframe to match the current chart's timeline. This ensures that as you move across your screen, the data remains perfectly aligned with the correct moments in time.
- Dual Data Tracking (Open vs. Closed): To provide more precise information, the indicator plots two sets of data simultaneously:
- Live/Open Bar Data: Represents the current, developing state of the Stochastic oscillator for the timeframe you have selected.
- Closed Candle Data: Represents the finalized value of the previous bar on that higher timeframe. This helps traders distinguish between fluctuating "real-time" noise and confirmed price movements.
- Visual Differentiation: The indicator uses different line styles (solid lines versus dashed/dotted lines) to help you visually separate the current live data from the previously completed data points.
User Customization
The logic provides several adjustable parameters to tailor the indicator to your specific trading style:
- Timeframe Selection: You can choose which specific period (e.g., M15, H1, D1) you want to overlay on your current chart.
- Stochastic Settings: You can modify the standard calculation inputs, including the K-Period, D-Period, and Slowing factors.
- Moving Average Methods: The tool supports various smoothing methods (Simple, Exponential, Smoothed, or Linear Weighted) to determine how the data lines are calculated.
- Price Field: You can choose whether the calculation is based on high/low prices or close prices.
Summary for Traders
By using this indicator, a trader can identify whether the current price action is supported by a larger trend. It serves as a "macro" filter, helping you decide if a trade on a small timeframe aligns with the momentum of a larger timeframe, thereby increasing the reliability of your entries and exits.
//+------------------------------------------------------------------+
//| MTF_Stochastic.mq4 |
//| Copyright © 2006, Keris2112 |
//| |
//| In this indicator, for the open bar plotting use this line.
//|
//| TF1_K1_0 = iStochastic(Symbol(), TimeFrame_1, TimeFrame,KPeriod,DPeriod,Slowing,MAMethod,PriceField, MODE_MAIN, sh1);
//|
//| And for closed candles
//|
//| TF1_K1_1 = iStochastic(Symbol(), TimeFrame_1, TimeFrame,KPeriod,DPeriod,Slowing,MAMethod,PriceField, MODE_MAIN, sh1+1);
//+------------------------------------------------------------------+
#property copyright "Copyright © 2006, Keris2112"
#property link "http://www.forex-tsd.com"
#property indicator_separate_window
#property indicator_buffers 4
#property indicator_color1 DarkTurquoise
#property indicator_color2 DarkTurquoise
#property indicator_color3 DarkTurquoise
#property indicator_color4 DarkTurquoise
#property indicator_width1 2
#property indicator_width2 1
#property indicator_width3 2
#property indicator_width4 1
#property indicator_level1 80
#property indicator_level2 20
#property indicator_level3 70
#property indicator_level4 30
#property indicator_maximum 100
#property indicator_minimum 0
//---- input parameters
/*************************************************************************
PERIOD_M1 1
PERIOD_M5 5
PERIOD_M15 15
PERIOD_M30 30
PERIOD_H1 60
PERIOD_H4 240
PERIOD_D1 1440
PERIOD_W1 10080
PERIOD_MN1 43200
You must use the numeric value of the timeframe that you want to use
when you set the TimeFrame' value with the indicator inputs.
---------------------------------------
MODE_SMA 0 Simple moving average,
MODE_EMA 1 Exponential moving average,
MODE_SMMA 2 Smoothed moving average,
MODE_LWMA 3 Linear weighted moving average.
You must use the numeric value of the MA Method that you want to use
when you set the 'ma_method' value with the indicator inputs.
**************************************************************************/
extern int TimeFrame=15;
extern int KPeriod=5;
extern int DPeriod=3;
extern int Slowing=3;
extern int MAMethod=0;
extern int PriceField=0;
// PriceField: 0=Hi/Low 1=Close/Close
double MainOpen[];
double SignalOpen[];
double MainClosed[];
double SignalClosed[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init()
{
//---- indicator line
SetIndexBuffer(0,MainOpen);
SetIndexStyle(0,DRAW_LINE,0,2);
SetIndexBuffer(1,SignalOpen);
SetIndexStyle(1,DRAW_LINE,STYLE_DASHDOT,1);
SetIndexBuffer(2,MainClosed);
SetIndexStyle(2,DRAW_LINE,0,2);
SetIndexBuffer(4,SignalClosed);
SetIndexStyle(4,DRAW_LINE,STYLE_DASHDOT,1);
//---- name for DataWindow and indicator subwindow label
switch(TimeFrame)
{
case 1 : string TimeFrameStr="M1"; break;
case 5 : TimeFrameStr="M5"; break;
case 15 : TimeFrameStr="M15"; break;
case 30 : TimeFrameStr="M30"; break;
case 60 : TimeFrameStr="H1"; break;
case 240 : TimeFrameStr="H4"; break;
case 1440 : TimeFrameStr="D1"; break;
case 10080 : TimeFrameStr="W1"; break;
case 43200 : TimeFrameStr="MN1"; break;
default : TimeFrameStr="Current Timeframe";
}
IndicatorShortName("Stoch "+TimeFrameStr+"("+KPeriod+","+DPeriod+","+Slowing+") ");
}
//----
return(0);
//+------------------------------------------------------------------+
//| MTF Stochastic |
//+------------------------------------------------------------------+
int start()
{
int i,shift,limit, sh, myTimeFrame;
int counted_bars=IndicatorCounted();
// Plot defined timeframe on to current timeframe
limit=Bars-counted_bars;
for(shift=0;shift<=limit;shift++)
{
myTimeFrame = TimeFrame;
if (TimeFrame == 0) myTimeFrame = Period();
sh = iBarShift(Symbol(), myTimeFrame, Time[shift]);
MainOpen[shift]=iStochastic(NULL,myTimeFrame,KPeriod,DPeriod,Slowing,MAMethod,PriceField,0,sh);
SignalOpen[shift]=iStochastic(NULL,myTimeFrame,KPeriod,DPeriod,Slowing,MAMethod,PriceField,1,sh);
MainClosed[shift]=iStochastic(NULL,myTimeFrame,KPeriod,DPeriod,Slowing,MAMethod,PriceField,0,sh + 1);
SignalClosed[shift]=iStochastic(NULL,myTimeFrame,KPeriod,DPeriod,Slowing,MAMethod,PriceField,1,sh + 1);
}
//
return(0);
}
//+------------------------------------------------------------------+
Comments