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

How to fix indicator timeframe to 1440 min (daily)

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

    How to fix indicator timeframe to 1440 min (daily)

    Im developping a custom indicator and wanted to know how to fix the timeframe of the indicator to 1440 min bars ie daily bars.
    So even if I am looking at a 30 min chart, if I add the indicator to the chart, it will still be kept on a 1440 min chart and therefore its calculation will be made on a 1440 min chart.

    Also I intend to call this indicator in a strategy based on intraday 30 min bars.
    So if the indicator is already fixed on a 1440 min chart, I will not have to do much except call the indicator within my strategy.

    Is there reference code on how this can be done or a function to do this ?

    #2
    qewcool, for the indicator this is unfortunately not supported for 6.5 as there's only support for MultiSeries strategies, not indicators...



    For your strategy you can add a secondary series to it and then process signals from both timeframes as explained in the link above.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Just in case that is not clear...

      You cannot add bars or series to an indicator, only to strategies. Also note a 1440 Minute indicator will go back 1440 minutes from now, not to the start of the previous day! To get a series that goes from start of day to end of day you will need to use Add(Period.Day,1);
      Last edited by Sleeping Troll; 03-15-2010, 09:22 AM.

      Comment


        #4
        Ran into a weird problem trying out the multi time frame.

        I added these 2 lines just to try :

        in the Initialize() section :
        Add(PeriodType.Minute, 1440);

        in the OnBarUpdate() section:
        if (BarsInProgress != 0)
        return;

        My strategy, which was working fine on a 15 min chart for example, ceased working on a backtest after the addition of those 2 lines.

        If I comment out the line in the Initialize() section :
        //Add(PeriodType.Minute, 1440);

        Then it works again so just that line is screwing stuff up.

        Do you have any idea as to why ? The BarsInProgress filter for index 0 should have kept the existing strategy working from what I understand reading the reference page .... so what is happening ?

        Comment


          #5
          qewcool, how many days back were you loading the strategy? Enought to satisfy the min bars required for the added 1440 min series? The strategy would only start processing as this is passed for all used bars objects...so your 15 min and 1440 min.

          Btw: any errors in the log tab to mention?
          BertrandNinjaTrader Customer Service

          Comment


            #6
            Hi

            I was backtesting on more than a year of data so it should be fine on that side.

            Looking at the log tab I do see an error when I run the backtest :

            "Error on calling 'OnBarUpdate' method for strategy 'CrossoverStrategy': You must use the overload that has a 'BarsInProgress' parameter when calling the BarsSinceEntry() method in the context of a multi-frame and instrument strategy"

            So it seems like my use of BarsSinceEntry is incorrect once I add the 1440 min Bar object even if I have a BarsInProgress filter for index 0 ?

            I must use this method :
            BarsSinceEntry(int barsInProgressIndex, string signalName, int entriesAgo)
            and specify barsInProgressIndex = 0 even if I have a BarsInProgress filter for index 0 at the very beginning of the OnBarUpdate() section ?

            Why is the BarsSinceEntry not working with the BarsInProgress filter for index 0 ?
            Last edited by qewcool; 03-18-2010, 12:10 PM.

            Comment


              #7
              qewcool, I'm not aware of you full code used, but yes for MultiSeries context you have to use the extended overload of BarsSinceEntry offering the BIP parameter. Did changing the code to this fix your issue?

              BertrandNinjaTrader Customer Service

              Comment


                #8
                Yes changing from
                BarsSinceEntry("LE")<30
                to
                BarsSinceEntry(0,"LE",0)<30

                made it work now but the results of the backtest changed
                It is off for about 10% less in Total Net Profit than before but the 2 entries for BarsSinceEntry should be equivalent ?

                Comment


                  #9
                  qewcool, from your posts prior I had the impression the strategy was not work at all for you, so I'm not sure what you compare it to...in a MultiSeries context you have to use the extended overload so it would point to the the correct BIP for the bars count involved.
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    Im using a strategy that is working prior to the addition of the second bar object using BarsSinceEntry("LE")<30 and is posting a positive total net profit on a backtest of a year.

                    once I add the second bar object, I then have to change to BarsSinceEntry(0,"LE",0)<30 to make it work. But it is now posting a total net profit of 10% less .... so I am asking myself why ? since nothing has changed in the strategy logic.

                    The only things that have changed are :
                    1) the addition of a second bar object (which I didnt start using yet in the strategy logic)
                    2) a BarsInProgress filter for index 0
                    3) the method of BarsSinceEntry that is called in my strategy logic but the present method should be equivalent to the prior method ....

                    So of those 3 changes I cannot see which would affect the results by 10% on the same historical data.

                    Comment


                      #11
                      Likely different data set you are running on. When you have a multi-series strategy, all Bars objects need to meet the minimum bars required before any strategy logic will begin processing.
                      Josh P.NinjaTrader Customer Service

                      Comment


                        #12
                        Originally posted by NinjaTrader_Josh View Post
                        Likely different data set you are running on. When you have a multi-series strategy, all Bars objects need to meet the minimum bars required before any strategy logic will begin processing.
                        Thanks thats good to know. It should be added to the help at the reference page :


                        I retested both case and yes the case with the additional Bar object does start a month later on the historical data even if the additional Bar object is not used at all in the strategy logic. I added the missing PnL for the missing period and it corresponds to the 10% less profit.

                        Thanks to Bertrand and Josh help on this. I will continue working on this.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by ScottWalsh, Today, 06:52 PM
                        4 responses
                        32 views
                        0 likes
                        Last Post ScottWalsh  
                        Started by olisav57, Today, 07:39 PM
                        0 responses
                        4 views
                        0 likes
                        Last Post olisav57  
                        Started by trilliantrader, Today, 03:01 PM
                        2 responses
                        19 views
                        0 likes
                        Last Post helpwanted  
                        Started by cre8able, Today, 07:24 PM
                        0 responses
                        6 views
                        0 likes
                        Last Post cre8able  
                        Started by Haiasi, Today, 06:53 PM
                        1 response
                        4 views
                        0 likes
                        Last Post NinjaTrader_Manfred  
                        Working...
                        X