← Назад к списку файлов

martin_zigzag_martingale.mq4

Поиск по коду файла

extern int    Magic              = 20081107;
extern double TakeProfit         = 45;
extern double Lots               = 0.01;
extern double InitialStop        = 300;
extern double TrailingStop       = 45;
extern int    MaxTrades          = 10;
extern double Multiplier         = 2;
extern int    Pips               = 30;
extern int    OrderstoProtect    = 6;
extern bool   Money_management   = false;
extern int    AccountType        = 2;        //0: Standard account(NorthFinance,MiG,Alpari) 1: Normal account(FXLQ,FXDD) 2:InterbankFX's NANO Account
extern double risk               = 0.5;
extern bool   ReverseSignal      = false;

extern bool UseTimeFilter=false;
extern int StopTrade = 18;
extern int StartTrade = 19;

extern int ExtDepth=17; //10-21 !15 !17
extern int ExtDeviation=7; //!7
extern int ExtBackstep=5;  //!5
int Urgency=2;

datetime TimeStamp=0;
int  OpenOrders=0, cnt=0;
int  slippage=5;
double sl=0, tp=0;
double BuyPrice=0, SellPrice=0;
double lotsi=0, mylotsi=0;
int mode=0, myOrderType=0;
bool ContinueOpening=True;
double LastPrice=0;
int  PreviousOpenOrders=0;
double Profit=0;
int LastTicket=0, LastType=0;
double LastClosePrice=0, LastLots=0;
double PipValue=0;
string text="", text2="",text3="",text4="";

int init()
  {
      // код доступен только после оплаты
   }

int deinit()
  {

   return(0);
  }

int start()
{
      // код доступен только после оплаты
   }

   double MinLots = NormalizeDouble((MarketInfo(Symbol(), MODE_MINLOT)),2);
   double MaxLots = NormalizeDouble((MarketInfo(Symbol(), MODE_MAXLOT)),2);
   double LotSizeValue = NormalizeDouble((MarketInfo(Symbol(), MODE_LOTSIZE)),0);
   double PipValue=MarketInfo(Symbol(),16);

   if(Money_management)
   {
      switch(AccountType)
      {
         case 0: lotsi=NormalizeDouble(MathCeil((risk*AccountEquity())/10000)/10,1); break;
         case 1: lotsi=NormalizeDouble((risk*AccountEquity())/100000,2); break;
         case 2: lotsi=NormalizeDouble((risk*AccountEquity())/1000,2); break;
         default: lotsi=NormalizeDouble(MathCeil((risk*AccountEquity())/10000)/10,1); break;
      }
   }
   else
   {
      lotsi=Lots;
   }

   if(lotsi<MinLots){lotsi=MinLots;}
   if(lotsi>MaxLots){lotsi=MaxLots;}

   OpenOrders=0;
   for(cnt=0;cnt<OrdersTotal();cnt++)   
   {
     OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
	  if (OrderSymbol()==Symbol() && OrderMagicNumber() == Magic)
	  {				
	  	  OpenOrders++;
	  }
   }     
   if (PreviousOpenOrders>OpenOrders) 
   {	  
	  for(cnt=OrdersTotal();cnt>=0;cnt--)
	  {
	     OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
	  	  mode=OrderType();
		  if (OrderSymbol()==Symbol() && OrderMagicNumber() == Magic) 
		  {
			if (mode==OP_BUY) { OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),slippage,Blue); }
			if (mode==OP_SELL) { OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),slippage,Red); }
			return(0);
		 }
	  }
   }

   PreviousOpenOrders=OpenOrders;
   if (OpenOrders>=MaxTrades) 
   {
	  ContinueOpening=False;
   } else {
	  ContinueOpening=True;
   }

   if (LastPrice==0) 
   {
	  for(cnt=0;cnt<OrdersTotal();cnt++)
	  {	
	    OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
		 mode=OrderType();	
		 if (OrderSymbol()==Symbol() && OrderMagicNumber() == Magic) 
		 {
			LastPrice=OrderOpenPrice();
			if (mode==OP_BUY) { myOrderType=2; }
			if (mode==OP_SELL) { myOrderType=1;	}
		 }
	  }
   }

   if (OpenOrders<1) 
   {
     if (UseTimeFilter)
     {//check trading time
        if (Hour()>StopTrade && Hour()<StartTrade) 
        {Comment("No trading, danger time zone!");
        return(0);}//End of trading time check
     }

	     myOrderType=ZIGZAG();

     	  if (ReverseSignal)
	     {
	  	     if (myOrderType==1) { myOrderType=2; }
		    else { if (myOrderType==2) { myOrderType=1; } }
	     }
   }

   for(cnt=OrdersTotal();cnt>=0;cnt--)
   {
     OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
	  if (OrderSymbol() == Symbol() && OrderMagicNumber() == Magic) 
	  {	
	  	  if (OrderType()==OP_SELL) 
	  	  {			
	  	  	  if (TrailingStop>0) 
			  {
				  if (OrderOpenPrice()-Ask>=(TrailingStop*Point+Pips*Point))  
				  {						
					 if (OrderStopLoss()>(Ask+Point*TrailingStop))
					 {			
					    OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderClosePrice()-TakeProfit*Point-TrailingStop*Point,800,Purple);
	  					 return(0);	  					
	  				 }
	  			  }
			  }
	  	  }

	  	  if (OrderType()==OP_BUY)
	  	  {
	  		 if (TrailingStop>0) 
	  		 {
			   if (Bid-OrderOpenPrice()>=(TrailingStop*Point+Pips*Point))  
				{
					if (OrderStopLoss()<(Bid-Point*TrailingStop)) 
					{					   
					   OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderClosePrice()+TakeProfit*Point+TrailingStop*Point,800,Yellow);
                  return(0);
					}
  				}
			 }
	  	  }
   	}
   }

   Profit=0;
   LastTicket=0;
   LastType=0;
	LastClosePrice=0;
	LastLots=0;	
	f

Показано первые 50% кода (символов: 7491)

Как получить полную версию?

Введите ваш email и нажмите кнопку, чтобы перейти к оплате.