Any questions from newcomers on MQL4 and MQL5, help and discussion on algorithms and codes - page 1370

 
Сергей Дыбленко:

It doesn't work at all! It doesn't work at all!

Tell me how you want to change the lot, relative to what?

Check out this library.

 
MakarFX:

Tell me how you want to change the lot, relative to what?

Look at this library

Relative to your depot!

I'm trying to make a Grail that doesn't lose, but always makes profit!

 
Сергей Дыбленко:

in relation to my depot!

Trying to make a Grail that doesn't drain and always gives a profit!

Here you go

//+--------------------------------------------------------------------------------------------------------------------+
//|  Расчет лота относительно маржи                                                                                    |
//+--------------------------------------------------------------------------------------------------------------------+
double MarginLot()
  {
   double Free    = AccountFreeMargin();
   double Prots   = Risk/100;
   double Lot     = MarketInfo(Symbol(), MODE_MARGINREQUIRED);
   double Step    = MarketInfo(Symbol(), MODE_LOTSTEP);
   double result  = MathFloor(Free * Prots / Lot / Step) * Step;

   if (result > MaxLot) result = MaxLot;
   else 
   if (result < MinLot) result = MinLot;
   return(result);
  }
 
Сергей Дыбленко:

It doesn't work at all! This is ridiculous!

this function increases the lot

up to 120 of your funds will open with 0.2 lot.

as your funds increase above 120 - 200 will open positions with lot 0.3

 
MACAR and SASHKA - thank you guys!!!!!!!!!!!!! Something's starting to come through for me!!!!
 
https://www.mql5.com/ru/code/26798 I've tried to make the lots cool in this fake! But it's too complicated for me!
 

Good afternoon everyone. I've managed to beat the opening of orders. But during the tick test, the Expert Advisor generates error 2021.01.30 17:31:29.755 2014.03.21 11:50:03 TREND+ _V_REAL-DEMO EURUSD,H1: OrderModify error 1

The order modification is prescribed in one place - in the parabolic trawl. Here is the code of the trawl


//--ТРАЛ ПО ПАРАбОЛИКУ
void Tral_parabolik()
{ // НАЧАЛО ТРАЛ ПО ПАРАБОЛИК
//+------------------------------------------------------------------+
   int    Tral = tral;
   double Sar  = iCustom(_Symbol,PeriodForWork_tral_parabolik,"Parabolic",step_tral_parabolik,max_tral_parabolik,1);
//+------------------------------------------------------------------+
   for(int pos=0;pos<OrdersTotal();pos++)
     { if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES))
      if(OrderSymbol()==_Symbol)
        {
         if(OrderType()==OP_SELL)
           {
            if(OrderOpenPrice()>Ask+Tral*Point&&OrderStopLoss()!= Sar)
            if(OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Sar,Digits),OrderTakeProfit(),0,clrBlack))
            {Print("Order SELL Modify");
            if (GetLastError()==141){Alert(GetLastError()); ExpertRemove();}// ПРОВЕРКА ОТ ДОЛБАНИЯ СЕРВЕРА И БАНА СЧЁТА
            }
           }
         if(OrderType()==OP_BUY)
           {
            if(OrderOpenPrice()<Bid-Tral*Point&&OrderStopLoss()!= Sar)
            if(OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Sar,Digits),OrderTakeProfit(),0,clrGreen))
            {
            Print("Order BUY Modify");
            if (GetLastError()==141){Alert(GetLastError()); ExpertRemove();}// ПРОВЕРКА ОТ ДОЛБАНИЯ СЕРВЕРА И БАНА СЧЁТА
            
            }
           }
        }

}
} // КОНЕЦ ТРАЛ ПО ПАРАБОЛИК

What should I correct in the trail function to avoid this error?

 

DanilaMactep:

What should be corrected in the trawl function to avoid this error?

Try this

//--ТРАЛ ПО ПАРАбОЛИКУ
void Tral_parabolik()
{ // НАЧАЛО ТРАЛ ПО ПАРАБОЛИК
//+------------------------------------------------------------------+
   int    Tral = tral;
   double Sar  = iCustom(_Symbol,PeriodForWork_tral_parabolik,"Parabolic",step_tral_parabolik,max_tral_parabolik,1);
//+------------------------------------------------------------------+
   for(int pos=0;pos<OrdersTotal();pos++)
     {
      if(OrderSelect(pos,SELECT_BY_POS,MODE_TRADES))
      if(OrderSymbol()==_Symbol)
        {
         if(OrderType()==OP_SELL)
           {
            if(OrderOpenPrice()>Ask+Tral*Point&&OrderOpenPrice()>Sar)
              {
               if(OrderStopLoss()!= Sar)
                 {
                  if(OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Sar,Digits),OrderTakeProfit(),0,clrBlack))
                    {
                     Print("Order SELL Modify",GetLastError());
                     if (GetLastError()==141){Alert(GetLastError()); ExpertRemove();}// ПРОВЕРКА ОТ ДОЛБАНИЯ СЕРВЕРА И БАНА СЧЁТА
                    }
                 }
              }
           }
         if(OrderType()==OP_BUY)
           {
            if(OrderOpenPrice()<Bid-Tral*Point&&OrderOpenPrice()<Sar)
              {
               if(OrderStopLoss()!= Sar)
                 {
                  if(OrderModify(OrderTicket(),OrderOpenPrice(),NormalizeDouble(Sar,Digits),OrderTakeProfit(),0,clrGreen))
                    {
                     Print("Order BUY Modify",GetLastError());
                     if (GetLastError()==141){Alert(GetLastError()); ExpertRemove();}// ПРОВЕРКА ОТ ДОЛБАНИЯ СЕРВЕРА И БАНА СЧЁТА
                    }
                 }
              }
           }
        }
     }
} // КОНЕЦ ТРАЛ ПО ПАРАБОЛИК  
 
MakarFX:

Here you go

Thank you. I'm gonna stick the code somewhere! I just wish I knew where to put it....

 
Сергей Дыбленко:

Thank you. I'll poke the code in! I just wish I knew where to put it....

At the bottom of the board.

Reason: