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

How to determine signal names of open position?

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

    How to determine signal names of open position?

    Hello.

    Say, I have position, opened by 3 orders with different names:

    PHP Code:

    protected override void OnStateChange()
    {
        if (
    State == State.SetDefaults)
        {
            
    Calculate                Calculate.OnBarClose;
            
    IsUmanaged             false;
            
    EntriesPerDirection        10;
            
    EntryHandling            EntryHandling.AllEntries;
        }
    }

    protected 
    override void OnBarUpdate()
    {            
        if( 
    State != State.Realtime ) return;
        
            
    EnterLong1"Signal_1" );
            
    EnterLong1"Signal_2" );
            
    EnterLong1"Signal_2" );

    How can I determine entries names ("Signal_1", "Signal_2", "Signal_3") from which the position is composed?
    fx.practic
    NinjaTrader Ecosystem Vendor - fx.practic

    #2
    Hello fx.practic,

    Thank you for the post.

    I am reviewing your inquiry and will be back with a reply shortly.

    I look forward to assisting further.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hello fx.practic,

      Thank you for your patience.

      To find a signal name, you will need to save your entries as an Order object. The order object has two properties: Name and FromEntrySignal.

      You would access you signal names like so:

      Order anOrder = EnterLong( 1, "Signal_1" );

      Print(anOrder.Name);

      Print(anorder.FromEntrySignal);

      More on the Order object here:


      If we may be of any further assistance, please let us know.
      Chris L.NinjaTrader Customer Service

      Comment


        #4
        Thank You.

        I think about this way, but hope it can be done using Position object.

        More logic, more places for great bugs.

        While internally NT still know signals names of opened position.
        fx.practic
        NinjaTrader Ecosystem Vendor - fx.practic

        Comment


          #5
          Hello fx.practic,

          Unfortunately, NinjaTrader does not provide the orders that have contributed to the current position.

          This would need to be stored yourself in a custom coded object such as an array, list, dictionary, etc.
          You would need to add the Order object from OnOrderUpdate() when the order fills, and remove the object when an opposing order using the same fromEntrySignal fills.

          I will submit a feature request on your behalf for the NinjaTrader Development to consider providing a collection of orders that have contributed to the Position.
          Once I have a tracking ID for this request I will post in this thread for future reference.


          antrux,

          I am moving your inquiry to a new thread, as this is unrelated to the current topic.
          Chelsea B.NinjaTrader Customer Service

          Comment


            #6
            NinjaTrader does not provide the orders that have contributed to the current position.

            Can any signal entry name that form the current position be called so that I can just flat that position due to that signal initiated position??

            Comment


              #7
              Hello stantenlee,

              If the entries making up a position have different signal names, each exit order using the from entry signal would only exit the quantity of the entry with that signal name.
              Chelsea B.NinjaTrader Customer Service

              Comment


                #8
                how about if i set two ways to flat my position either by trailingstop or by indicator --exit position, i always found that the position get reverse which meansit get flat and one more position(when i long at start, it hit the stop by indicator and trailstop at same time so that i got one long position flattened and one short position created

                Comment


                  #9
                  Hello stantenlee,

                  I'm not sure I'm understanding your inquiry.

                  However, if you are using multiple exit orders for the same entry order, this could result in both orders filling causing an overfill.


                  Trying to call an exit order and an entry order at the same time will also result in an overfill.
                  Chelsea B.NinjaTrader Customer Service

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by funk10101, Today, 09:43 PM
                  0 responses
                  6 views
                  0 likes
                  Last Post funk10101  
                  Started by pkefal, 04-11-2024, 07:39 AM
                  11 responses
                  37 views
                  0 likes
                  Last Post jeronymite  
                  Started by bill2023, Yesterday, 08:51 AM
                  8 responses
                  44 views
                  0 likes
                  Last Post bill2023  
                  Started by yertle, Today, 08:38 AM
                  6 responses
                  26 views
                  0 likes
                  Last Post ryjoga
                  by ryjoga
                   
                  Started by algospoke, Yesterday, 06:40 PM
                  2 responses
                  24 views
                  0 likes
                  Last Post algospoke  
                  Working...
                  X