Discussion of article "Automated exchange grid trading using stop pending orders on Moscow Exchange (MOEX)"

 

New article Automated exchange grid trading using stop pending orders on Moscow Exchange (MOEX) has been published:

The article considers the grid trading approach based on stop pending orders and implemented in an MQL5 Expert Advisor on the Moscow Exchange (MOEX). When trading in the market, one of the simplest strategies is a grid of orders designed to "catch" the market price.

The grid is characterized by the following parameters:

  • grid width
  • grid step
  • take profit
  • stop loss

The grid width is the area covered by the placed orders. Grid step is the distance between orders. Grid width and step are calculated in points. Thus, we have reached the definition of the grid method of trading. A trading method, in which the entry into the market is carried out using many orders usually located at the same distance from each other and on both sides of the current price is called a grid. 

Whatever direction the market price goes, it will still pass through the grid of positions. Profitable trades can accumulate up to a certain amount, but they can also be closed as soon as the price turns the next order placed on the grid into a market position. Placing next orders in the grid (for example, when the price moves up and triggers buy stop orders, as well as accumulates market position volumes with subsequent placing sell market orders closer to the price (updating the grid)) with subsequent small price downward rollbacks triggering sell stop orders performs the role of the so-called partial closing of the position, which is shown in Fig. 1.

placing and executing orders

Author: Roman Shiredchenko

 

1) The code is obviously overloaded with unnecessary functionality. I removed the unnecessary, leaving only the essence of the idea. Thus the size of the source code decreased almost 3 times. For the idea and the opportunity to feel, thank you.

2) Not in the essence of the question ... you are not a 1C programmer by any chance ? )... The code is very specific. You could say we have a dispute here ... 1C programmer or not )))

 
  1. How did you define the rules and parameters for placing pending orders based on the current price position and closed trades? What factors and criteria were taken into account when developing these rules?
  2. How do you evaluate the effectiveness of using Buy-Stop and Sell-Stop order grid in different market conditions? What factors or signals do you consider when forecasting the main trend to decide on the direction of pending orders?
  3. How do you solve the problem of drawdowns in case of activation of several stop orders in both directions? What strategies or methods are used to get out of such drawdowns and restore the account balance?
  4. How does automated grid trading manage risk? What security measures or restrictions are used to minimise potential losses or undesirable situations associated with activating multiple orders in both directions?
  5. What factors or signals are used to determine when to exit a take profit position? What criteria or methods are used to set take profit levels?
  6. How do you account for flat market conditions and the possibility of long-term price range? What strategies or techniques are used to prevent unnecessary activation of stop orders in such situations?
  7. What is the role and importance of the time factor in grid trading on stop orders? What time intervals or periods are considered when making decisions about placing pending orders and exiting positions?
  8. How do you manage the size of the order grid and the spacing between orders? What factors or techniques are used to determine optimal values for these parameters?
  9. What factors or tools are used to evaluate market conditions and make decisions about symbol selection for grid trading? What symbol characteristics are considered most favourable for this type of trading?
  10. How do you assess the applicability and effectiveness of grid trading on stop orders for different types of traders? What recommendations or advice can you give to traders who want to use this strategy?
 
Bohdan Suvorov pending orders based on the current price position and closed trades? What factors and criteria were taken into account when developing these rules?
  • How do you evaluate the effectiveness of using Buy-Stop and Sell-Stop order grid in different market conditions? What factors or signals do you consider when forecasting the main trend to decide on the direction of pending orders?
  • How do you solve the problem of drawdowns in case of activation of several stop orders in both directions? What strategies or methods are used to get out of such drawdowns and restore the account balance?
  • How does automated grid trading manage risk? What security measures or restrictions are used to minimise potential losses or undesirable situations associated with activating multiple orders in both directions?
  • What factors or signals are used to determine when to exit a take profit position? What criteria or methods are used to set take profit levels?
  • How do you account for flat market conditions and the possibility of long-term price range? What strategies or methods are used to prevent unnecessary activation of stop orders in such situations?
  • What is the role and importance of the time factor in grid trading on stop orders? What time intervals or periods are considered when making decisions about placing pending orders and exiting positions?
  • How do you manage the size of the order grid and the spacing between orders? What factors or techniques are used to determine optimal values for these parameters?
  • What factors or tools are used to evaluate market conditions and make decisions about symbol selection for grid trading? What symbol characteristics are considered most favourable for this type of trading?
  • How do you assess the applicability and effectiveness of grid trading on stop orders for different types of traders? What recommendations or advice can you give to traders who want to use this strategy?
  • I am not the author ... but I will give my thoughts

    1) You set the range of the price corridor ... which is divided by the number of levels (pending orders).

    2) There is no trend ... you set a trap grid of pending limit orders ..... The trap trap has worked out, makes a profit (total on the grid) and closes the whole grid.

    Although in my test robot based on the presented code, I have redesigned ... closes not the entire grid only open positions, I don't see the point of generating a bunch of closed, not triggered orders at every sneeze.

    3) How to solve them ... the principle of grid trading is like this ... we wait until either the price movement itself goes to the already opened positions in the desired direction or a sufficient number of positions in the opposite direction will be opened to cover the loss from unprofitable positions.

    5) summarise the profit and loss on open positions ... in total if there is a set profit we exit ... although I have changed it to profit in pips instead of per cent.

    6) In this robot there are no factors affecting the sideways movement ... I have added the ability to switch on or off the prohibition to set stops in the direction in which there are already open positions ... i.e. if we get into a flat, we can get two positions in different directions blocking drawdown at a certain level.

    7) I, for example, do not understand the question ... the grid hangs during the whole period of trying to catch the total net profit ... the lifetime of the pending stops does not matter here ... because the price corridor is fixed ... the stop will expire in 12 months ... ... it will simply be redrawn in the same place))))) ... in the original Expert Advisor you can set the maximum time of holding positions in the hope of getting a given profit ... i.e. if it fails to gain the set profit level, then close it at a profit greater than zero.

    8) The price corridor is divided by the number of specified levels (orders) in the grid ... i.e. we set a corridor of 500 - 400 ... we have a corridor of 100 quid .... For example, if we set 10 orders, the grid step will be 10 quid.

    9) Grid trading does not involve market analysis ... grid trading ideally makes money no matter where the price moves .....

     
    Sergei Toroshchin #:

    I'm not the author. but I'll give you my thoughts

    1) The range of the price corridor is set ... which is divided by the number of levels (pending orders)

    2) There is no trend ... a trap grid of pending limit orders is set ..... The trap trap has worked out, makes a profit (total on the grid) and closes the whole grid.

    Although in my test robot based on the presented code, I redesigned ... closes not the whole grid only open positions, I don't see the sense in generating a bunch of closed, not triggered orders for every sneeze.

    3) How to solve them ... the principle of grid trading is like this ... we wait until either the price movement itself will go to the already opened positions in the desired direction or a sufficient number of positions will be opened in the opposite direction to cover the loss from unprofitable positions.

    5) summarise the profit and loss on open positions ... in total if there is a set profit we exit ... although I have changed it to profit in pips instead of per cent.

    6) In this robot there are no factors affecting the sideways movement ... I have added the ability to switch on or off the prohibition to set stops in the direction in which there are already open positions ... i.e. if we get into a flat, we will get two positions in different directions blocking the drawdown at a certain level.

    7) I, for example, do not understand the question ... the grid hangs during the whole period of trying to catch the total net profit ... the lifetime of the pending stops does not really matter here ... because the price corridor is fixed ... the stop will expire in 12 months ... ... it will simply be redrawn in the same place))))) ... in the original Expert Advisor you can set the maximum time of holding positions in the hope of getting a given profit ... i.e. if it does not gain the set profit level, then close at a profit greater than zero.

    8) The price corridor is divided by the number of specified levels (orders) in the grid ... i.e. we set a corridor of 500 - 400 ... we have a corridor of 100 quid .... For example, if we set 10 orders, the grid step will be 10 quid.

    9) Grid trading does not involve market analysis ... grid trading ideally makes money no matter where the price moves .....

    7) timeframe

     
    Bohdan Suvorov #:

    7) timeframe

    In my tests the timeframe is only a factor in how often the check for a profit and close ... i.e. let's say we have a short timeframe and a small timeframe, a profit will be caught ... if the timeframe is long, there is a chance that no profit will be caught and the grid will generally go backwards.

    In my redesigned version I have two types of TFs set ... one is responsible for checking and closing positions for a profit ... and the second TF is responsible for maintaining a grid of pending orders.

    As a result, I also removed the upper and lower limits of the price corridor as useless rubbish ... now it just maintains the minimum number of pending orders placed in each direction ... but no more than the maximum number of orders. I.e. in my case it is minimum 5 and maximum 7 ... which allows not to spam with constant placing and removal of orders and not to worry about the price corridor ... the corridor itself follows the current price

     
    Did the author trade his work on the real?
     
    prostotrader #:
    Has the author traded on the real with his work?

    It's a stock market robot - an expert. Any substantive suggestions? Not satisfied?

    I'm not imposing.

    Yes. Unfortunately, the broker BKS stopped supporting MT 5.

    I'll continue it in another one. I will post the reports here.

    Realisation of the trend trading approach is embodied in the code for MT 5 terminal.

     
    Sergei Toroshchin #:

    1) The code is obviously overloaded with unnecessary functionality. I removed the unnecessary, leaving only the essence of the idea. Thus the size of the source code decreased almost 3 times. Thanks for the idea and the opportunity to feel it.

    2) Not in the essence of the question ... you are not a 1C programmer by any chance ? )... The code is very specific. You could say we have a dispute here ... 1C programmer or not))))

    :-)

    Recently, noticed - discussion ... not excluded. Solved the implementation of the trade approach "head-on".

    Programmer (this is not my main specialisation :-)), not 1 C.

     
    Sergei Toroshchin #:

    I'm not the author. but I'll give you my thoughts

    1) The range of the price corridor is set ... which is divided by the number of levels (pending orders).

    2) There is no trend ... you set a trap grid of pending limit orders ..... The trap trap has worked out, makes a profit (total on the grid) and closes the whole grid.

    Although in my test robot on the basis of the presented code, I have redesigned ... closes not the entire grid only open positions, I don't see the point of generating a bunch of closed, not triggered orders at every sneeze.

    3) How to solve them ... the principle of grid trading is like this ... we wait until either the price movement itself goes to the already opened positions in the desired direction or a sufficient number of positions in the opposite direction will be opened to cover the loss from unprofitable positions.

    5) summarise the profit and loss on open positions ... in total if there is a set profit we exit ... although I have changed it to profit in pips instead of per cent.

    6) In this robot there are no factors affecting the sideways movement ... I have added the ability to switch on or off the prohibition to set stops in the direction in which there are already open positions ... i.e. if we get into a flat, we can get two positions in different directions blocking drawdown at a certain level.

    7) I, for example, do not understand the question ... the grid hangs during the whole period of trying to catch the total net profit ... the lifetime of the pending stops does not matter here ... because the price corridor is fixed ... the stop will expire in 12 months ... ... it will simply be redrawn in the same place))))) ... in the original Expert Advisor you can set the maximum time of holding positions in the hope of getting a given profit ... i.e. if it doesn't gain the set profit level, then close it at a profit greater than zero.

    8) The price corridor is divided by the number of specified levels (orders) in the grid ... i.e. we set a corridor of 500 - 400 ... we have a corridor of 100 quid .... for example, if we set 10 orders, then the grid step will be 10 quid.

    9) Grid trading does not involve market analysis ... grid trading ideally makes money no matter where the price moves .....

    Opps. Mostly agree. I'll elaborate a bit below...

     

    Bohdan Suvorov #:

    ...

    7. What is the role and importance of the time factor in grid trading on stop orders? What time intervals or periods are considered when making decisions about placing pending orders and exiting positions?

    ...

    7. Initially (based on the possible dynamics of the futures (stock) according to statistics) it is assumed that if the trend has started - it goes smoothly upwards, for example, with small pullbacks.

    Therefore, it is assumed to trade in the direction of the main price movement of the symbol, regardless of its direction, taking into account the nature of the price movement in the past, it is assumed to use this trading approach from a week and above.

    Naturally, with control from the side. I.e. the price has chattered in the range, some number of orders have worked - further, when the price goes beyond the boundaries of the previously selected range, you can close the position yourself, for example, in parts. In fact, the inter-day interval is traded with the transfer of the position cumulative through the night.

    Timeframe for calculating the price range: min-max from a week.... month (+ is the upper boundary, - is the lower boundary).

    After that, sketch a new range network of orders.

    In essence, as trading is implemented here (yes - you don't buy cheaper - but more expensive), if the movement is going on - the position is gained gradually, if the pullbacks are not big and do not attract opposite orders, the equity grows faster, also allowing to gain further by stop orders the cumulative current position.

    Further - also outside this robot - it is possible to exit by parts, as I have realised in practice.