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

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 wzgy0920, 04-20-2024, 06:09 PM
              2 responses
              27 views
              0 likes
              Last Post wzgy0920  
              Started by wzgy0920, 02-22-2024, 01:11 AM
              5 responses
              32 views
              0 likes
              Last Post wzgy0920  
              Started by wzgy0920, 04-23-2024, 09:53 PM
              2 responses
              49 views
              0 likes
              Last Post wzgy0920  
              Started by Kensonprib, 04-28-2021, 10:11 AM
              5 responses
              193 views
              0 likes
              Last Post Hasadafa  
              Started by GussJ, 03-04-2020, 03:11 PM
              11 responses
              3,235 views
              0 likes
              Last Post xiinteractive  
              Working...
              X