The buy price, which is “TradePrice”, is graphed at 1.04910; the blue arrows indicating the entry show it at over 1.0520. When I run the backtest, I do NOT have the “Spread” option checked (enabled).
It’s similar for the sell as well.
Here is the relevant code. This is the only place in the code where the value for theBuyTradePrice is set and also the only place in the code where the values are graphed:
Code is read at Close, and orders are launched at next open, it means that at the time when the code is read, we have no hint of what would be the exact open price, you’ll have to wait for the order to be launched for that.. (next bar!).
1) the “tradeprice” should be the same “open” price of the next bar if the orders are executed on the next open, correct?
2) to get the actual price, we have to set a flag to let us know when the next bar comes around. Then, when that next bar does come around, we can do “tradeprice” to get the exact price from the order in the code executed from the previous bar’s close?
3) Or is there an easier/better way to do #2 above?
To help us continually offer you the best experience on ProRealCode, we use cookies. By clicking on "Continue" you are agreeing to our use of them. You can also check our "privacy policy" page for more information.Continue