Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

strategy ignore entershortlimitorder when im in long

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    strategy ignore entershortlimitorder when im in long

    Hello I hope you doing well
    when im in longtrade i want to exit trade and make a limit order
    the strategy ignore limit order

    here is the code


    else if(((ab.ShortSignal[0] == 1 ) ) && !sell1 && BarsInProgress == 0 && Short && Position.MarketPosition != MarketPosition.Short){



    ExitLong("Buy1");

    ExitLong("Buy2");






    if(true ){

    if(GetCurrentBid() > c1[0]){



    // Stop Loss

    SetStopLoss("Sell1", CalculationMode.Price, GetCurrentBid() + isl*TickSize, false);

    SetStopLoss("Sell2", CalculationMode.Price, GetCurrentBid() + isl*TickSize, false);



    // Profit Target:


    SetProfitTarget("Sell1", CalculationMode.Price, GetCurrentBid() - tp1*TickSize);

    SetProfitTarget("Sell2", CalculationMode.Price, GetCurrentBid() - tp2*TickSize);


    EnterShort(q1,"Sell1");

    EnterShort(q2,"Sell2");

    }

    else{

    SetStopLoss("Sell1", CalculationMode.Price, c1[0] + isl*TickSize, false);

    SetStopLoss("Sell2", CalculationMode.Price, c1[0] + isl*TickSize, false);


    // Profit Target:

    SetProfitTarget("Sell1", CalculationMode.Price, c1[0] - tp1*TickSize);

    SetProfitTarget("Sell2", CalculationMode.Price, c1[0] - tp2*TickSize);



    EnterShortLimit(0, true, q1, c1[0], "Sell1");

    EnterShortLimit(0, true, q2, c1[0], "Sell2");

    }










    #2
    Hello ajgauss13,

    To understand why an order is ignored, enable TraceOrders and view the output in the output window.


    It does take time for orders to fill and for the position to change.
    If you would like to submit an exit and then submit a new entry, you will need to wait for the order to fill in OnExecutionUpdate() and send the new order from there.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    161 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    81 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    125 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    206 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    184 views
    0 likes
    Last Post CarlTrading  
    Working...
    X