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 charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        66 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        149 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        162 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        99 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        286 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X