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

 
Nerd Trader #:

...



 
Nerd Trader #:
In ide settings, how do I remove the nonsense insertion of a rectangle between functions?

It's completely unnecessary for me too:

class cMy_class
  {
public:
   //Тут плюсуем
   int               Plus(
      int a,b//Это a и b
   );//Возвращает результат плюсования
  };
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int cMy_class::Plus(int a,b)
  {
   return a+b;
  }
 
Nerd Trader #:
if there's a space, it still won't see the comment.

This is how he sees things

/*******************Expert initialization function*******************/
int OnInit()
 {
  trade.LogLevel(LOG_LEVEL_NO);
  trade.SetExpertMagicNumber(1212);
  return(INIT_SUCCEEDED);
 }/******************************************************************/

/************************Expert tick function************************/
void OnTick()
 {
  Comment("", "\n",
//"p =  ", sizeP, "\n",
//"m =  ", sizeM, "\n",
//"summPlus =  ", DoubleToString(summPlus, 2), "\n",
//"summMinus =  ", DoubleToString(summMinus, 2), "\n",
//"profitStep =  ", DoubleToString(profitStep, 2),
          "\n"
         );
 }/******************************************************************/

/*********************TradeTransaction function**********************/
void OnTradeTransaction(const MqlTradeTransaction& trans,
                        const MqlTradeRequest& request,
                        const MqlTradeResult& result)
 {
if(trans.type == TRADE_TRANSACTION_DEAL_ADD)
 {
Even I can see the beginning of the function and the end.
 
Alexey Viktorov #:

That's how he sees things.

Even I can see the beginning of the function and the end.

It's not a problem for anyone to see.
If there is a blank line before and after the comment:

an idea inserts



However, this is not really important, you just need to use a different id.

 

Good day!!!

Help me find a bug in trailing stop on parabolic code

Here is a command to open a trailing stop along the par abolic

//-------------------------------------------------------------------+  Команда на модификацию трейлинг стоп первых ордеров по параболику
   if(Update_Time != iTime(Symbol(),TimeframesIndicators,0))
      Update_Time = iTime(Symbol(),TimeframesIndicators,0);
   if(CountTrade(0) == 1 || CountTrade(1) == 1)
      ParabolicTrail();

Trailing Stop by Par abolic

//+----------------------------------------------------------------------------+
//| Трейлинг стоп одиночных ордеров по параболику                              |
//+----------------------------------------------------------------------------+
void ParabolicTrail()
  {
   double PSAR = iSAR(Symbol(),TimeframesIndicators, 0.02, 0.2,0);

   int Order_total = OrdersTotal();
   for(int i=Order_total-1; i>=0; i--)
     {
      if(!OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
         continue; //если не получилось выделить ордер
      if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderProfit() > 0 && OrderStopLoss() != 0 && OrderType() < 2)
        {
         if(OrderType() == OP_BUY)
           {
            if(PSAR < Ask && PSAR > OrderStopLoss())
              {
               if(OrderModify(OrderTicket(), OrderOpenPrice(), PSAR, OrderTakeProfit(), 0))
                 {
                  Print("Trailing Stop: Стоп Лосс ордера на покупку #",OrderTicket()," перенесен на цену ", DoubleToString(PSAR,Digits));
                 }
              }
           }
         else
            if(OrderType() == OP_SELL)
              {
               if(PSAR > Bid && PSAR < OrderStopLoss())
                 {
                  if(OrderModify(OrderTicket(), OrderOpenPrice(), PSAR, OrderTakeProfit(), 0))
                    {
                     Print("Trailing Stop: Стоп Лосс ордера на продажу #",OrderTicket()," перенесен на цену ", DoubleToString(PSAR,Digits));
                    }
                 }
              }
        }
     }
  }

No errors in the log, but trail does not start

Thank you!!!

 
EVGENII SHELIPOV parabolic code

Here is a command to open a trailing stop along the par abolic

Trailing Stop by Par abolic

No errors in the log, but trail does not start

Thank you!!!

Are you sure there are no errors?

and under your condition it is unnecessary

if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderProfit() > 0 && OrderStopLoss() != 0 && OrderType() < 2)
 

EVGENII SHELIPOV #:

No errors in the logbook but the trawl won't start either

Thank you!!!

Try it like this.

//+----------------------------------------------------------------------------+
//| Трейлинг стоп одиночных ордеров по параболику                              |
//+----------------------------------------------------------------------------+
void ParabolicTrail()
  {
   double PSAR = iSAR(Symbol(),TimeframesIndicators, 0.02, 0.2,0);

   int Order_total = OrdersTotal();
   for(int i=Order_total-1; i>=0; i--)
     {
      if(OrderSelect(i, SELECT_BY_POS, MODE_TRADES))
        {
         if(OrderSymbol() == Symbol() && OrderMagicNumber() == Magic && OrderProfit() > 0 && OrderStopLoss() != 0)
           {
            if(OrderType() == OP_BUY)
              {
               if(PSAR < Ask && PSAR > OrderStopLoss())
                 {
                  if(OrderModify(OrderTicket(), OrderOpenPrice(), PSAR, OrderTakeProfit(), 0))
                    {
                     Print("Trailing Stop: Стоп Лосс ордера на покупку #",OrderTicket()," перенесен на цену ", DoubleToString(PSAR,Digits));
                    }
                 }
              }
            if(OrderType() == OP_SELL)
              {
               if(PSAR > Bid && PSAR < OrderStopLoss())
                 {
                  if(OrderModify(OrderTicket(), OrderOpenPrice(), PSAR, OrderTakeProfit(), 0))
                    {
                     Print("Trailing Stop: Стоп Лосс ордера на продажу #",OrderTicket()," перенесен на цену ", DoubleToString(PSAR,Digits));
                    }
                 }
              }
           }
        }
     }
  }

In any case you need to check MODE_STOPLEVEL

 
MakarFX #:
Are you sure there are no errors?

and under your condition it's unnecessary.

No, it still won't start.

 
EVGENII SHELIPOV #:

No it still won't start

Show the order opening function
 
EVGENII SHELIPOV #:

No, it still won't start.

From the screenshot these conditions are not met

  OrderStopLoss() != 0
Reason: