Course Name: Deep Reinforcement Learning in Trading, Section No: 22, Unit No: 3, Unit type: Notebook
Hello ,
i am trying a strategy in live . But sometimes the price go very down and i want to avoid this situation .
How to set up a stop loss in order to have a strategy who can record also when the stop loss is used and learn from that ?
thank
Hi Christelle,
You can do the same in the following way.
In the backtesting function under the "while not game over" loop you can add an if condition:
When env.pnl is less than your desired stop loss you can take either of the two actions based on the current position. If current position == -1, set the action = 2 i.e. buy and if current position == 1, set action = 1, i.e. sell. This will end the game and get rewards & trade duration.
Hope this helps!
Thanks,
Akshay