Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to create a universally accessible price Series

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

    How to create a universally accessible price Series

    NT Forum,

    What is the best way to create price Series (like Open & Close) such that they are universally accessible (like Open[0] and Close[0])? They should be accessible in multiple Indicators and Strategies.

    I am attempting to create price Series for Upper (the higher of Open & Close) and Lower (the lower of Open & Close). Please find below the basic formula. Please find attached the concept as an Indicator which falls short on the universal accessibility. Any insight is welcome.

    Code:
    protected override void OnBarUpdate()
    {
      if (Close[0] > Open[0])
      {
        Upper[0] = Close[0];
        Lower[0] = Open[0];
      }
      else
      {
        Upper[0] = Open[0];
        Lower[0] = Close[0];
      }
    }
    Thanks
    Shannon
    Attached Files

    #2
    Hello,

    Thank you for the question.

    There would not be a way to exactly mirror the internal Series, meaning that you wouldn't necessarily be able to make a global data series like Close. There is logic being run internally so that these values are pushed to the NinjaScript object you are using.

    Instead, you can define a Series as you have inside of a specific indicator or strategy and utilize it for storing and retrieving values.

    In general the suggested approach would be to create an indicator that does the processing, then call that indicator from other indicators or strategies using an exposed Plot or Series.

    Please let me know if I may be of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Jesse,

      Thanks for your response. Could you please elaborate on the process making an exposed Series.

      Thanks again
      Shannon

      Comment


        #4
        Hello,

        We actually have a good example on exposing Series here: http://ninjatrader.com/support/forum...ead.php?t=4991

        This is a sample for Series<bool>, it still completely applies you would just change Series<bool> to Series<double>
        Everything else would be the same aside from the value you assign to the series, it would need to be a double and not a bool.

        The main take away point is the public property:

        Code:
        [Browsable(false)]
        [XmlIgnore]
        public Series<bool> BearIndication
        {
            get { return bearIndication; }
        }
        The public Series<double> in your case would expose the property so it can be accessed from other items like Indicators or Strategies. You would then access this in the same way you would a plot:

        Code:
        MyCustomIndicator(anyParams).MySeriesName[0]
        JesseNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by DanielTynera, Today, 01:14 AM
        0 responses
        2 views
        0 likes
        Last Post DanielTynera  
        Started by yertle, 04-18-2024, 08:38 AM
        9 responses
        40 views
        0 likes
        Last Post yertle
        by yertle
         
        Started by techgetgame, Yesterday, 11:42 PM
        0 responses
        12 views
        0 likes
        Last Post techgetgame  
        Started by sephichapdson, Yesterday, 11:36 PM
        0 responses
        2 views
        0 likes
        Last Post sephichapdson  
        Started by bortz, 11-06-2023, 08:04 AM
        47 responses
        1,615 views
        0 likes
        Last Post aligator  
        Working...
        X