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 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
    71 views
    0 likes
    Last Post jeronymite  
    Working...
    X