atomrus1993

ШАБЛОН баблокосилка!!!!

Nov 13th, 2016
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.76 KB | None | 0 0
  1. #property copyright "skype atomrus1993"
  2. #property link      "e-mail [email protected]"
  3. #property description "описание"
  4. extern string S1           = "Общие параметры";
  5. extern int    Magic        = 26082012;//магик номер
  6. int    Slippage     = 20;//максимальное проскальзывание в пунктах
  7. extern bool  model         = true;
  8. extern int    TakeProfit   = 60;//тейк профит
  9. extern int    StopLoss     = 20;//стоп лосс
  10. extern double Lot          = 0.1;//первоначальный лот
  11. extern int  h_start        = 8;
  12. extern int  h_end          = 19;
  13. extern bool d1             = true;
  14. extern bool d2             = true;
  15. extern bool d3             = true;
  16. extern bool d4             = true;
  17. extern bool d5             = true;
  18.  int    LotDigits    = 2;//кол-во цифр после запятой для лота
  19. extern double Koef         = 1;//коэффициент увеличение лота при пройгрыше
  20. //+------------------------------------------------------------------+
  21. //| expert initialization function                                   |
  22. //+------------------------------------------------------------------+
  23. int init()
  24.   {
  25. //----
  26.  
  27. //----
  28.    return(0);
  29.   }
  30. //+------------------------------------------------------------------+
  31. //| expert deinitialization function                                 |
  32. //+------------------------------------------------------------------+
  33. int deinit()
  34.   {
  35. //----
  36.    
  37. //----
  38.    return(0);
  39.   }
  40. //+------------------------------------------------------------------+
  41. //| expert start function                                            |
  42. //+------------------------------------------------------------------+
  43. int start()
  44.   {
  45. //----
  46.   if (all () > 0) return (0);
  47. //----определение лота
  48.   double lot = 0;
  49.   if (last ("p") >= 0) lot = Lot;
  50.   else lot = last ("l")*Koef;
  51.   lot = norm_lot (lot);
  52. //----открытие сделки
  53.  
  54.   int day = DayOfWeek(); bool dayT=false;
  55.   if(day==1 && d1==true){dayT=true;}
  56.   if(day==2 && d2==true){dayT=true;}
  57.   if(day==3 && d3==true){dayT=true;}
  58.   if(day==4 && d4==true){dayT=true;}
  59.   if(day==5 && d5==true){dayT=true;}
  60.  
  61.   bool timeT = false;
  62.   if (Hour() >= h_start && Hour() <= h_end) {timeT = true;} else {timeT = false;}
  63.   bool trade = false;
  64.   if (dayT == true && timeT == true) {trade = true;}
  65.   int b,s;
  66.   if (model == true)
  67.    {b = 0; s = 1;}
  68.       else
  69.    {b = 1; s = 0;}
  70.   double
  71.   ATR1 = iATR(Symbol(),0,14,1),
  72.   ATR2 = iATR(Symbol(),0,14,2),
  73.   ATR3 = iATR(Symbol(),0,14,3);
  74.   if ( trade == true ) {
  75.   if (ATR1 > ATR2 && ATR2 > ATR3) open (b, lot); // buy
  76.   if (ATR1 < ATR2 && ATR2 < ATR3) open (s, lot); // sell
  77.   }
  78. //----
  79.    return(0);
  80.    
  81.   }
  82. //+------------------------------------------------------------------+
  83. int open (int type, double lot)
  84. {
  85.   int tic = -1;
  86.   double price_take, price_stop;
  87.   for (int i = 0; i <= 5; i ++)
  88.   {
  89.     if (type % 2 == 0)
  90.     {
  91.       if (TakeProfit > 0) price_take = NormalizeDouble (Bid + TakeProfit*Point, Digits);
  92.       if (StopLoss > 0) price_stop = NormalizeDouble (Bid - StopLoss*Point, Digits);
  93.       tic = OrderSend (Symbol (), type, lot, NormalizeDouble (Ask, Digits), Slippage, price_stop, price_take, "", Magic);
  94.     }
  95.     if (type % 2 == 1)
  96.     {
  97.       if (TakeProfit > 0) price_take = NormalizeDouble (Ask - TakeProfit*Point, Digits);
  98.       if (StopLoss > 0) price_stop = NormalizeDouble (Ask + StopLoss*Point, Digits);
  99.       tic = OrderSend (Symbol (), type, lot, NormalizeDouble (Bid, Digits), Slippage, price_stop, price_take, "", Magic);
  100.     }
  101.     if (tic != -1) break;
  102.   }
  103.   return (tic);
  104. }
  105.  
  106. int all ()
  107. {
  108.   int all = 0;
  109.   for (int i = OrdersTotal () - 1; i >= 0; i --)
  110.     if (OrderSelect (i, SELECT_BY_POS) && OrderMagicNumber () == Magic && OrderSymbol () == Symbol ())
  111.       all ++;
  112.   return (all);
  113. }
  114.  
  115. double last (string mode)
  116. {
  117.   int time = -1;
  118.   double profit = 0, lot = 0;
  119.   for (int i = OrdersHistoryTotal () - 1; i >= 0; i --)
  120.     if (OrderSelect (i, SELECT_BY_POS, MODE_HISTORY) && OrderMagicNumber () == Magic && OrderSymbol () == Symbol ())
  121.       if (time < OrderOpenTime ())
  122.       {
  123.         time = OrderOpenTime ();
  124.         profit = OrderProfit ();
  125.         lot = OrderLots ();
  126.       }
  127.    double ec;
  128.   if (mode == "p") ec = profit;
  129.   if (mode == "l") ec = lot;
  130.   return ec;
  131. }
  132.  
  133. double norm_lot (double lot)
  134. {
  135.   if (lot < MarketInfo (Symbol (), MODE_MINLOT)) lot = MarketInfo (Symbol (), MODE_MINLOT);
  136.   if (lot > MarketInfo (Symbol (), MODE_MAXLOT)) lot = MarketInfo (Symbol (), MODE_MAXLOT);
  137.   lot = NormalizeDouble (lot, LotDigits);
  138.        Comment("Баланс: "+AccountBalance()+"\nСредства: "+AccountEquity()+"\nЛот: "+lot);
  139.   return (lot);
  140. }
Advertisement
Add Comment
Please, Sign In to add comment