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

Exposing indicator values that are not plots AND NOT DATASERIES

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

    Exposing indicator values that are not plots AND NOT DATASERIES

    Hi ,

    I saw an example in


    Regarding NT 6.5 :

    Because of memory considerations I want to avoid creation of additional data series and I want to expose certain indicator value as a property.
    My code is like:

    Indicator A:

    protected override void OnBarUpdate()
    {
    .............
    state1 = [certain value]
    ..........
    }

    Read only property:
    public int IPos
    {
    // read only - for external usage.
    get { return state1 ; }
    }


    Indicator B (or strategy B )
    val1 = IndicatorA(2,10).IPos ;

    There are no compilation errors, but val1 is always 0 , despite the "state1" has different values for different bars.

    I would expect that this statement will return current value of the property for every OnBarUpdate called.

    I suspect my problem has something to do with a way my strategy calls OnBarUpdate().

    What's wrong ?

    #2
    xTrader, if you haven't taken a look at the indicator potion of the sample titled exposing indicator values please do so.

    The code for the publically exposed variable needs to have a section that "updates" the value, like so:
    Code:
    public double ExposedVariable
    {
         // We need to call the Update() method to ensure our exposed variable is up-to-date.
         get { Update(); return exposedVariable; }
    }
    So for your situation, try this and see if it works:
    Code:
    public int IPos
    {
        // read only - for external usage.
        get { Update(); return state1; }
    }
    AustinNinjaTrader Customer Service

    Comment


      #3
      Sorry , I overlooked.

      It appears not only in the example, but also in the help file.

      Now it works. Thanks.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by bortz, 11-06-2023, 08:04 AM
      47 responses
      1,607 views
      0 likes
      Last Post aligator  
      Started by jaybedreamin, Today, 05:56 PM
      0 responses
      9 views
      0 likes
      Last Post jaybedreamin  
      Started by DJ888, 04-16-2024, 06:09 PM
      6 responses
      19 views
      0 likes
      Last Post DJ888
      by DJ888
       
      Started by Jon17, Today, 04:33 PM
      0 responses
      6 views
      0 likes
      Last Post Jon17
      by Jon17
       
      Started by Javierw.ok, Today, 04:12 PM
      0 responses
      15 views
      0 likes
      Last Post Javierw.ok  
      Working...
      X