• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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, 04: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 pstrusi, Today, 09:06 AM
              0 responses
              1 view
              0 likes
              Last Post pstrusi
              by pstrusi
               
              Started by vpzdcv, Today, 02:31 AM
              0 responses
              8 views
              0 likes
              Last Post vpzdcv
              by vpzdcv
               
              Started by YevhenShynkarenko, Today, 01:22 AM
              0 responses
              16 views
              0 likes
              Last Post YevhenShynkarenko  
              Started by ttodua, Today, 12:52 AM
              0 responses
              7 views
              0 likes
              Last Post ttodua
              by ttodua
               
              Started by ttodua, Today, 12:50 AM
              0 responses
              6 views
              0 likes
              Last Post ttodua
              by ttodua
               
              Working...
              X