if(Short)
// Basket order 1: submit a market order with 1 qty , trail stop 10 tick & target 10 tick
// Basket order 2: submit a limit order Ask + 3 ticks with 2 qty :- trail stop 8 tick & target 20 tick
// Basket order 3: submit a limit order Ask + 7 ticks with 3 qty. - trail stop 6 tick & target 30 tick
ach of these will have a different trail stop and target. i have coded majority of the part but for some weird reason ninja is throwing moving ordr 1 trail stop loss below market price even if the price is going down, actually changing trail stop. this only happens when trail stop becomes very close to order 2/3 limit price and once they are filled ninja is changing order 1 trail stoploss for weird reason moving it up above market price and resulting into below exception.
2019-07-13 21:17:59:337|0|32|Playback101, Stop price can't be changed below the market. affected Order: BuyToCover 2 StopMarket @ 59.43
Attaching log for review, as well as some of my snippet which is creating long order and placing stoptrail order.
On barUpdate:
if(BarsInProgress == 1) { 1 second data series
if (SHORT_CONDICTION ) {
exitOpenPendingPosition(); // exit any open limit order if they are not yet filled.
if (PositionAccount.MarketPosition == MarketPosition.Long) ExitLong();
EnterShort(1,"ShortOrder-MKT"); // Basket Order 1: Market Order
entryOrderShort1a = EnterShortLimit(0,true,2,GetCurrentAsk() +3*TickSize,"ShortLimitOrder-1a"); // Basket Order 2: Limit Order
entryOrderShort1b = EnterShortLimit(0,true,3,GetCurrentAsk() +7*TickSize,"ShortLimitOrder-1b");// Basket Order 2: Limit Order
lastShortBarCounter = CurrentBars[0];
}
}
if(State == State.DataLoaded) {
SetProfitTarget("ShortOrder-MKT", CalculationMode.Ticks, target_MktOrder); // Basket order 1: Target
SetProfitTarget("ShortLimitOrder-1a", CalculationMode.Ticks, target_basket1); // Basket order 2: Target , keep order 3 open and only trail.
SetTrailStop("ShortOrder-MKT", CalculationMode.Ticks, 10,false);//, 0.03, 0.3, 0.01);
SetTrailStop("ShortLimitOrder-1a", CalculationMode.Ticks, 8,false);//, 0.03, 0.3, 0.01);
SetTrailStop("ShortLimitOrder-1b", CalculationMode.Ticks, 6,false);//, 0.03, 0.3, 0.01);
}
Comment