Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Quick IOrder questions

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

    Quick IOrder questions

    I have just been finishing up a simple strategy with IOrders and I had the following questions

    1) When using the OnExection() method, the method will update on the event automatically, so I dont need to call it anywhere (because I tried calling it and I got an error)

    2) If that is the case, will the OnExection() method also update on the exit of a position? Does the method know the difference between entreris and exits? Is there a way to call just when the entry is filled

    3) With the IOrder I added a Profit and loss target (which I hope i can do), that I assume are submitted when the order is first executed on the entry. I want to cancel those Profit and Loss target after XX bars. So I called the CancelOrder() method after my counter reaches XX, and canceled the original order. Are the profit and loss targets treated as member of the original order, or do I need to make new orders for each

    Thank you kindly

    #2
    bah I just found the SampleOnOrder Upadte strategy. So I guess the orders are not links, though I do remember seeing something for OCO orders.

    No big deal, so I guess I have to make separate stop and profit loss orders. Kind of annoying but then I do get to have more control over them

    Cheers previous material on the forms!

    Comment


      #3
      eurostoxx,

      I am happy you figured it out.

      Please let us know if you require additional assistance.
      Adam P.NinjaTrader Customer Service

      Comment


        #4
        last question, which I guess I will find out very soon when I try it on the sim, but to update an IOrder (say to move the price up or down) do I need to delete the old intance of it and then make a new one, or if I just create a new one, will it delete the old one, assuming that same signal name.

        From the code I have been reviewing it seems I dont need to cancel it

        Comment


          #5
          eurostoxx,

          You can simply resubmit the order at the new price.

          Here is an example : http://www.ninjatrader.com/support/f...ad.php?t=33998

          For a helpful reference sample on using IOrder objects, please see the following link : http://www.ninjatrader.com/support/f...ad.php?t=45474

          Please let me know if I may assist further.
          Adam P.NinjaTrader Customer Service

          Comment


            #6
            excellent. Thanks. Now I just have a little problem entering orders within the OnExecution() method.

            On historical bars, I am getting an error for my exit and stop loss order. Any ideas?

            Here is what I am doing

            if (myEntryOrder != null && myEntryOrder == execution.Order)
            {
            // do a bunch of stuff
            //Set the profit and loss orders
            myExitOrder = ExitLongLimit(0, true, 1, exit_price, "signal1_exit", "signal1");
            myExit_StopOrder = EnterLongStop(0, true, 1, exit_price_stop, "signal1_exit_stop");
            if (myExitOrder != null && myExitOrder == execution.Order)
            {

            CancelOrder(myExit_StopOrder);

            }

            if (myExit_StopOrder != null && myExit_StopOrder == execution.Order)
            {
            CancelOrder(myExitOrder);

            }
            }

            }

            Comment


              #7
              ahh I did the if(historical) and it seems to stop the error.

              So if I try to cancel an order that is null, I will get an error, but will the script continue to run? Or do I need to check first

              Comment


                #8
                eurostoxx trader,

                Please find a reference sample on checking for Null orders below.



                Please let me know if I may assist further.
                Adam P.NinjaTrader Customer Service

                Comment


                  #9
                  thanks, I'll add the check to the line.

                  So if you have a stop exit & stop loss order, if one of those is executed, then the other is cancelled immediatly? That is where i was getting the error, trying to delete the other

                  Comment


                    #10
                    eurostoxx trader,

                    Are you using the stop exit and stop loss for the same purpose?

                    Here is a thread on using stop losses creatively : http://www.ninjatrader.com/support/f...t=food+thought

                    Here is our reference sample on using stop-losses / take-profits : http://www.ninjatrader.com/support/f...ead.php?t=3222

                    Please let me know if I may assist further.
                    Adam P.NinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by michi08, 10-05-2018, 09:31 AM
                    2 responses
                    737 views
                    0 likes
                    Last Post Denver_Wayne  
                    Started by sightcareclickhere, Today, 01:55 PM
                    0 responses
                    1 view
                    0 likes
                    Last Post sightcareclickhere  
                    Started by Mindset, 05-06-2023, 09:03 PM
                    9 responses
                    258 views
                    0 likes
                    Last Post ender_wiggum  
                    Started by Mizzouman1, Today, 07:35 AM
                    4 responses
                    18 views
                    0 likes
                    Last Post Mizzouman1  
                    Started by philmg, Today, 01:17 PM
                    1 response
                    8 views
                    0 likes
                    Last Post NinjaTrader_ChristopherJ  
                    Working...
                    X