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 Timeframe issue

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

    Multiple Timeframe issue

    I am facing Multiple Timeframe issue.
    The primary instrument is 5 min timeframe.
    I have initialized the other timeframes as below in Initialize()

    Add(PeriodType.Minute, 15);
    Add(PeriodType.Minute,
    60);


    I have created a simple Spread function
    public double Spread(IDataSeries data1, IDataSeries data2) {
    return data1[0]-data2[0];
    }


    I create a strategy where I want to compute a variable x such that
    x = Spread(15min-low, 60min-high)*100

    Using
    x = Spread(Lows[1][0],Highs[2][0]) *100

    doesnot work correctly due to datatype error.


    Please advise.
    Last edited by ripwinkle; 07-29-2012, 05:34 AM.

    #2
    ripwinkle.

    Could you show us the exact error here?
    Adam P.NinjaTrader Customer Service

    Comment


      #3
      the errors are as below :-

      ErrorThe best overloaded method match for 'NinjaTrader.Strategy.Strategy.Spread(NinjaTrader. Data.IDataSeries, NinjaTrader.Data.IDataSeries)' has some invalid argumentsArgument '1': cannot convert from 'double' to 'NinjaTrader.Data.IDataSeries'Argument '2': cannot convert from 'double' to 'NinjaTrader.Data.IDataSeries'

      where method points to 'Spread'
      argument 1 points to 'Lows'
      argument 2 points to 'Highs'

      Please advise.

      Comment


        #4
        Originally posted by ripwinkle View Post
        I am facing Multiple Timeframe issue.
        The primary instrument is 5 min timeframe.
        I have initialized the other timeframes as below in Initialize()

        Add(PeriodType.Minute, 15);
        Add(PeriodType.Minute,
        60);


        I have created a simple Spread function
        public double Spread(IDataSeries data1, IDataSeries data2) {
        return data1[0]-data2[0];
        }


        I create a strategy where I want to compute a variable x such that
        x = Spread(15min-low, 60min-high)*100

        Using
        x = Spread(Lows[1][0],Highs[2][0]) *100

        doesnot work correctly due to datatype error.


        Please advise.
        I haven't typed this up,

        but does this work?

        Code:
        x = Spread(Lows[1],Highs[2]) *100;





        Comment


          #5
          This does work Sledge and I have previously tried it also.

          1. But I want to confirm if this is exactly going to provide the output that I originally intended ?
          Is Lows[1] = Lows[1][0] ?

          2. Also, if the computation was not on the current bar, and I intended to compute on one bar ago i.e.

          x = Spread(Lows[1][1],Highs[2][1]) *100

          then how can I achieve the same ?

          Please assist.

          Comment


            #6
            ripwinkle,

            Lows[1] refers to the dataseries of your 15 minute instrument. Lows[1][1] refers to the Low double value of [1] 15 minute candle ago. If you want to use the double values of a certain candle of your choice, instead of the current value, trying changing your function definition to take doubles as arguments instead of DataSeries':

            Code:
            public double Spread(double data1, double data2) {
                return data1-data2;
            }
            Now when you call the function you can use:

            Code:
            x = Spread(Lows[1][1],Highs[2][1]) *100
            Hope that helps,

            Kenny

            Comment


              #7
              Thanks Kenny!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Tim-c, Today, 03:54 AM
              0 responses
              3 views
              0 likes
              Last Post Tim-c
              by Tim-c
               
              Started by FrancisMorro, Today, 03:24 AM
              0 responses
              2 views
              0 likes
              Last Post FrancisMorro  
              Started by Segwin, 05-07-2018, 02:15 PM
              10 responses
              1,771 views
              0 likes
              Last Post Leafcutter  
              Started by Rapine Heihei, 04-23-2024, 07:51 PM
              2 responses
              31 views
              0 likes
              Last Post Max238
              by Max238
               
              Started by Shansen, 08-30-2019, 10:18 PM
              24 responses
              945 views
              0 likes
              Last Post spwizard  
              Working...
              X