Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

GetValueAt() - is this expected

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

    GetValueAt() - is this expected

    I am seeing a difference between what OnBarUpdate shows as the value for Input versus what OnRender shows for Input--OnRender uses GetValueAt(). I also created iInput and set this value to Input in OnBarUpdate, which if pulled the same way Input (GetValueAt()) in OnRender, I am able to pull the correct values.

    Steps to reproduce:
    1. Create new chart
    2. Load attached indicator
    3. Change the input for the indicator to CCI(14)
    4. Look at the output window

    The output is as follows on OnBarUpdate:
    OnBarUpdate***
    Input: 50.8486082824375 (this is the correct value of CCI(14))
    iInput: 50.8486082824375 (this is the correct value of CCI(14))

    The output is as follows on OnRender:
    OnRender****
    Indicator Input
    Input: 2708.5 (this is NOT the correct value of CCI(14))--it looks like Input.GetValueAt() always pulls the value from the Bars
    iInput: 50.8486082824375 (this is the correct value of CCI(14))

    Is this an expected behavior?
    Attached Files

    #2
    Hello Jack22,

    Thank you for your note.

    To confirm, you are showing that when using an indicator as the input series for this indicator, Input.GetValueAt() is not returning the value of the indicator and is returning the Close[0] price (or Bars.GetClose()) instead? Is this correct?

    I will test and if I am able to reproduce I will report to our development.

    I will let you know what I find.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      That's correct

      Comment


        #4
        Hello Jack22,

        Our development pointed out something I overlooked.

        From the help guide:

        "Tip: If called directly from the instance of the NinjaScript object, the value which is returned corresponds to the input series the object is running. (e.g., Close, High, Low, SMA, etc.). If you're attempting to obtain another indicator value, you will need to pull this from the calculated indicator Value or Plot:
        SMA(20).GetValueAt(123); // bar value
        SMA(20).Values[0].GetValueAt(123); // indicator value"



        Use:
        Code:
        (Input as Indicator).Values[0].GetValueAt(Bars.Count - bar)
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Just tested and that solved my issues. Thanks. Can you add that as an example in the help documentation so it's a little more clear for anyone else who runs into this?

          Comment


            #6
            Hello Jack22,

            I will send your request for this example to be added to the help guide.

            Let me know if I may further assist.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Geovanny Suaza, 02-11-2026, 06:32 PM
            0 responses
            576 views
            0 likes
            Last Post Geovanny Suaza  
            Started by Geovanny Suaza, 02-11-2026, 05:51 PM
            0 responses
            334 views
            1 like
            Last Post Geovanny Suaza  
            Started by Mindset, 02-09-2026, 11:44 AM
            0 responses
            101 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Geovanny Suaza, 02-02-2026, 12:30 PM
            0 responses
            553 views
            1 like
            Last Post Geovanny Suaza  
            Started by RFrosty, 01-28-2026, 06:49 PM
            0 responses
            551 views
            1 like
            Last Post RFrosty
            by RFrosty
             
            Working...
            X