Thanks for your advice and I have now finished writing and testing my code, it can work really well now.
But my last step is try to plot the performance. I tried to use the basic plot function, but it seems that it plot the stocks separately (as shown in the portfolio). Is there any way to plot at portfolio value?
Thanks for the detailed reply. Agree there was some clumsiness about the setup, but I had mirrored what I had in a single data example which was working. I have streamlined it now though per your suggestion.
Anyway, after some banging of my head on the desk, I found what was wrong with my multi-data version and it was simple.....the magical runonce=False, which i hadnt copied over from my single-data example.
# Run over everything
cerebro.run(runonce=False, maxcpus=1) # runonce = False is required
now it all works as expected. Thanks for helping me though it. Hopefully the Dynamic Trailstop indicator is useful to other folks too now that its shared. Cheers!
@run-out I understand that - I mentioned that in the initial post. My question is why were close_over_sma, close_over_ema, sma_ema_diff and buy_sig created in the Strategy rather than one or all of them being created as their own Indicator object?
What benefit was achived by creating them in the Strategy, and what benefit would have been achieved by creating them as Indicators?
The question isn't about init vs next. I'm trying to understand when I should create my own Indicator objects and when I should just put everything into the Strategy object.