Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Help with Displacement for Moving Average

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

    Help with Displacement for Moving Average

    Hello. I am using a moving average crossover system. And I would like to use the feature "Displacement -1" So for my EMA 15, I would like to "displace it" by -1

    Can you please tell me how to do this with the Strategy Builder? I would prefer to use the Builder as I am not familiar with the code.

    Thank you!!

    #2
    Hello geotrades1,

    Thanks for your post.

    In NinjaScript there is no concept of "displacement". You would instead use the BarsAgo concept to reference data from other bars. For example, if you wanted to compare an MA against itself for a different bar value, you would use a BarsAgo of 1 or the number of bars you wanted ago.

    Note that Displacement does not change the barsAgo value for a plot value in an indicator. This is only used for visual purposes only on the chart and does not affect the indicator plot values called for a script.

    In this case, the Visual Displacement property that can normally be used with Indicators would not be avaliable as the strategy is hosting the indicator. It is technically possible to manually code into a strategy Displacement = 1 to displace the visuals but not while using the Strategy Builder.

    If you are trying to Visually displace the indicators from the Strategy Builder, I will need to submit a feature request to expose the strategies Displacement property. Otherwise, if you are trying to access data from 1 BarsAgo, you could use [1] for the BarsAgo instead of [0] to access the prior data.​​

    Strategy Builder Conditions: https://ninjatrader.com/support/help...on_builder.htm
    Brandon H.NinjaTrader Customer Service

    Comment


      #3
      OK, thank you. I will try and figure out the Bars Ago feature.

      So, the BarsAgo can be used in the same way as the Displace in the attached pic?

      Thanks!!


      Comment


        #4
        Hello geotrades1,

        Thanks for your notes.

        The Displacement property cannot be used for indicators in the Strategy Builder since in NinjaScript there is no concept of "displacement".

        You would instead use the BarsAgo concept to reference indicator data from other bars.

        The BarsAgo value you pass into the indicator method in the Strategy Builder will access the indicator value for that bar.

        For example, passing in a BarsAgo value of 0 would access the indicator value on the current bar on the chart. Passing in a BarsAgo vale of 1 would access the indicator value of the bar 1 bar prior to the current bar. Passing in a BarsAgo value of 2 would access the indicator value for the bar 2 bars prior to the current bar on the chart, and so on.
        Brandon H.NinjaTrader Customer Service

        Comment


          #5
          OK, thanks Brandon!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by PhillT, 04-19-2024, 02:16 PM
          4 responses
          34 views
          0 likes
          Last Post PhillT
          by PhillT
           
          Started by ageeholdings, 05-01-2024, 05:22 AM
          5 responses
          37 views
          0 likes
          Last Post ageeholdings  
          Started by reynoldsn, Today, 02:34 PM
          0 responses
          13 views
          0 likes
          Last Post reynoldsn  
          Started by nightstalker, Today, 02:05 PM
          0 responses
          19 views
          0 likes
          Last Post nightstalker  
          Started by llanqui, Yesterday, 09:59 AM
          8 responses
          32 views
          0 likes
          Last Post llanqui
          by llanqui
           
          Working...
          X