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 charlesugo_1, 05-26-2026, 05:03 PM
          0 responses
          67 views
          0 likes
          Last Post charlesugo_1  
          Started by DannyP96, 05-18-2026, 02:38 PM
          1 response
          150 views
          0 likes
          Last Post NinjaTrader_ChelseaB  
          Started by CarlTrading, 05-11-2026, 05:56 AM
          0 responses
          162 views
          0 likes
          Last Post CarlTrading  
          Started by CarlTrading, 05-10-2026, 08:12 PM
          0 responses
          99 views
          0 likes
          Last Post CarlTrading  
          Started by Hwop38, 05-04-2026, 07:02 PM
          0 responses
          286 views
          0 likes
          Last Post Hwop38
          by Hwop38
           
          Working...
          X