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

Specifying a range of bars in strategy wizard

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

    Specifying a range of bars in strategy wizard

    Hi

    Can someone please help me here. For the life of me I cannot figure out how to specify a range of previous bars in a strategy. Like , if this event happened anytime during the last 5 bars. Example:

    Price high > SMA 15 "anytime during the last 5 bars". I can do 1 bar ago 2 bars ago, or 3 bars ago, but where do I tell strategy wizard "anytime over the last x bars"?

    So in the "bars ago" field, instead of a single value like "1" bar ago, can i specify a range?

    Thanks!!!
    Last edited by matthew splitt; 08-22-2017, 02:24 PM.

    #2
    Hello matthew splitt,

    Thanks for opening the thread.

    To create a condition that will look for the high being above a moving average, you have a few different options.

    You can create a CrossAbove() condition that checks if the price crossed above anywhere in the last number of bars specified for the Lookback period.

    You can also create smaller conditions that define this logic. For example, you can create multiple conditions that check if the High is greater than a previous SMA value. These conditions can then set a bool to true. This bool can then be checked to see: "If any of these conditions, do this action." Finally, you can create a last condition set without a condition, that sets the bool back to a false value.

    The Strategy Wizard is designed only for creating simple strategies. More robust logic can be handwritten, but requires unlocking the code and making modifications manually and is reserved for advanced users.

    If you have any additional questions, please don't hesitate to ask.
    Last edited by NinjaTrader_Jim; 08-22-2017, 03:02 PM.
    JimNinjaTrader Customer Service

    Comment


      #3
      Thank you!

      Comment


        #4
        How do you specify a "lookback period?" How is this used in NinjaTrader? (Note, if this is only feasible after unlocking the code; please explain how to do this after unlocking)

        TIA

        Comment


          #5
          It means -- starting at the most recently closed bar -- how many previous recently
          closed bars shall the algorithm examine (aka, "lookback") to see if the 'event' or
          'condition' has happened.

          [EDIT: The 'algorithm' is the NinjaScript code the Strategy Wizard (NT8 calls it the
          Strategy Builder) will generate for you -- the code is the result of all the conditions you
          specified in the Wizard -- a 'lookback' is usually a crucial part of those conditions.]

          For ex, on a 1-min chart, a lookback of 5 bars means "did this occur within the last 5 mins?"

          Looked at in a vacuum, a lookback doesn't really mean much when talking about one
          signal. (Remember, in the Wizard, think of one 'condition' as one 'signal'.)

          But a lookback becomes really useful when identifying a concurrence of multiple signal
          events all happening close enough together.

          What does that mean?
          Thank about it, rarely do multiple signals all happen on the exact same bar. So, most of the time
          you're more interested in finding events that all occurred inside an 'event window' -- well, that is
          your lookback period. That is, they all occur within a few bars of each other.

          For ex: if all your signals, say, SMA crossing above the High, and RSI below X, the MACD rising, etc
          etc -- well, if all those events occur within the same lookback period of 5 bars (ie, all events occurred
          in the same 5-bar event window) then you have just found your signal for entry. Make sense?

          See attached screenshot.

          After you unlock the code, the lookback period becomes a coding effort. Either you have
          a loop examining your signals over the most recent 5 bars, or you specify '5' as an argument
          to certain functions, such as CrossAbove or CrossBelow.
          Attached Files
          Last edited by bltdavid; 06-02-2020, 07:53 AM.

          Comment


            #6
            Hello mfletch,

            Thank you for your reply.

            Looks like bltdavid is quick on the draw this morning and he's pretty much covered it: essentially is is the number of bars to look back to check for the test condition. The test is evaluated on the current bar and the bars in the look back period.

            In the Wizard, you'd primarily use this with CrossBelow and CrossAbove conditions, as he mentioned:





            https://ninjatrader.com/support/help...on_builder.htm - Specifically the section on creating a crossover condition

            Please let us know if we may be of further assistance to you.


            Kate W.NinjaTrader Customer Service

            Comment


              #7
              Thanks everyone. Appreciate the input. Got it!

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Christopher_R, Today, 12:29 AM
              0 responses
              9 views
              0 likes
              Last Post Christopher_R  
              Started by sidlercom80, 10-28-2023, 08:49 AM
              166 responses
              2,235 views
              0 likes
              Last Post sidlercom80  
              Started by thread, Yesterday, 11:58 PM
              0 responses
              3 views
              0 likes
              Last Post thread
              by thread
               
              Started by jclose, Yesterday, 09:37 PM
              0 responses
              8 views
              0 likes
              Last Post jclose
              by jclose
               
              Started by WeyldFalcon, 08-07-2020, 06:13 AM
              10 responses
              1,415 views
              0 likes
              Last Post Traderontheroad  
              Working...
              X