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

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 traderqz, Today, 12:06 AM
            10 responses
            18 views
            0 likes
            Last Post traderqz  
            Started by algospoke, 04-17-2024, 06:40 PM
            5 responses
            46 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Started by arvidvanstaey, Today, 02:19 PM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Zachary  
            Started by mmckinnm, Today, 01:34 PM
            3 responses
            5 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by f.saeidi, Today, 01:32 PM
            2 responses
            8 views
            0 likes
            Last Post f.saeidi  
            Working...
            X