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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    47 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    23 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    33 views
    1 like
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    50 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Working...
    X