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

Multi-time frame strategy

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

    Multi-time frame strategy

    I am running into a bit of trouble with using a second time frame in my strategy. I've used Add to get the 2nd time frame included and seem to be ok accessing Close[n] price from Closes[1][n]. Problem comes up when I use ATR(BarsArray[1], 13)[1]. I don't get the right value returned and I get an error in the log:
    5/24/2009 4:48:07 PM Strategy Error on calling 'OnBarUpdate' method for strategy 'LPSuperTrend1': You must use the overload that has a 'BarsInProgress' parameter when calling the BarsSinceEntry() method in the context of a multi-time frame and instrument strategy.

    Can you give me any pointers to track this down?
    Thanks

    #2
    BarsSinceExit() and BarsSinceEntry() need the time frame, ie

    BarsSinceExit(1, "long", 1)

    for time frame 1 (barsinprogress=1), signal "long".

    Mike

    Comment


      #3
      Mike
      Thanks for your reply but I have not explicitly used BarsSinceEntry() nor BarsSinceExit() in my script.

      The piece of code I'm using:

      if (BarsInProgress == 1)
      return;
      Print ("Close[1]: " + Closes[1][1] + " Close[14]: " + Closes[1][14]);
      Print (Time[0].ToString() + " ATR(13): " + ATR(BarsArray[1], 13)[1].ToString("0.000000") + " Volatility: " + volatility.ToString("0.0000"));

      The Close values are ok but not the ATR values.


      Edit!!! - on inspection, looks like I have! I will investigate further....
      Last edited by laparker; 05-24-2009, 05:02 PM.

      Comment


        #4
        Originally posted by laparker View Post
        Mike
        Thanks for your reply but I have not explicitly used BarsSinceEntry() nor BarsSinceExit() in my script.

        The piece of code I'm using:

        if (BarsInProgress == 1)
        return;
        Print ("Close[1]: " + Closes[1][1] + " Close[14]: " + Closes[1][14]);
        Print (Time[0].ToString() + " ATR(13): " + ATR(BarsArray[1], 13)[1].ToString("0.000000") + " Volatility: " + volatility.ToString("0.0000"));

        The Close values are ok but not the ATR values.


        Edit!!! - on inspection, looks like I have! I will investigate further....
        Did you try to omit BarsArray[1]? and just use ATR(13)[1]?

        Comment


          #5
          Hi Roonius
          I tried taking out BarsArray[1] and just going with ATR(13)[1] but I get this gives the ATR from the first time series, index 0, 1 bar back. I want the ATR(13) for the second time series, index 1. The first time series is 5mins and second, 1 day.

          The problem I'm getting is that the ATR that ATR(BarsArray[1], 13)[1] returns is not the same as displayed using a single series day chart nor with a script using a single day series. It looks like when it returns the value from the 1st or second bar, it's off by about 4%. This difference gets smaller with each new day bar, reducing to about 0.01% 100 bars in and then a few bars after the difference disappearing. Obviously it would be nice to have no difference from the start! What do you reckon?

          Thanks

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Barry Milan, Yesterday, 10:35 PM
          5 responses
          16 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by DanielSanMartin, Yesterday, 02:37 PM
          2 responses
          13 views
          0 likes
          Last Post DanielSanMartin  
          Started by DJ888, 04-16-2024, 06:09 PM
          4 responses
          12 views
          0 likes
          Last Post DJ888
          by DJ888
           
          Started by terofs, Today, 04:18 PM
          0 responses
          11 views
          0 likes
          Last Post terofs
          by terofs
           
          Started by nandhumca, Today, 03:41 PM
          0 responses
          8 views
          0 likes
          Last Post nandhumca  
          Working...
          X