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

hans123trader_v8m1_1_r.mq4

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

#include <stdlib.mqh>

extern int                       BeginSession1=          5;
extern int                       LengthSession1=         4;
extern int                       BeginSession2=          9;
extern int                       LengthSession2=         4;

extern double                    Lots =                  1;

extern int                       LocalTimeZone=          1;
extern int                       DestTimeZone=           1;

extern int                       ClsOnlUnprTX=1;                                  
extern int                       ProtectYourInvestments= 1;                       
extern int                       Type_TS_Calc=           1;                                  
extern double                    FactorTSCalculation =   0.5;

datetime                         bartime =               0;
double                           Slippage=               3;
int                              OrderInterval =         10000;

int start()
   {
      // код доступен только после оплаты
   }
   int                           cnt, ticket, err, i, j;
   int                           MagicNumber;
   double                        ts, tp, sl, LowestPrice, HighestPrice, Price;
   bool                          Order[5];
   string                        setup;
   datetime                      Validity=0;
   double                        TrailingStop;
   double                        TakeProfit;
   double                        InitialStopLoss;
   int                           PipsForEntry;
   int                           TimeZoneDiff= LocalTimeZone - DestTimeZone;   

	MagicNumber = func_Symbol2Val(Symbol()); 

   setup="H123v8.1_" + Symbol();

   if (Symbol()=="GBPUSD") 
   {
      PipsForEntry= 13;
      TrailingStop = 32;
      TakeProfit = 62;
      InitialStopLoss=52;
   } 

    else    if (Symbol()=="EURUSD") 
    {
      PipsForEntry= 13;
      TrailingStop = 30;
      TakeProfit = 52;
      InitialStopLoss=42;
    } 

    else    if (Symbol()=="USDCHF") 
    {
      PipsForEntry= 13;
      TrailingStop = 30;
      TakeProfit = 62;
      InitialStopLoss=52;
    } 

    else 
    {      
      PipsForEntry= 13;
      TrailingStop = 32;
      TakeProfit = 52;
      InitialStopLoss=42;
    } 

   if (bartime == Time[0]) 
   {
      return(0);
   } 

   else 
   {
      bartime = Time[0]; 
   }

   for(cnt=OrdersTotal();cnt>=0;cnt--)
   {
      if (OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES)) {
      err = GetLastError();
  		if (err>1) { Print("Error selecting order [" + setup + "]: (" + err + ") " + ErrorDescription(err)); }

      if(OrderType()==OP_BUY && OrderSymbol()==Symbol() && (OrderMagicNumber()==(MagicNumber+1) || OrderMagicNumber()==(MagicNumber+3))) {
      	if(TimeDay(OrderOpenTime())!=TimeDay(Time[0])) {
            if (ClsOnlUnprTX==1) {
               if(Bid-OrderOpenPrice()<Point*TrailingStop) {
                  OrderClose(OrderTicket(), Lots, Bid, 3, Red);
               }  
            } else {
         		 OrderClose(OrderTicket(), Lots, Bid, 3, Red);
         	}
            err = GetLastError();
      		if (err>1) { Print("Error closing buy order [" + setup + "]: (" + err + ") " + ErrorDescription(err)); }
			} else if (TrailingStop>0) {
			   if (ProtectYourInvestments==1 && Bid-OrderOpenPrice()>Point*TrailingStop) {
			      ts = OrderOpenPrice();
			   } else {
			      if (Type_TS_Calc==1) {
                  ts = Bid-(Point*TrailingStop);
               } else if (Type_TS_Calc==2) {
                  ts = Low[0] - FactorTSCalculation * iATR(NULL,0,14,0);
               } else if (Type_TS_Calc==3) {
                  ts = Low[0] - (FactorTSCalculation *(High[0]-Low[0]));
               }
				}
				if (OrderStopLoss()<ts && Bid-OrderOpenPrice()>Point*TrailingStop) OrderModify(OrderTicket(),OrderOpenPrice(),ts,OrderTakeProfit(),0,White);
            err = GetLastError();
      		if (err>1) { Print("Error modifying buy order [" + setup + "]: (" + err + ") " + ErrorDescription(err)); }
			}
      } else if(OrderType()==OP_SELL && OrderSymbol()==Symbol() && (OrderMagicNumber()==(MagicNumber+2) || OrderMagicNumber()==(MagicNumber+4))) {
      	if(TimeDay(OrderOpenTime())!=TimeDay(Time[0])) {
            if (ClsOnlUnprTX==1) {
               if((OrderOpenPrice()-Ask)<(Point*TrailingStop)) {
                  OrderClose(OrderTicket(), Lots, Ask, 3, Red);
               }
            } else {
         		 OrderClose(OrderTicket(), Lots, Ask, 3, Red);
         	}
            err = GetLastError();
      		if (err>1) { Print("Error closing Sell order [" + setup + "]: (" + err + ") " + ErrorDescription(err)); }
			} else if (TrailingStop>0) {	
			   if (ProtectYourInvestments==1 && (OrderOpenPrice()-Ask)>(Point*TrailingStop)) {
			      ts = OrderOpenPrice();
			   } else {
			      if (Type_TS_Calc==1) {
                  ts = Ask+(Point*TrailingStop);
               } else if (Type_TS_Calc==2) {
                  ts = High[0] + FactorTSCalculation * iATR(NULL,0,14,0);
               } else if (Type_TS_Calc==3) {
                  ts = High[0] + (FactorTSCalculation *(High[0]-Low[0]));
               }
				}

				if (OrderStopLoss()>ts && (OrderOpenPrice()-Ask)>(Point*TrailingStop)) OrderModify(OrderTicket(),OrderOpenPrice(),ts,OrderTakeProfit(),0,White);
            err = GetLastError();
      		if (err>1) { Print("Error modifyin sell order [" + setup + "]: (" + err + ") " + ErrorDescription(err)); }
			}
		}
		}
	}

   if(AccountFreeMargin()<(1000*Lots)) return(0);  

	Validity=StrToTime(TimeYear(Time[0]) + "." + TimeMonth(Time[0]) + "." + TimeDay(Time[0]) + " 23:59")+(TimeZoneDiff*3600);

	for(i=1;i<5;i++) { Order[i]=false; } 

   for(cnt=OrdersTotal();cnt>=0;cnt--)
   {

      OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);

		err = GetLastError();

      if(OrderSymbol()==Symbol() && OrderMagicNumber()==(MagicNumber+1)) 
      {
      	Order[1]=true;
      } 

      else if (OrderSymbol()==Symbol() && OrderMagicNumber()==(MagicNumber+2)) 
      {
      	Order[2]=true;
      } 

      else if (OrderSymbol()=

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

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

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