Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Donchian Channel

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

    Donchian Channel

    Hi Members,

    I hope I'm in the correct forum.

    I'm learning programming as well as using the Strategy wizard to build my system.

    Can anyone please help add a donchian channel to my strategy using the Strategy wizard?
    I have experience with the wizard using basic SMA crosssover's and would like to add a donchian channel using the condition builder in the Strategy wizard. I like to start off with using the wizard before hard coding because the wizard helps me to "think it out" so to speak as oppose to hard coding which is a bit more difficult to understand what is actually happening. After I use the wizard I can go back and view the code and I will understand it better at that point.

    When I bring up the strategy wizard and build a condition using the donchian channel indicator, I'm just not sure which "relational operator" to use (located in the middle of the "condition Builder" window. Do I choose "donchian channel" indicator for both sides of the "how to complete this part of the "condition Builder" window (left side and right side)?

    Appreciate any help and thank you for your patience and time.

    #2
    Hi Helicopter, you can use whatever relational operator you'd like to use. I'm not exactly sure how Donchian Channels work but, for example, if you want to do something when the current price (close) is between the middle and the upper channel, you could do something like the attached picture indicates.
    Attached Files
    AustinNinjaTrader Customer Service

    Comment


      #3
      Helicopter:

      if you go to the Help Index, under Donchian you can find how to reference the Mean, Upper and Lower values of the Donchian Channel default indicator:

      // Prints the current upper value of a 20 period DonchianChannel using default price type
      double value = DonchianChannel(20).Upper[0];
      Print("The current DonchianChannel upper value is " + value.ToString());
      // Prints the current lower value of a 20 period DonchianChannel using high price type
      double value = DonchianChannel(High, 20).Lower[0];
      Print("The current DonchianChannel lower value is " + value.ToString());


      ++++++++++


      so you can say something like:



      if (Close[0] > DonchianChannel(period).Upper[0])
      { do something;}


      if (Close[0] < DonchianChannel(period).Lower[0])
      { do something;}

      ( where period = your period length for the Donchians; you may have used a different word than period for that in the Variables section.}

      Comment


        #4
        Hi Austin & cclsys,

        Appreciate the help. Lots ogf great info. But I believe I'm one step ahead of myself. I'd like to refine my question please.

        At this point I'd simply like to be able to plot a Donchian Channel on my chart and I would like to know if this can be done using the Strategy Wizard (condition builder) or must I hard code using NinjaScript?

        I went to the "Help Guide" as you recommended and found the sysntax formula to create the Donchian Channel. It is:

        DonchianChannel(int period)
        DonchianChannel(IDataSeries inputData,int period)
        Returns mean value (middle band)
        DonchianChannel(int period)[int barsAgo]
        DonchianChannel(IDataSeries inputData,int period)[int barsAgo]
        Returns upper band value
        DonchianChannel(int period).Upper[int barsAgo]
        DonchianChannel(IDataSeries inputData, int period).Upper[int barsAgo]
        Returns lower band value
        DonchianChannel(int period).Lower[int barsAgo]
        DonchianChannel(IDataSeries inputData, int period).Lower[int barsAgo]
        Can you please help me complete the words in Blue above. I'm not sure what they are referring to but I assume the sysntax wants a number for "int". I'm not sure what the word "IDataSeries" means. Do I have to change this as well?

        I am not a programmer but I am studying C# language. Hopefully these most basic questions will end as I advance.

        Just a complete example would be fine on how to plot a basic Donchian channel using upper, lower and middle bands.

        Thank you

        Comment


          #5
          Hi Austin & cclsys,

          Ammended reply.

          Appreciate the help. Lots ogf great info. But I believe I'm one step ahead of myself. I'd like to refine my question please.

          At this point I'd simply like to be able to plot a Donchian Channel on my chart and I would like to know if this can be done using the Strategy Wizard (condition builder) or must I hard code using NinjaScript?

          I went to the "Help Guide" as you recommended and found what I believe is the syntax formula to create a Donchian Channel. It is:

          DonchianChannel(int period)
          DonchianChannel(IDataSeries inputData,int period)
          Returns mean value (middle band)
          DonchianChannel(int period)[int barsAgo]
          DonchianChannel(IDataSeries inputData,int period)[int barsAgo]
          Returns upper band value
          DonchianChannel(int period).Upper[int barsAgo]
          DonchianChannel(IDataSeries inputData, int period).Upper[int barsAgo]
          Returns lower band value
          DonchianChannel(int period).Lower[int barsAgo]
          DonchianChannel(IDataSeries inputData, int period).Lower[int barsAgo]

          Can you please help me complete the words in "Blue" above. I'm not sure what they are referring to but I assume the syntax in "Blue" wants a number or period for "int". I'm not sure what the word "IDataSeries" means. Do I have to change this as well?

          I am not a programmer but I am studying C# language. Hopefully these most basic questions will end as I advance.

          Just a complete example would be helpful on how to plot a basic Donchian channel on my chart (or in my Strategy) using upper, lower and middle bands.

          Thank you

          Comment


            #6
            Helicopter,

            If all you want to do is plot the indicator, you don't need to touch the code at all. You can do this in the Strategy Wizard by adding the indicator to a Condition and setting the parameter of "Plot on chart" to true.
            Josh P.NinjaTrader Customer Service

            Comment


              #7
              Hi Josh

              That certainly worked, Thank you for the suggestion.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Barry Milan, Today, 10:35 PM
              1 response
              6 views
              0 likes
              Last Post NinjaTrader_Manfred  
              Started by WeyldFalcon, 12-10-2020, 06:48 PM
              14 responses
              1,427 views
              0 likes
              Last Post Handclap0241  
              Started by DJ888, Yesterday, 06:09 PM
              2 responses
              9 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by jeronymite, 04-12-2024, 04:26 PM
              3 responses
              40 views
              0 likes
              Last Post jeronymite  
              Started by bill2023, Today, 08:51 AM
              2 responses
              16 views
              0 likes
              Last Post bill2023  
              Working...
              X