• 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

open position after n bars close above average

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

    open position after n bars close above average

    Hello,

    I am trying to create a strategy through the Strategy Builder where a long position is initiated after 2 consecutive price bars close above the SMA. To achieve this I tried adding two conditions in Conditions and Actions as follows;

    IF ALL of the following conditions are met:
    1st condition:
    Price --> Close --> Bars Ago (0)
    Cross Above --> Look back period (1)
    Indicator --> SMA --> Bars Ago (0)

    2nd condition:
    Price --> Close --> Bars Ago (1)
    Cross Above --> Look back period (1)
    Indicator --> SMA --> Bars Ago (1)

    Do the following:
    EnterLong(DefaultQuantity,"");

    And I tried various combinations but its not giving the desired results.

    Thank you,
    Remo

    #2
    Bool saves the day!

    I had been searching the forums but didn't find the answer so after posting above I decided to browse the forums to learn new things and found the bool example at the thread https://ninjatrader.com/support/foru...dicator-does-y

    Replicated it and worked like a charm.

    Thanks.

    Comment


      #3
      This is a brilliant solution that you have found.

      Comment


        #4
        Hello remorim,

        You would not want to use CrossAbove as the operator in the center.

        You would want two conditions in the same condition set. The first is Price > Close > Bars Ago 0, is greater than, Indicators > SMA > Period. The second is Price > Close > Bars Ago 1, is greater than, Indicators > SMA > Period.

        The solution you have linked would not be looking for two consecutive bar closes above the sma. Instead, this would be creating a trigger with a bool after one action, and then triggering another action after a certain amount of bars, basically using each condition set as a wait for a new bar..
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hello Chelsea,

          Your suggestion worked as well. It's much simpler than using the bool's.

          Many thanks.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by timcjpfx, Today, 03:52 AM
          0 responses
          1 view
          0 likes
          Last Post timcjpfx  
          Started by tonynt, Today, 01:42 AM
          0 responses
          7 views
          0 likes
          Last Post tonynt
          by tonynt
           
          Started by NT-Roland, Yesterday, 04:36 PM
          0 responses
          3 views
          0 likes
          Last Post NT-Roland  
          Started by Newtrader101, Yesterday, 03:40 PM
          2 responses
          13 views
          0 likes
          Last Post Newtrader101  
          Started by Branpo, Yesterday, 02:58 PM
          2 responses
          15 views
          0 likes
          Last Post Branpo
          by Branpo
           
          Working...
          X