PaulParticipant
Master
Is it possible in the the orderlist (and the closed positions list?) from a backtest to display why the trade exits if they are custom programmed?
That would be use-full information, perhaps as an extra column.
from a backtest to display why the trade exits
Sounds good! I’m intrigued.
What would be an example reason?
The reason why a strategy exits is always the same – because your strategy sent an order to the market!
The easiest way to find out which order is to run a back test version of the strategy which sets a flag every time an exit condition is met and then GRAPH the result.
c1exit = 0
if longonmarket and c1 then
c1exit = 1
sell at market
endif
graph c1exit
For pending orders you have to work out if they were hit.
sell at exitprice limit
pendingsellexit = 0
if longonmarket and high > exitprice then
pendingsellexit = 1
endif
graph pendingsellexit
If you use SET TARGET PROFIT then you need to similarly check to see if your exit price was ever hit.
To make it more accurate you really need to include some sort of spread in the calculations.
PaulParticipant
Master
In the charts I can see why it exits and your suggestion is also nice!
But the purpose for the request is to have it displayed in the orderlist, just like the built-in exit profit/stoplos/trailing are displayed.
If the strategy has 6 custom reasons to exit, those reasons would be nice to have a name in the orderlist. Not just “exit”.
Although something minor I still thought worth mentioning.
But what if you had 100 reasons to exit? What if 50 of these reasons to exit were true at the time of exit? Would they need to add 100 columns? How would they know what conditions were met without you coding something into each strategy to say this is reason 1, this is reason 2…… this is reason 100?
Often when I code a strategy I will add code that counts how many exits can be allocated to each reason and how much profit each reason would have made. This helps you see how over optimized each exit is.
PaulParticipant
Master
only one column was needed, or none if it was done like the built-in sl/pt/ts.
But I see your point! If more exits where true it would be a problem.
Thanks for the feedback!
What we need is a textual log journal, it would be much easier to debug and understand the orders behavior! 🙂