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

Indicator value set and get question (n00b)

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

    Indicator value set and get question (n00b)

    Please correct my understanding of the following:

    I set an indicator's value with
    Value.Set = High + 3;

    and I can get "previous bar" values of the indicator by
    double foo = Value.Get(0); //gets current value
    foo = Value.Get(1); //previous bar?

    From the manual it implies I could also
    double foo = Values[1]; // previous bar?

    Thanks!
    Regards,
    Raj

    #2
    Hi Raj,

    Always use for setting:

    Value.Set(High[0] + 3);

    For getting, always use:

    Values[int barsAgo]
    RayNinjaTrader Customer Service

    Comment


      #3
      Comparing Values

      Ray, hi,
      Thanks for the advice.
      I am setting the indicator value with what should be a "double", such as

      double foo = ...some math...;
      Value.Set(foo);


      Then I want to compare current/previous-bar indicator values, for example,
      if((Values[0] > Values[1]) & (Values[1]< Values[2]))
      {. . . }

      But I get the compiler warning
      "Operator '>' cannot be applied to operands of type 'NinjaTrader.Data.DataSeries and NinjaTrader.Data.DataSeries"

      So I'm still doing something wrong. Thanks again for your help!
      Regards,
      Raj

      Comment


        #4
        "Values" is an array that holds DataSeries objects so you are comparing a DataSeries object in slot 0 to one in slot 1. What you need to do is something like:

        Values[0][0] > Values[0][1] && Values[0][1] > Values[0][2]....
        RayNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by inanazsocial, Today, 01:15 AM
        0 responses
        2 views
        0 likes
        Last Post inanazsocial  
        Started by trilliantrader, 04-18-2024, 08:16 AM
        5 responses
        22 views
        0 likes
        Last Post trilliantrader  
        Started by Davidtowleii, Today, 12:15 AM
        0 responses
        3 views
        0 likes
        Last Post Davidtowleii  
        Started by guillembm, Yesterday, 11:25 AM
        2 responses
        9 views
        0 likes
        Last Post guillembm  
        Started by junkone, 04-21-2024, 07:17 AM
        9 responses
        70 views
        0 likes
        Last Post jeronymite  
        Working...
        X