Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator to pass values to a strategy

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

    Indicator to pass values to a strategy

    Hi

    I have an indicator in which I have created some public Property Getters / Setters, see below;

    public double RangeDifference
    {
    get { Update(); return _rangeDifference; }
    set { _rangeDifference = value;}
    }

    public int ResetCrossAfterLowOrHigh
    {
    get { Update(); return _resetCrossAfterLowOrHigh; }
    set { _resetCrossAfterLowOrHigh = value;}
    }


    In my code I assign values to these properties using code like;
    RangeDifference = 20.15;

    In my strategy I access these values and can see the values to use them. However, if I try to add the [0] suffix I get an error saying I cannot use type double. If I compare my indicator to something like the Bollinger Bands "Upper" I notice they are getters only and they are declared as Series<double>

    Should my properties be created as Series<double> and be only getters?
    and if I want to use my indicator "correctly" is this how it should work?


    Regards

    #2
    Hello fishbed,

    Thanks for writing in to our Support team.

    You cannot add a [0] suffix to these properties since they are defined as an int and a double - the [0] suffix is included with Series<T> objects for the purpose of accessing historical values that are included in the series.

    If you are interested in accessing historical values via the bars ago suffix denoted via enclosed brackets [] then you should set up your properties as Series<T> objects. For instance, if you want to retrieve the RangeDifference value on a bar other than the bar your code is currently running on, then you would want to implement your properties as Series<T> objects. If you want your properties to be read-only and you do not want to set the values, then you would want to remove the set accessor.

    You can find more information about Series<T> objects here:
    http://ninjatrader.com/support/helpG...us/seriest.htm

    Please let me know if I may be of any further assistance.
    Alan S.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Mindset, 04-21-2026, 06:46 AM
    0 responses
    44 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    54 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    34 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    95 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    57 views
    0 likes
    Last Post PaulMohn  
    Working...
    X