I am relatively new to backtesting and I want to migrate my system to simulated trading via Amibrokers Interactive Broker's API.
What I have been doing is setting trade delays such that when a Buy or Short signal occurs, the algorithm buy or short on the next Open.
Here is a sample code:
**BuySignal = Cross( Close, MA(Close, 100 ) ); // buy on the next bar Buy = Ref( BuySignal, -1); BuyLimitPrice = Ref( Close, -1) * 0.99; // now we check if limit was hit Buy = Buy AND L < BuyLimitPrice; // if Open price is below the limit, then we use Open for entry BuyPrice = Min( Open, BuyLimitPrice );**
The question is that: When you migrate this to real-time or simulated trading, what price do you use for Open?
This is what I am struggling with - there are two options:
a) Use real-time data for the price of the stock (i.e., GetRTData( "Last" ) ) which is the "last" value that the ticker was traded at, or
b) Use the value of Open of the stock for that bar, which can be obtained by the system.
Which value is the correct or the best one to use (i.e,