//+------------------------------------------------------------------+ //| Big Stochastic.mq4 | //| author : Skyline | //| email : glicci@yahoo.it | //+------------------------------------------------------------------+ // You can find me at following forums : // www.forexpertutti.it (italian forum) // www.fastbrokers.net/forum (international forum) // www.forexfactory.com (international forum) // v1.0 [01 May 2007] ** Indicator created // v1.1 [02 May 2007] ** Added arrows indicator #property copyright "" #property link "" #property indicator_chart_window extern color Color = Black; extern int Label_Size = 30; extern int Sto_period = 5; // Set to 5 or 14 as prefered extern int Sto_1 = 15; // Shortest time period - is displayed on the far right hand side extern int Sto_2 = 30; extern int Sto_3 = 60; extern int Sto_4 = 240; extern bool Sto_Alert = true; // will give an alert when Sto_4 & 3 or 3 & 2 are both > 61.8 and rising or < 38.2 and falling. Alert given only once per bar so may be best to place indicator on the chart of lowest timeframe. //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- ObjectDelete("Big_Stochastic_Sto_1"); ObjectDelete("ArrowUp_Sto_1"); ObjectDelete("Big_Stochastic_Sto_2"); ObjectDelete("ArrowUp_Sto_2"); //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { string Sto_1_stoch_char, Sto_2_stoch_char, Sto_3_stoch_char, Sto_4_stoch_char; int counted_bars=IndicatorCounted(); double Sto_1_main = iStochastic(NULL,Sto_1,Sto_period,3,3,MODE_SMA,0,MODE_MAIN,0); double Sto_1_mainprev = iStochastic(NULL,Sto_1,Sto_period,3,3,MODE_SMA,0,MODE_MAIN,1); double Sto_1_signal = iStochastic(NULL,Sto_1,Sto_period,3,3,MODE_SMA,0,MODE_SIGNAL,0); // Colours = 1) > 80 or < 20 Gold ; 2) > 61.8 & < 80 & rising = Blue, 3) < 38.2 & > 20 & falling = Red, //4) Between 38.2 & 61.8 or > 61.8 & < 80 & falling or < 38.2 & > 20 & rising = Black if ( Sto_1_main >= 80 || Sto_1_main <= 20 ) {Color = Gold;} if ( Sto_1_main >= 61.8 && Sto_1_main < 80 && Sto_1_main > Sto_1_mainprev) {Color = Blue;} if ( Sto_1_main <= 38.2 && Sto_1_main > 20 && Sto_1_main < Sto_1_mainprev) {Color = Red;} if (( Sto_1_main > 38.2 && Sto_1_main < 61.8 )|| ( Sto_1_main >= 61.8 && Sto_1_main < 80 && Sto_1_main < Sto_1_mainprev) || (Sto_1_main < 31.8 && Sto_1_main > 20 && Sto_1_main > Sto_1_mainprev)){ Color = Black;} if ( Sto_1_main > Sto_1_signal ) Sto_1_stoch_char="Ù"; else Sto_1_stoch_char="Ú"; // Stochastic ObjectCreate("Big_Stochastic_Sto_1", OBJ_LABEL, 0, 0, 0); ObjectSet("Big_Stochastic_Sto_1", OBJPROP_CORNER, 4); ObjectSet("Big_Stochastic_Sto_1", OBJPROP_XDISTANCE, 455); ObjectSet("Big_Stochastic_Sto_1", OBJPROP_YDISTANCE, 20); ObjectSetText("Big_Stochastic_Sto_1", DoubleToStr(Sto_1_main,2), Label_Size, "Comic Sans MS", Color); // Arrow ObjectDelete("ArrowUp_Sto_1"); ObjectCreate("ArrowUp_Sto_1", OBJ_LABEL, 0, 0, 0); ObjectSetText("ArrowUp_Sto_1",Sto_1_stoch_char,Label_Size, "Wingdings", Color); ObjectSet("ArrowUp_Sto_1", OBJPROP_CORNER, 4); ObjectSet("ArrowUp_Sto_1", OBJPROP_XDISTANCE,560); ObjectSet("ArrowUp_Sto_1", OBJPROP_YDISTANCE,20); double Sto_2_main = iStochastic(NULL,Sto_2,Sto_period,3,3,MODE_SMA,0,MODE_MAIN,0); double Sto_2_mainprev = iStochastic(NULL,Sto_2,Sto_period,3,3,MODE_SMA,0,MODE_MAIN,1); double Sto_2_signal = iStochastic(NULL,Sto_2,Sto_period,3,3,MODE_SMA,0,MODE_SIGNAL,0); if ( Sto_2_main >= 80 || Sto_2_main <= 20 ) {Color = Gold;} if ( Sto_2_main >= 61.8 && Sto_2_main < 80 && Sto_2_main > Sto_2_mainprev) {Color = Blue;} if ( Sto_2_main <= 38.2 && Sto_2_main > 20 && Sto_2_main < Sto_2_mainprev) {Color = Red;} if (( Sto_2_main > 38.2 && Sto_2_main < 61.8 )|| ( Sto_2_main >= 61.8 && Sto_2_main < 80 && Sto_2_main < Sto_2_mainprev) || (Sto_2_main < 31.8 && Sto_2_main > 20 && Sto_2_main > Sto_2_mainprev)){ Color = Black;} if ( Sto_2_main > Sto_2_signal ) Sto_2_stoch_char="Ù"; else Sto_2_stoch_char="Ú"; // Stochastic ObjectCreate("Big_Stochastic_Sto_2", OBJ_LABEL, 0, 0, 0); ObjectSet("Big_Stochastic_Sto_2", OBJPROP_CORNER, 4); ObjectSet("Big_Stochastic_Sto_2", OBJPROP_XDISTANCE, 305); ObjectSet("Big_Stochastic_Sto_2", OBJPROP_YDISTANCE, 20); ObjectSetText("Big_Stochastic_Sto_2", DoubleToStr(Sto_2_main,2), Label_Size, "Comic Sans MS", Color); // Arrow ObjectDelete("ArrowUp_Sto_2"); ObjectCreate("ArrowUp_Sto_2", OBJ_LABEL, 0, 0, 0); ObjectSetText("ArrowUp_Sto_2",Sto_2_stoch_char,Label_Size, "Wingdings", Color); ObjectSet("ArrowUp_Sto_2", OBJPROP_CORNER, 4); ObjectSet("ArrowUp_Sto_2", OBJPROP_XDISTANCE,410); ObjectSet("ArrowUp_Sto_2", OBJPROP_YDISTANCE,20); double Sto_3_main = iStochastic(NULL,Sto_3,Sto_period,3,3,MODE_SMA,0,MODE_MAIN,0); double Sto_3_mainprev = iStochastic(NULL,Sto_3,Sto_period,3,3,MODE_SMA,0,MODE_MAIN,1); double Sto_3_signal = iStochastic(NULL,Sto_3,Sto_period,3,3,MODE_SMA,0,MODE_SIGNAL,0); if ( Sto_3_main >= 80 || Sto_3_main <= 20 ) {Color = Gold;} if ( Sto_3_main >= 61.8 && Sto_3_main < 80 && Sto_3_main > Sto_3_mainprev) {Color = Blue;} if ( Sto_3_main <= 38.2 && Sto_3_main > 20 && Sto_3_main < Sto_3_mainprev) {Color = Red;} if (( Sto_3_main > 38.2 && Sto_3_main < 61.8 )|| ( Sto_3_main >= 61.8 && Sto_3_main < 80 && Sto_3_main < Sto_3_mainprev) || (Sto_3_main < 31.8 && Sto_3_main > 20 && Sto_3_main > Sto_3_mainprev)){ Color = Black;} if ( Sto_3_main > Sto_3_signal ) Sto_3_stoch_char="Ù"; else Sto_3_stoch_char="Ú"; // Stochastic ObjectCreate("Big_Stochastic_Sto_3", OBJ_LABEL, 0, 0, 0); ObjectSet("Big_Stochastic_Sto_3", OBJPROP_CORNER, 4); ObjectSet("Big_Stochastic_Sto_3", OBJPROP_XDISTANCE, 155); ObjectSet("Big_Stochastic_Sto_3", OBJPROP_YDISTANCE, 20); ObjectSetText("Big_Stochastic_Sto_3", DoubleToStr(Sto_3_main,2), Label_Size, "Comic Sans MS", Color); // Arrow ObjectDelete("ArrowUp_Sto_3"); ObjectCreate("ArrowUp_Sto_3", OBJ_LABEL, 0, 0, 0); ObjectSetText("ArrowUp_Sto_3",Sto_3_stoch_char,Label_Size, "Wingdings", Color); ObjectSet("ArrowUp_Sto_3", OBJPROP_CORNER, 4); ObjectSet("ArrowUp_Sto_3", OBJPROP_XDISTANCE,260); ObjectSet("ArrowUp_Sto_3", OBJPROP_YDISTANCE,20); double Sto_4_main = iStochastic(NULL,Sto_4,Sto_period,3,3,MODE_SMA,0,MODE_MAIN,0); double Sto_4_mainprev = iStochastic(NULL,Sto_4,Sto_period,3,3,MODE_SMA,0,MODE_MAIN,1); double Sto_4_signal = iStochastic(NULL,Sto_4,Sto_period,3,3,MODE_SMA,0,MODE_SIGNAL,0); if ( Sto_4_main >= 80 || Sto_4_main <= 20 ) {Color = Gold;} if ( Sto_4_main >= 61.8 && Sto_4_main < 80 && Sto_4_main > Sto_4_mainprev) {Color = Blue;} if ( Sto_4_main <= 38.2 && Sto_4_main > 20 && Sto_4_main < Sto_4_mainprev) {Color = Red;} if (( Sto_4_main > 38.2 && Sto_4_main < 61.8 )|| ( Sto_4_main >= 61.8 && Sto_4_main < 80 && Sto_4_main < Sto_4_mainprev) || (Sto_4_main < 31.8 && Sto_4_main > 20 && Sto_4_main > Sto_4_mainprev)){ Color = Black;} if ( Sto_4_main > Sto_4_signal ) Sto_4_stoch_char="Ù"; else Sto_4_stoch_char="Ú"; // Stochastic ObjectCreate("Big_Stochastic_Sto_4", OBJ_LABEL, 0, 0, 0); ObjectSet("Big_Stochastic_Sto_4", OBJPROP_CORNER, 4); ObjectSet("Big_Stochastic_Sto_4", OBJPROP_XDISTANCE, 5); ObjectSet("Big_Stochastic_Sto_4", OBJPROP_YDISTANCE, 20); ObjectSetText("Big_Stochastic_Sto_4", DoubleToStr(Sto_4_main,2), Label_Size, "Comic Sans MS", Color); // Arrow ObjectDelete("ArrowUp_Sto_4"); ObjectCreate("ArrowUp_Sto_4", OBJ_LABEL, 0, 0, 0); ObjectSetText("ArrowUp_Sto_4",Sto_4_stoch_char,Label_Size, "Wingdings", Color); ObjectSet("ArrowUp_Sto_4", OBJPROP_CORNER, 4); ObjectSet("ArrowUp_Sto_4", OBJPROP_XDISTANCE,110); ObjectSet("ArrowUp_Sto_4", OBJPROP_YDISTANCE,20); // Alerts only given once per bar - remove NewBar if constant alerts are required. { if ( Sto_Alert == true && Sto_4_main > Sto_4_mainprev && Sto_3_main > Sto_3_mainprev && (Sto_3_mainprev < 61.8 && Sto_3_main > 61.8 && Sto_4_main > 61.8) || (Sto_4_mainprev < 61.8 && Sto_4_main > 61.8 && Sto_3_main > 61.8) ) if (NewBar()) // The wording is set for 5 - 15 & 30 min charts - re-write all as necessary Alert (Symbol()," "," 30 min & 15 min Stochastics both > 61.8 Buy on lower timeframe confirmation"); } { if ( Sto_Alert == true && Sto_3_main > Sto_3_mainprev && Sto_2_main > Sto_2_mainprev && (Sto_2_mainprev < 61.8 && Sto_2_main > 61.8 && Sto_3_main > 61.8) || (Sto_3_mainprev < 61.8 && Sto_3_main > 61.8 && Sto_2_main > 61.8) ) if (NewBar()) Alert (Symbol()," "," 15 min & 5 min Stochastics both > 61.8 Buy on lower timeframe confirmation"); } { if ( Sto_Alert == true && Sto_4_main < Sto_4_mainprev && Sto_3_main < Sto_3_mainprev && (Sto_3_mainprev > 38.2 && Sto_3_main < 38.2 && Sto_4_main < 38.2) || (Sto_4_mainprev > 38.2 && Sto_4_main < 38.2 && Sto_3_main < 38.2) ) if (NewBar()) Alert (Symbol()," "," 30 min & 15 min Stochastics both < 38.2 Sell on lower timeframe confirmation"); } { if ( Sto_Alert == true && Sto_3_main < Sto_3_mainprev && Sto_2_main < Sto_2_mainprev && (Sto_2_mainprev > 38.2 && Sto_2_main < 38.2 && Sto_3_main < 38.2) || (Sto_3_mainprev > 38.2 && Sto_3_main < 38.2 && Sto_2_main < 38.2) ) if (NewBar()) Alert (Symbol()," "," 15 min & 5 min Stochastics both < 38.2 Sell on lower timeframe confirmation"); } } bool NewBar() { static datetime dt = 0; if (dt != Time[0]) { dt = Time[0]; Sleep(100); // wait for tick return(true); } return(false); } //---- //---- return(0); //+------------------------------------------------------------------+