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

externally accessible custom indicator variable?

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

    externally accessible custom indicator variable?

    a custom indicator VolumePRV calculates an estimated Volume & plots it.
    Inside this custom indicator is a private (double) variable, that I need to make publicly accessible for other Indicators & Strategies. Thus far, nothing I've tried has worked.

    Is there an example I may look at that does this?

    Thanks!

    #2
    You can expose it as a public property. Something like this:
    Code:
    [Browsable(false)]
    [XmlIgnore()]
    public double ExposedVariable
    {
        get { Update(); return exposedVariable; }
    }
    This would generally go in the "Properties" segment of your code. "exposedVariable" would be your private variable.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Ah, I had something similar without the [] stmts & in Misc instead of properties. Rewrote it to match, thanks!

      However, how do I use it?
      In another indicator to use it, I tried simply
      double PRVol = VolumePRV.PRV();
      = VolumePRV.PRV; // Ninjascript fills it in this way

      neither will compile. I even tried it w/o the VolumePRV prefix but it really didn't like that.

      It is listed in my choices in the Ninjascript Intellisense list box as a double, but I can't seem to use it?

      Comment


        #4
        OK, I tried this:
        private VolumePRV V = new VolumePRV();
        PRVol = V.PRV;

        It compiles but V.PRV is always 0.

        Are there examples in the existing indicators that I can examine?

        Comment


          #5
          Well phooey. I gave up & took a different path. I copied your BOP indicator & changed the name to PRV, plugged in the correct calculation and it works. I use call this PRV indicator in other indicators and presumably strategies & market analysis since your code covers all that.
          Don't even have to add it to a chart.

          A better choice anyway for what we needed.

          Cheers!

          Comment


            #6
            For the record this is how you would do it:

            Code:
            double indVal = IndicatorName().exposedVariable;
            The parenthesis goes with the indicator method. The exposed variable is just a property of that method. There are no indexes that goes with it.
            Josh P.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by burtoninlondon, Today, 12:38 AM
            0 responses
            10 views
            0 likes
            Last Post burtoninlondon  
            Started by AaronKoRn, Yesterday, 09:49 PM
            0 responses
            14 views
            0 likes
            Last Post AaronKoRn  
            Started by carnitron, Yesterday, 08:42 PM
            0 responses
            11 views
            0 likes
            Last Post carnitron  
            Started by strategist007, Yesterday, 07:51 PM
            0 responses
            14 views
            0 likes
            Last Post strategist007  
            Started by StockTrader88, 03-06-2021, 08:58 AM
            44 responses
            3,983 views
            3 likes
            Last Post jhudas88  
            Working...
            X