Send new trade at open
-
Hello everybody!
Reading the doc https://www.backtrader.com/docu/cerebro/ i found the following note:In step 1 above when the data feeds deliver the new set of bars, those bars are closed. This means the data has already happened.
It is correct, of course, to avoid look-ahead bias and provide reliable backtests, but there are strategies that need a different timing of entry.
For example, please consider a classical crossover strategy based on a simple moving average on OPEN PRICE.
In that case if the open price is crossing the moving average (based on OPEN PRICE too) i should put my order there without waiting the next candle. Why should my order be executed on the next candle?
Maybe it is a rare situation, and prevent look ahead is correct too. But if all my strategy is based on opens i should execute my order at open price, without waiting the next new candle.
Does it make sense?
-
you may want to read docs further and find out
cheat-on-open
feature, which allows to trade usingopen
prices.working with the daily bars and making decisions on the
open
(ie inside the bar) is cheating and should be done considering accurate slippage, since it takes some time to make a decision (5 min, 10 min, 30 sec whatever). Make a trade on the exactopen
price is sometime impossible, especially on the very quick markets. For example, I was founding the case when simulating the trade on theopen
gives profitable strategy, but use of the price at 5 min after open was breaking the strategy. -
Thank you! I did not reach that part of doc, grr.. sorry.
Ok, so the good thing is that we can send order on open too. Yeah the slippage "problem" is correct, you are right, i need to handle it carefully.However, i also have read that we can run some optimizers giving a range of indicator's parameters, the optimizer basically find the best set of parameters. It could be useful for me but, again, there maybe be a problem with timing.
Suppose the same crossover strategy with a simple moving average, and run the optimizer to test the moving average on Open, High, Low, Close ... is there a way to set that COO parameter WHEN the base price of that indicator is "open" ?
-
@damiano said in Send new trade at open:
Suppose the same crossover strategy with a simple moving average, and run the optimizer to test the moving average on Open, High, Low, Close ... is there a way to set that COO parameter WHEN the base price of that indicator is "open" ?
I don't understand your question. You can create your simple moving average on any time series in
bt
.cheat-on-open
is independent from the indicators.