Add a 2nd data feed, create the moving averages on the different feeds and check the crossover.
The crossover indicator doesn't care what the moving averages are tracking (it could be a moving average of another indicator)
If your problem is adding a 2nd data feed: https://www.backtrader.com/blog/posts/2017-04-09-multi-example/multi-example/
But the code in the home page DOES apply.
@backtrader BTW, do you know how can I replace the following line?:
exec('self.lines.' + i + ' = DfMresistances.value.take([n])')
I tried to use thes two alternatives, but they don't work:
setattr(self, 'lines.' + i + '', DfMresistances.value.take([n]))
setattr(self.lines, + i + '', DfMresistances.value.take([n]))
@backtrader thank you for the explanations.
Yes, I was trying to use one symbol that's trading on pre-market to trigger prenext. As you can see it didn't help much, i.e. it crashed backtrader.
What I was trying to ask (and apparently failed) is: if creating orders without price data supported by backtrader at all? If it's possible then it would be great if you explain how to do it without loading data as @ab_trader suggested. If it's not possible ... well I'll try to work around it using @ab_trader's suggestion.
@MarkWhatson answering your initial question - you need to add conditions for your force selling to __init__ or next() and then issue corresponding orders in the next(). This is all I can say based on what was shown here.
That's right. This works:
data = ibstore.getdata(dataname="AAPL-STK-SMART-USD", historical=True, fromdate=datetime(2019, 1, 1), todate=datetime(2019, 8, 1), timeframe=bt.TimeFrame.Minutes, compression=5)
I am sorry for having been a nuisance. BT is an impressive project and the forums show that you provide prompt and straight-to-the-point support even to stupid questions. Keep up the good work!
Thanks for the reply.
Im using Oanda v1 as per backtrader docs. Everything works in terms live data feed or adding static data from file or pandas but the backfill_from is giving me trouble.
In any case ill try to migrate to v20 and see if i get the same troubles.
It is a library and although nothing prevents a broker implementation which can be called from different instances, no such thing exists.
Unless you can provide more details, I can only guess you have to use standard methods and tools to work, such as git (directly or over a provider like GitHub, GitLab, ...), Slack/Teams, ...