cheat-on-close in the forum and documentation.
Posts made by ab_trader
RE: Broker to execute the order with the closing price and not with the average price
RE: Initializing Indicator Changes Portfolio Value Without Touching Buy/Sell Logic
With the new indicator you introduce longer period of waiting to get long term indicator value. Therefore in your backtest you have less trades open and therefore different PnL.
RE: highest/lowest function, get date of trigger candle
Try to use indicators
RE: Easy Strategy: Begginer RSI
But with only buying, it happens:
Your code has no means to print this.
If someone can explain me why it doesn't function... I will be very grateful.
First, your code is functioning, it prints logs. Second, if somehow it doesn't, show us what did you do to debug your own code before post the question on the community forum?
To avoid duplicate steps.
RE: margin problem when selling then buying in next
Even though the sell orders get executed before the buy orders, the value of the portfolio isn't updated. hence no available balance for the set of buying order.
Cash is updated internally after each executed sell/buy order, but the broker cash amount is delivered to the strategy level only at the next price available. On your issue my guess (since your logs don't show any issues, than guess only) would be is that you affected by differences in close and open prices. You rebalance the portfolio based on the previous bar equity and previous bar close prices, but orders are executed based on the coming bar open prices. Open prices are usually different from previous close prices, therefore it maybe not enough money from sales to execute buy order, especially last one. Use 95-99% of the portfolio equity to mitigate this effect.
To have earlier cash change notifications try to set
quicknotify=True, might help to see the changes in cash, but I don't think that the issue is here - Docs - Cerebro - Reference
I am also having the same confusion. Seems like the BT takes in all orders in the loop at once and processes it later.
Reading docs will help to avoid confusion and guessing Docs - Cerebro - Backtesting Logic
RE: How to add a StopTrail to an existing position
Is it possible to add a StopTrail to an existing position without issuing another buy/sell order?
The answer is NO, because the StopTrail actually is a buy/sell order.