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 CarlTrading, Yesterday, 09:41 PM
      1 response
      20 views
      0 likes
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, Today, 02:41 AM
      0 responses
      7 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, Yesterday, 11:44 PM
      0 responses
      18 views
      1 like
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      35 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      33 views
      0 likes
      Last Post CarlTrading  
      Working...
      X