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 Mindset, 04-21-2026, 06:46 AM
      0 responses
      117 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by M4ndoo, 04-20-2026, 05:21 PM
      0 responses
      166 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by M4ndoo, 04-19-2026, 05:54 PM
      0 responses
      85 views
      0 likes
      Last Post M4ndoo
      by M4ndoo
       
      Started by cmoran13, 04-16-2026, 01:02 PM
      0 responses
      130 views
      0 likes
      Last Post cmoran13  
      Started by PaulMohn, 04-10-2026, 11:11 AM
      0 responses
      88 views
      0 likes
      Last Post PaulMohn  
      Working...
      X