• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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...crossabove.htm

            https://ninjatrader.com/support/help...crossbelow.htm

            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 digibob, 07-08-2020, 03:45 AM
              5 responses
              35 views
              0 likes
              Last Post johnnymustard  
              Started by kanavancbduk, Today, 01:21 AM
              0 responses
              7 views
              0 likes
              Last Post kanavancbduk  
              Started by yalmandraku, Today, 01:21 AM
              0 responses
              5 views
              0 likes
              Last Post yalmandraku  
              Started by kanavancbduk, Today, 01:20 AM
              0 responses
              4 views
              0 likes
              Last Post kanavancbduk  
              Started by josenfit, Today, 01:03 AM
              0 responses
              3 views
              0 likes
              Last Post josenfit  
              Working...
              X