the code that produces the stop order is below.
[FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] OnExecution(IExecution execution)
{
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]//if (entryOrder != null && entryOrder.Token == execution.Order.Token)
[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// Print(execution.ToString());
[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// we have execution. now handle the trades.
[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]( (entryorder!= [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] ) && (execution.Order.Token == entryorder.Token))
{
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// make sure that there is a stop
[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2](exitstoporder != [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]null[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])
{
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// modify the exitstoporder to have the full position value.
[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]}
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]else
[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]{
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]switch[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (execution.MarketPosition)
{
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]case[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] MarketPosition.Long:
ExitLongStop(entryorder.AvgFillPrice- ATRValue, SIGNALZLREXIT_STOP, SIGNALZLR_ENTRY);
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]case[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] MarketPosition.Short:
ExitLongStop(entryorder.AvgFillPrice+ ATRValue, SIGNALZLREXIT_STOP, SIGNALZLR_ENTRY);
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]default[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]:
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// crap happened.
[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]Log([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"It reached OnExecution/switch (execution.MarketPosition) default section "[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], NinjaTrader.Cbi.LogLevel.Alert);
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]break[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2];
}
}
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// check if we have partial or full fills
[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]}
[/SIZE][/FONT]

Comment