Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Displacement in a strategy

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

    #16
    Yes, you could use this overload from DataSeries class.

    DataSeries.Set(int barsAgo, double value)
    You can also set the value for historical bars by including a "barsAgo" value that represents the number of bars ago that you want the double value to be stored at.

    This could be an advantage if both crossing values needed to be based on bars ago values. Since it looks like only one of yours is, this wouldn't offer an advantage over just applying indexing to SMA to make it a double.
    Ryan M.NinjaTrader Customer Service

    Comment


      #17
      Originally posted by MiniDowTrader View Post
      Would it be possible to create a new indicator that would account for the displacement? And then have the "5 SMA" cross the newly created "5 SMA displaced"?

      Just throwing out ideas. I appreciate the help.
      This should work.

      Code:
      private int Displacement = 5; //or whatever you want it to be. Make it a parameter?
      Code:
      ...
      if (CrossAbove(SMA(Weighted, 5), SMA(Weighted, 5)[B][COLOR=Red][Displacement][/COLOR][/B], 1))
                  {
                      EnterLong(DefaultQuantity, "");
                  }
      ...
      and so on.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      651 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      370 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      109 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      574 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      577 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X