• 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 datahogg, Today, 07:02 AM
          0 responses
          2 views
          0 likes
          Last Post datahogg  
          Started by lju45, Today, 07:00 AM
          0 responses
          4 views
          0 likes
          Last Post lju45
          by lju45
           
          Started by Yaron, Today, 04:01 AM
          2 responses
          14 views
          0 likes
          Last Post Yaron
          by Yaron
           
          Started by babouin77, Today, 06:23 AM
          2 responses
          12 views
          0 likes
          Last Post babouin77  
          Started by schwamm, Today, 04:26 AM
          1 response
          16 views
          0 likes
          Last Post NinjaTrader_ChristopherS  
          Working...
          X