In this recipe, you will continue with the coding of the StrategyMACDBracketOrder class. Here, you will code the strategy_enter_position() method, a mandatory method enforced by the StrategyBase base class. This method is called by the AlgoBulls core engine every time the strategy_select_instruments_for_entry() method returns non-empty data. This method may not be called for every new candle for backtesting, paper trading, and real trading services.
Please refer to the flowchart in the introduction of this chapter to understand how the AlgoBulls core engine calls the strategy_enter_position() method during strategy execution.
Getting ready
Make sure you have followed the previous recipe before starting this recipe.
How to do it…
Continue coding the StrategyMACDBracketOrder class. Define a method to punch new orders for a given instrument and enter a new position:
class StrategyMACDBracketOrder(StrategyBase...