The following code is meant to trade the next Daily bar on the Close but is instead sometimes trading at the Open of the following day and sometimes at the Close. In both cases the Trade Date is reported as being the day before the price actually occurred as an Open or Close; so the backtest shows an incorrect date for the trade and is trading at a different point than intended. This occurs for buys and sells though the code below is for a sell:
Code: Select all
if Condition1 then sell short next bar at close limit