Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Look back period

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

    Look back period

    Hello,

    I have a short question. When doing a strategy and backtesting there appears sometimes that the lookback period is to understand in 2 ways. Eg with a value of 3

    a.) it seems and I thought condition is filled when this happens within the 3 bars (not matter if bars-1 or bars-2 or bars-3 is the one where it occurs)

    b.) but sometimes it seems that it is filled only when exactly at the bar indicated (here bars-3) the referring condition occurs, eg the crossover has to happen exactly at this bar.

    What is the correct one? (I think the "within" a. but can it happen in the coding that the b. works, too?)

    Thanks
    Tony
    Last edited by tonynt; 01-11-2011, 01:10 PM. Reason: typing error

    #2
    Hello,

    Thanks for your note.

    It does check if it occured between the current bar and the number of bars back.

    However when your running it live. The earliest cross over condition will be true if the crossover occured on bar 1 bar 2, or bar 3.

    Let me know if I can be of further assistance.
    BrettNinjaTrader Product Management

    Comment


      #3
      Lookback period

      Hello,

      thanks for your reply. Can I add within the coding also lookback-period to

      KeyReversalDown(1)[0] == 1

      ???

      Because within the wizard it is not possible.

      Might it be eg for lookback period 3: KeyReversalDown(1)[3] == 1

      Referring to my inital question can you please tell me if so and if this is also "within 3 bars" or maybe in this case "exactly 3 bars ago"?

      Thanks
      Tony

      Comment


        #4
        Hello Tony,

        This is exactly three bars ago and not within three bars. For "within 3 bars" type of statement you can work with built in method CountIf(). This counts the number of occurrences of the condition over the specified lookback period.
        Ryan M.NinjaTrader Customer Service

        Comment


          #5
          Look back period

          Hello,

          thank you for your reply. Of course I checked the link with CountIf but I can not do it for KeyReversalBar. SORRY!

          Can you please write this line with KeyReversal for me to understand.

          Thank you!

          Best regards
          Tony
          (lifetime-member)

          Comment


            #6
            Hi Tony, this would unfortunately not be possible in the wizard - but with custom coding take for example the snippet below as example -

            if (CountIf(delegate {return KeyReversalUp(1)[0] == 1;}, 3) >= 1)
            EnterLong();

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by CarlTrading, 03-31-2026, 09:41 PM
            1 response
            38 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by CarlTrading, 04-01-2026, 02:41 AM
            0 responses
            18 views
            0 likes
            Last Post CarlTrading  
            Started by CaptainJack, 03-31-2026, 11:44 PM
            0 responses
            25 views
            1 like
            Last Post CaptainJack  
            Started by CarlTrading, 03-30-2026, 11:51 AM
            0 responses
            40 views
            0 likes
            Last Post CarlTrading  
            Started by CarlTrading, 03-30-2026, 11:48 AM
            0 responses
            34 views
            0 likes
            Last Post CarlTrading  
            Working...
            X