Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Creating Donchian Channel Crossover Strategy

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

    Creating Donchian Channel Crossover Strategy

    Hey Guys,I am working on a strategy that goes short when the price closes under the lower donchian channel and long when it closes above the upper band. I have the look back period set to 1. I have created this strategy in the strategy wizard, but it does not seem to enter any trades. Can someone take a look at the code here and tell me what I am doing wrong?
    thanks in advance
    {
    // Condition set 1
    if (CrossAbove(Close, DonchianChannel(Period).Upper, 1))
    {
    EnterLong(DefaultQuantity, "");
    }

    // Condition set 2
    if (CrossBelow(Close, DonchianChannel(Period).Lower, 1))
    {
    EnterShort(DefaultQuantity, "");
    }

    // Condition set 3
    if (CrossBelow(Close, DonchianChannel(Period).Lower, 1))
    {
    ExitLong("", "");
    }

    // Condition set 4
    if (CrossAbove(Close, DonchianChannel(Period).Upper, 1))
    {
    ExitShort("", "");
    }
    }

    #2
    Price may rarely cross outside the Donchian's depending on your settings - please include a drawing in your conditions to visually check when the signals you setup can be expected to trigger -

    Comment


      #3
      Since price rarely crosses the Donchian Channel could we make the lookback period a few bars ago so that it reads the price of the donchian channel high/low from a few bars back?

      Is this how I would look for the Donchian Value 3 bars back since the current bars donchian channel is always at or above current price.

      && CrossAbove(Close, DonchianChannel(20).Upper[3],1

      Comment


        #4
        Hello brucelevy,

        The code you provided would indeed let you know whether a crossover condition occurred between the 3rd and 4th bars back on the upper channel band. Please let us know if there are any other ways we can help.
        Jessica P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by brucelevy View Post
          Since price rarely crosses the Donchian Channel could we make the lookback period a few bars ago so that it reads the price of the donchian channel high/low from a few bars back?

          Is this how I would look for the Donchian Value 3 bars back since the current bars donchian channel is always at or above current price.

          && CrossAbove(Close, DonchianChannel(20).Upper[3],1
          You need to look back exactly one bar for the channel break.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          558 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          324 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          101 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          545 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          547 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X