Tell me how to prepare a martin so as not to drain...

 
Please advise how to programmatically skip 1 - 2 negative trades (do not apply a martin to them) that usually go on an unsuccessful start of a flat... or rather unsuccessful entry into a flat by the first trade or it often happens on reversal to a new track...
 
Сергей Криушин:
Please advise how to programmatically skip 1 - 2 negative trades (do not apply martin to them) that usually go on an unsuccessful start of a flat... or rather unsuccessful entry into a flat by the first trade or it often happens on a reversal to a new track...

OnTradeTransaction - catching losing trades and increasing counter.

 
Vladimir Karputov:

OnTradeTransaction - catching losing trades and increasing the counter.

Thanks for the reply, but there's nothing in there about history and getting the last negative trade, which is what the martingale multiplies
 
Сергей Криушин:
Thanks for the reply, but there's nothing there about history and getting the last negative trade, which is what the martingale multiplies

Please read carefully:

Now it is more detailed:

STEP 1: Caught a negative trade.

Step 2: Increase counter.

Step Three: as long as the counter is 1 or 2 - do not use a martin.


It is inOnTradeTransaction that we get ALL the information about the last trade.

 
Сергей Криушин:
Thanks for the reply, but there's nothing in there about history and getting the last negative trade, which is what the martingale multiplies

Search for the wordOnTradeTransaction.

 
Сергей Криушин:

Here's a code where everything is clear, but it's not clear how to catch the last deals... and there in your abstruse documentation you can't understand anything, as if they write for abstruse people and it's useless to read and reread... I read it twice myself and didn't understand what of what and from what

//+----------------------------------------------------------------------------+
//|  Автор    : Ким Игорь В. aka KimIV,  http://www.kimiv.ru                   |
//+----------------------------------------------------------------------------+
//|  Версия   : 19.02.2008                                                     |
//|  Описание : Возвращает флаг убыточности последней позиции.                 |
//+----------------------------------------------------------------------------+
//|  Параметры:                                                                |
//|    sy - наименование инструмента   (""   - любой символ,                   |
//|                                     NULL - текущий символ)                 |
//|    op - операция                   (-1   - любая позиция)                  |
//|    mn - MagicNumber                (-1   - любой магик)                    |
//+----------------------------------------------------------------------------+
bool isLossLastPos(string sy="", int op=-1, int mn=-1) {
  datetime t;
  int      i, j=-1, k=OrdersHistoryTotal();

  if (sy=="0") sy=Symbol();
  for (i=0; i<k; i++) {
    if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) {
      if (OrderSymbol()==sy || sy=="") {
        if (OrderType()==OP_BUY || OrderType()==OP_SELL) {
          if (op<0 || OrderType()==op) {
            if (mn<0 || OrderMagicNumber()==mn) {
              if (t<OrderCloseTime()) {
                t=OrderCloseTime();
                j=i;
              }
            }
          }
        }
      }
    }
  }
  if (OrderSelect(j, SELECT_BY_POS, MODE_HISTORY)) {
    if (OrderProfit()<0) return(True);
  }
  return(False);
}

What does it mean to catch the next unprofitable one and skip it? Tell the bot that there is no signal.

 
Galim_V:

What does it mean to catch the next unprofitable one and miss it? Tell the bot that there is no signal.

You can't tell the MQL5 bot nothing with this code))))

At least pay some attention to the topic!

 
Vitaly Muzichenko:

He won't tell the MQL5 bot anything with this code))))

At least keep an eye on the subject!

I agree. I'm far away from MQL5. The key thing in this code for him is(OrderProfit()<0)

 

"so that you don't lose..." - that is, how do you get a profitable EA?

That's the question on everyone's mind here

;)

 
Renat Akhtyamov:

"so you don't lose..." - that is, how do you get a profitable EA?

That's the question on everyone's mind.

;)

What's the worry? Do not enter the whole cutlet, and exit the market on time - do not wait for a stop-out. That's all for 5 kopecks.)

 
Galim_V:

Agreed. I'm far away from MQL5. The key thing in this code for him is(OrderProfit()<0)

Wrong approach - it should beOrderProfit()>Spread

Reason: