Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to modify an order from a strategy?

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

    How to modify an order from a strategy?

    I want to have an entry stop limit order working but it needs to have it's parameters altered as conditions change. How do I do that from the code in a strategy?

    tu Max

    #2
    To modify your order just call EnterLongStopLimit() or whichever method you were using again with your new parameters.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I suspected that might do it, thanks much...

      Comment


        #4
        I have this double entry problem where my strategy cancels the OLD limit order and
        sends in a NEW one at the opening of the next bar.

        I've able to produce this same bug few times.

        What happened was the OLD limit order did NOT cancel on time when the NEW limit order was issue. If the price touch the OLD + NEW limit order prices quickly (fast market), it will result in BOTH the OLD + NEW limit order being filled.

        Can I modify my existing LIMIT ORDER to prevent this from happening?

        Thanks!
        >Jim

        Comment


          #5
          Jim,

          As you call EnterLongLimit() again it should just modify any preexisting order. If your existing order was filled in that very instant that the order was making it across the internet to your brokerage then the scenario you are seeing is very possible.

          What you want to do in these instances is to address the extra order and immediately cancel that when you notice such a case. To cancel an order you can use CancelOrder(). Also, prevention is key here too. Try using if (Position.MarketPosition == MarketPosition.Flat) to ensure you are flat at the time of order submission. This will not weed out all race conditions, but will help keep it rare.
          Josh P.NinjaTrader Customer Service

          Comment


            #6
            To Modify a Limit order

            Originally posted by NinjaTrader_Josh View Post
            To modify your order just call EnterLongStopLimit() or whichever method you were using again with your new parameters.
            Hi Josh,
            In my strategy, I have limit order and stop/profit target orders tied to it. see code:

            entryLongOrder = EnterLongLimit(0, true, 1, entryPrice, "LongEntry");
            SetStopLoss("LongEntry", CalculationMode.Ticks, stopOffset, false);
            SetProfitTarget(
            "LongEntry", CalculationMode.Ticks, profTargetOffset);

            My question is, if I want to modify the limit price by recall EnterLongLimit(...) with a new entry price, do I need to do anything with the StopLoss and ProfTarget orders? (My guess is not, since I use the offset mode for these orders, unless I want change these offsets, Am I right?)

            Regards,
            JD

            Comment


              #7
              You are right. Changing the limit price for entry does not require changing your stop/targets.
              Josh P.NinjaTrader Customer Service

              Comment


                #8
                Nice thread.

                I was wondering, is it possible (in a strategy) to change the entry and exit prices? For example, if I wanted to measure the efficiency of an trading strategy, I would like to compare it to the results of buying at the bottom and selling at the top. That way I can measure how much of the total move gets captured by the strategy, which in turn gives an indication of quality of the strategy.

                But to arrive at the data of the total move (and all the moves in the time window), I need to code something as "if the move is over, the enter long price was the MIN(Low) value and the exit long was the MAX(high) value". Can I change the entry and exit prices afterwards? Perhaps there is a different way?

                Can anyone give me some pointers for the creation of such a (non-tradeable) strategy?

                Regards,
                Last edited by J_o_s; 07-14-2010, 03:02 AM. Reason: typo's, expanded

                Comment


                  #9
                  J_o_s,

                  Unfortunately you cannot change the entry/exit prices afterwards. What you can try to do is try creating your own fill algorithm and using that instead of the default ones supplied.

                  Josh P.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                  0 responses
                  572 views
                  0 likes
                  Last Post Geovanny Suaza  
                  Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                  0 responses
                  331 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by Mindset, 02-09-2026, 11:44 AM
                  0 responses
                  101 views
                  0 likes
                  Last Post Mindset
                  by Mindset
                   
                  Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                  0 responses
                  549 views
                  1 like
                  Last Post Geovanny Suaza  
                  Started by RFrosty, 01-28-2026, 06:49 PM
                  0 responses
                  550 views
                  1 like
                  Last Post RFrosty
                  by RFrosty
                   
                  Working...
                  X