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 argusthome, 03-08-2026, 10:06 AM
      0 responses
      105 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      53 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      35 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      38 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      74 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X