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 Rapine Heihei, Today, 08:19 PM
            1 response
            3 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by Rapine Heihei, Today, 08:25 PM
            0 responses
            4 views
            0 likes
            Last Post Rapine Heihei  
            Started by f.saeidi, Today, 08:01 PM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by Rapine Heihei, Today, 07:51 PM
            0 responses
            6 views
            0 likes
            Last Post Rapine Heihei  
            Started by frslvr, 04-11-2024, 07:26 AM
            5 responses
            97 views
            1 like
            Last Post caryc123  
            Working...
            X