//+------------------------------------------------------------------+ //| CIA MTF Stochastic Standard .mq4 | //| Copyright © 2006, MetaQuotes Software Corp. | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ //| MTF_4Period STOCH.mq4 | //| mod ForexTSD.com ki | //|------------------------------------------------------------------+ #property copyright "Copyright © 2006, Keris2112" #property link "http://www.forex-tsd.com" #property link " extra timeframes by cja" #property indicator_separate_window #property indicator_buffers 8 #property indicator_color1 Olive #property indicator_color2 Olive #property indicator_color3 SeaGreen #property indicator_color4 SeaGreen #property indicator_color5 Red #property indicator_color6 Red #property indicator_color7 DodgerBlue #property indicator_color8 DodgerBlue #property indicator_maximum 100 #property indicator_minimum 0 #property indicator_level1 76.4 #property indicator_level2 61.8 #property indicator_level3 50 #property indicator_level4 38.2 #property indicator_level5 23.6 #property indicator_levelcolor DarkSlateGray #property indicator_width1 4 #property indicator_width3 3 #property indicator_width5 2 #property indicator_width7 1 /* Price Options PRICE_CLOSE = 0 Close price. PRICE_OPEN = 1 Open price. PRICE_HIGH = 2 High price. PRICE_LOW = 3 Low price. PRICE_MEDIAN = 4 Median price, (high+low)/2. PRICE_TYPICAL = 5 Typical price, (high+low+close)/3. PRICE_WEIGHTED = 6 Weighted close price, (high+low+close+close)/4. Line Style Options STYLE_SOLID = 0 The line is solid. STYLE_DASH = 1 The line is dashed. STYLE_DOT = 2 The line is dotted. STYLE_DASHDOT = 3 The line has alternating dashes and dots. STYLE_DASHDOTDOT = 4 The line has alternating dashes and double dots. Ma Options 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. */ extern string IIIIIIIIIIIIIIIIIIIIIIIIIIII=">>> Stochastic #1 Settings >>>>>>>>>>>>>>>"; extern int TimeFrame1=0; extern bool Show_STOCH_1 = true; extern int K_period1 = 14; extern int D_period1 = 3; extern int S_period1 = 3; extern int STOCH_1_MAIN_Line_Style = 0; extern int STOCH_1_SIGNAL_Line_Style = 2; extern int STOCH_1_Price_field = 1; extern int STOCH_1_MAIN_Ma_Mode = 1; extern int STOCH_1_SIGNAL_Ma_Mode = 1; extern string IIIIIIIIIIIIIIIIIIIIIIIIIIIII=">>> Stochastic #2 Settings >>>>>>>>>>>>>>>>>"; extern int TimeFrame2=60; extern bool Show_STOCH_2 = true; extern int K_period2 = 14; extern int D_period2 = 3; extern int S_period2 = 3; extern int STOCH_2_MAIN_Line_Style = 0; extern int STOCH_2_SIGNAL_Line_Style = 2; extern int STOCH_2_Price_field = 1; extern int STOCH_2_MAIN_Ma_Mode = 1; extern int STOCH_2_SIGNAL_Ma_Mode = 1; extern string IIIIIIIIIIIIIIIIIIIIIIIIIIIIII=">>> Stochastic #3 Settings >>>>>>>>>>>>>>>>>>>"; extern int TimeFrame3=240; extern bool Show_STOCH_3 = true; extern int K_period3 = 14; extern int D_period3 = 3; extern int S_period3 = 3; extern int STOCH_3_MAIN_Line_Style = 0; extern int STOCH_3_SIGNAL_Line_Style = 2; extern int STOCH_3_Price_field = 1; extern int STOCH_3_MAIN_Ma_Mode = 1; extern int STOCH_3_SIGNAL_Ma_Mode = 1; extern string IIIIIIIIIIIIIIIIIIIIIIIIIIIIIII=">>> Stochastic #4 Settings >>>>>>>>>>>>>>>>>>>>>"; extern int TimeFrame4=1440; extern bool Show_STOCH_4 = true; extern int K_period4 = 14; extern int D_period4 = 3; extern int S_period4 = 3; extern int STOCH_4_MAIN_Line_Style = 0; extern int STOCH_4_SIGNAL_Line_Style = 2; extern int STOCH_4_Price_field = 1; extern int STOCH_4_MAIN_Ma_Mode = 1; extern int STOCH_4_SIGNAL_Ma_Mode = 1; extern bool Show_StochLabels = true; extern int Labels_Corner = 0; extern int Labels_Shift = 0; extern int Labels_X_Distance = 535; extern int Labels_Y_Distance = 20; extern string note_MA_Method = "SMA0 EMA1 SMMA2 LWMA3"; extern string Price_field_ = "0Low/High 1Close/Close"; extern string TimeFrames = "M1;5,15,30,60H1;240H4;1440D1;10080W1;43200MN"; double MainBuffer1[]; double SignalBuffer1[]; double MainBuffer2[]; double SignalBuffer2[]; double MainBuffer3[]; double SignalBuffer3[]; double MainBuffer4[]; double SignalBuffer4[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicator line if(Show_STOCH_1 ==true){Show_STOCH_1=DRAW_LINE; } else {Show_STOCH_1=DRAW_NONE; } SetIndexBuffer(6,MainBuffer1); SetIndexStyle(6,Show_STOCH_1 ,STOCH_1_MAIN_Line_Style); SetIndexLabel(6,"STO#1_Main["+TimeFrame1+"]("+K_period1+","+D_period1+", "+S_period1+" )"); SetIndexBuffer(7,SignalBuffer1); SetIndexStyle(7,Show_STOCH_1 ,STOCH_1_SIGNAL_Line_Style); SetIndexLabel(7,"STO#1_Signal["+TimeFrame1+"]("+K_period1+","+D_period1+","+S_period1+" )"); if(Show_STOCH_2 ==true){Show_STOCH_2=DRAW_LINE; } else {Show_STOCH_2=DRAW_NONE; } SetIndexBuffer(4,MainBuffer2); SetIndexStyle(4,Show_STOCH_2 ,STOCH_2_MAIN_Line_Style); SetIndexLabel(4,"STO#2_Main ["+TimeFrame2+"]("+K_period2+","+D_period2+","+S_period2+")"); SetIndexBuffer(5,SignalBuffer2); SetIndexStyle(5,Show_STOCH_2 ,STOCH_2_SIGNAL_Line_Style); SetIndexLabel(5,"STO#2_Signal ["+TimeFrame2+"]("+K_period2+","+D_period2+","+S_period2+")"); if(Show_STOCH_3 ==true){Show_STOCH_3=DRAW_LINE; } else {Show_STOCH_3=DRAW_NONE; } SetIndexBuffer(2,MainBuffer3); SetIndexStyle(2,Show_STOCH_3 ,STOCH_3_MAIN_Line_Style); SetIndexLabel(2,"STO#3_Main["+TimeFrame3+"]("+K_period3+","+D_period3+","+S_period3+")"); SetIndexBuffer(3,SignalBuffer3); SetIndexStyle(3,Show_STOCH_3 ,STOCH_3_SIGNAL_Line_Style); SetIndexLabel(3,"STO#3_Signal["+TimeFrame3+"]("+K_period3+","+D_period3+","+S_period3+" )"); if(Show_STOCH_4 ==true){Show_STOCH_4=DRAW_LINE; } else {Show_STOCH_4=DRAW_NONE; } SetIndexBuffer(0,MainBuffer4); SetIndexStyle(0,Show_STOCH_4 ,STOCH_4_MAIN_Line_Style); SetIndexLabel(0,"STO#4_Main ["+TimeFrame4+"]("+K_period4+","+D_period4+","+S_period4+")"); SetIndexBuffer(1,SignalBuffer4); SetIndexStyle(1,Show_STOCH_4 ,STOCH_4_SIGNAL_Line_Style); SetIndexLabel(1,"STO#4_Signal["+TimeFrame4+"]("+K_period4+","+D_period4+","+S_period4+")"); //---- name for DataWindow and indicator subwindow label IndicatorShortName("STOStd_4TF"); } //---- return(0); //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- ObjectDelete("stoLABEL1"); ObjectDelete("stoLABEL2"); ObjectDelete("stoLABEL3"); ObjectDelete("stoLABEL4"); //---- return(0); } //+------------------------------------------------------------------+ //| MTF Stochastic | //+------------------------------------------------------------------+ int start() { datetime TimeArray1[],TimeArray2[],TimeArray3[],TimeArray4[]; int i,shift,limit,y1=0,y2=0,y3=0,y4=0,counted_bars=IndicatorCounted(); // Plot defined timeframe on to current timeframe ArrayCopySeries(TimeArray1,MODE_TIME,Symbol(),TimeFrame1); ArrayCopySeries(TimeArray2,MODE_TIME,Symbol(),TimeFrame2); ArrayCopySeries(TimeArray3,MODE_TIME,Symbol(),TimeFrame3); ArrayCopySeries(TimeArray4,MODE_TIME,Symbol(),TimeFrame4); limit=MathMax(Bars-counted_bars,TimeFrame1/Period()); limit=MathMax( limit,TimeFrame2/Period()); limit=MathMax( limit,TimeFrame3/Period()); limit=MathMax( limit,TimeFrame4/Period()); for(i=0,y1=0,y2=0,y3=0,y4=0;i<limit;i++) { if (Time[i]<TimeArray1[y1]) y1++; if (Time[i]<TimeArray2[y2]) y2++; if (Time[i]<TimeArray3[y3]) y3++; if (Time[i]<TimeArray4[y4]) y4++; MainBuffer1[i] =iStochastic(NULL,TimeFrame1,K_period1,D_period1,S_period1,STOCH_1_MAIN_Ma_Mode,STOCH_1_Price_field,MODE_MAIN,y1); SignalBuffer1[i]=iStochastic(NULL,TimeFrame1,K_period1,D_period1,S_period1,STOCH_1_SIGNAL_Ma_Mode,STOCH_1_Price_field,MODE_SIGNAL,y1); MainBuffer2[i] =iStochastic(NULL,TimeFrame2,K_period2,D_period2,S_period2,STOCH_2_MAIN_Ma_Mode,STOCH_2_Price_field,MODE_MAIN,y2); SignalBuffer2[i]=iStochastic(NULL,TimeFrame2,K_period2,D_period2,S_period2,STOCH_2_SIGNAL_Ma_Mode,STOCH_2_Price_field,MODE_SIGNAL,y2); MainBuffer3[i] =iStochastic(NULL,TimeFrame3,K_period3,D_period3,S_period3,STOCH_3_MAIN_Ma_Mode,STOCH_3_Price_field,MODE_MAIN,y3); SignalBuffer3[i]=iStochastic(NULL,TimeFrame3,K_period3,D_period3,S_period3,STOCH_3_SIGNAL_Ma_Mode,STOCH_3_Price_field,MODE_SIGNAL,y3); MainBuffer4[i] =iStochastic(NULL,TimeFrame4,K_period4,D_period4,S_period4,STOCH_4_MAIN_Ma_Mode,STOCH_4_Price_field,MODE_MAIN,y4); SignalBuffer4[i]=iStochastic(NULL,TimeFrame4,K_period4,D_period4,S_period4,STOCH_4_SIGNAL_Ma_Mode,STOCH_4_Price_field,MODE_SIGNAL,y4); } string STF1=""; if(TimeFrame1<1){STF1 = "TF0";} if(TimeFrame1==1){STF1 = "M1 ";} if(TimeFrame1==5){STF1 = "M5 ";} if(TimeFrame1==15){STF1 = "M15";} if(TimeFrame1==30){STF1 = "M30";} if(TimeFrame1==60){STF1 = "H1 ";} if(TimeFrame1==240){STF1 = "H4 ";} if(TimeFrame1==1440){STF1 = "D1 ";} if(TimeFrame1==10080){STF1 = "W1 ";} if(TimeFrame1==43200){STF1 = "MN ";} string STF2=""; if(TimeFrame2<1){STF2 = "TF0";} if(TimeFrame2==1){STF2 = "M1 ";} if(TimeFrame2==5){STF2 = "M5 ";} if(TimeFrame2==15){STF2 = "M15";} if(TimeFrame2==30){STF2 = "M30";} if(TimeFrame2==60){STF2 = "H1 ";} if(TimeFrame2==240){STF2 = "H4 ";} if(TimeFrame2==1440){STF2 = "D1 ";} if(TimeFrame2==10080){STF2 = "W1 ";} if(TimeFrame2==43200){STF2 = "MN ";} string STF3=""; if(TimeFrame3<1){STF3 = "TF0";} if(TimeFrame3==1){STF3 = "M1 ";} if(TimeFrame3==5){STF3 = "M5 ";} if(TimeFrame3==15){STF3 = "M15";} if(TimeFrame3==30){STF3 = "M30";} if(TimeFrame3==60){STF3 = "H1 ";} if(TimeFrame3==240){STF3 = "H4 ";} if(TimeFrame3==1440){STF3 = "D1 ";} if(TimeFrame3==10080){STF3 = "W1 ";} if(TimeFrame3==43200){STF3 = "MN ";} string STF4=""; if(TimeFrame4<1){STF4 = "TF0";} if(TimeFrame4==1){STF4 = "M1 ";} if(TimeFrame4==5){STF4 = "M5 ";} if(TimeFrame4==15){STF4 = "M15";} if(TimeFrame4==30){STF4 = "M30";} if(TimeFrame4==60){STF4 = "H1 ";} if(TimeFrame4==240){STF4 = "H4 ";} if(TimeFrame4==1440){STF4 = "D1 ";} if(TimeFrame4==10080){STF4 = "W1 ";} if(TimeFrame4==43200){STF4 = "MN ";} if(Show_StochLabels==true) { ObjectCreate ("stoLABEL1", OBJ_LABEL,WindowFind("STOStd_4TF"), 0, 0); ObjectSetText("stoLABEL1","STO #1 : "+K_period1+" "+D_period1+" "+S_period1+" "+STF1+"", 8, "Tahoma Narrow", indicator_color7); ObjectSet("stoLABEL1", OBJPROP_CORNER, Labels_Corner); ObjectSet("stoLABEL1", OBJPROP_XDISTANCE, Labels_X_Distance+Labels_Shift); ObjectSet("stoLABEL1", OBJPROP_YDISTANCE, Labels_Y_Distance); ObjectCreate ("stoLABEL2", OBJ_LABEL,WindowFind("STOStd_4TF"), 0, 0); ObjectSetText("stoLABEL2","STO #2 : "+K_period2+" "+D_period2+" "+S_period2+" "+STF2+"", 8, "Tahoma Narrow", indicator_color5); ObjectSet("stoLABEL2", OBJPROP_CORNER, Labels_Corner); ObjectSet("stoLABEL2", OBJPROP_XDISTANCE, Labels_X_Distance+Labels_Shift); ObjectSet("stoLABEL2", OBJPROP_YDISTANCE, Labels_Y_Distance+10); ObjectCreate ("stoLABEL3", OBJ_LABEL,WindowFind("STOStd_4TF"), 0, 0); ObjectSetText("stoLABEL3","STO #3 : "+K_period3+" "+D_period3+" "+S_period3+" "+STF3+"", 8, "Tahoma Narrow", indicator_color3); ObjectSet("stoLABEL3", OBJPROP_CORNER, Labels_Corner); ObjectSet("stoLABEL3", OBJPROP_XDISTANCE, Labels_X_Distance+Labels_Shift); ObjectSet("stoLABEL3", OBJPROP_YDISTANCE, Labels_Y_Distance+20); ObjectCreate ("stoLABEL4", OBJ_LABEL,WindowFind("STOStd_4TF"), 0, 0); ObjectSetText("stoLABEL4","STO #4 : "+K_period4+" "+D_period4+" "+S_period4+" "+STF4+"", 8, "Tahoma Narrow", indicator_color1); ObjectSet("stoLABEL4", OBJPROP_CORNER, Labels_Corner); ObjectSet("stoLABEL4", OBJPROP_XDISTANCE, Labels_X_Distance+Labels_Shift); ObjectSet("stoLABEL4", OBJPROP_YDISTANCE, Labels_Y_Distance+30); } return(0); } //+------------------------------------------------------------------+
Sample
Analysis
Market Information Used:
Series array that contains open time of each bar
Indicator Curves created:
Implements a curve of type Show_STOCH_1
Implements a curve of type Show_STOCH_2
Implements a curve of type Show_STOCH_3
Implements a curve of type Show_STOCH_4
Indicators Used:
Stochastic oscillator
Custom Indicators Used:
Order Management characteristics:
Other Features: