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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    87 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    132 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    68 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    118 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    67 views
    0 likes
    Last Post PaulMohn  
    Working...
    X