Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Input[0]

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

    Input[0]

    There is a piece of code in the MACD indicator:
    Code:
    protected override void OnBarUpdate()
    
    {
    
    double input0 = Input[0];
    ​
    What is the Input[0] variable/object? Where does it come from? It seems to be a built in series object?

    I searched help but too many results came back.

    Thanks, Caesar.

    #2
    Input is whatever price the indicator is configured to be based on. You can change this in the indicator's properties. Typically, it's the same as "Close" but you can, for instance, make an SMA of the High, without doing any programming and in that case Input is equal to High.
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      When you are writing your own indicator, if you want to make it possible for users to choose the input, make your calculations based on Input which will default to Close. If you want to ignore their choice and do your own thing (such as always using High or Open or whatever) just code it to that series directly and don't refer to Input. It's a good practice to use Input for indicators that require a single series, such as an SMA.
      Bruce DeVault
      QuantKey Trading Vendor Services
      NinjaTrader Ecosystem Vendor - QuantKey

      Comment


        #4
        Hello Skechers,

        Just to follow up on what was already said about Input, you can find its documentation here: https://ninjatrader.com/support/help.../nt8/input.htm

        It is good to take note which indicators use Input in their code, some indicators do not use Input and rely on specific price series. The indicators which do not use input in their code generally won't support inputting other indicator plot values if they use more than just the close price. As mentioned its good practice to use Input in your code if you plan to make the indicator work for all types of input.

        Just as a quick example I attached a version of the ADX converted to use input, the default adx does not use input and uses specific price series. This script can help you to see how you might incorporate using input in your own script if you use more than just the Close price.
        Attached Files

        Comment


          #5
          Many Thanks Jesse, Bruce!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by NullPointStrategies, Yesterday, 05:17 AM
          0 responses
          71 views
          0 likes
          Last Post NullPointStrategies  
          Started by argusthome, 03-08-2026, 10:06 AM
          0 responses
          143 views
          0 likes
          Last Post argusthome  
          Started by NabilKhattabi, 03-06-2026, 11:18 AM
          0 responses
          76 views
          0 likes
          Last Post NabilKhattabi  
          Started by Deep42, 03-06-2026, 12:28 AM
          0 responses
          47 views
          0 likes
          Last Post Deep42
          by Deep42
           
          Started by TheRealMorford, 03-05-2026, 06:15 PM
          0 responses
          51 views
          0 likes
          Last Post TheRealMorford  
          Working...
          X