Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Problem with entering the market with a stop limit

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

    Problem with entering the market with a stop limit

    Hello

    I want to enter the market with a stop limit, but also to say that if market goes 10 ticks away from my limit, then limit must be removed from the market. I try already using this code:

    private double limitRemove = 10;
    ...
    EnterLongStopLimit(1, High[5] + 1 * TickSize, High[5] + 1 * TickSize - limitRemove * TickSize);


    Trying with
    private IOrder myEntryOrder = null;
    ...
    OnBarUpdate()
    {
    currentValue = High[5] + 1 * TickSize;
    ....
    }
    ...
    myEntryOrder = EnterLongLimit(0, true, 1, High[5] + 1 * TickSize, "Buy");

    ....

    if (myEntryOrder != null && currentValue == (orderValue - limitRemove * TickSize))
    {
    CancelOrder(myEntryOrder);
    }

    It is compiling, but not working. Where can be the error?

    Thanks for help!

    #2
    Hello,


    Thank you for your note.


    What specifically is not working with it? Does the limit order submit or does it not cancel?

    Finally If you add TraceOrders = True in the Initialize Method you will be able to trace the orders to see what is happening.




    I look forward to assisting you further.
    BrettNinjaTrader Product Management

    Comment


      #3
      I forgot to say it before I put
      TraceOrders = true in Initialize()
      but still trades do not cancel.

      I don't see difference between using EnterLongLimit with or without CancelOrder when I backtest strategy for a 30 days. I don't see it either when I use EnterLongStopLimit.

      Thanks

      Comment


        #4
        If the order never cancells this means this code never runs:

        if (myEntryOrder != null && currentValue == (orderValue - limitRemove * TickSize))
        {
        CancelOrder(myEntryOrder);
        }

        Would suggest adding a print to find out why this would not run.

        -Brett

        BrettNinjaTrader Product Management

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        648 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        369 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        109 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        573 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        575 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X