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

Obtaining values from a 3rd party indicator on the chart.

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

    Obtaining values from a 3rd party indicator on the chart.

    I am trying to get values from a 3rd party indicator, to use in a strategy I'm developing in NT8.
    Do I need to declare my own instance of the indicator in my strategy?
    Can I simply reference the 3rd party indicator (which is on the chart), to obtain values from it to determine actions?

    I get the following error when compiling my strategy in NT8:

    Cannot implicitly convert type 'NinjaTrader.NinjaScript.Indicators.ncatVolumeSpre adScalper' to 'NinjaTrader.NinjaScript.Indicators.Indicator'

    Portions of the code:
    ---------------------
    #region Variables
    Indicator myIndicator;
    #endregion

    protected override void OnStateChange()
    {
    if (State == State.SetDefaults)
    {
    } else if (State == State.Configure)
    {
    myIndicator = ncatVolumeSpreadScalper("Enabled", "Enabled", "Enabled", "Enabled", 5, 20, 70, 25, 70, 200, 150, "19892", "Minutes", 5, false, 5);
    }
    }

    protected override void OnBarUpdate()
    {
    double ActiveHigh = (double)myIndicator.ActiveHigh[0];
    double LineBreakUp = (int)myIndicator.LinebreakUp[0];
    double LineBreakDown = (int)myIndicator.LinebreakDown[0];
    }

    #2
    Hello epete,

    Thanks for your post.

    ncatVolumeSpreadScalper would inherit from the Indicator class, but it has its own type which should not be confused with the type of Indicator. The indicator should be declared with its own type.

    As a best practice, we recommend to instantiate indicators in State.DataLoaded instead of referencing the indicator methods in OnBarUpdate. Indicators must also be programmed into the script to be accessed by the script. We would not advise searching through indicators on the chart to be used in your script.

    Performance Best Practices (See Referencing Indicator Methods) - https://ninjatrader.com/support/help...tm#Performance

    The Strategy Builder can be used to generate syntax for how we recommend to add and use indicators. If the indicator is compatible with the Strategy Builder, you could use this tool to add an indicator and then click View Code to see the resulting syntax. If it is not compatible, you could use the Strategy Builder to generate syntax for a system indicator and model your syntax off the generated code.

    Strategy Builder 301 - https://www.youtube.com/watch?v=HCyt90GAs9k

    Please let us know if we can be of further assistance.
    JimNinjaTrader Customer Service

    Comment


      #3
      Can you provide the code needed to declare the indicator with its own type?

      Comment


        #4
        Hello epete,

        I do not have this indicator to verify, but you can observe the syntax for how other indicators are declared and you can use the Strategy Builder to create syntax if the indicator is supported in the Strategy Builder.

        Demo - https://drive.google.com/file/d/1F_J...w?usp=drivesdk

        I look forward to being of further assistance.
        JimNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by gravdigaz6, Today, 11:40 PM
        1 response
        7 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by MarianApalaghiei, Today, 10:49 PM
        3 responses
        10 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by XXtrader, Today, 11:30 PM
        0 responses
        4 views
        0 likes
        Last Post XXtrader  
        Started by love2code2trade, Yesterday, 01:45 PM
        4 responses
        28 views
        0 likes
        Last Post love2code2trade  
        Started by funk10101, Today, 09:43 PM
        0 responses
        9 views
        0 likes
        Last Post funk10101  
        Working...
        X