+1
на новостях отложки ставят
avatar

verta81

  • 16 декабря 2021, 23:55
0
Премного благодарен)
avatar

verta81

  • 16 декабря 2021, 18:17
0
В настройках советника TakeProfit он же «ЯЗЬ», задайте значение=0
avatar

verta81

  • 16 декабря 2021, 00:28
0
в файлах кажись есть такое уже: www.opentraders.ru/downloads/3002/
avatar

verta81

  • 2 декабря 2021, 18:35
0
С каждым разом тамада лучше становится, и конкурсы все веселее))
avatar

verta81

  • 1 декабря 2021, 20:50
0
Вот ты как придумаешь)))
avatar

verta81

  • 1 декабря 2021, 20:47
0

void OnTick()
  {
    CloseOne();
//--------------
   
  }


// +------------------------------------------------------------------+
// |                                                                  |
// +------------------------------------------------------------------+
void CloseOne()
  {
   bool cl;
   double pr=0;
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol()&& OrderMagicNumber() == MagicNumber)
           {
            if(OrderType()<2)
              {
               pr=OrderProfit()+OrderCommission()+OrderSwap();
               double pro=(pr/AccountBalance())*100;
               if(pro>=Procent && Procent>0)
                 {
                  RefreshRates();
                  cl=OrderClose(OrderTicket(),OrderLots(),NormalizeDouble(Ask,_Digits),Slippage,Gold);
                 }
              }
           }
        }
     }
  }
avatar

verta81

  • 1 декабря 2021, 14:11
0
правильно, общая сумма бай или селл.
поэтому и спрашивали: какой ордер закрывать? последний?
avatar

verta81

  • 1 декабря 2021, 13:29
0

//---------------закрывает селл--------------
double pro=(AllProfit(1)/AccountBalance())*100;
if(pro>=Procent && Procent>0)// 2000/10000*100=20
CloseAll(1);//закрывает селл
//------------------------закрывает бай--------------------
double pro=(AllProfit(0)/AccountBalance())*100;
if(pro>=Procent && Procent>0)// 2000/10000*100=20
CloseAll(0);//закрывает бай
avatar

verta81

  • 1 декабря 2021, 12:24
0
прикрутить не проблема!
"… сделать так чтобы в процентах закрывался только один ордер?..."
Какой ордер? первый, последний?
avatar

verta81

  • 1 декабря 2021, 11:34
0

//+------------------------------------------------------------------+
//|                                               TrailClosePart.mq4 |
//|                        Copyright 2021, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

extern int TrailingStop     = 500;        // трал
extern int TrailingStep     = 50;        // трал степ
extern double KClose        = 0.5;      // K.Close
double MINLOT,MAXLOT;
int countb=1;
int counts=1;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   MINLOT = MarketInfo(Symbol(),MODE_MINLOT);
   MAXLOT = MarketInfo(Symbol(),MODE_MAXLOT);
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//-------------------
  }
//+------------------------------------------------------------------+
//| Подсчет ордеров по типу                                          |
//+------------------------------------------------------------------+
int CountOrders(int type=-1)
  {
   int count=0;
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol())
           {
            if(OrderType()==type || type==-1)
               count++;
           }
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
//|     функция трала и частичного закрытия ордеров                  |
//+------------------------------------------------------------------+
void Trailing()
  {
   bool mod,cl;
   double sl=0,lot=0,CloseLot=0;
   
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol())
           {
            if(OrderType()==0)
              {
               if(Bid-OrderOpenPrice()>(TrailingStop*countb)*_Point)
                 { 
                  lot=OrderLots();
                  CloseLot=NormalizeDouble(lot*KClose,2);
                  countb++;
                  if(CloseLot<MINLOT)
                    {
                      CloseLot=MINLOT;
                      countb=1;
                    }
                   cl=OrderClose(OrderTicket(),CloseLot,NormalizeDouble(Bid,Digits),Slip,White);
                  }
                if(Bid-OrderOpenPrice()>TrailingStop*_Point && OrderStopLoss()<Bid-(TrailingStop+TrailingStep)*_Point)
                  {
                   sl=NormalizeDouble(Bid-TrailingStop*_Point,_Digits);
                   if(OrderStopLoss()!=sl)
                      mod=OrderModify(OrderTicket(),OrderOpenPrice(),sl,OrderTakeProfit(),0,Yellow);
                  }
               }
            if(OrderType()==1)
              {
               if(OrderOpenPrice()-Ask>(TrailingStop*counts)*_Point)
                 {
                  lot=OrderLots();
                  CloseLot=NormalizeDouble(lot*KClose,2);
                  counts++;
                  if(CloseLot<MINLOT)
                    {
                      CloseLot=MINLOT;
                      counts=1;
                    }
                   cl=OrderClose(OrderTicket(),CloseLot,NormalizeDouble(Bid,Digits),Slip,White);
                  }
                if(OrderOpenPrice()-Ask>TrailingStop*_Point && OrderStopLoss()>(Ask+(TrailingStop+TrailingStep)*_Point))
                  {
                   sl=NormalizeDouble(Ask+TrailingStop*_Point,_Digits);
                   if(OrderStopLoss()!=sl)
                      mod=OrderModify(OrderTicket(),OrderOpenPrice(),sl,OrderTakeProfit(),0,Yellow);
                  }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(CountOrders()>0)
   Trailing();
  }
//+------------------------------------------------------------------+

avatar

verta81

  • 28 ноября 2021, 17:45
0
В индикаторе есть формула:
Ch1up_Buffer1[i] = ma + atr*Mult_Factor1;
ее применить не получилось?
Это линейно-взвешенная машка с тремя уровнями вверх и вниз.
avatar

verta81

  • 28 ноября 2021, 14:11
0
Четкое ТЗ!
Все бы так писали.
avatar

verta81

  • 18 ноября 2021, 21:14
0
Одно ТЗ в месяц.
В следующем месяце создавайте топик, с четким тз.
У Вас будет время обдумать всё
avatar

verta81

  • 17 ноября 2021, 21:59
0

//+------------------------------------------------------------------+
//|                                                       ProBoy.mq4 |
//|                                              Copyright 2021, AM2 |
//|                                     https://www.forexsystems.biz |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, AM2"
#property link      "https://www.forexsystems.biz"
#property version   "1.00"
#property strict

//--- Inputs
extern double Lots       = 0.1;      // лот
extern double KLot       = 2;        // умножение лота
extern double MaxLot     = 5;        // лот для вирта

extern int StopLoss      = 0;      // лось
extern int TakeProfit    = 0;     // язь

extern int Candles       = 20;       // свечей в коробке
extern int CandleTrail   = 10;       // свечей для трала

extern int Delta         = 100;      // расстояние от цены
extern int Slip          = 30;        // реквот
extern int Magic         = 123;        // магик

extern bool BuyStop      = true;        // BuyStop
extern bool SellStop     = true;        // SellStop

datetime t=0;
double hi=0,lo=0;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   Comment("");
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   Comment("");
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
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,Lot(),NormalizeDouble(price,_Digits),Slip,sl,tp,"",Magic,0,clr);
   return;
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
double Lot()
  {
   double lot=Lots;
   for(int i=OrdersHistoryTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY))
        {
         if(OrderProfit()>0)
            break;
         if(OrderProfit()<0)
           {
            lot=OrderLots()*KLot;
            break;
           }
        }
     }
   if(lot>MaxLot)
      lot=Lots;
   return(lot);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int CountTrades()
  {
   int count=0;
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
           {
            if(OrderType()<2)
               count++;
           }
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
//| Подсчет ордеров по типу                                          |
//+------------------------------------------------------------------+
int CountOrders(int type)
  {
   int count=0;
   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
           {
            if(OrderType()==type)
               count++;
           }
        }
     }
   return(count);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void ModeOOP()
  {
   bool m=1;
   double sl=0,tp=0;
   lo=Low[iLowest(NULL,0,1,Candles,0)];
   hi=High[iHighest(NULL,0,2,Candles,0)];
   double opb=NormalizeDouble(hi+Delta*_Point,_Digits);
   double slb=NormalizeDouble(Low[iLowest(NULL,0,1,CandleTrail,1)],Digits);
   double ops=NormalizeDouble(lo-Delta*_Point,_Digits);
   double sls=NormalizeDouble(High[iHighest(NULL,0,2,CandleTrail,1)],_Digits); 

   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
           {
            if(OrderType()==OP_SELLLIMIT)//4
              {
               if(OrderOpenPrice()!=opb)
                 {
                  if(TakeProfit>0)
                   {
                    tp=NormalizeDouble(OrderOpenPrice()-TakeProfit*_Point,_Digits);
                   }
                  if(StopLoss>0)
                   {
                    sl=NormalizeDouble(OrderOpenPrice()+StopLoss*_Point,_Digits);
                   }
                  m=OrderModify(OrderTicket(),opb,sl,tp,0,Blue);
                  return;
                 }
              }

            if(OrderType()==OP_BUYLIMIT)//5
              {
               if(OrderOpenPrice()!=ops)
                 {
                  if(TakeProfit>0)
                   {
                    tp=NormalizeDouble(OrderOpenPrice()+TakeProfit*_Point,_Digits);
                   }
                  if(StopLoss>0)
                   {
                    sl=NormalizeDouble(OrderOpenPrice()-StopLoss*_Point,_Digits);
                   }
                  m=OrderModify(OrderTicket(),ops,sl,tp,0,Blue);
                  return;
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void CandleTrailing()
  {
   bool mod=1;
   double tp=0;

   for(int i=OrdersTotal()-1; i>=0; i--)
     {
      if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES))
        {
         if(OrderSymbol()==Symbol() && OrderMagicNumber()==Magic)
           {
            if(OrderType()==0)
              {
               tp=NormalizeDouble(High[iHighest(NULL,0,2,CandleTrail,1)],Digits);

               if(Bid<tp)
                 {
                  if(OrderTakeProfit()<tp || OrderTakeProfit()==0)
                    {
                     if(OrderTakeProfit()!=tp)
                        mod=OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),tp,0,Yellow);
                     return;
                    }
                 }
              }

            if(OrderType()==1)
              {
               tp=NormalizeDouble(Low[iLowest(NULL,0,1,CandleTrail,1)],Digits);

               if(Ask>tp)
                 {
                  if(OrderTakeProfit()>tp || OrderTakeProfit()==0)
                    {
                     if(OrderTakeProfit()!=tp)
                        mod=OrderModify(OrderTicket(),OrderOpenPrice(),OrderStopLoss(),tp,0,Yellow);
                     return;
                    }
                 }
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(t!=Time[0])
     {
      lo=Low[iLowest(NULL,0,1,Candles,0)];
      hi=High[iHighest(NULL,0,2,Candles,0)];

      ModeOOP();

      if(CandleTrail>0)
         CandleTrailing();

      if(CountTrades()<1)
        {
         if(BuyStop && CountOrders(3)<1)
           {
            PutOrder(3,hi+Delta*_Point);
           }
         if(SellStop && CountOrders(2)<1)
           {
            PutOrder(2,lo-Delta*_Point);
           }
        }
      t=Time[0];
     }

   Comment("\n Lot: ",Lot());
  }
//+------------------------------------------------------------------+

avatar

verta81

  • 15 ноября 2021, 00:30
0
Take на High/Low 10 свечей? и ждать бешенного импульса для срабатывания тэйка?
StopLoss не тралится, или фиксированный — это длительная просадка в ожидании лося или профита.
Может для лимитников лучше входить на экстремумах за 10 свечей и тралить стоп по экстремумам за 20 свечей, к примеру.
avatar

verta81

  • 14 ноября 2021, 21:03
0
И вместо StopLoss тралить ордера по TakeProfit. это как?
avatar

verta81

  • 14 ноября 2021, 20:16
0
Давай, жги Петрович)))
avatar

verta81

  • 12 ноября 2021, 19:12