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

Multi instrument indicator

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

    Multi instrument indicator

    hi

    if I have a multi instrument indicator, when I add that to a chart, do I have to load data series for Both instruments that are being used in the indicator? Or is NT smart enough to fetch data that is not loaded on the chart? I'm asking, because I get different values for my indicator when I have loaded both instruments, vs, when I have loaded only 1 instrument

    i've added the below in initlize()

    Add(FirstInstrument, PeriodType.Day, 1);
    Add(SecondInstrument, PeriodType.Day, 1);

    ------------

    OBU()

    and i'm using Closes[1][0], Closes[2][0], Closes[1][30], Closes[2][30]; in my indicator.

    ---

    so my question is, for the below indicator to work properly, do I have to load firstinstrument data series AND secondinstrument data series? Because as of right now, I have been only viewing this by loading only the first instrument data series, and I accidentally loaded both data series and added the indicator, and my values are completely different. Someone give me pain medicine

    And yes my data input for the indicator when I added it to the chart are identical for both methods. This is the input that is asked when you add a indicator to the chart
    Last edited by staycool3_a; 03-16-2015, 10:52 PM.

    #2
    Hello Calhawk01,

    Thank you for your post.

    Just to clarify, when you add another chart bars that uses the same instrument and time series as your added underlying series, it will give you completely different values than what the bars on the chart say?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Cal View Post
      Hello Calhawk01,

      Thank you for your post.

      Just to clarify, when you add another chart bars that uses the same instrument and time series as your added underlying series, it will give you completely different values than what the bars on the chart say?
      Create Multi instrument indicator that calculates spread between two instruments. Then open up a chart with only instrument. Add the indicator on this chart that you created earlier. The indicator value equals 12

      Open up a new chart and are both instruments on it. Panel 1 instrument 1 and panel 2 instrument 2. Then add indicator on panel 3. The indicate value is 10

      Above data series are both on daily bars. Both are loading 180 days worth of days.

      Comment


        #4
        Calhawk01,

        What are you merge policy settings set to?

        Tools -> Options -> Data Tab

        I would recommend DoNotMerge so that you get the next contract data and not the current one since the rollover has not occurred yet.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Cal View Post
          Calhawk01,

          What are you merge policy settings set to?

          Tools -> Options -> Data Tab

          I would recommend DoNotMerge so that you get the next contract data and not the current one since the rollover has not occurred yet.


          Mergebackadjusted

          What does my issue have with the above? I don't it does. My issue is different. I'm calculating spread between ES and NQ.

          Indicator= spread

          Initialize()
          Add daily ES data
          Add daily NQ data

          OBU()
          Code:
                  {		
          			if (CurrentBarArray[0] > 0 && CurrentBarArray[1] > 0 && CurrentBarArray[2] > 0)
          			{
          				if (BarsInProgress == 0) 
          					
          				a = (((Closes[2][0]-open2)/ticksize2) *usd2);
          				b = (((Closes[1][0]-open1)/ticksize1) *usd1);
          				c = (a - b);	
          				
          				{
          					Ratio.Set(c);
          				}
          			}
          		}
          My issue is occurring when I add this indicator to a chart that only has loaded ES data. Previously I was ASSUMING that since I have added the data series for both ES and NQ in my indicator code, the indicator is able to fetch the data for ES and NQ in the background and calculate and plot the "ratio"

          But now I'm seeing that I am getting different results when I Load ES and NQ data on chart.


          So for example if I load 180 worth of daily bars on chart:

          METHOD 1: Panel 1 has ES, Panel 2 has indicator. My indicator value is 12.

          Method 2: panel one has ES, and panel 2 has NQ. And panel 3 has indicator. The indicator input is ES. My indicator value is 4

          Why is this happening? I would assume I get the same values. In the above example, Method 1 has the correct values when I manually check it.
          Last edited by staycool3_a; 03-17-2015, 07:34 AM.

          Comment


            #6
            Calhawk01,

            I am not able to reproduce this on my end. I can get both the data and create a matching indicator between the two charts.

            Can you give a sample script that you are working on that re-creates this issue?
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              es data series screenshot = shows only es data series on chart


              es data series = shows the indicator values when only ES is loaded on the chart (ie. the settings in the above screenshot)
              es and nq data series screenshot = shows both es and nq data series being added to chart
              es and nq data series indicator values = shows the indicator values when both nq and es are added on the chart. why do these values change?
              indicator settings screenshot = shows the settings for the indicator. note the "data -> input series" in all of the above remains ES 06-15

              why is this happening? I guess i could always just not add multiple data series on the chart, but why is this happening? the correct values only appear when I only add 1 data series on the chart. What is the correct way to load data series when your indicator has data series for multiple instruments?
              Attached Files

              Comment


                #8
                Originally posted by calhawk01 View Post
                es data series screenshot = shows only es data series on chart


                es data series = shows the indicator values when only ES is loaded on the chart (ie. the settings in the above screenshot)
                es and nq data series screenshot = shows both es and nq data series being added to chart
                es and nq data series indicator values = shows the indicator values when both nq and es are added on the chart. why do these values change?
                indicator settings screenshot = shows the settings for the indicator. note the "data -> input series" in all of the above remains ES 06-15

                why is this happening? I guess i could always just not add multiple data series on the chart, but why is this happening? the correct values only appear when I only add 1 data series on the chart. What is the correct way to load data series when your indicator has data series for multiple instruments?
                ok nvm. i think i figured it out. it was my mistake. the chart templates were different!

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by NRITV, Today, 01:15 PM
                2 responses
                8 views
                0 likes
                Last Post NRITV
                by NRITV
                 
                Started by frankthearm, Today, 09:08 AM
                7 responses
                31 views
                0 likes
                Last Post NinjaTrader_Clayton  
                Started by maybeimnotrader, Yesterday, 05:46 PM
                5 responses
                26 views
                0 likes
                Last Post NinjaTrader_ChelseaB  
                Started by quantismo, Yesterday, 05:13 PM
                2 responses
                19 views
                0 likes
                Last Post quantismo  
                Started by adeelshahzad, Today, 03:54 AM
                5 responses
                33 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Working...
                X