//+------------------------------------------------------------------+ //| #MTF Stochastic Standard.mq4 | //| Copyright © 2006, Keris2112 | //| http://www.metaquotes.net | //+------------------------------------------------------------------+ #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 Red #property indicator_color2 Red #property indicator_color3 DodgerBlue #property indicator_color4 DodgerBlue #property indicator_color5 SeaGreen #property indicator_color6 SeaGreen #property indicator_color7 Olive #property indicator_color8 Olive #property indicator_level1 80 #property indicator_level2 20 #property indicator_levelcolor Blue /******************************************************************* 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 bool Show_StochLabels=false; extern int Shift_Text=0; extern string IIIIIIIIIIIIIIIIIIIIIIIIIIII=">>> Stoch #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_MAIN_Line_Style1=0; extern int STOCH_SIGNAL_Line_Style1=2; extern int STOCH_MAIN_Price1=0; extern int STOCH_SIGNAL_Price1=0; extern int STOCH_MAIN_Ma1=0; extern int STOCH_SIGNAL_Ma1=0; extern string IIIIIIIIIIIIIIIIIIIIIIIIIIIII=">>> Stoch #2 Settings >>>>>>>>>>>>>>>>>"; extern int TimeFrame2=0; extern bool Show_STOCH_2=false; extern int K_period2=5; extern int D_period2=3; extern int S_period2=3; extern int STOCH_MAIN_Line_Style2=0; extern int STOCH_SIGNAL_Line_Style2=2; extern int STOCH_MAIN_Price2=0; extern int STOCH_SIGNAL_Price2=1; extern int STOCH_MAIN_Ma2=0; extern int STOCH_SIGNAL_Ma2=0; extern string IIIIIIIIIIIIIIIIIIIIIIIIIIIIII=">>> Stoch #3 Settings >>>>>>>>>>>>>>>>>>>"; extern int TimeFrame3=0; extern bool Show_STOCH_3=false; extern int K_period3=56; extern int D_period3=12; extern int S_period3=12; extern int STOCH_MAIN_Line_Style3=0; extern int STOCH_SIGNAL_Line_Style3=2; extern int STOCH_MAIN_Price3=1; extern int STOCH_SIGNAL_Price3=1; extern int STOCH_MAIN_Ma3=0; extern int STOCH_SIGNAL_Ma3=0; extern string IIIIIIIIIIIIIIIIIIIIIIIIIIIIIII=">>> Stoch #4 Settings >>>>>>>>>>>>>>>>>>>>>"; extern int TimeFrame4=0; extern bool Show_STOCH_4=false; extern int K_period4=84; extern int D_period4=18; extern int S_period4=3; extern int STOCH_MAIN_Line_Style4=0; extern int STOCH_SIGNAL_Line_Style4=2; extern int STOCH_MAIN_Price4=1; extern int STOCH_SIGNAL_Price4=1; extern int STOCH_MAIN_Ma4=0; extern int STOCH_SIGNAL_Ma4=0; //---- 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(0,MainBuffer1); SetIndexStyle(0,Show_STOCH_1 ,STOCH_MAIN_Line_Style1); SetIndexLabel(0,"MAIN #1 ( "+(string)K_period1+" )( "+(string)D_period1+" )( "+(string)S_period1+" )"); SetIndexBuffer(1,SignalBuffer1); SetIndexStyle(1,Show_STOCH_1 ,STOCH_SIGNAL_Line_Style1); SetIndexLabel(1,"SIGNAL #1 ( "+(string)K_period1+" )( "+(string)D_period1+" )( "+(string)S_period1+" )"); //---- if(Show_STOCH_2 ==true){Show_STOCH_2=DRAW_LINE; } else {Show_STOCH_2=DRAW_NONE; } SetIndexBuffer(2,MainBuffer2); SetIndexStyle(2,Show_STOCH_2 ,STOCH_MAIN_Line_Style2); SetIndexLabel(2,"MAIN #2 ( "+(string)K_period2+" )( "+(string)D_period2+" )( "+(string)S_period2+" )"); SetIndexBuffer(3,SignalBuffer2); SetIndexStyle(3,Show_STOCH_2 ,STOCH_SIGNAL_Line_Style2); SetIndexLabel(3,"SIGNAL #2 ( "+(string)K_period2+" )( "+(string)D_period2+" )( "+(string)S_period2+" )"); //---- if(Show_STOCH_3 ==true){Show_STOCH_3=DRAW_LINE; } else {Show_STOCH_3=DRAW_NONE; } SetIndexBuffer(4,MainBuffer3); SetIndexStyle(4,Show_STOCH_3 ,STOCH_MAIN_Line_Style3); SetIndexLabel(4,"MAIN #3 ( "+(string)K_period3+" )( "+(string)D_period3+" )( "+(string)S_period3+" )"); SetIndexBuffer(5,SignalBuffer3); SetIndexStyle(5,Show_STOCH_3 ,STOCH_SIGNAL_Line_Style3); SetIndexLabel(5,"SIGNAL #3 ( "+(string)K_period3+" )( "+(string)D_period3+" )( "+(string)S_period3+" )"); //---- if(Show_STOCH_4 ==true){Show_STOCH_4=DRAW_LINE; } else {Show_STOCH_4=DRAW_NONE; } SetIndexBuffer(6,MainBuffer4); SetIndexStyle(6,Show_STOCH_4 ,STOCH_MAIN_Line_Style4); SetIndexLabel(6,"MAIN #4 ( "+(string)K_period4+" )( "+(string)D_period4+" )( "+(string)S_period4+" )"); SetIndexBuffer(7,SignalBuffer4); SetIndexStyle(7,Show_STOCH_4 ,STOCH_SIGNAL_Line_Style4); SetIndexLabel(7,"SIGNAL #4 ( "+(string)K_period4+" )( "+(string)D_period4+" )( "+(string)S_period4+" )"); //---- name for DataWindow and indicator subwindow label IndicatorShortName("MTF 4Period STOCH #1 "); return(0); } //---- //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- ObjectsDeleteAll(0,OBJ_LABEL); //---- return(0); } //+------------------------------------------------------------------+ //| MTF Stochastic | //+------------------------------------------------------------------+ int start() { datetime TimeArray[]; int i,limit,y=0,counted_bars=IndicatorCounted(); // Plot defined timeframe on to current timeframe ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame1); ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame2); ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame3); ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame4); //---- limit=Bars-counted_bars+TimeFrame1/Period(); limit=Bars-counted_bars+TimeFrame2/Period(); limit=Bars-counted_bars+TimeFrame3/Period(); limit=Bars-counted_bars+TimeFrame4/Period(); for(i=0,y=0;i