Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Sequencing strategy events

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

    Sequencing strategy events

    Here's an example of what I have been attempting:

    Lets assume I am using a simple moving average cross.

    If it crosses above, I get long but if it then crosses below once I am at 50% of my profit target I get out.

    The syntax asks me for a "lookback period" which I want to be the following

    int lookBackPeriod = [??????];

    where [??????] is the exact number of bars since position entry (or as I like to think of it, "elapsed time since position entry". Of course, this number will dynamically update OnBarClose.

    Is there a reasonable method for counting or measuring the number of bars since position entry?

    Thank you and regards,

    Andrew

    #2
    Hello Andrew,
    Thanks for your note.

    You can use the BarsSinceEntry to do it. Please refer to our help guide to know more about it.
    JoydeepNinjaTrader Customer Service

    Comment


      #3
      Yep. This.

      Awesome, simple, clean and done.

      TY again Joydeep.

      Regards,

      Andrew

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by DannyP96, 05-18-2026, 02:38 PM
      1 response
      27 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 05-11-2026, 05:56 AM
      0 responses
      117 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 05-10-2026, 08:12 PM
      0 responses
      69 views
      0 likes
      Last Post CarlTrading  
      Started by Hwop38, 05-04-2026, 07:02 PM
      0 responses
      226 views
      0 likes
      Last Post Hwop38
      by Hwop38
       
      Started by CaptainJack, 04-24-2026, 11:07 PM
      0 responses
      417 views
      0 likes
      Last Post CaptainJack  
      Working...
      X