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

Referencing Previous Indicator values

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

    Referencing Previous Indicator values

    Is there a way to reference a previous indicator value?

    For example,

    EMA(5)[0] - EMA(5)[20]

    This will not produce a result. Does anybody know a way to get around this or to do this?

    Thanks.

    #2
    JamesF, this should work - please make sure to take consideration of this tip at your OnBarUpdate start - http://www.ninjatrader-support2.com/...ead.php?t=3170
    BertrandNinjaTrader Customer Service

    Comment


      #3
      So say I was trying to achieve some thing like this....


      number = EMA(5)[0] - EMA(5)[lookbackperiod]

      plot0 = "number";


      would I just insert a snippit in the on bar update above it?

      {
      if (EMA[0] > EMA[Math.Min(CurrentBar, lookbackperiod)])
      // Do something
      }

      Comment


        #4
        I'm not sure what you're trying to achieve, if 'lookbarperiod' should be a user defined input parameter you can change on the fly to adjust, please take a look at this tip on how to create those in your scripts - http://www.ninjatrader-support2.com/...ead.php?t=5782
        BertrandNinjaTrader Customer Service

        Comment


          #5
          I have an indicator that adds up all the times the direction of an ma changes. I want it to only display the number of changes in the last 20 bars or so, the "lookbackperiod" variable. So, I am wondering how I can obtain the number of changes by subtracting the number of changes at [20] or [lookbackperiod] from the number at [0].

          Hence,

          localvaribale = Indicator(5)[0] - Indicator(5)[20];
          plot0= "localvariable";

          I need to be able to reference the number that the indicator displays at [20] to do this. Is this possible?

          Comment


            #6
            Then you would need to work with dataseries objects that hold the historical indicator values - http://www.ninjatrader-support.com/H...iesObject.html

            BertrandNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by kempotrader, Today, 08:56 AM
            0 responses
            6 views
            0 likes
            Last Post kempotrader  
            Started by kempotrader, Today, 08:54 AM
            0 responses
            4 views
            0 likes
            Last Post kempotrader  
            Started by mmenigma, Today, 08:54 AM
            0 responses
            2 views
            0 likes
            Last Post mmenigma  
            Started by halgo_boulder, Today, 08:44 AM
            0 responses
            1 view
            0 likes
            Last Post halgo_boulder  
            Started by drewski1980, Today, 08:24 AM
            0 responses
            4 views
            0 likes
            Last Post drewski1980  
            Working...
            X