I am developing a strategy for backtesting and I am not certiain of the following three items:
1. I am using OnOrderUpdate(IOrder order) function and I am using the fololowing code in OnBarUpdate()
if(null == entryOrder && actualStatus >= minP)
EnterLong(0, 1, Instrument.FullName);
elseif(null == entryOrder && actualStatus <= -minP)
EnterShort(0, 1, Instrument.FullName);
My question is: Is this correct usage?
2. I am NOT using OnPositionUpdate(...)
but I have the following code in OnBarUpdate()
if(Position.MarketPosition == MarketPosition.Long)
{
... custom trailing stop calculation
// Exit position condition
ExitLongStop(trailStop);
}
elseif(Position.MarketPosition == MarketPosition.Short)
{
... custom trailing stop calculation
// Exit position condition
ExitShortStop(trailStop);
}
Here is the weird thing for me. I am constantly getting MarketPosition as Flat even though backtesting shows that I am entering positions. Can anyone please suggest how I can get MarketPosition to show Long or Short when an order is entered? Dop I need to use OnPositionUpdate() method?
3. I wish to use a custom trailing stop. I understand that in Backtesting the only price available is the Price.Average. Any suggestions as how I could actually get and use the fill (entry) price?
Thank you very much for any advice you may be able to offer.
P

Comment