Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Indicator based on several dataseries

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

    Indicator based on several dataseries

    Hello,
    1. Can I base an indicator on a dataseries other than the one on the chart?
    2. Can I base an indicator on the inverse of a currency pair?
    3. Can I base an indicator on a percentage value of several dataseries, say 25% of each of four different currency pairs?
    4. How would I go about setting up a basket of say four currencies to which each individual currency is paired, for use as the dataseries in an indicator?
    5. Is it possible to have just the indicator plots display and have no dataseries selected for the chart?


    Thank you.

    #2
    Hello,

    Thank you for the post.

    1. Yes this is possible, adding additional series is possible through NinjaScript. There is also a good framework in place to deal with the multiple series to know what series should execute logic at what time. Please see the following links:



    2. I am not certain I know exactly what you mean by the inverse of a pair, if you mean negative or some equated value this would be possible.

    3. Yes, an indicator can add multiple series or plots, and then you can use that data as input to other calculations in the script.

    4. I am not certain I understand the question, Could you provide further detail on this?

    5. This would not be possible, some Primary series is needed to start the chart. You could make the primary charts bars transparent and also not make use of the primary series at all if needed. In this case you may need to utilize Overlay as the ScaleJustification if the prices are very different.

    Comment


      #3
      Thanks for the reply Jesse.

      What I am trying to build is an indicator to show which foreign currency is Overbought or Oversold. This can be done on an individual pairs basis as per the image attached.
      This is based on the following snippet of code:
      Code:
      myDataSeries6A.Set(Math.Log10(bullVolPerTick / bearVolPerTick)/Period);
      
      			Bsl6A.Set(SUM(myDataSeries6A, Period)[0]);
      
      			if (BarsInProgress == 1)
      			{
      			myDataSeries6B.Set(Math.Log10(bullVolPerTick / bearVolPerTick)/Period);
      			Bsl6B.Set(SUM(myDataSeries6B, Period)[0]);	
      			}			
      			if (BarsInProgress == 2)
      			{
      			myDataSeries6E.Set(Math.Log10(bullVolPerTick / bearVolPerTick)/Period);
      			Bsl6E.Set(SUM(myDataSeries6E, Period)[0]);
      			}
      			if (BarsInProgress == 3)
      			{
      			myDataSeries6J.Set(Math.Log10(bullVolPerTick / bearVolPerTick)/Period);				
      			Bsl6J.Set(SUM(myDataSeries6J, Period)[0]);
      			}
      What I also want is to be able to base each plot on 25% of 4 different dataseries, but when I try to do the calculations such as:
      Code:
      Bsl6B.Set(SUM((myDataSeries6B * 0.25) + (myDataSeriesPJY * 0.25), Period)[0]);
      etc. by using + or * signs in the .Set method, I get NT0019 errors "Operator "+" or "*" cannot be applied to operands of the type Ninjatrader.Data.DataSeries. How would I go about using more than one data series in the calculations for each plot line?

      Also,
      1. Is there a way to add a label at the right end of each plot from the script - the labels in the image have been added to the chart after.
      2. Is there a way for me to write the script so that I can change the Period.Type and Value from a chart?

      Thank you.
      Attached Files
      Last edited by GeorgeW; 11-27-2016, 10:26 AM.

      Comment


        #4
        Hello,

        Thank you for the reply.

        The error you are seeing: "Operator "+" or "*" cannot be applied to operands of the type Ninjatrader.Data.DataSeries

        This tells us exactly what is happening, math operators can not be applied to a DataSeries, a whole DataSeries. Instead you would need to use a BarsAgo value to get the price and then use math on that value:

        Code:
        Bsl6B.Set(SUM((myDataSeries6B[B][0][/B] * 0.25) + (myDataSeriesPJY[B][0][/B] * 0.25), Period)[0]);

        Regarding the Labels, what you have already shown is likely the easiest way to accomplish this. There is not a way to add Price markers with text, so some chart drawing would be needed like Text or to render Text using the plot override.

        For the PeriodType, the most simple way would be to use an enum property and decide based on its value.

        Code:
        [Description("Numbers of bars used for calculations")]
        [GridCategory("Parameters")]
        public PeriodType MyPeriod{get;set;}
        Although if this is intended to be used in Initialize to control Add statements, I would not suggest to do this. For items in Initialize like Add, these should not be toggled as the changes may not be reflected upon Reloading, instead removing the instance and re adding it may be needed.

        I look forward to being of further assistance.

        Comment


          #5
          Thanks Jesse.

          I did get the computations to work by setting up variables and doing the calculations there first, then including them in the .Set methods like so:
          Code:
          if (BarsInProgress == 2)
          			myDataSeries6E.Set(Math.Log10(1/currencyBasketIndexEUR + 1/currencyBasketIndexRP + 1/currencyBasketIndexEAD 
          			+ 1/currencyBasketIndexRY )/Period);
          			Bsl6E.Set(SUM(myDataSeries6E, Period)[0]);
          I'll take a look at your example to see if it gives the same results.

          Comment


            #6
            I am getting errors CS1502 "The best overload method... has some invalid arguments" and NT1503 "Argument 1 cannot convert from double to to Ninjatrader.Data.IDataSeries" when I try to compile using the code as illustrated by you.
            Code:
            Bsl6A.Set(SUM(((myDataSeries6A[0]) + (myDataSeriesEADInv[0]) + (myDataSeriesAJY[0]) + 
            			((myDataSeries6A[0] * myDataSeries6BInv[0]))), Period)[0]);

            Comment


              #7
              Hello,

              In this case the SUM is causing the error because it wants a DataSeries but you are trying to give it a Double. I am sorry I should have been more specific previously, the Result would need to be added to a DataSeries if you will be using SUM or any other indicator.

              Just as you have created other Plots/DataSeries (myDataSeries6A), you would need to make one for the calculated value as well so the SUM can access the series of result data.

              To break what you have apart for that, you could do something like the following:

              Code:
              double result = myDataSeries6A[0] + myDataSeriesEADInv[0] + myDataSeriesAJY[0] + (myDataSeries6A[0] * myDataSeries6BInv[0]);
              
              ResultSeries.Set(result);
              
              Bsl6A.Set(SUM(ResultSeries, Period)[0]);
              You basically have everything needed aside from one additional DataSeries to store the calculated data. Once you Store the data in a DataSeries, that data can be passed to other items like Indicators or SUM.

              I look forward to being of further assistance.

              Comment


                #8
                Thanks Jesse, that's fixed it.

                On a related point, for some of the Forex Futures such as EAD (EUR/AUD) and RP (EUR/GBP), data appears for them on the Market Analyzer, but if I try to access them directly through an indicator script, I get the error message "Error on loading chart data for EAD 12-16 Globex, NinjaTrader data server does not support this instrument, no data available." How is it possible that data shows up on the Market Analyzer but the script error message is saying no data exists for that instrument?

                Comment


                  #9
                  Hello,

                  What symbol are you using in the MarketAnalyzer specifically?

                  Is this set up specifically as a future instrument in the Instrument Manager? If so, the contract dates should be able to be used. Otherwise if this is set up as anything else like a Stock or Forex, you would need to remove the contract month and year and just use the symbol.

                  If you can tell me how the instrument is configured in the Instrument manager that would be helpful.

                  I look forward to being of further assistance.

                  Comment


                    #10
                    They are set up as Type: "Future" in the Instrument Manager. The symbols used in the Market Analyzer are: EAD 12-16 and RP 12-16.

                    Comment


                      #11
                      Hello,

                      Thank you for the reply.

                      One other item, does this instrument get Historical data through the connection or had you imported historical data?

                      Based on the error message it seems the server is unable to provide Historical data for the instrument. This could either be that there is no data or that something is not configured correctly.

                      Could you tell me also who are you connecting to? I could try to load the instrument on the same connection and see if I have the same result.

                      I look forward to being of further assistance.

                      Comment


                        #12
                        I am connecting to Continuum and I get historical data through the connection.

                        Comment


                          #13
                          Hello,

                          Thank you for the reply.

                          Is this an instrument you have subscribed for specifically with Continuum? I was unable to access the data for this instrument on the Demo connections for continuum unfortunately. This could potentially be caused also if I do not have the correct symbol mapping for the instrument.

                          I had received the same error as you had while trying to access the instrument, there was no data to be downloaded using the symbol. To further assist you, could you email me at platform support [at] ninjatrader.com? I would like to review the instrument you have created on my end to see if I can download the data for this, and if not we can schedule a remote assistance call. Please include a link to this forum post in the email.

                          I look forward to being of further assistance.

                          Comment


                            #14
                            This is the information I received when I emailed support about the data issue for these Forex Futures instruments:
                            "Currently historical data is not recorded for these instruments therefore only real time data will be available for these instruments. In order to backfill charts with this data you would need to connect to a provider that provides historical data for these instruments."

                            Comment


                              #15
                              Hello,

                              Thank you for the reply.

                              In this case it seems there is no historical data for the instrument so the error would be justified. The script is requesting historical data for the instrument which there is none, the Market Analyzer would not require this step preventing the message.

                              In this case you can turn on the option to Record live data as historical data to persist the data. You can turn this on in the Tools -> Options -> Data menu.

                              The script could then use that saved data to calculate but may still receive the error message because the instrument does not have historical data when the script requests it.

                              I look forward to being of further assistance.

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                              0 responses
                              581 views
                              0 likes
                              Last Post Geovanny Suaza  
                              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                              0 responses
                              338 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by Mindset, 02-09-2026, 11:44 AM
                              0 responses
                              103 views
                              0 likes
                              Last Post Mindset
                              by Mindset
                               
                              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                              0 responses
                              554 views
                              1 like
                              Last Post Geovanny Suaza  
                              Started by RFrosty, 01-28-2026, 06:49 PM
                              0 responses
                              552 views
                              1 like
                              Last Post RFrosty
                              by RFrosty
                               
                              Working...
                              X