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

Stop and Limit Orders

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

    Stop and Limit Orders

    In NT8, how do check to see if a stop and limit order exist for an existing position?

    Thanks.

    #2
    Hello GibbsB613,

    Thanks for opening the thread.

    You could loop through your orders and find information about any current orders. You could for example find out if an Order has a FromEntrySignal assigned to it. This is technically finding the opposite of what you are requesting, but you could follow the same approach to then deduce which orders have FromEntrySignals (Profit Targets and Stop Losses.)

    Here is a loop that will Print out any orders that are associated with an FromEntrySignal:
    Code:
    foreach (Order o in Orders)
    {
    	if (o.FromEntrySignal != null)
    		Print(o.Name + " is attached to " + o.FromEntrySignal);
    }
    It is generally good practice to use Order objects in your strategy with appropriate names and signal names so you can manage your orders without having to loop through to find the orders you are looking for.

    For reference, here is the documentation on the Order class: https://ninjatrader.com/support/help...-us/?order.htm

    Please let me know if I may be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      So I have this in my code for the stop and limit, how and when do I set the signal names for my orders?

      else if (State == State.Configure)
      {
      SetProfitTarget(@"", CalculationMode.Pips, 250);
      SetStopLoss("", CalculationMode.Pips, 50, false);
      }

      Thanks!
      Last edited by GibbsB613; 06-16-2017, 02:27 PM.

      Comment


        #4
        Hello GibbsB613,

        Thanks for the additional question.

        You can set the signal names using the appropriate overload for your Order Entry Methods.

        Here are a couple examples:

        SetProfitTarget()
        Code:
        SetProfitTarget(string fromEntrySignal, CalculationMode mode, double value)
        EnterLong()
        Code:
        EnterLong(string signalName)
        For an example on how to write a strategy that uses Order objects for order management, I would suggest to take a look at the SampleOnOrderUpdate example and its relevant documentation.

        You can reference all overloads for Order Entry methods in the relevant sections in the help guide.

        SetProfitTarget() - https://ninjatrader.com/support/help...ofittarget.htm

        EnterLong() - https://ninjatrader.com/support/help.../enterlong.htm

        SampleOnOrderUpdate - http://ninjatrader.com/support/forum...ead.php?t=7499

        If you have any additional questions, please don't hesitate to ask.
        JimNinjaTrader Customer Service

        Comment


          #5
          Can the signal name be dynamically set?

          Thanks.

          Comment


            #6
            Hello GibbsB613,

            Yes. The Order methods take a string as an argument for the entry signal, and you could create your own string and pass it through if you want.

            I suggest to try out these sort of inquiries when experimenting with your code so you know what you can and cannot do.

            Please let me know if I can be of further help.
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by martin70, 03-24-2023, 04:58 AM
            15 responses
            114 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by The_Sec, Today, 02:29 PM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by jeronymite, 04-12-2024, 04:26 PM
            2 responses
            31 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by Mindset, 05-06-2023, 09:03 PM
            10 responses
            265 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by michi08, 10-05-2018, 09:31 AM
            5 responses
            743 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Working...
            X