1) I assume that the Unmanaged Approach can only be used for real time, is this correct?
2) I am trying to backtest a strategy that enters on a stop and always has a stop and limit associated with the entry. I would like to be able to reverse the position if, in a trade that has not been taken out by a stop or limit. I can't get the strategy to reverse. Below is a condensed version of the entry/exit code. Is there anyway to allow reversals under these conditions in the Managed Approach. can I use the unmanaged approach for backtesting?
NOTE- The undefined variables below are defind in the actual code. I used "....." as place holders
protected override void OnBarUpdate()
{
.
.
.
// Long Entry
Condition1 = ......;
if(Condition1 && Position.MarketPosition != MarketPosition.Long )
{
EnterLongStop(ContractsToTrade,FactorBuyPrice,"Fac torBuy");
Factor_LongStopPrice = .....;
Factor_ShortStopPrice = ......;
}
// Short Entry
Condition2 = ........
if(Condition2 && Position.MarketPosition != MarketPosition.Short )
{
EnterShortStop(ContractsToTrade,FactorSellPrice,"F actorSell");
Factor_ShortStopPrice = .......;
Factor_ShortLimitPrice = .......;
}
// Exits
ExitLongStop(ContractsToTrade,Factor_LongStopPrice ,"FactorL_Stop","FactorBuy");
ExitLongLimit(ContractsToTrade,Factor_LongLimitPri ce,"FactorL_Limit","FactorBuy");
ExitShortStop(ContractsToTrade,Factor_ShortStopPri ce,"FactorS_Stop","FactorSell");
ExitShortLimit(ContractsToTrade,Factor_ShortLimitP rice,"FactorS_Limit","FactorSell");
}
Comment