Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Two timeframes

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

    Two timeframes

    Hallo,
    I am trying to develop a strategy with two timeframes. I use 30min bars and the code is finished. It works.
    However, I want to add a filter that check whether the EMA of the DAILY bars.

    For backtest, I imported the CAC40 05-08.txt in 30 min bars and I imported the CAC40 ##-##.txt with daily bars, So i write in the inialize method:

    Add("CAC40 ##-##",PeriodType.Day,1);
    Add(EMA(BarsArray[1], MediaLarga));

    And then, in the OnBarUpdate method:
    if (Close[0] > EMA(BarsArray[1], MediaLarga)[0]));

    The strategy compiles ok but it is not taking into account the EMA of the daily bars

    What I am missing here?

    Thanks!!!

    #2
    Please take a look at the Control Center's Log tab for errors.

    This line should cause errors: Add(EMA(BarsArray[1], MediaLarga));
    You can't call BarsArray[] in the Initialize section.

    If you wish to plot the EMA of the daily bar on the chart please see this reference sample for an idea of how you can achieve this: http://www.ninjatrader-support.com/v...ead.php?t=6651
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Oh, I see.

      So let´s say I have an strategy for 30min bars that works ok. I just want to make a check on the daily bars, how shall I make the strategy check on daily bars??

      My database are txt files: 1.- CAC40 05-08.txt for 30 min bars and 2.- CAC40 ##-##.txt for daily bars.

      How do I make the system look into the daily bars?

      Thanks!!!

      Juan Rivera

      Comment


        #4
        Juan,

        By chance have you review this? The answer lies in here - http://www.ninjatrader-support.com/H...struments.html
        RayNinjaTrader Customer Service

        Comment


          #5
          Ok, I have read all this, but still not working.

          I have a couple of questions:

          1) The txt files. The two txt files mentioned above are the source of OHLCV bars. The 30min txt bar starts in 2005 and it is the primary bars. The daily txt starts in 1993. Is that a problem?

          2) Does NT check on the date of the two timeframes? I mean, the first 30 min bar that should be checked upon is from 03-01-2005 and it should check on the corresponding bar (same date) in the daily txt file.

          I am not sure it does it that way

          Thanks for any help you can give me in this issue. Many of the strategies I am developing have this kind of filters and I need to solve it.

          Comment


            #6
            First, you will need to import your data files into the NinjaTrader database through the steps here: http://www.ninjatrader-support.com/H...V6/Import.html

            After you have your data inputted you can then use it to run through your strategies. NinjaTrader will indeed only check the data it has in sync with your overall data set. Your daily bars will start being processed and since NinjaTrader does not have corresponding 30min bars to work with those older daily bars it will skip that time frame and keep going in the daily bars series. When the 30min bar series kicks in then it will start the alternation between the two series. It will go 30min, 30min, 30min, daily, 30min, 30min, etc. The dates should correspond with each other and everything is executed in a sequential manner. Hope that helps.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Thank you

              Ok, thanks so much for your help!!

              Now it works!!

              Best regards,

              Juan Rivera

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Geovanny Suaza, 02-11-2026, 06:32 PM
              0 responses
              648 views
              0 likes
              Last Post Geovanny Suaza  
              Started by Geovanny Suaza, 02-11-2026, 05:51 PM
              0 responses
              369 views
              1 like
              Last Post Geovanny Suaza  
              Started by Mindset, 02-09-2026, 11:44 AM
              0 responses
              108 views
              0 likes
              Last Post Mindset
              by Mindset
               
              Started by Geovanny Suaza, 02-02-2026, 12:30 PM
              0 responses
              572 views
              1 like
              Last Post Geovanny Suaza  
              Started by RFrosty, 01-28-2026, 06:49 PM
              0 responses
              573 views
              1 like
              Last Post RFrosty
              by RFrosty
               
              Working...
              X