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 helpwanted, Today, 03:06 AM
      1 response
      7 views
      0 likes
      Last Post sarafuenonly123  
      Started by Brevo, Today, 01:45 AM
      0 responses
      7 views
      0 likes
      Last Post Brevo
      by Brevo
       
      Started by aussugardefender, Today, 01:07 AM
      0 responses
      5 views
      0 likes
      Last Post aussugardefender  
      Started by pvincent, 06-23-2022, 12:53 PM
      14 responses
      242 views
      0 likes
      Last Post Nyman
      by Nyman
       
      Started by TraderG23, 12-08-2023, 07:56 AM
      9 responses
      385 views
      1 like
      Last Post Gavini
      by Gavini
       
      Working...
      X