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 Kensonprib, 04-28-2021, 10:11 AM
    5 responses
    191 views
    0 likes
    Last Post Hasadafa  
    Started by GussJ, 03-04-2020, 03:11 PM
    11 responses
    3,230 views
    0 likes
    Last Post xiinteractive  
    Started by andrewtrades, Today, 04:57 PM
    1 response
    14 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by chbruno, Today, 04:10 PM
    0 responses
    7 views
    0 likes
    Last Post chbruno
    by chbruno
     
    Started by josh18955, 03-25-2023, 11:16 AM
    6 responses
    441 views
    0 likes
    Last Post Delerium  
    Working...
    X