Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Access an indicator var from a strategy?

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

    Access an indicator var from a strategy?

    Its possible acces to a indicator public var from an strategy?

    I am trying but the value is always the first declared.

    Indicator example code:
    Code:
    //Indicator var declaration
    public int myvar=0;
    ....
    
    //Indicator update
    protected override void OnBarUpdate(){
    myvar=x;
    ...
    Strategy example code:
    Code:
    /Strategy update
    protected override void OnBarUpdate(){
    
    //Print indicator var
    print(MyIndicator().myvar);
    ...
    And the printed value always is the first declaration value; 0.
    How can i take the updated value?

    Thank you very much for help.
    Mary

    #2
    You need to include an Update() in the get function for the property.

    get{myvar = Update(); return value;}

    ref: http://www.ninjatrader.com/support/h...tml?update.htm
    Last edited by koganam; 01-30-2011, 07:08 AM.

    Comment


      #3
      Fantastic koganam, thank you very much !!

      Comment


        #4
        marynja, there is also a reference sample that details how to get an indicator value in a strategy, which is pretty much what you've already done with koganam's help.
        AustinNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by charlesugo_1, 05-26-2026, 05:03 PM
        0 responses
        60 views
        0 likes
        Last Post charlesugo_1  
        Started by DannyP96, 05-18-2026, 02:38 PM
        1 response
        147 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 05-11-2026, 05:56 AM
        0 responses
        161 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 05-10-2026, 08:12 PM
        0 responses
        97 views
        0 likes
        Last Post CarlTrading  
        Started by Hwop38, 05-04-2026, 07:02 PM
        0 responses
        284 views
        0 likes
        Last Post Hwop38
        by Hwop38
         
        Working...
        X