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

Multiple Instruments/time frames example for indicator NT7

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

    Multiple Instruments/time frames example for indicator NT7

    Hello ,

    I have just spent 2 hours looking for any examples for multiple instruments INDICATOR(not strategy) code for NT7 beta 6. To my surprise couldn't find any solution. I thought that was one of the bigger promisses of NT7 to allow spread charting and trading???
    Any suggestions? It would be nice to have a working example of an indicator for spread between 2 stocks.
    Is implementation the same as within strategy?
    What about example for multiple time frame indicator?
    Thank you for Help.

    P.S There is many similar requests, but no usefull example.
    Most posts have future release of NT7 as reply... well it is here...

    #2
    I provided a reply to a similar request of yours here: http://www.ninjatrader-support2.com/...ead.php?t=9092

    Comment


      #3
      Still need an example

      Thank you for quick reply,

      However I am not able to make an indicator with a strategy code.

      This simply DOES NOT WORK in indicator:
      In initialize:
      Add("XTO", PeriodType.Minute, 15);
      In OnBarUpdate()
      double Spread = (( 0.5*(Close[0]))-(Close[BarsArray[1]]));

      Specifically compiler complains about BarsArray[1]
      Can not convert NinjaTrader.Data.Bars to int
      First DataSeries is "XOM"

      All I am asking for is a general example of a working code of the Multy Insrument /Multy Timeframe INDICATOR.
      I guess there must be a little more than just copying strategy code to indicator???
      And if it is indeed that easy why not just post the SampleMultiiInstrumentStrategy file as an Indicator???

      Thank You for Help.

      P.S I am sure this subject is of great interest to many NT7 users.

      Comment


        #4
        I am creating a spread between 2 instruments :

        XOM - XTO

        (Close[BarsArray[1]])is the wrong way to go about it, just can't figure out how to do it

        Comment


          #5
          You can calculate the spread between the primary bar series and the seconday bar series using the following:

          Code:
          double Spread = (( 0.5*(Close[0]))-(Closes[1][0]));
          More information on this topic can be found here.

          Refer to the section "Accessing the Price Data in a Multi-Bars Strategy" in the link above.
          Ryan M.NinjaTrader Customer Service

          Comment


            #6
            Thank you Ryan,

            It almost works except for the number must be an int? But the ratio is double (0,7098).

            double Spread = (( 2*(Close[0]))-(Closes[1][0]));// this works

            double Spread = ((0,7098*(Close[0]))-(Closes[1][0]));//and this doesn't

            This is how it is done in Tradestation:
            Spread = (( Alpha*(Close of Data1))+number1)-(Close of Data2)+ number2;

            C# is more advanced than Easy Language, but some times simple things require more work.

            Thank you for Help!

            Comment


              #7
              Also I have just realized that with an instrument hardcoded into indicator:

              Add("XTO", PeriodType.Minute, 15);

              I will have to create an indicator for each pair of stocks.
              There must be another way. Is it possible somehow use Input[1]and Input[2] instead of Add method?

              Thank you.

              Comment


                #8
                Which exact compile error do you get? Does this below work?

                Code:
                 
                double Spread = ((0.7098*(Close[0]))-(Closes[1][0]));//
                Forgot to add - for making this indicator more flexible you can use string user defined inputs for the symbol and period.
                Last edited by NinjaTrader_Bertrand; 01-06-2010, 06:20 AM.
                BertrandNinjaTrader Customer Service

                Comment


                  #9
                  Good Morning Bertrand,

                  NT7 has a bug in compiler, it doesn't give message when compilation is succesfull...

                  The code with double ratio compiles, but input defaults to 1 in indicator properties.

                  Thank you very much.

                  Gene.
                  Attached Files

                  Comment


                    #10
                    Yes, your property for the input defaults to a min value of 1 in your indicator properties.

                    This is not a bug in the NT7 compiler, but expected - you hear a sound now confirming successfull compilation.
                    BertrandNinjaTrader Customer Service

                    Comment


                      #11
                      Hello Bertrand,
                      Sorry for confusion, I have managed to plot correct ratio.
                      I think the problem was that I have initially compiled indicator via vizard with default and min values being the same 1.00. I am not sure if this is normal behavior. Also chart data for XOM_XTO pair full of Gaps? While individually ploted dataseries complete. I use IQfeed. Is it another bug or maybe there is something I am doing wrong?

                      On the separate issue. There is a wonderfull Pivots indicator in NT7. I am strugling with the coding of Price Crossing above/below pivot levels for market analyzer and alert window. Can you please point me to resources for this (other then ninja tutorial).I have so far coded else if block, but that only allerts of price being near pivot, not direction(cross).

                      Thank You.

                      Gene.

                      Comment


                        #12
                        Bertrand,
                        In NT6.5 there was an option in properties
                        1)to exclude weekends, holidays
                        2) specify 9:30am-4:00pm session.

                        In NT7 first I can't find and second there is no template for NYSE?

                        Thank You.

                        Gene.

                        Comment


                          #13
                          Gene,

                          1. Correct all done now with the Session templates / Session Manager.

                          2. Please use the US Equities RTH template for this.

                          For your prior post -

                          3. Is your testing on the latest beta 6?

                          4. Expected for a multiseries chart in NT7 using non equidistance bar spacing per default.

                          5. Have you tried working with Cross Above / Cross Below for this script? There's also an overload for comparing a dataserie (i.e. Close) to a doublevalue (your pivot value).
                          BertrandNinjaTrader Customer Service

                          Comment


                            #14
                            Thank You Bertrand,

                            I am not able to eliminate gap from 11/31/2009 to 1/4/2010 on APA-APC pair, I have used USA equities RTH template.
                            My testing on the latest beta 6. I am not sure what this means?
                            4. Expected for a multiseries chart in NT7 using non equidistance bar spacing per default.
                            I have tried using Cross Above / Cross Below , however I have managed to crush NT7 (code compiled)while loading indicator to Market Analyzer. As a result I could not recover workspace(had to rebuilt workspace from scratch). I did something like:
                            if (CrossAbove(Close, PP, 1))//PP is pivot
                            Are you refering to overload for CrossAbove?

                            Thank you for Help!

                            Gene.


                            Comment


                              #15
                              Gene, which broker or datafeed are you using for feeding NT7?

                              For the crash, please contact me via the Help > Mail to Support feature with your logs and include which exact code you used so I could check into, thanks.
                              BertrandNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by SnailHorn, Today, 10:49 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post SnailHorn  
                              Started by naanku, Today, 07:25 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post naanku
                              by naanku
                               
                              Started by milfocs, Today, 07:23 PM
                              0 responses
                              6 views
                              0 likes
                              Last Post milfocs
                              by milfocs
                               
                              Started by PaulMohn, Today, 06:59 PM
                              0 responses
                              8 views
                              0 likes
                              Last Post PaulMohn  
                              Started by bortz, 11-06-2023, 08:04 AM
                              48 responses
                              1,756 views
                              0 likes
                              Last Post carnitron  
                              Working...
                              X