Discussion of article "Useful and exotic techniques for automated trading"

 

New article Useful and exotic techniques for automated trading has been published:

In this article I will demonstrate some very interesting and useful techniques for automated trading. Some of them may be familiar to you. I will try to cover the most interesting methods and will explain why they are worth using. Furthermore, I will show what these techniques are apt to in practice. We will create Expert Advisors and test all the described techniques using historic quotes.

In fact, this technique can be used not only for martingale, but also for any other strategies that have a sufficiently high trading frequency. In this example, I will use the metric based on the balance drawdown. Because everything related to balance is considered easier. Let us divide the balance chart into rising and falling segments. Two adjacent segments form a half-wave. The number of half-waves tends to infinity as the number of transactions tends to infinity. A finite sample will be enough for us to make the martingale a little more profitable. The following diagram explains the idea:

Balance waves

The figure shows a formed half-wave and the one that has just begun. Any balance graph consists of such half-waves. The size of these half-waves constantly fluctuates, and we can always distinguish groups of such half-waves on the chart. The size of these half-waves is smaller in one wave and is larger in the other. So, by gradually lowering the lots, we can wait until a half-wave with a critical drawdown appears in the current group. Since the lots of this critical drawdown will be minimal in the series, this will increase the overall average metrics of all groups of waves and, as a result, the same performance variables of the original test should also increase.

For implementation, we need two additional input parameters for the martingale:

  • { DealsMinusToBreak } - the number of losing trades for the previous cycle, reaching which the starting lot of the cycle should be reset to the starting value
  • LotDecrease } - step for decreasing the starting lot of the cycle when a new cycle appears in the history of trades

These two parameters will allow us to provide increased lots for safe half-wave groups and reduced lots for dangerous half-wave groups, which should, in theory, increase the above mentioned performance metrics.

Author: Evgeniy Ilin

 

traditionally useful and insightful.

thought-provoking

 

something all the functions converged to the classic

volume_in_market = K*exp(N*balance drawdown)

or I was reading on the wrong diagonal :-)

🤔

 
Maxim Kuznetsov:

all the functions have gone to the classics.

volume_in_market = K*exp(N*balance drawdown)

or I was reading on the wrong diagonal :-)

🤔

Well if we are talking about classic martingale then yes ) I take it you mean the last point. It's a bit different there. Perhaps I should explain. If we divide the equity or balance line into segments, there will be segments with increased average drawdown and decreased, on those segments where the drawdown is increased we should try to provide minimum lots and where the drawdown is decreased maximum lots, so we reduce the importance of risky areas, and increase the importance of safe ones. The result is that a losing strategy can be turned into a slightly positive one with skilful use of this technique. There can be a lot of variations, you just need to try, otherwise there is no way. Theory without practice is just theory )

 
Evgeniy Ilin:

Well, if we talk about classical martingale, then yes ) I understand you mean the last point. It's a bit different there. Perhaps I should explain. If we divide the equity or balance line into segments, there will be segments with increased average drawdown and decreased, on those segments where the drawdown is increased we should try to provide minimum lots, and where the drawdown is decreased maximum lots, so we reduce the importance of risky areas, and increase the importance of safe ones. The result is that a losing strategy can be turned into a slightly positive one with skilful use of this technique. There can be a lot of variations, you just need to try, otherwise there is no way. Theory without practice is just theory )

if I knew where to fall, I would have made a bed :-))

it's about the areas of increased/reduced balance drawdown and risky areas...

they are not known in advance, only after-the-fact. And if they were known, then the method of "sitting on the fence" will rule everything :-) just don't trade on riskier areas.

 
Maxim Kuznetsov:

if I knew where to fall, I'd have made a bed for it.)

it's about the areas of increased/reduced balance drawdown and risky areas....

they are not known in advance, only after-the-fact. And if they were known, then the method of "sitting on the fence" will rule everything :-) just don't trade on riskier areas.

It's simple, a lower drawdown is always followed by a higher drawdown and vice versa ) now you can lay a straw )

 

really very useful. T o make profit by controlling lots instead of using fixed lots.

By the way, what is the testing Timeframe for the PartialClosing EA?

 
Zhongquan Jiang:

really very useful. T o make profit by controlling lots instead of using fixed lots.

By the way, what is the testing Timeframe for the PartialClosing EA?

Thanks! Partial closing backtest is 2000-2021 on M5 timeframe. But i think it must be workeable on M1 or any higher timeframes. )

 
Evgeniy Ilin:

It's simple, lower drawdown is always followed by higher drawdown and vice versa ) now you can lay your straw )

In practice, the picture from the article should have a couple more points, like this.


moments when drawdown has gone beyond the model or recovery clearly...
after which actions are taken to manipulate lots
the closer they are to the tops, the closer we are to classical martingales, but further away, of course, more interesting.

 
Maxim Kuznetsov:

in practice, the picture from the article should have a couple more points like this


moments when the drawdown has gone beyond the model or recovery clearly...
after which actions are taken to manipulate lots
the closer they are to the tops, the closer we are to classical martingales, but further away, of course, more interesting.

Well, in general, yes, but it is necessary to leave some food for people ) to start thinking a little ). There is no explicit recipe, just the general principle that all these things are a wave process, how to precisely define the boundaries of areas is a great scope for creativity, I just gave the simplest example. In general, the very understanding of this principle gives a fulcrum from which to start thinking ) and it is not even necessary that my recipes will be the best ) the more people the less likely that my solution will be the best .

 

I probably didn't quite get the point, but should it really be like this and not the other way round (highlighted)?

void PartialCloseType()//partially close the order
   {
   bool ord;
   double ValidLot;
   MqlTick TickS;
   SymbolInfoTick(_Symbol,TickS);
            
   for ( int i=0; i<OrdersTotal(); i++ )
      {
      ord=OrderSelect( i, SELECT_BY_POS, MODE_TRADES );
                            
      if ( ord && OrderMagicNumber() == MagicF && OrderSymbol() == _Symbol )
         {
         if ( OrderType() == OP_BUY )
            {
            ValidLot=CalcCloseLots(OrderLots(),(Open[0]-Open[1])/_Point);
            if ( ValidLot > 0.0 ) ord=OrderClose(OrderTicket(),ValidLot,TickS.bid,MathAbs(SlippageMaxClose),Green);
            }
         if ( OrderType() == OP_SELL )
            {
            ValidLot=CalcCloseLots(OrderLots(),(Open[1]-Open[0])/_Point);
            if ( ValidLot > 0.0 ) ord=OrderClose(OrderTicket(),ValidLot,TickS.ask,MathAbs(SlippageMaxClose),Red);
            }         
         break;
         }
      }

In this case, partial closing of a position occurs when the price movement and the set order coincide in direction. I.e. a profitable position is closed, while a losing position remains.