There is a problem if I send both orders in the next.
the actual fit price is not known in next.
That's again not a problem. It's how trading works. You cannot operate on the price you currently see (you can only expect to get it in the future, but you may not) and you don't know what the next incoming prices will be.
As suggested by @ab_trader you can use cheat-on-open to have a chance to operate on incoming prices, but that defeats the purpose of backtesting and getting a profitable entry/exit approach, because you are examining prices before executing actions, what you actually cannot do in real life.
# Cerebro Sub Class
params = (("startdate", None), ("enddate", None))
if self.env.p.startdate is not None:
if self.env.p.startdate > self.datas.datetime.date(0):
if self.env.p.enddate is not None:
if self.env.p.enddate < self.datas.datetime.date(0):
# Your Logic goes here
This works as intended but not as efficient as it can be since the indicators are calculated inside the strategy from the beginning of the data feed.
@ab_trader - I am doing my best. I have already submitted pull requests for new Fisher Transform indicator and Simulated Order. And I am sharing all my code snippets here along with explanations whenever relevant.
When I say the framework should have this or that, I dont mean that someone should implement them but that we shall implement it for everybody's benefit.
Cerebro doesn't know that you are looping and cannot know it. The runs inside the optimization re-use the file which has already been loaded, but the runs doesn't know that you had another set of runs before with the same file.
You could try to keep the data feed outside of the loop and execute a data.home() after the cerebro.run(...) is done to reset the pointer.
The platform is not meant to deliver bid/ask prices. Those only make sense when you are working with ticks or else you have to implement a resampling model and decide whats the askandbid` prices you return with higher timeframes.
@gindeleo thanks for your answer. I am not using Oanda data feed. I want to use an internal data feed that I have. Will try to understand the one implemented with Oanda (in the link I sent) and see if I can adapt for my case.