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

Locate Plot associated with a DataSeries

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

    #16
    Hello,

    For the updates, this all revolves around the data that is incoming from the instrument.

    So lets say you have a single data series in a chart with no indicators or NinjaScript items.

    This data series and its graphical representations (bars on the chart) will be updated automatically when new data is received.

    The current bar or the building bar depending on what time frame you have set will update accordingly.

    Example: a 1 tick chart will generate a new bar for every tick of data, if you have last selected this would just be 1 bar for every last price that is received.

    Example: a 1 minute chart will generate a new bar for every 1 minute of data that is received, if there is no market data no bars will be generated until more data is received.

    Now for indicators and NinjaScript items and drawing objects.

    A drawing object is not really attached to a specific dataseries on the chart in this sense, it is merely being drawn on this chart at X value and will be graphically updated when the value is updated for this object such as an OnBarUpdate event in the previous examples.

    The same goes for the indicators, they will be updated in a few different ways

    CaclulateOnBarClose true will allow the indicaors OnBarUpdate event to be called every time a bar closes in ANY data series on the chart
    CaclulateOnBarClose false will allow the indicaors OnBarUpdate event to be called every time a tick is received in ANY data series on the chart.

    The graphical representation to plots, or any other items that the indicator specifically is drawing will be updated on either of these events if the value that is being plotted changes otherwise it will retain its original value and graphics.

    There are also other events that happen in Indicators such as OnMarketData which is similar to how OnBarUpdate works but this event happens for any price data item that is updated, so last, ask, bid, vol etc...

    For the question on the SMA, if you add an SMA to a chart, the underlying code Sets the plots value in the OnBarUpdate event, you can look at this code if you go to Tools -> Edit NinjaScript -> Indicator and select the SMA and open it.

    The SMA uses Value.Set to set its value for the plot rather than calling it by a name or using Values.

    Value.set() would set the 0 index of Values where Values you can specify an index in the collection of plots such as Values[1].Set();


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #17
      Excellent.

      So, SMA is passed a DataSeries when an update is required.

      Now, if I have multiple DataSeries and multiple SMAs, how does it know which DataSeries to pass to a given SMA?

      Comment


        #18
        Hello,

        For Indicators you add directly through the chart, this would be set using the "Input Series" in the indicators properties.

        For indicators added through script, it is the same but you do this in the call to the indicator or:

        double price = SMA(12)[0]; //this would give you the SMA using the charts default data series

        double price = SMA(Close, 12)[0]; //this would give you the SMA using the Close prices of the charts default dataseries.

        double price = SMA(Closes[1], 12)[0]; //this would give you the SMA using the Close prices of a secondary data series or data series index 1

        Here is some information on data series
        Take a look at Close first then Closes



        Also this is relevant with adding multiple data series for the BarsInProgress
        JesseNinjaTrader Customer Service

        Comment


          #19
          Thanks. That all makes sense.

          I must still be missing something, though.

          When the SMA indicator is called, it passed a reference to a DataSeries. Is that correct?

          If so, how does NT know which DataSeries that this indicator requires?

          Comment


            #20
            Hello,

            Thats what I was explaining in the last post,

            If it is added from the chart directly through the indicators panel, if you open that up now and look you will see in each of the indicators properites there is a "Input Series" this defines the data series that this indicator specifically will use while it is loaded in this chart.

            Otherwise if you are using a indicator in a script you need to pass the data series to the indicator in an overload which were these examples;

            Code:
            double price = SMA(12)[0]; //this would give you the SMA using the charts default data series
            
            double price = SMA(Close, 12)[0]; //this would give you the SMA using the Close prices of the charts default dataseries.
            
            double price = SMA(Closes[1], 12)[0]; //this would give you the SMA using the Close prices of a secondary data series or data series index 1
            If you have multiple data series thats where the 3rd example comes in, you need to specify the index of the data series.

            Lets say you have a chart and this indicator adds an additional data series to the chart.

            you see visually on the chart the 1 data series you added but in memory there is the second that the indicator has added.

            In this example you would need to specify is this indicator using data series 0 or data series 1, or Closes[0] or Closes[1] or SMA(Closes[1],12)
            JesseNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by kempotrader, Today, 08:56 AM
            0 responses
            6 views
            0 likes
            Last Post kempotrader  
            Started by kempotrader, Today, 08:54 AM
            0 responses
            4 views
            0 likes
            Last Post kempotrader  
            Started by mmenigma, Today, 08:54 AM
            0 responses
            2 views
            0 likes
            Last Post mmenigma  
            Started by halgo_boulder, Today, 08:44 AM
            0 responses
            1 view
            0 likes
            Last Post halgo_boulder  
            Started by drewski1980, Today, 08:24 AM
            0 responses
            4 views
            0 likes
            Last Post drewski1980  
            Working...
            X