Navigation:Home > Content >

StochScalp^^2^^1.mq4

Time: 2016-12-18 | Download file:StochScalp^^2^^1.mq4

//+------------------------------------------------------------------+
//|                                              StochScalp^^2^^.mq4 |
//|                                                      Nicholishen |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Nicholishen @ Apex Group Investments,LLC"
#property link      "www.forex-tsd.com"

#include 
#include 


   extern bool   EcnBroker     = true;
   extern int    Confirm       = 0;
   extern int    K             = 15;
   extern int    D             = 2;
   extern int    SL            = 1;
   extern double lots          = 0.1;            
   extern int    TakeProfit    = 100;             
   extern int    StopLoss      = 100;            
   extern bool   UseTrail      = false; 
   
   extern double TrailingAct   = 6;    
   extern double TrailingStep  = 6;

 
   extern bool   UseTimeFilter = false;
   extern int    BeginHour     = 8;
   extern int    EndHour       = 18;
   
   extern int    OrderID       = 9898989;
   extern int    slippage      = 3;
 
  
   int bar;
   int TestStart;
   int k;
   int mm,dd,yy,hh,min,ss,tf;
   string comment;
   string syym;
   string qwerty;
   double TrailPrice;
   double pipMultiplier = 1;
//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+


int TimeFilter(){
   if(Hour()>EndHour || Hour()99 ){
      if(Rev){
         return(1);
      }else{
         return(2);
      }
   }

   if(sto1 < 1 ){
      if(Rev){
         return(2);
      } else{
         return(1);
      }
   }
}
if(functyp==2){
   if(sto1 >99){
      if(Rev){
         return(1);
      }else{
         return(2);
      }
   }
   if(sto1 < 1){
      if(Rev){
         return(2);
      } else{
         return(1);
      }
   }
}
   return(0);
}

//+------------------------------------------------------------------+
//| Open Conditions                       |
//+------------------------------------------------------------------+

void CheckForOpen(){
double sl,tp; int error;

  if(TradeSignal(1)==2){
      if (StopLoss==0)   {sl=0;} else sl=Bid+Point*pipMultiplier*StopLoss;
      if (TakeProfit==0) {tp=0;} else tp=Bid-Point*pipMultiplier*TakeProfit;
      bar=Bars;
      if (!EcnBroker)
      OrderSend(Symbol(),OP_SELL,lots,Bid,slippage*Point*pipMultiplier,sl,tp,"D2",OrderID,0,Blue); // def
      else
      {
      int sellTicket = OrderSend(Symbol(),OP_SELL,lots,Bid,slippage*Point*pipMultiplier,0,0,"D2",OrderID,0,Blue);		    		    
      if (sellTicket >= 0)
      OrderModify(sellTicket,OrderOpenPrice(),sl,tp,0,CLR_NONE);
      }		       
      if(sellTicket<0){
      error=GetLastError();
      Print("Error = ",ErrorDescription(error));
      }
  }
  if(TradeSignal(1)==1){
      if (StopLoss==0) {sl=0;} else sl=Ask-Point*pipMultiplier*StopLoss;
      if (TakeProfit==0) {tp=0;} else tp=Ask+Point*pipMultiplier*TakeProfit;
      bar=Bars;
      if (!EcnBroker)
      OrderSend(Symbol(),OP_BUY,lots,Ask,slippage*Point*pipMultiplier,sl,tp,"D2",OrderID,0,Red); // def
      else
      {
      int buyTicket = OrderSend(Symbol(),OP_BUY,lots,Ask,slippage*Point*pipMultiplier,0,0,"D2",OrderID,0,Red);
      if (buyTicket >= 0)
      OrderModify(buyTicket,OrderOpenPrice(),sl,tp,0,CLR_NONE);
             }		       
      if(buyTicket < 0){
      error=GetLastError();
      Print("Error = ",ErrorDescription(error));
      }
  }
}   
  
//+------------------------------------------------------------------+
//| Close conditions                      |
//+------------------------------------------------------------------+
void CheckForClose(){

   for(int i=0;i0 && TrailPrice < Bid-TrailingStep*Point*pipMultiplier){
               TrailPrice=Bid-TrailingStep*Point*pipMultiplier;
               Print("TRAIL PRICE MODIFIED: ",TrailPrice);
            }
            if (TrailPrice >0 && TrailPrice >= Bid-TrailingStep*Point*pipMultiplier){
               CloseOrder(1);
            }
         }
         if (OrderType()==OP_SELL) {
            if (OrderOpenPrice()-Ask > TrailingAct*Point*pipMultiplier && TrailPrice ==0) {
               TrailPrice=Ask+TrailingStep*Point*pipMultiplier;
               Print("TRAIL PRICE MODIFIED: ",TrailPrice);
            }
            if (TrailPrice>0 && TrailPrice > Ask+TrailingStep*Point*pipMultiplier){
               TrailPrice=Ask+TrailingStep*Point*pipMultiplier;
               Print("TRAIL PRICE MODIFIED: ",TrailPrice);
            }
            if (TrailPrice >0 && TrailPrice <= Ask+TrailingStep*Point*pipMultiplier){
               CloseOrder(2);
            }   
         }
      }
   }
}}

void CloseOrder(int ord){
    for(int i=0;i

Recommend