Navigation:Home > Content >

4Stochs_v0.1.mq4

Time: 2013-04-09 | Download file:4Stochs_v0.1.mq4

//+------------------------------------------------------------------+
//|                                      4Stochs EA for MetaTrader 4 |
//|                                                      version 0.1 |
//|                                   Copyright © 2008 Forex-Factory |
//|                   Strategy first published by David (ljyljl5555) |
//|                                     EA Conversion by Azmel Ainul |
//+------------------------------------------------------------------+

extern int    Magic        = 775769;
extern double LotSize      = 0.01;
extern int    TP           = 10;
extern int    SL           = 10;
extern string LongComment  = "4Stochs Long";
extern string ShortComment = "4Stochs Short";

double S1M;
double S1S;
double S2M;
double S2S;
double S3M;
double S3S;
double S4M;
double S4S;

string Signal;
string Status;

double ticket;
double slippage=5;

int init()
{
   S1M=iStochastic(NULL,PERIOD_M5,5,3,3,MODE_SMA,0,MODE_MAIN,0);
   S1S=iStochastic(NULL,PERIOD_M5,5,3,3,MODE_SMA,0,MODE_SIGNAL,0);
   S2M=iStochastic(NULL,PERIOD_M30,5,3,3,MODE_SMA,0,MODE_MAIN,0);
   S2S=iStochastic(NULL,PERIOD_M30,5,3,3,MODE_SMA,0,MODE_SIGNAL,0);
   S3M=iStochastic(NULL,PERIOD_H1,5,3,3,MODE_SMA,0,MODE_MAIN,0);
   S3S=iStochastic(NULL,PERIOD_H1,5,3,3,MODE_SMA,0,MODE_SIGNAL,0);
   S4M=iStochastic(NULL,PERIOD_H1,14,3,3,MODE_SMA,0,MODE_MAIN,0);
   S4S=iStochastic(NULL,PERIOD_H1,14,3,3,MODE_SMA,0,MODE_SIGNAL,0);
   
   Signal="NONE";
   Status="READY";
   if(S1M>S1S && S2M>S2S && S3M>S3S && S4M>S4S)
   {
      Signal="LONG";
      Status="SHORT ACTIVE";
   }
   if(S1MS1S && S2M>S2S && S3M>S3S && S4M>S4S)
   {
      Signal="LONG";
   }
   if(S1M-1)
      {
         Status="LONG ACTIVE";
      }
   }
   
   if(Status=="READY" && Signal=="SHORT")
   {
      ticket=OrderSend(Symbol(),OP_SELL,LotSize,Bid,slippage,Bid+SL*Point,Bid-TP*Point,ShortComment,Magic,0,Red);
      if(ticket>-1)
      {
         Status="SHORT ACTIVE";
      }
   }
   
   if(Status=="LONG ACTIVE" && (Signal=="NONE" || Signal=="SHORT"))
   {
      Status="READY";
   }
   
   if(Status=="SHORT ACTIVE" && (Signal=="NONE" || Signal=="LONG"))
   {
      Status="READY";
   }
   return(0);
}
   

Recommend