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 Barry Milan, Today, 10:35 PM
              0 responses
              0 views
              0 likes
              Last Post Barry Milan  
              Started by DJ888, Yesterday, 06:09 PM
              2 responses
              9 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by jeronymite, 04-12-2024, 04:26 PM
              3 responses
              40 views
              0 likes
              Last Post jeronymite  
              Started by bill2023, Today, 08:51 AM
              2 responses
              16 views
              0 likes
              Last Post bill2023  
              Started by sidlercom80, 10-28-2023, 08:49 AM
              167 responses
              2,260 views
              0 likes
              Last Post jeronymite  
              Working...
              X