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 cre8able, Today, 01:16 PM
      1 response
      3 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by chbruno, 04-24-2024, 04:10 PM
      3 responses
      47 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by samish18, Today, 01:01 PM
      1 response
      6 views
      0 likes
      Last Post NinjaTrader_LuisH  
      Started by WHICKED, Today, 12:56 PM
      1 response
      8 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Started by WHICKED, Today, 12:45 PM
      1 response
      11 views
      0 likes
      Last Post NinjaTrader_Gaby  
      Working...
      X