Announcement

Collapse
No announcement yet.

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.

    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.

        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.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by NullPointStrategies, Today, 05:17 AM
            0 responses
            38 views
            0 likes
            Last Post NullPointStrategies  
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            124 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            64 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            41 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            46 views
            0 likes
            Last Post TheRealMorford  
            Working...
            X