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 helpwanted, Today, 03:06 AM
        1 response
        11 views
        0 likes
        Last Post sarafuenonly123  
        Started by Brevo, Today, 01:45 AM
        0 responses
        9 views
        0 likes
        Last Post Brevo
        by Brevo
         
        Started by aussugardefender, Today, 01:07 AM
        0 responses
        5 views
        0 likes
        Last Post aussugardefender  
        Started by pvincent, 06-23-2022, 12:53 PM
        14 responses
        242 views
        0 likes
        Last Post Nyman
        by Nyman
         
        Started by TraderG23, 12-08-2023, 07:56 AM
        9 responses
        387 views
        1 like
        Last Post Gavini
        by Gavini
         
        Working...
        X