Indicators Used
Miscellaneous
0
Views
0
Downloads
0
Favorites
_2523MTF_Stochastic_sh1 15[1].5.3.3 Turq_fixed
//+------------------------------------------------------------------+
//| 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()
{
datetime TimeArray[];
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);
}
//
//FIX for display
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++
if (TimeFrame>Period()) {
int PerINT=TimeFrame/Period()+1;
datetime TimeArr[]; ArrayResize(TimeArr,PerINT);
ArrayCopySeries(TimeArr,MODE_TIME,Symbol(),Period());
for(i=0;i<PerINT+1;i++) {if (TimeArr[i]>=TimeArray[0]) {
//----
/************************************************ by Raff
Refresh buffers: buffer[i] = buffer[0];
********************************************************/
MainOpen[shift] = MainOpen[0];
SignalOpen[shift] = SignalOpen[0];
MainClosed[shift] = MainClosed[0];
SignalClosed[shift] = SignalClosed[0];
//----
} } }
//+++++++++++++++++++++++++++++++++++++++++++++++++++
//END of fix
return(0);
}
//+------------------------------------------------------------------+
Comments
Markdown Formatting Guide
# H1
## H2
### H3
**bold text**
*italicized text*
[title](https://www.example.com)

`code`
```
code block
```
> blockquote
- Item 1
- Item 2
1. First item
2. Second item
---