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.
        https://www.screencast.com/t/8Cn1LgVXE

        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 gravdigaz6, Today, 01:43 AM
        0 responses
        2 views
        0 likes
        Last Post gravdigaz6  
        Started by DayneSwift, Yesterday, 11:06 PM
        0 responses
        2 views
        0 likes
        Last Post DayneSwift  
        Started by AidanLawrence, Yesterday, 10:03 PM
        0 responses
        2 views
        0 likes
        Last Post AidanLawrence  
        Started by butt_toast, Yesterday, 09:47 PM
        0 responses
        2 views
        0 likes
        Last Post butt_toast  
        Started by GaryOz, Yesterday, 06:54 PM
        0 responses
        5 views
        0 likes
        Last Post GaryOz
        by GaryOz
         
        Working...
        X