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

goblin.mq4

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

extern double    TakeProfit = 40;           // Profit Goal for the latest order opened
extern double    Lots = 0.1;                // First order will be for this lot size
extern double    InitialStop = 0;           // StopLoss
extern double    TrailingStop = 20;         // Pips to trail the StopLoss

extern int       MaxTrades=10;              // Maximum number of orders to open
extern int       Pips=15;                   // Distance in Pips from one order to another
extern int       SecureProfit=10;           // If profit made is bigger than SecureProfit we close the orders
extern int       AccountProtection=1;       // If one the account protection will be enabled, 0 is disabled
extern int       OrderstoProtect=3;         // This number subtracted from MaxTrades is the number of open orders to enable the account protection.

extern int       ReverseCondition=0;        // If one the decision to go long/short will be reversed
extern int       StartYear=2005;            // Year to start (only for backtest)
extern int       StartMonth=1;              // Month to start (only for backtest)
extern int       EndYear=2050;              // Year to stop trading (backtest and live)
extern int       EndMonth=12;               // Month to stop trading (backtest and live)

extern int       mm=0;                      // if 1, the lots size will increase based on account size
extern int       risk=12;                   // risk to calculate the lots size (only if mm is enabled)
extern int       AccountisNormal=0;         // Zero if account is not mini/micro                            
extern int       Magic = 123987;            // Magic number for the orders placed

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 Pivot=0;
double PipValue=0;
string text="", text2="";
double DnTrendVal=0,UpTrendVal=0,TrendVal=0;
string TrendTxt="analyzing...";
int RSX_Period=17;
int trendtype=0;

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

int deinit()
  {

   return(0);
  }

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

   if (AccountisNormal==1)
   {
	  if (mm!=0) { lotsi=MathCeil(AccountBalance()*risk/10000); }
		else { lotsi=Lots; }
   } else {  // then is mini
    if (mm!=0) { lotsi=MathCeil(AccountBalance()*risk/10000)/10; }
		else { lotsi=Lots; }
   }

   if (lotsi>100){ lotsi=100; }

   OpenOrders=0;
   for(cnt=0;cnt<OrdersTotal();cnt++)   
   {
     OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
	  if (OrderSymbol()==Symbol() && OrderMagicNumber() == Magic)
	  {				
	  	  OpenOrders++;
	  }
   }     

   if (OpenOrders<1) 
   {
	  if (TimeYear(CurTime())<StartYear) { return(0);  }
	  if (TimeMonth(CurTime())<StartMonth) { return(0); }
	  if (TimeYear(CurTime())>EndYear) { return(0); }
	  if (TimeMonth(CurTime())>EndMonth ) { return(0); }
   }

   double PipValue = MarketInfo(Symbol(),MODE_TICKVALUE);
   if (PipValue==0) { PipValue=5; }

   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) 
   {
     myOrderType=OpenOrdersBasedOnTrendRSX();
 	  if (ReverseCondition==1)
	  {
	  	  if (myOrderType==1) { myOrderType=2; }
		  else { if (myOrderType==2) { myOrderType=1; } }
	  }
   }

   Check_Trend();

   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+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+Pips)*Point) 
				{
					if (OrderSt

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

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

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