To check if my strategy was correct I tried to replicate the results from the following website:
Golden Cross – Which is the best?
I'm making the calculations for 6 indexes instead of 16 like that website because it takes a long time to finish. And I don't know if I'm using the same beginning and end dates as the website. I'm using 1994-01-01 to 2019-12-31.
But even with this differences I would expect the return to be more similar to the one from the website. For the 13-48 EMA crossover I get a 4.23% total return and the website for the 13-48.5 gets a 10.16% on the long side.
I was thinking maybe if I only execute long orders I get a higher return? But even though the return on the short side is lower it is not negative so it shouldn't decrease the total return.
Other thing that might be happening is that I can't compare the results from the TimeReturn analyzer that I'm using with the annual return from the website but I've used that beggining and end date to be 25 years exactly.
What might be making my results to be lower than those from the website?
In my table I'm using TimeReturn and the one below uses Annualized Return During Exposure so I'm not expecting them to be the same. I just expect the maximum from my table to be close to 10.16%.
@vladisld Thank you for your answer! However I got another error from that inheriting part : "feed" since I don't know about backtrader very much yet so I googled but couldn't find how to import relevant module to find "feed" class. ..
@dasch @vladisld Thank you! This explains why my tests are more profitable on lower timeframes. Because the SL and TP get hit in the order they occur, so sometimes TP occurs first. Whereas on the higher timeframe, sometimes they both occur in the same bar, and BT will execute the SL first.
@genkisushijai said in Buy/sell and P&L indicators plotted incorrectly:
@ab_trader Thanks ab_trader.
Does anyone else know how to fix the Buy/Sell indicators in incorrect position, in the 2 data feed scenario?
pass oldtrades=True to cerebro
@Eduardo-De-La-Garza said in How to handle repeated code in next and prenext?:
From what I understand that would overload the function and the parent code wouldn't run.
inside of MyBaseStrat
then overwrite next2 for your strategy specific functionality
Please take a look at the following docs:
backtrader calls next when all buffers (indicators, data feeds) can deliver at least data point. A 100-bar moving average will obviously only deliver when it has 100 data points from the data feed.
This means that when entering next, the data feed will have 100 data points to be examined and the moving average just 1 data point
backtrader offers prenext as hook to let the developer access things before the aforementioned guarantee can be met. This is useful for example when several data feeds are in play and they start date is different. The developer may want some examination or action be taken, before all guarantees for all data feeds (and associated indicators) are met and next is called for the first time.