One Problem with the “Next Bar” Paradigm – market position nor entryPrice are adjusted by the end of the bar
Whenever I develop a strategy I like to program all of my entries and exits without utilizing TradeStations built-in execution functions. I just got use to doing this when I started programming in Fortran many years ago. However, there a few scenarios where this isn’t possible. If you enter a trade and use the following logic to get you out with a loss or a profit when referencing your entryPrice, you will be surprised with your results. This is because you are telling the computer to use entryPrice before you know what it is.
This logic is absolutely correct in its intention. However, TradeStation doesn’t realize you are in a position at the end of the bar and can’t properly reference entryPrice. Okay so we force TradeStation to only issue orders once it has a valid entryPrice.TradeStation only realizes the correct marketPosition the following day and then issues an order for the next bar. So we get the one bar delay. It would be helpful if TradeStation would set the marketPosition at the close of the bar on the bar of entry. However, you can overcome this with TradeStation’s built-in execution functions. For some reason these functions know exactly when you get in – you can also get the same results by inserting the respective strategies on the chart.
But this little bug can creep into other areas of your programming. Keep an eye on this.