Hi,
1. when order is placed at OnExecutionUpdate Stoploss or trailstop is not placing for new order ?
2. When new order is placed quatity is getting doubled .Please let me know why it is doubled.?
protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
{
Print("OnExecutionUpdate="+execution.Name+"executi onId="+executionId+"price="+price+"time="+time);
if(execution.Name=="Buy"){
Print("normal buy");
isNormalBuy=true;
isNormalShort=false;
}
if(execution.Name=="Sell short"){
Print("normal Short");
isNormalShort=true;
isNormalBuy=false;
}
if((execution.Name=="Stop loss") || ("Trail stop"==execution.Name)){
Print("normal Stop loss");
if(isNormalBuy) { Print(" BUY SL Executed so enter new SHORT");
EnterShort(Convert.ToInt32(DefaultQuantity));
SetTrailStop(CalculationMode.Percent, 0.0003);
isNormalShort=true;
isNormalBuy=false;
}
if(isNormalShort){ Print(" Short SL Executed so enter new LONG");
EnterLong(Convert.ToInt32(DefaultQuantity));
SetTrailStop(CalculationMode.Percent, 0.0003);
isNormalBuy=true;
isNormalShort=false;
}
}
}
Comment