Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to get the entry signal or bars array index for an open position

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

    How to get the entry signal or bars array index for an open position

    I have a multi-timeframe strategy and when it comes to my exit I want it to exit on the same bars array (timeframe)? How can I know what bars array was used for the entry?

    What I'm doing now is I create my entrySignal so that it contains the bars array and I exit using the entry signal parameter so it only exits on the right timeframe. the only disadvantage to this is that I submit exit orders that are not valid (due to the entry signal not matching), and that I don't know ahead of time if the exit will work.

    Is there a better way?

    #2
    Hi cunparis, could you please post some of your entry / exit codes as sample? Also you can also use BarsInProgress() to check which Bars object has called the OnBarUpdate() and then submit your orders - http://www.ninjatrader-support.com/H...BarSeries.html

    Comment


      #3
      Originally posted by NinjaTrader_Bertrand View Post
      Hi cunparis, could you please post some of your entry / exit codes as sample? Also you can also use BarsInProgress() to check which Bars object has called the OnBarUpdate() and then submit your orders - http://www.ninjatrader-support.com/H...BarSeries.html
      Hi Bertrand thank you for your offer to help. Here is my entry & exit:

      Code:
                          EnterLong(1, 1, "L" + BarsInProgress);
      
                          ExitLong("exit", "L" + BarsInProgress);
      What I'm doing is using BarsInProgress to tag my entries so that I can see what timeframe I used in the list of trades and also so I can match up my exit.

      With the exit, when the exit condition is met on each timeframe, it will try to exit. Only the right one will succeed. I think it's a bit sloppy. What I'd like to know is there a way to get the BarsArray of the current position. Like this:

      Code:
      // Made up the next line just for this example
      if(Position.BarsArray == BarsInProgress) {
        ExitLong("exit", "L" + BarsInProgress);
      }
      If this isn't possible then there is another choice: I store the BarsArray of the entry in a variable.

      Thanks

      Comment


        #4
        Hi cunparis, I see thanks - you could check into the Positions array for your code - http://www.ninjatrader-support.com/H...Positions.html

        Although I'm not 100% sure, because it's normally used in a multi instrument context...

        The variable way looks straightforward to me...

        Merry Christmas!

        Comment


          #5
          Originally posted by NinjaTrader_Bertrand View Post
          Hi cunparis, I see thanks - you could check into the Positions array for your code - http://www.ninjatrader-support.com/H...Positions.html

          Although I'm not 100% sure, because it's normally used in a multi instrument context...

          The variable way looks straightforward to me...

          Merry Christmas!
          The Positions array won't work because it's per instrument. So Positions[0] will contain the position whether it was entered on barsarray 0 or 1.

          Looks like the variable way is the way to go. I'll have to use a hashtable because it's multi-instrument.

          Thanks and Merry Christmas to you too!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          61 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          148 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          162 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          98 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          286 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X