Navigation:Home > Content >

Boxinglife_Stochastic2.mq4

Time: 2012-07-14 | Download file:Boxinglife_Stochastic2.mq4

//+------------------------------------------------------------------+
//|                                        Boxinglife 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 [07 May 2007] ** Indicator created
// v1.1 [10 july 2007 ] ** Indicator modified by Melpheos
#property copyright ""
#property link      ""

#property indicator_chart_window
extern color  Color      = White;
extern int    Label_Size = 20;
extern int    Signal = 10;
extern int    Slowing = 20;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
     ObjectDelete("Label_M5");
     ObjectDelete("Label_M15");
     ObjectDelete("Label_M30");
     ObjectDelete("Label_H1");
     ObjectDelete("Label_H4");
     ObjectDelete("Label_D1");
     ObjectDelete("Label_W1");
     ObjectDelete("Label_5");
     ObjectDelete("Label_30");
     ObjectDelete("Label_50");
     ObjectDelete("Label_70");
     ObjectDelete("Label_90");
     ObjectDelete("Label_110");
     ObjectDelete("Label_130");
     ObjectDelete("Label_150");
     ObjectDelete("ArrowStoch5_TF5");
     ObjectDelete("ArrowStoch30_TF5");
     ObjectDelete("ArrowStoch50_TF5");
     ObjectDelete("ArrowStoch70_TF5");
     ObjectDelete("ArrowStoch90_TF5");
     ObjectDelete("ArrowStoch110_TF5");
     ObjectDelete("ArrowStoch130_TF5");
     ObjectDelete("ArrowStoch150_TF5");
     ObjectDelete("ArrowStoch5_TF15");
     ObjectDelete("ArrowStoch30_TF15");
     ObjectDelete("ArrowStoch50_TF15");
     ObjectDelete("ArrowStoch70_TF15");
     ObjectDelete("ArrowStoch90_TF15");
     ObjectDelete("ArrowStoch110_TF15");
     ObjectDelete("ArrowStoch130_TF15");
     ObjectDelete("ArrowStoch150_TF15");
     ObjectDelete("ArrowStoch5_TF30");
     ObjectDelete("ArrowStoch30_TF30");
     ObjectDelete("ArrowStoch50_TF30");
     ObjectDelete("ArrowStoch70_TF30");
     ObjectDelete("ArrowStoch90_TF30");
     ObjectDelete("ArrowStoch110_TF30");
     ObjectDelete("ArrowStoch130_TF30");
     ObjectDelete("ArrowStoch150_TF30");
     ObjectDelete("ArrowStoch5_TF60");
     ObjectDelete("ArrowStoch30_TF60");
     ObjectDelete("ArrowStoch50_TF60");
     ObjectDelete("ArrowStoch70_TF60");
     ObjectDelete("ArrowStoch90_TF60");
     ObjectDelete("ArrowStoch110_TF60");
     ObjectDelete("ArrowStoch130_TF60");
     ObjectDelete("ArrowStoch150_TF60");
     ObjectDelete("ArrowStoch5_TF240");
     ObjectDelete("ArrowStoch30_TF240");
     ObjectDelete("ArrowStoch50_TF240");
     ObjectDelete("ArrowStoch70_TF240");
     ObjectDelete("ArrowStoch90_TF240");
     ObjectDelete("ArrowStoch110_TF240");
     ObjectDelete("ArrowStoch130_TF240");
     ObjectDelete("ArrowStoch150_TF240");
     ObjectDelete("ArrowStoch5_TF1440");
     ObjectDelete("ArrowStoch30_TF1440");
     ObjectDelete("ArrowStoch50_TF1440");
     ObjectDelete("ArrowStoch70_TF1440");
     ObjectDelete("ArrowStoch90_TF1440");
     ObjectDelete("ArrowStoch110_TF1440");
     ObjectDelete("ArrowStoch130_TF1440");
     ObjectDelete("ArrowStoch150_TF1440");
     ObjectDelete("ArrowStoch5_TF10080");
     ObjectDelete("ArrowStoch30_TF10080");
     ObjectDelete("ArrowStoch50_TF10080");
     ObjectDelete("ArrowStoch70_TF10080");
     ObjectDelete("ArrowStoch90_TF10080");
     ObjectDelete("ArrowStoch110_TF10080");
     ObjectDelete("ArrowStoch130_TF10080");
     ObjectDelete("ArrowStoch150_TF10080");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {

         
   int    counted_bars=IndicatorCounted();

   // Disegna label per timeframe
   DrawTFLabel(5,"Label_M5",210,40);
   DrawTFLabel(15,"Label_M15",210,60);
   DrawTFLabel(30,"Label_M30",210,80);
   DrawTFLabel(60,"Label_H1",210,100);
   DrawTFLabel(240,"Label_H4",210,120);
   DrawTFLabel(1440,"Label_D1",210,140);
   DrawTFLabel(10080,"Label_W1",210,160);
 
   // Disegna label per stoch
   DrawStochLabel(5,"Label_5",185,20);
   DrawStochLabel(30,"Label_30",160,20);
   DrawStochLabel(50,"Label_50",135,20);
   DrawStochLabel(70,"Label_70",110,20);
   DrawStochLabel(90,"Label_90",85,20);
   DrawStochLabel(110,"Label_110",60,20);
   DrawStochLabel(130,"Label_130",35,20);
   DrawStochLabel(150,"Label_150",10,20);

   // Disegna Freccie per TF5
   DrawArrow(5,5,"ArrowStoch5_TF5",180,35);
   DrawArrow(5,30,"ArrowStoch30_TF5",157,35);
   DrawArrow(5,50,"ArrowStoch50_TF5",133,35);
   DrawArrow(5,70,"ArrowStoch70_TF5",110,35);
   DrawArrow(5,90,"ArrowStoch90_TF5",85,35);
   DrawArrow(5,110,"ArrowStoch110_TF5",60,35);
   DrawArrow(5,130,"ArrowStoch130_TF5",35,35);
   DrawArrow(5,150,"ArrowStoch150_TF5",10,35);

   // Disegna Freccie per TF15   
   DrawArrow(15,5,"ArrowStoch5_TF15",180,56);
   DrawArrow(15,30,"ArrowStoch30_TF15",157,56);
   DrawArrow(15,50,"ArrowStoch50_TF15",133,56);
   DrawArrow(15,70,"ArrowStoch70_TF15",110,56);
   DrawArrow(15,90,"ArrowStoch90_TF15",85,56);
   DrawArrow(15,110,"ArrowStoch110_TF15",60,56);
   DrawArrow(15,130,"ArrowStoch130_TF15",35,56);
   DrawArrow(15,150,"ArrowStoch150_TF15",10,56);
   
   // Disegna Freccie per TF30
   DrawArrow(30,5,"ArrowStoch5_TF30",180,75);
   DrawArrow(30,30,"ArrowStoch30_TF30",157,75);
   DrawArrow(30,50,"ArrowStoch50_TF30",133,75);
   DrawArrow(30,70,"ArrowStoch70_TF30",110,75);
   DrawArrow(30,90,"ArrowStoch90_TF30",85,75);
   DrawArrow(30,110,"ArrowStoch110_TF30",60,75);
   DrawArrow(30,130,"ArrowStoch130_TF30",35,75);
   DrawArrow(30,150,"ArrowStoch150_TF30",10,75);
      
   // Disegna Freccie per TF60   
   DrawArrow(60,5,"ArrowStoch5_TF60",180,96);
   DrawArrow(60,30,"ArrowStoch30_TF60",157,96);
   DrawArrow(60,50,"ArrowStoch50_TF60",133,96);
   DrawArrow(60,70,"ArrowStoch70_TF60",110,96);
   DrawArrow(60,90,"ArrowStoch90_TF60",85,96);
   DrawArrow(60,110,"ArrowStoch110_TF60",60,96);
   DrawArrow(60,130,"ArrowStoch130_TF60",35,96);
   DrawArrow(60,150,"ArrowStoch150_TF60",10,96);
   
   // Disegna Freccie per TF240   
   DrawArrow(240,5,"ArrowStoch5_TF240",180,116);
   DrawArrow(240,30,"ArrowStoch30_TF240",157,116);
   DrawArrow(240,50,"ArrowStoch50_TF240",133,116);
   DrawArrow(240,70,"ArrowStoch70_TF240",110,116);
   DrawArrow(240,90,"ArrowStoch90_TF240",85,116);
   DrawArrow(240,110,"ArrowStoch110_TF240",60,116);
   DrawArrow(240,130,"ArrowStoch130_TF240",35,116);
   DrawArrow(240,150,"ArrowStoch150_TF240",10,116);
   
   // Disegna Freccie per TF1440   
   DrawArrow(1440,5,"ArrowStoch5_TF1440",180,136);
   DrawArrow(1440,30,"ArrowStoch30_TF1440",157,136);
   DrawArrow(1440,50,"ArrowStoch50_TF1440",133,136);
   DrawArrow(1440,70,"ArrowStoch70_TF1440",110,136);
   DrawArrow(1440,90,"ArrowStoch90_TF1440",85,136);
   DrawArrow(1440,110,"ArrowStoch110_TF1440",60,136);
   DrawArrow(1440,130,"ArrowStoch130_TF1440",35,136);
   DrawArrow(1440,150,"ArrowStoch150_TF1440",10,136);
   
   // Disegna Freccie per TF10080   
   DrawArrow(10080,5,"ArrowStoch5_TF10080",180,156);
   DrawArrow(10080,30,"ArrowStoch30_TF10080",157,156);
   DrawArrow(10080,50,"ArrowStoch50_TF10080",133,156);
   DrawArrow(10080,70,"ArrowStoch70_TF10080",110,156);
   DrawArrow(10080,90,"ArrowStoch90_TF10080",85,156);
   DrawArrow(10080,110,"ArrowStoch110_TF10080",60,156);
   DrawArrow(10080,130,"ArrowStoch130_TF10080",35,156);
   DrawArrow(10080,150,"ArrowStoch150_TF10080",10,156);
   
//----
   
//----
   return(0);
  }
   //DrawTFLabel(5,"Label_M5",150,40);

// Routine per disegnare le label degli stoch
  // DrawStochLabel(5,"Label_Stoch5",110,20);
void DrawStochLabel(int TipoStoch, string Label, int PosX, int PosY)
{
    // Stoch5 Label
   ObjectCreate(Label, OBJ_LABEL, 0, 0, 0);
   ObjectSet(Label, OBJPROP_CORNER, 1);
   ObjectSet(Label, OBJPROP_XDISTANCE, PosX);
   ObjectSet(Label, OBJPROP_YDISTANCE, PosY);  
   if (TipoStoch == 5)  ObjectSetText(Label, "5", 8, "Comic Sans MS", White);
   if (TipoStoch == 30) ObjectSetText(Label, "30", 8, "Comic Sans MS", White);   
   if (TipoStoch == 50) ObjectSetText(Label, "50", 8, "Comic Sans MS", White);
   if (TipoStoch == 70)  ObjectSetText(Label, "70", 8, "Comic Sans MS", White);
   if (TipoStoch == 90) ObjectSetText(Label, "90", 8, "Comic Sans MS", White);   
   if (TipoStoch == 110) ObjectSetText(Label, "110", 8, "Comic Sans MS", White); 
   if (TipoStoch == 130)  ObjectSetText(Label, "130", 8, "Comic Sans MS", White);
   if (TipoStoch == 150) ObjectSetText(Label, "150", 8, "Comic Sans MS", White);   
  
}
      
// Routine per disegnare le label dei timframe
void DrawTFLabel(int TF, string Label, int PosX, int PosY)
{
   // M5 Label
   ObjectCreate(Label, OBJ_LABEL, 0, 0, 0);
   ObjectSet(Label, OBJPROP_CORNER, 1);
   ObjectSet(Label, OBJPROP_XDISTANCE, PosX);
   ObjectSet(Label, OBJPROP_YDISTANCE, PosY);
   if (TF == 5)  ObjectSetText(Label, "M5", 8, "Comic Sans MS", White);
   if (TF == 15) ObjectSetText(Label, "M15", 8, "Comic Sans MS", White);
   if (TF == 30) ObjectSetText(Label, "M30", 8, "Comic Sans MS", White);   
   if (TF == 60) ObjectSetText(Label, "H1", 8, "Comic Sans MS", White); 
   if (TF == 240) ObjectSetText(Label, "H4", 8, "Comic Sans MS", White);
   if (TF == 1440) ObjectSetText(Label, "D1", 8, "Comic Sans MS", White);  
   if (TF == 10080) ObjectSetText(Label, "W1", 8, "Comic Sans MS", White);
}

// Routine per disegnare la freccia
void DrawArrow(int TF, int TipoStoch, string NameArrow, int PosX, int PosY)
{ string Temp;
    // Arrow Stoch5_TF5 
   if ( StochMain(TF,TipoStoch) > StochSignal(TF,TipoStoch) && StochMain(TF,TipoStoch)<80 && StochMain(TF,TipoStoch)>20) 
   { 
    Temp="Щ";
    Color = Green;
   }
   if ( StochMain(TF,TipoStoch)>80 )
   { 
    Temp="Щ";
    Color = Green;
   }
   if ( StochMain(TF,TipoStoch) < StochSignal(TF,TipoStoch) && StochMain(TF,TipoStoch)>20 && StochMain(TF,TipoStoch)<80) 
   { 
    Temp="Ъ";
    Color = Red;
   } 
   if ( StochMain(TF,TipoStoch)<20 )
   {
    Temp="Ъ";
    Color = Red;
   } 
   
   ObjectDelete(NameArrow);
   ObjectCreate(NameArrow, OBJ_LABEL, 0, 0, 0);
   ObjectSetText(NameArrow,Temp,15, "Wingdings", Color);
   ObjectSet(NameArrow, OBJPROP_CORNER, 1);
   ObjectSet(NameArrow, OBJPROP_XDISTANCE,PosX);
   ObjectSet(NameArrow, OBJPROP_YDISTANCE,PosY);

}
 
// Rileva valore Main Stocastico
double StochMain(int TF,int TipoStoch)
{ double valore;
  if (TipoStoch == 5)  valore = iStochastic(NULL,TF,TipoStoch,3,3,MODE_SMA,0,MODE_MAIN,0);
  if (TipoStoch == 30) valore = iStochastic(NULL,TF,TipoStoch,Signal,Slowing,MODE_SMA,0,MODE_MAIN,0); 
  if (TipoStoch == 50) valore = iStochastic(NULL,TF,TipoStoch,Signal,Slowing,MODE_SMA,0,MODE_MAIN,0);
  if (TipoStoch == 70)  valore = iStochastic(NULL,TF,TipoStoch,Signal,Slowing,MODE_SMA,0,MODE_MAIN,0);
  if (TipoStoch == 90) valore = iStochastic(NULL,TF,TipoStoch,Signal,Slowing,MODE_SMA,0,MODE_MAIN,0); 
  if (TipoStoch == 110) valore = iStochastic(NULL,TF,TipoStoch,Signal,Slowing,MODE_SMA,0,MODE_MAIN,0); 
  if (TipoStoch == 130)  valore = iStochastic(NULL,TF,TipoStoch,Signal,Slowing,MODE_SMA,0,MODE_MAIN,0);
  if (TipoStoch == 150) valore = iStochastic(NULL,TF,TipoStoch,Signal,Slowing,MODE_SMA,0,MODE_MAIN,0); 
  return(valore);
}  

// Rileva valore Signal Stocastico
double StochSignal(int TF,int TipoStoch)
{ double valore;
  if (TipoStoch == 5)  valore = iStochastic(NULL,TF,TipoStoch,3,3,MODE_SMA,0,MODE_SIGNAL,0);
  if (TipoStoch == 30) valore = iStochastic(NULL,TF,TipoStoch,Signal,Slowing,MODE_SMA,0,MODE_SIGNAL,0); 
  if (TipoStoch == 50) valore = iStochastic(NULL,TF,TipoStoch,Signal,Slowing,MODE_SMA,0,MODE_SIGNAL,0);
  if (TipoStoch == 70)  valore = iStochastic(NULL,TF,TipoStoch,Signal,Slowing,MODE_SMA,0,MODE_SIGNAL,0);
  if (TipoStoch == 90) valore = iStochastic(NULL,TF,TipoStoch,Signal,Slowing,MODE_SMA,0,MODE_SIGNAL,0); 
  if (TipoStoch == 110) valore = iStochastic(NULL,TF,TipoStoch,Signal,Slowing,MODE_SMA,0,MODE_SIGNAL,0); 
  if (TipoStoch == 130)  valore = iStochastic(NULL,TF,TipoStoch,Signal,Slowing,MODE_SMA,0,MODE_SIGNAL,0);
  if (TipoStoch == 150) valore = iStochastic(NULL,TF,TipoStoch,Signal,Slowing,MODE_SMA,0,MODE_SIGNAL,0); 
  return(valore);  
}  

//+------------------------------------------------------------------+

Recommend