Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Crosses above SMA or below SMA

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

    Crosses above SMA or below SMA

    I have been trying to create an if statement that would avoid entering a trade if the bars keep on whipping above and below the SMA. I tried many different scenarios but to no avail I have failed. I was trying to see if the the bars were crossing above or below the SMA within the last 5 bars but I can not get it to work.


    The theory is to stay away from CHOP.

    #2
    Hello ballboy11,

    What the actual rule that you would like to create?

    Are you looking to see if a crossabove has occurred multiple times on a single bar?

    If so, you would need to have a counter that is reset on each new bar. As a crossabove occurs increment the counter. You can then know how many times the cross happened on that bar.

    Are you looking to see if multiple crossaboves have occurred on multiple bars within a certain time frame or a certain amount of bars?

    There are multiple ways to accomplish this. You could create custom bool series and for each bar save a value of false if there was no cross and a true if there was a cross. Then you can loop backwards and know if that bar had a cross.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_ChelseaB View Post
      Hello ballboy11,

      What the actual rule that you would like to create?

      Are you looking to see if a crossabove has occurred multiple times on a single bar?

      If so, you would need to have a counter that is reset on each new bar. As a crossabove occurs increment the counter. You can then know how many times the cross happened on that bar.

      Are you looking to see if multiple crossaboves have occurred on multiple bars within a certain time frame or a certain amount of bars?

      There are multiple ways to accomplish this. You could create custom bool series and for each bar save a value of false if there was no cross and a true if there was a cross. Then you can loop backwards and know if that bar had a cross.
      Hi Chelsea,
      Could you point me to a link or give me an example of how to see if multiple crossaboves have occurred on multiple bars within a certain time frame or a certain amount of bars?

      Comment


        #4
        Hello seeseea,

        Below is a link to a short video that shows how to add multiple crossabove conditions to a condition set in the Strategy Builder and how to adjust the lookback period.

        In this condition the SMA with a period of 5 must crossabove the SMA with a period of 10 anywhere within the last 5 bars and the ADX with a period of 5 must have crossed above the ADX with a period of 10 within the last 10 bars.
        Free online storage and sharing with Screencast.com. 2 GB of storage and 2 GB of bandwidth per month for free. We won't compress, alter or take ownership of your content.


        This is just a general concept of how to add multiple conditions to a condition set and how to change the lookback period.
        Anything further would be custom logic that needs to be developed by the programmer.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by sidlercom80, 10-28-2023, 08:49 AM
        167 responses
        2,260 views
        0 likes
        Last Post jeronymite  
        Started by warreng86, 11-10-2020, 02:04 PM
        7 responses
        1,361 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by Perr0Grande, Today, 08:16 PM
        0 responses
        5 views
        0 likes
        Last Post Perr0Grande  
        Started by elderan, Today, 08:03 PM
        0 responses
        9 views
        0 likes
        Last Post elderan
        by elderan
         
        Started by algospoke, Today, 06:40 PM
        0 responses
        10 views
        0 likes
        Last Post algospoke  
        Working...
        X