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 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 zstheorist, Today, 07:52 PM
    0 responses
    7 views
    0 likes
    Last Post zstheorist  
    Started by pmachiraju, 11-01-2023, 04:46 AM
    8 responses
    150 views
    0 likes
    Last Post rehmans
    by rehmans
     
    Started by mattbsea, Today, 05:44 PM
    0 responses
    6 views
    0 likes
    Last Post mattbsea  
    Started by RideMe, 04-07-2024, 04:54 PM
    6 responses
    33 views
    0 likes
    Last Post RideMe
    by RideMe
     
    Started by tkaboris, Today, 05:13 PM
    0 responses
    6 views
    0 likes
    Last Post tkaboris  
    Working...
    X