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 lightsun47, Today, 03:51 PM
            0 responses
            5 views
            0 likes
            Last Post lightsun47  
            Started by 00nevest, Today, 02:27 PM
            1 response
            10 views
            0 likes
            Last Post 00nevest  
            Started by futtrader, 04-21-2024, 01:50 AM
            4 responses
            46 views
            0 likes
            Last Post futtrader  
            Started by Option Whisperer, Today, 09:55 AM
            1 response
            14 views
            0 likes
            Last Post bltdavid  
            Started by port119, Today, 02:43 PM
            0 responses
            10 views
            0 likes
            Last Post port119
            by port119
             
            Working...
            X