Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

how do i create a custom index?

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

    how do i create a custom index?

    I'm really just interested in combining two different EOD securties into a single price series for charting and backtesting. Is that possible in NT? Big time noobie, just trying to figure out where to start, if this is possible.
    thanks for your help,
    rhoward

    #2
    Hello,

    There is not a way to do this right out of the box, but it would be possible to accomplish this by custom coding an indicator. If you would like to go this route, I'll be happy to point you in the right direction.
    Dave I.NinjaTrader Product Management

    Comment


      #3
      I would appreciate that, Dave..Hopefully the coding would not be too much of a daunting task! I have a little experience in creating indicators, but not in NT.
      thanks again,
      rhoward

      Comment


        #4
        I'll be happy to help, and the task should not be too daunting if you have previous coding experience.

        There is a pre-loaded indicator called HeikenAshi that already hides and replaces the data series with its own series of bars on a chart, and you can use this indicator as a starting point to develop what you are looking for. You will need to open the source of the HeikenAshi indicator via Tools > Edit NinjaScript > Indicator, then copy all of the code and paste it into a new indicator via Tools > New NinjaScript > Indicator.

        In the new indicator, you can use the Add() method to add any two data series that you wish, such as two daily series. You can then delete all of the logic related to the HeikenAshi calculations in HAClose.Set(), HAOpen.Set(), etc., and replace it with your own calculations to combine the values of the two data series.

        Assuming you wish to find the average between the prices of both data series, you could do something like the following:

        HAClose.Set((BarsArray[1].GetClose(0) + BarsArray[2].GetClose(0)) / 2);

        ...and the same for HAHigh, HALow, and HAOpen.

        One quick thing to note -- If you go this route, you will need to make sure that "Auto Scale" is set to "False" in the Data Series window for the primary data series, so that you don't run into any scaling issues.

        Please let me know if I can assist further.
        Dave I.NinjaTrader Product Management

        Comment


          #5
          I am looking for a way to plot the oil crack spread for NT8, which has three futures instruments and this weighting 84*RB + 42*HO - 3*CL. Would the Heikin-Ashi code provide a base to allow three instruments and the multiplication and subtraction?

          BTW, in NT8, I found a HeikenAshiBarsType, but not a HeikinAshi indicator.

          I found a "Spread" NT8 indicator in futures.io that may be a good foundation. It has two dataseries, and parameters for the ratios. I will see if I can add a third.
          Last edited by BruceK; 11-14-2018, 10:43 PM.

          Comment


            #6
            Hello BruceK,

            Thanks for your inquiry.

            NinjaTrader 8 has a Heiken Ashi BarsType which rounds values to a tick size so they can be backtested appropriately. This makes the calculation different from the indicator which uses the data points without rounding the input. We have a Heiken Ashi indicator that can be downloaded below.

            Heiken Ashi - https://ninjatraderecosystem.com/use...heiken-ashi-8/

            The Heiken Ashi indicator would be a good example to use for rendering candlesticks based off your own Open High Low and Close Series. Calculating based off of additional data series could be better referenced in a spread indicator.

            For adding additional data series to your script, this would be done using AddDataSeries and following the multi time frame documentation linked below. Please note that it is not technically supported to use user defined input for adding additional data series. (See notes in AddDataSeries) A spread indicator that uses user defined input for the data series would break this rule, and issues can particularly be seen if you are running optimizations in the Strategy Analyzer. There are several cases where this does work, but if you run into issues, be sure to test with a hardcoded data series, which we do support.

            Multi Time Frame and Instruments - https://ninjatrader.com/support/help...nstruments.htm

            Let us know if we can be of further assistance.
            JimNinjaTrader Customer Service

            Comment


              #7
              So I'm a bit late to the party as this thread is from 4 years ago, but I'm trying to get this happening in NT8 and I can't get HAClost.Set() to compile. I've spent most of the afternoon in MultiTimeFrame & Instruments and I can't get this happening. I can AddDataSeries() just fine but when I try to put it on the chart via HAClose/HALow, etc, NT8 is only taking the last bar of data and plotting that across every bar on that chart. instruments (via AddDataSeries) and plot their sum on the chart. So far, I can plot the last bar of data (OHLCV) on every bar on the chart. I suspect that HAClose.Set() is specific to NT7. What is the equivalent on NT8?

              Thanks

              Brennan

              Comment


                #8
                Hello Brenan,

                Set is not a method of Series<t> objects in NinjaTrader 8. We would assign from the barsago reference in NinjaTrader 8. Please see our Code Breaking Changes page of the Help Guide to reference differences between NinjaTrader 7 and NinjaTader 8.

                I also suggest viewing our AddPlot documentation which explains how you can add multiple plots and assign values to those plots. The HeikenAshi indicator creates 4 plots for OHLC and then uses SharpDX to draw those plots as bars.

                Code Breaking Changes (Filter by "Set" to see the NinjaTrader 8 suggestion for Set) - https://ninjatrader.com/support/help...ng_changes.htm

                AddPlot - https://ninjatrader.com/support/help...8/?addplot.htm

                We look forward to assisting.

                JimNinjaTrader Customer Service

                Comment


                  #9
                  So as a simple 'first step' I'm trying to just add a secondary series and reference the data from it. I've got a 1min chart of AUDCHF and I'm trying to add EURUSD to it and reference EURUSD data. I've got "AddDataSeries("EURUSD") - [leaving the barperiodtype out because I think if it's unspecified it follows the chart's property] - in OnStateChange() -> if(State == State.Configure) and that much seems to work well enough but I can't seem to get them to sync up between AUDCHF and EURUSD. I've tried to specify the 1min timeframe on AddDataSeries(), I've tried to create a Series with Series<double> x = new Series<double>(BarsArray[1]) or using 'this' in the constructor, etc. I've tried to specify via if(BarsInProgress == 1) return, etc. to no luck so far. I try to send the data to the LogScreen via Print(Close[0] + " " + BarsArray[1].GetClose(0)) or Print(Close[0] + " " + Closes[1][0]) and it seem to just put the last close of EURUSD with each close of AUDCHF.

                  Can you help me find what I'm missing here?

                  Thanks,
                  Brennan

                  Comment


                    #10
                    Hello Brennan,

                    Thanks for your reply.

                    I may suggest posting questions in a new thread so we can keep this thread on focus with NinjaTrader 7, and so your question and answers can be quickly found in a thread in the NinjaTrader 8 forums.

                    We should note that NinjaTrader is event based, meaning bars are updated with incoming ticks, and are not checked on a timer. A bar closure is signaled when we see the first tick of a new bar. If there is no tick, there will be no bar, so you could have cases where there is a bar on one data series, but no bar on another data series. It would not be easily possible to have two synchronized data series since they are updated by different data streams.

                    I would suggest following our Multi Time Frame documentation and specifically reviewing the True Event Driven OnBarUpdate section. Here we can simply print the following in each BarsInProgress check:

                    Code:
                    Print(String.Format("BIP: {0} Time[0]: {1} Close[0]: {2}", BarsInProgress, Time[0], Close[0]));
                    Multi Time Frame and Instruments - https://ninjatrader.com/support/help...nstruments.htm

                    Your prints will then make more sense. If you have additional questions, please provide them in a new thread, and please include a simple test script showing what you are testing. With a clear and simple example, we will better be able to assist you. You can include the text "Attn Jim" and link this thread, and my colleagues will know the message should be received by me.

                    Exporting as source code - https://ninjatrader.com/support/help...tAsSourceFiles

                    Also related, please see the AdvanceDecline indicator we have shared. This indicator can get close because the data series are closely related, but because these are separate streams and we can't "add a bar to the primary series if we only see a secondary bar"

                    Advance Decline indicator - https://ninjatraderecosystem.com/use...vance-decline/

                    The link above is publicly available.

                    The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.


                    I look forward to assisting.
                    Last edited by NinjaTrader_Jim; 12-22-2020, 04:43 PM.
                    JimNinjaTrader Customer Service

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by andrewtrades, Today, 04:57 PM
                    1 response
                    9 views
                    0 likes
                    Last Post NinjaTrader_Manfred  
                    Started by chbruno, Today, 04:10 PM
                    0 responses
                    6 views
                    0 likes
                    Last Post chbruno
                    by chbruno
                     
                    Started by josh18955, 03-25-2023, 11:16 AM
                    6 responses
                    436 views
                    0 likes
                    Last Post Delerium  
                    Started by FAQtrader, Today, 03:35 PM
                    0 responses
                    8 views
                    0 likes
                    Last Post FAQtrader  
                    Started by rocketman7, Today, 09:41 AM
                    5 responses
                    19 views
                    0 likes
                    Last Post NinjaTrader_Jesse  
                    Working...
                    X