for (int esuhs = 0, esuhsx = intSizeESES; esuhs < esuhsx; esuhs++)
{
if (intSizeESES >= 1)
{
myEntryOrderESSHORT = SubmitOrderUnmanaged(1,OrderAction.Sell,OrderType. Limit,1,CurrentDayOHL(Opens[1]).CurrentOpen[0]-14,0, "", "ES SHORT LIMIT"+ esuhs);
barNumberOfOrderES = CurrentBars[0];
EStradetoday = true;
}
}
OnExecution the following code successfully creates the associated StopLoss and Profit Targets:
if (myEntryOrderESSHORT != null && myEntryOrderESSHORT == execution.Order)
{
for (int esuhsx = 0, esuhsxx = intSizeESES; esuhsx < esuhsxx; esuhsx++)
{
if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
{
myStopOrderESSHORT = SubmitOrderUnmanaged(1, OrderAction.BuyToCover, OrderType.StopMarket,1,0,((Math.Max(MinStopESx, (ATR(Closes[1], 5)[1]*10))) + CurrentDayOHL(Opens[1]).CurrentOpen[0]),"oco"+GetAtmStrategyUniqueId()+esuhsx, "ESUHSHORTstop"+esuhsx);
myTargetOrderESSHORT = SubmitOrderUnmanaged(1, OrderAction.BuyToCover, OrderType.Limit,1,PriorDayOHLC(Closes[1]).PriorClose[0]-20,0,"oco"+ GetAtmStrategyUniqueId()+esuhsx, "ESSHORTtarget"+esuhsx);
if (execution.Order.OrderState != OrderState.PartFilled)
{
myEntryOrderESUHSHORT = null;
}
}
}
}
QUESTION: How do employ ChangeOrder in this case to adjust the stoploss myStopOrderESSHORT and profit target myTargetOrderESSHORT levels to new values? Something like this? Do I reference the myStopOrderESSHORT" or can I loop through the "ESSHORTtarget"+esuhsx" signalname? Regards and many thanks.
for (int esuhsc = 0, esuhscx = intSizeESES; esuhsc < esuhscx; esuhsc++)
{
ChangeOrder(myStopOrderESSHORT,myStopOrderESSHORT. Quantity,0,Position.AveragePrice+((Math.Max(Mi nStopESx, (ATR(Closes[1], 5)[1]*10)))));
ChangeOrder(myTargetOrderESSHORT,myTargetOrderESSH ORT.Quantity, Position.AveragePrice-(CurrentDayOHL(Opens[1]).CurrentOpen[0] - PriorDayOHLC(Closes[1]).PriorClose[0]),0);
}
}
Comment