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 cmoran13, 04-16-2026, 01:02 PM
        0 responses
        43 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        25 views
        0 likes
        Last Post PaulMohn  
        Started by CarlTrading, 03-31-2026, 09:41 PM
        1 response
        162 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        98 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        158 views
        2 likes
        Last Post CaptainJack  
        Working...
        X