In the Backtest Order Flow Stategy Module I saw a large amount of backtest trades that seemed to open and close at the midpoint. I was wondering if these were actually simulated trades or not. I'm modifying parts of the code to see if I can improve the results. Has anyone tested this module in the course?
This is an example of the output of a trade that opened and closed at the same price:
Entering long position
Long entering time 2013-10-02 02:58:16.233600
pos is 1
exiting long
long exiting time 2013-10-02 02:58:37.488000
[Timestamp('2013-10-02 02:58:16.233600'), Timestamp('2013-10-02 02:58:37.488000'), 1, 1430.875, 1430.875]
pos is 0
Hello,
As you have rightly pointed out, the trades were closed at the entry price (midpoint). There are a few reasons for this trade behaviour in the backtester, which I will explain below:
1. Data selection:
The backtest was performed on E-mini S&P 500 futures specifically for the date 2013-10-02.
It is important to note that the trading activity of the contract on that particular day was relatively low. As a result, the midpoint remained unchanged for many ticks, leading to a higher number of trades being closed at the entry price. Out of the 61624 ticks analyzed, there were only 168 unique midpoints due to the limited trading activity on the selected date.
To address this issue, it is recommended to choose a more active contract or a different trading day. This would introduce more frequent changes in the midpoint and provide additional scenarios for entering and exiting trades at different prices.
2. Trading rules:
The defined trading rules themselves may contribute to the scenario of trades being closed at the entry price.
For instance, the thresholds set for stop-loss and take-profit levels, as well as the one-minute look-back period, can result in trades with very short holding periods. Modifying these thresholds and look-back periods for evaluating stop-loss and take-profit breaches can have a significant impact on the holding period and reduce the frequency of closing and entering trades at the same midpoint.
I would like to emphasize that this backtesting notebook serves as a template to construct an event based backtester. To optimize the performance of the strategy and the behaviour of trades, we encourage you to experiment with different look-back periods and thresholds for determining entry and exit conditions. This iterative process will allow you to refine and enhance the strategy accordingly.
I hope this helps!!
Thank you
Perfect! Thank you very much!