0
За чужой код сейчас берусь очень редко.
avatar

AM2

  • 30 июля 2016, 07:56
0
Переделываю и исправляю когда есть информация от которой можно оттолкнуться. В вашем случае нет ни скринов ни логов. У себя ставил работает нормально.
avatar

AM2

  • 30 июля 2016, 06:55
0
не 3 а 24 :D 
меня Оксана на 3 недели заменяет с 1-го по 21 включительно :D 
avatar

AM2

  • 29 июля 2016, 20:23
0
Один выполненный заказ есть, я к тому.
avatar

AM2

  • 29 июля 2016, 17:01
0
Торопимся? :) 
avatar

AM2

  • 29 июля 2016, 16:45
0
Все добавил. Так на рандоме может довольно долго продолжаться. Также добавил стоп в рублях.
www.opentraders.ru/downloads/1273/

avatar

AM2

  • 29 июля 2016, 09:38
0
Бесплатно делают по условиям: zakaz.opentraders.ru/25597.html
avatar

AM2

  • 28 июля 2016, 15:19
0
Еще нужно добавить 4-в противоположную сторону.

От чего в противоположную?
avatar

AM2

  • 28 июля 2016, 15:15
0
Рандом что хочет то и вытворяет :)  www.opentraders.ru/downloads/1273/

avatar

AM2

  • 28 июля 2016, 11:59
0
Может генерить и так. Это не ко мне почему все время баит.

avatar

AM2

  • 28 июля 2016, 11:47
0
По рандому как выцепляет разворот! *good*  <img src='http://opentraders.ru/templates/skin/g6h/images/smilies/003.gif' alt=' :D '>&nbsp; 



//+------------------------------------------------------------------+
//|                                                       Random.mq4 |
//|                                              Copyright 2016, AM2 |
//|                                      http://www.forexsystems.biz |
//+------------------------------------------------------------------+

#property copyright "Copyright 2016, AM2"
#property link      "http://www.forexsystems.biz"
#property version   "1.00"
#property strict

//--- Inputs
extern double Lots       = 0.1;      // лот
extern int StopLoss      = 500;      // лось
extern int TakeProfit    = 500;      // язь
extern int BULevel       = 0;        // уровень БУ
extern int BUPoint       = 30;       // пункты БУ
extern int TrailingStop  = 0;        // трал
extern int BarsCount     = 3;        // через сколько баров открывать
extern int BuySell       = 0;        // 0-Candle 1-buy 2-sell 3-random
extern int Slip          = 30;       // реквот
extern int Magic         = 123;      // магик

datetime t=0;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   MathSrand(GetTickCount());
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Установка ордера                                                 |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
  {
   int r=0;
   color clr=Green;
   double sl=0,tp=0;

   if(type==1 || type==3 || type==5)
     {
      clr=Red;
      if(StopLoss>0)   sl=NormalizeDouble(price+StopLoss*Point,Digits);
      if(TakeProfit>0) tp=NormalizeDouble(price-TakeProfit*Point,Digits);
     }

   if(type==0 || type==2 || type==4)
     {
      clr=Blue;
      if(StopLoss>0)   sl=NormalizeDouble(price-StopLoss*Point,Digits);
      if(TakeProfit>0) tp=NormalizeDouble(price+TakeProfit*Point,Digits);
     }

   r=OrderSend(NULL,type,Lots,NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,0,clr);
   return;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int CountTrades()
  {
   int count=0;
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderType()<2) count++;
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
datetime OOT()
  {
   datetime oot=0;
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderType()<2) oot=OrderOpenTime();
         break;
        }
     }
   return(oot);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Trailing()
  {
   bool mod;
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() || OrderMagicNumber()==Magic)
           {
            if(OrderType()==OP_BUY)
              {
               if(Bid-OrderOpenPrice()>TrailingStop*Point)
                 {
                  if(OrderStopLoss()<Bid-TrailingStop*Point)
                    {
                     mod=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*Point,OrderTakeProfit(),0,Yellow);
                     return;
                    }
                 }
              }

            if(OrderType()==OP_SELL)
              {
               if((OrderOpenPrice()-Ask)>TrailingStop*Point)
                 {
                  if((OrderStopLoss()>(Ask+TrailingStop*Point)) || (OrderStopLoss()==0))
                    {
                     mod=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+TrailingStop*Point,OrderTakeProfit(),0,Yellow);
                     return;
                    }
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void BU()
  {
   bool m;
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() || OrderMagicNumber()==Magic)
           {
            if(OrderType()==OP_BUY)
              {
               if(OrderOpenPrice()<=(Bid-(BULevel+BUPoint)*Point) && OrderOpenPrice()>OrderStopLoss())
                 {
                  m=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+BUPoint*Point,OrderTakeProfit(),0,Yellow);
                  return;
                 }
              }

            if(OrderType()==OP_SELL)
              {
               if(OrderOpenPrice()>=(Ask+(BULevel+BUPoint)*Point) && (OrderOpenPrice()<OrderStopLoss() || OrderStopLoss()==0))
                 {
                  m=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-BUPoint*Point,OrderTakeProfit(),0,Yellow);
                  return;
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   MathSrand(GetTickCount());
   bool buy=true,sell=true;
   if(BuySell==0){buy=Close[1]>Open[1]; sell=Close[1]<Open[1];}
   if(BuySell==1){buy=true; sell=false;}
   if(BuySell==2){buy=false; sell=true;}
   if(BuySell==3)
     {
      int res=MathRand();
      if(res>16383) {buy=true; sell=false;}
      if(res<16383) {buy=false; sell=true;}
     }

   if(CountTrades()<1) PutOrder(1,Bid);

   if(t!=Time[0] && TimeCurrent()-OOT()>BarsCount*PeriodSeconds())
     {
      if(buy) PutOrder(0,Ask);
      if(sell) PutOrder(1,Bid);
      t=Time[0];
     }

   if(BULevel>0) BU();
   if(TrailingStop>0) Trailing();

   Comment(MathRand());
  }
//+------------------------------------------------------------------+
avatar

AM2

  • 28 июля 2016, 11:36
+3
Веселитесь :) 



//+------------------------------------------------------------------+
//|                                                       Random.mq4 |
//|                                              Copyright 2016, AM2 |
//|                                      http://www.forexsystems.biz |
//+------------------------------------------------------------------+

#property copyright "Copyright 2016, AM2"
#property link      "http://www.forexsystems.biz"
#property version   "1.00"
#property strict

//--- Inputs
extern double Lots       = 0.1;      // лот
extern int StopLoss      = 500;      // лось
extern int TakeProfit    = 500;      // язь
extern int BULevel       = 0;        // уровень БУ
extern int BUPoint       = 30;       // пункты БУ
extern int TrailingStop  = 0;        // трал
extern int BarsCount     = 3;        // через сколько баров открывать
extern int BuySell       = 0;        // 0-Candle 1-buy 2-sell 3-random
extern int Slip          = 30;       // реквот
extern int Magic         = 123;      // магик

datetime t=0;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Установка ордера                                                 |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
  {
   int r=0;
   color clr=Green;
   double sl=0,tp=0;

   if(type==1 || type==3 || type==5)
     {
      clr=Red;
      if(StopLoss>0)   sl=NormalizeDouble(price+StopLoss*Point,Digits);
      if(TakeProfit>0) tp=NormalizeDouble(price-TakeProfit*Point,Digits);
     }

   if(type==0 || type==2 || type==4)
     {
      clr=Blue;
      if(StopLoss>0)   sl=NormalizeDouble(price-StopLoss*Point,Digits);
      if(TakeProfit>0) tp=NormalizeDouble(price+TakeProfit*Point,Digits);
     }

   r=OrderSend(NULL,type,Lots,NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,0,clr);
   return;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int CountTrades()
  {
   int count=0;
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderType()<2) count++;
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
datetime OOT()
  {
   datetime oot=0;
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderType()<2) oot=OrderOpenTime();
         break;
        }
     }
   return(oot);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Trailing()
  {
   bool mod;
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() || OrderMagicNumber()==Magic)
           {
            if(OrderType()==OP_BUY)
              {
               if(Bid-OrderOpenPrice()>TrailingStop*Point)
                 {
                  if(OrderStopLoss()<Bid-TrailingStop*Point)
                    {
                     mod=OrderModify(OrderTicket(),OrderOpenPrice(),Bid-TrailingStop*Point,OrderTakeProfit(),0,Yellow);
                     return;
                    }
                 }
              }

            if(OrderType()==OP_SELL)
              {
               if((OrderOpenPrice()-Ask)>TrailingStop*Point)
                 {
                  if((OrderStopLoss()>(Ask+TrailingStop*Point)) || (OrderStopLoss()==0))
                    {
                     mod=OrderModify(OrderTicket(),OrderOpenPrice(),Ask+TrailingStop*Point,OrderTakeProfit(),0,Yellow);
                     return;
                    }
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void BU()
  {
   bool m;
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() || OrderMagicNumber()==Magic)
           {
            if(OrderType()==OP_BUY)
              {
               if(OrderOpenPrice()<=(Bid-(BULevel+BUPoint)*Point) && OrderOpenPrice()>OrderStopLoss())
                 {
                  m=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+BUPoint*Point,OrderTakeProfit(),0,Yellow);
                  return;
                 }
              }

            if(OrderType()==OP_SELL)
              {
               if(OrderOpenPrice()>=(Ask+(BULevel+BUPoint)*Point) && (OrderOpenPrice()<OrderStopLoss() || OrderStopLoss()==0))
                 {
                  m=OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-BUPoint*Point,OrderTakeProfit(),0,Yellow);
                  return;
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   bool buy=true,sell=true;
   if(BuySell==0){buy=Close[1]>Open[1]; sell=Close[1]<Open[1];}
   if(BuySell==1){buy=true; sell=false;}
   if(BuySell==2){buy=false; sell=true;}
   if(BuySell==3)
     {
      if(MathRand()/32768==0) {buy=true; sell=false;}
      else {buy=false; sell=true;}
     }

   if(CountTrades()<1) PutOrder(1,Bid);

   if(t!=Time[0] && TimeCurrent()-OOT()>BarsCount*PeriodSeconds())
     {
      if(buy) PutOrder(0,Ask);
      if(sell) PutOrder(1,Bid);
      t=Time[0];
     }

   if(BULevel>0) BU();
   if(TrailingStop>0) Trailing();
  }
//+------------------------------------------------------------------+
avatar

AM2

  • 27 июля 2016, 17:26
0
Посмотрю значит сегодня.
avatar

AM2

  • 27 июля 2016, 15:46
+2
Такое веселое задание. Развлекаетесь?
avatar

AM2

  • 27 июля 2016, 15:38
+1
Главное, чтобы присутствовал, данный пункт т.з.: "- объём ордера, если 0, то такой же, как рыночный".


Добавил эту функцию: www.opentraders.ru/downloads/1272/

avatar

AM2

  • 27 июля 2016, 15:19
+1
Вспомнил как делал тот советник. Данный набросок поставит отложку каждой новой открытой позиции, если он установлен на графике во время открытия позиций и удалит отложки если нет поз.




//+------------------------------------------------------------------+
//|                                                      Poshnik.mq4 |
//|                                              Copyright 2016, AM2 |
//|                                      http://www.forexsystems.biz |
//+------------------------------------------------------------------+

#property copyright "Copyright 2016, AM2"
#property link      "http://www.forexsystems.biz"
#property version   "1.00"
#property strict

//--- Inputs
extern double Lots       = 0.1;      // лот
extern int StopLoss      = 500;      // лось
extern int TakeProfit    = 500;      // язь
extern int Delta         = 100;      // 
extern int BuySell       = 0;        // 1-buy 2-sell 0-off
extern int Slip          = 30;       // реквот
extern int Magic         = 123;      // магик
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Установка ордера                                                 |
//+------------------------------------------------------------------+
void PutOrder(int type,double price)
  {
   int r=0;
   color clr=Green;
   double sl=0,tp=0;

   if(type==1 || type==3 || type==5)
     {
      clr=Red;
      if(StopLoss>0)   sl=NormalizeDouble(price+StopLoss*Point,Digits);
      if(TakeProfit>0) tp=NormalizeDouble(price-TakeProfit*Point,Digits);
     }

   if(type==0 || type==2 || type==4)
     {
      clr=Blue;
      if(StopLoss>0)   sl=NormalizeDouble(price-StopLoss*Point,Digits);
      if(TakeProfit>0) tp=NormalizeDouble(price+TakeProfit*Point,Digits);
     }

   r=OrderSend(NULL,type,Lots,NormalizeDouble(price,Digits),Slip,sl,tp,"",Magic,0,clr);
   return;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int CountTrades()
  {
   int count=0;
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderType()<2) count++;
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double MarketOOP()
  {
   double oop=0;

   if(OrderSelect(OrdersTotal()-1,SELECT_BY_POS,MODE_TRADES))
     {
      if(OrderType()<2) oop=OrderOpenPrice();
     }

   return(oop);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int LastType()
  {
   int type=8;

   if(OrderSelect(OrdersTotal()-1,SELECT_BY_POS,MODE_TRADES))
     {
      if(OrderType()<2) type=OrderType();
     }

   return(type);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double StopOOP()
  {
   double oop=0;

   if(OrderSelect(OrdersTotal()-1,SELECT_BY_POS,MODE_TRADES))
     {
      if(OrderType()>1) oop=OrderOpenPrice();
     }

   return(oop);
  }
//+------------------------------------------------------------------+
//| Удаление отложенных ордеров                                      |
//+------------------------------------------------------------------+
void DelOrder()
  {
   bool del;
   for(int i=OrdersTotal()-1;i>=0;i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderType()>1) del=OrderDelete(OrderTicket());
        }
     }
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(CountTrades()<1)
     {
      DelOrder();
      if(BuySell==1) PutOrder(0,Ask);
      if(BuySell==2) PutOrder(1,Bid);
     }

   if(MarketOOP()>0 && StopOOP()!=NormalizeDouble(MarketOOP()-Delta*Point,Digits) && LastType()==0) PutOrder(5,MarketOOP()-Delta*Point);
   if(MarketOOP()>0 && StopOOP()!=NormalizeDouble(MarketOOP()+Delta*Point,Digits) && LastType()==1) PutOrder(4,MarketOOP()+Delta*Point);
  }
//+------------------------------------------------------------------+

avatar

AM2

  • 26 июля 2016, 21:20
0
Помню как то делал здесь подобный и тогда я долго репу чесал как его сделать. Но сейчас я его вряд ли найду, а с нуля не возьмусь. С одной позицией еще могу сделать а когда открыты несколько и к ним надо поставить отложки это не ко мне.
avatar

AM2

  • 26 июля 2016, 20:22
0
Сегодня буду смотреть.
avatar

AM2

  • 26 июля 2016, 17:34
0
Проблема в том, что если открылись и закрылись в рамках одной свечи, то открывается новая серия?

Именно в этом неточность, нужно просто добавить контроль свечи. Одну половину я добавил а другую на десерт оставил :) 
avatar

AM2

  • 26 июля 2016, 12:59
0
Делайте заказ у кого лимит в порядке. Поправлю и мани добавлю.
avatar

AM2

  • 26 июля 2016, 10:45