Course Name: Price Action Trading Strategies Using Python, Section No: 26, Unit No: 10, Unit type: Notebook
Hello, even after getting analytics where the total PnL is negative the strategy shows a positive cumulative return. Why is this?
https://i.imgur.com/wOxaH8O.png
Hi Daniel,
As you know, PnL is simply adding the profits and subtracting the losses. Hence you got a negative number in PnL. However, the profit factor is fractional value. ( (
Thanks for your answer Rekhit,
However check the equity's chart: it shows a positive cumulative returns, why? It should be negative equity curve…
Hi Daniel,
Let me check and get back to you.
Hello Rekhit,
Did you find why is the equity curve positive?
Hi Daniel,
This was an interesting case, but after a thorough review of the backtesting conditions, this was fixed and now both the PnL and equity curve results are consistent.
Thanks.
Can you tell me what was wrong to check if I have the same error?
Hi Daniel,
You should check that all types of scenarios ie combinations and permutations are considered when you are updating the current position. This includes if you are holding a position and the current signal tells you to exit.
Hope this helps.
Please share the new code changes in the backtester function to update mine.
Thanks.
Hi Daniel,
It has been updated in the utility file.
Hope this helps.
Sorry,
I've downloaded the script again and it doesn't have any change. Please update here the fix…
Hi Daniel,
The zipfile has been checked and updated again. Can you download the zip file from the last section of the course and check the "backtester" function in the "price_action_util_quantra.py" file in the "data_modules" folder of the zip file. The code added is an if condition for both short and long position. We are also checking if we have an open position and the signal is to exit.
Hope this helps.
But adding a close by "signal" will change the purpose of the strategy and all the strategies on the course: enter at some price and exit ONLY when TP / SL has been reached.
Now it's true the equity it's showing correctly but IMO the solution should be calculate strategy performance based on entry_date and exit_date of the tradebook and place between these dates the column "signal" = 1 and then multiply "signal".shift(1) * "Close".pct_change().
Hi Daniel,
There are different ways to execute and backtest a trading hypothesis. In the strictest sense, your point on exiting only when TP/SL is reached is valid. And yes, it will be a different strategy altogether from one where we are also checking another condition where the signal is changed.
With respect to the change in purpose of the strategy, let us evaluate once and get back to you.
But yes, your idea seems right as well and might be a different strategy as well.
Hope this helps.
Thanks, I'll wait for your reply.
Hi Daniel,
As we had mentioned, there are different ways to create the strategy. We went through the strategy and updated it to include only the stop loss and take profit level related exits, as you have mentioned. We also showed an alternative approach using different take profit exits.
Thanks.