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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        649 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        370 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        109 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        574 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        576 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X