Crossover Stochs v1

Author: Skyline, 2008
Crossover Stochs v1
Indicators Used
Stochastic oscillator
Miscellaneous
Implements a curve of type %1It issuies visual alerts to the screenIt sends emails
0 Views
0 Downloads
0 Favorites
Crossover Stochs v1
//+------------------------------------------------------------------+
//|                                          Crossover Stochs v1.mq4 |
//|                      Copyright © 2008, MetaQuotes Software Corp. |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+

#property copyright "Skyline, 2008"
#property link      "http://www.forexpertutti.it"

#property indicator_chart_window
#property indicator_buffers 2
#property indicator_color1 DodgerBlue
#property indicator_color2 Magenta
#property indicator_width1 2
#property indicator_width2 2

extern string Version              = "Crossover Stochs Alerter v1 - coded by Skyline based on Spudfyre trading system - [25 Nov 2008]";

extern string Null4                = "----- Arrows settings -----";
extern int    Arrow_Width          = 3;
extern double Arrow_Position       = 1;

extern string Null5                = "----- Alerts settings -----";
extern bool   EnableSoundAlert     = true;
extern bool   EnableVisualAlert    = true;
extern bool   EnableEmailAlert     = true;

double CrossUp[];
double CrossDown[];

static datetime alertTag = D'1980.01.01'; 
static datetime soundTag = D'1980.01.01';
static datetime emailTag = D'1980.01.01';

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
    SetIndexStyle(0, DRAW_ARROW, EMPTY,Arrow_Width);
    SetIndexArrow(0, 233);
    SetIndexBuffer(0, CrossUp);
    SetIndexStyle(1, DRAW_ARROW, EMPTY,Arrow_Width);
    SetIndexArrow(1, 234);
    SetIndexBuffer(1, CrossDown);   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   Comment("");
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() 
{
   int limit, i, counter;
   double Range, AvgRange;
   
   int counted_bars=IndicatorCounted();
   
   //Comment("\n"+Version); // Current version
   
//---- check for possible errors

   if(counted_bars<0) return(-1);
   
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;

   limit=Bars-counted_bars;
   
   for(i = 0; i <= limit; i++) 
   {
   
      counter=i;
      Range=0;
      AvgRange=0;
      for (counter=i ;counter<=i+9;counter++)
      {
         AvgRange=AvgRange+MathAbs(High[counter]-Low[counter]);
      }
      Range=AvgRange/10;
      
      // Importa Indicatori //
      double OriginLine_now       = NormalizeDouble(iStochastic(NULL,0,14,3,3,MODE_SMA,0,MODE_MAIN,i),4);
      double OriginLine_previous  = NormalizeDouble(iStochastic(NULL,0,14,3,3,MODE_SMA,0,MODE_MAIN,i+1),4);
      double OriginLine_after     = NormalizeDouble(iStochastic(NULL,0,14,3,3,MODE_SMA,0,MODE_MAIN,i-1),4);  

      double PriceLine_now        = NormalizeDouble(iStochastic(NULL,0,100,3,3,MODE_SMA,0,MODE_MAIN,i),4);
      double PriceLine_previous   = NormalizeDouble(iStochastic(NULL,0,100,3,3,MODE_SMA,0,MODE_MAIN,i+1),4);
      double PriceLine_after      = NormalizeDouble(iStochastic(NULL,0,100,3,3,MODE_SMA,0,MODE_MAIN,i-1),4);       

      double Stoch_M5_now         = NormalizeDouble(iStochastic(NULL,0,14,1,1,MODE_SMA,0,MODE_MAIN,i),4);
      double Stoch_M5_previous    = NormalizeDouble(iStochastic(NULL,0,14,1,1,MODE_SMA,0,MODE_MAIN,i+1),4);
      double Stoch_M5_after       = NormalizeDouble(iStochastic(NULL,0,14,1,1,MODE_SMA,0,MODE_MAIN,i-1),4);     

      int BarShift_M15            = iBarShift(NULL,PERIOD_M15,Time[i],true)+1;

      double Stoch_M15_now        = NormalizeDouble(iStochastic(NULL,PERIOD_M15,14,1,1,MODE_SMA,0,MODE_MAIN,BarShift_M15),4);
      double Stoch_M15_previous   = NormalizeDouble(iStochastic(NULL,PERIOD_M15,14,1,1,MODE_SMA,0,MODE_MAIN,BarShift_M15+1),4);    
      double Stoch_M15_after      = NormalizeDouble(iStochastic(NULL,PERIOD_M15,14,1,1,MODE_SMA,0,MODE_MAIN,BarShift_M15-1),4);
     

      if (
          OriginLine_previous < 23.6 && OriginLine_now > 23.6 && 
          PriceLine_previous < 23.6  && PriceLine_now < 23.6  &&
          Stoch_M5_now > Stoch_M15_now                        &&
          Stoch_M5_now > 20                                   &&
          Stoch_M5_previous < Stoch_M5_now                    &&
          OriginLine_previous < OriginLine_now                &&
          PriceLine_previous < PriceLine_now                  &&
          Stoch_M15_previous < Stoch_M15_now                  
         )
      {
         CrossUp[i] = Low[i] - Range*Arrow_Position;
         
         // Alert visivo //
         if (EnableVisualAlert==true && i==1 && alertTag!=Time[0])
         {
          Alert("[Crossover Stochs] - ",Symbol()," LONG @ ",DoubleToStr(Close[i],Digits));
          alertTag = Time[0];
         }     
         // Alert Sonoro //
         if (EnableSoundAlert==true && i==1 && soundTag!=Time[0])
         {
          PlaySound ("alert.wav");
          soundTag = Time[0];
         }     
         // Alert Email //
         if (EnableEmailAlert==true && i==1 && emailTag!=Time[0])
         {
          SendMail("[Crossover Stochs]",Symbol()+" LONG @ "+DoubleToStr(Close[i],Digits));
          emailTag = Time[0];
         }                 
      }
      else 
      if (
          OriginLine_previous > 76.4 && OriginLine_now < 76.4 && 
          PriceLine_previous > 76.4  && PriceLine_now > 76.4  &&
          Stoch_M5_now < Stoch_M15_now                        &&
          Stoch_M5_now < 80                                   &&
          Stoch_M5_previous > Stoch_M5_now                    &&
          OriginLine_previous > OriginLine_now                &&
          PriceLine_previous > PriceLine_now                  &&
          Stoch_M15_previous > Stoch_M15_now  
         )      

      {
          CrossDown[i] = High[i] + Range*Arrow_Position;
          
          // Alert visivo //
          if (EnableVisualAlert==true && i==1 && alertTag!=Time[0])
          {
           Alert("[Crossover Stochs] - ",Symbol()," SHORT @ ",DoubleToStr(Close[i],Digits));
           alertTag = Time[0];
          }    
          // Alert Sonoro //
          if (EnableSoundAlert==true && i==1 && soundTag!=Time[0])
          {
           PlaySound ("alert.wav");
           soundTag = Time[0];
          }
         // Alert Email //
         if (EnableEmailAlert==true && i==1 && emailTag!=Time[0])
         {
          SendMail("[Crossover Stochs]",Symbol()+" SHORT @ "+DoubleToStr(Close[i],Digits));
          emailTag = Time[0];
         }                          
      }       
   }
   return(0);
}

/*
string Periodo(int TF)
{
 if (TF==1)    { return("M1"); }
 if (TF==5)    { return("M5"); }
 if (TF==15)   { return("M15"); }
 if (TF==30)   { return("M30"); } 
 if (TF==60)   { return("H1"); } 
 if (TF==240)  { return("H4"); } 
 if (TF==1440) { return("D1"); }  
}
*/

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---