Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Donchian channel entry?

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

    Donchian channel entry?

    Hey. I'm trying to develop a strategy where I enter a trade when the slope of the upper donchian channel is > 0. Meaning that I enter when the slope changes from 0 (or a flat line) to greater than 0 (I.e. An increasing line.). Can someone please help me with the code. Thanks.. Ive tried using the strategy wizard but I cant get it to work.

    #2
    Originally posted by kringle427 View Post
    Hey. I'm trying to develop a strategy where I enter a trade when the slope of the upper donchian channel is > 0. Meaning that I enter when the slope changes from 0 (or a flat line) to greater than 0 (I.e. An increasing line.). Can someone please help me with the code. Thanks.. Ive tried using the strategy wizard but I cant get it to work.
    Try thinking in simpler terms. Instead of thinking of slopes and such arcana, just get down to basics. You want to trigger a trade when the Donchian Channel starts to rise from a flat state. That translates to: "DonchianChannel 2 bars ago equals DonchianChannel 1 bar ago, and DonchianChannel 1 bar ago is less than DonchianChannel on this bar.
    Code:
    private int period = 20; //say
    if (DonchianChannel(period)[2] == DonchianChannel(period)[1] 
    && DonchianChannel(period)[1] < DonchianChannel(period)[0] ) MakeMegaBucks();
    Last edited by koganam; 01-12-2015, 01:24 AM.

    Comment


      #3
      Hello kringle427,

      Thank you for your post and welcome to the NinjaTrader Support Forum!

      koganam provides great insight and an example here. So instead of looking at the slope koganam broke it down to the basic idea of if the values were flat-lined and now are trending up then execute the desired methods.

      Comment


        #4
        Thanks a lot for your help koganam. I'm relatively new to programming. So just one more question. What is the "Private period = 20; //say". All about and where do I put it? I.e. Onbarupdate(), above the if, or initialize(). Or are you just referring to the period of the channel. Thanks again for your help. I'm going to try programming it tomorrow!

        Comment


          #5
          Originally posted by kringle427 View Post
          Thanks a lot for your help koganam. I'm relatively new to programming. So just one more question. What is the "Private period = 20; //say". All about and where do I put it? I.e. Onbarupdate(), above the if, or initialize(). Or are you just referring to the period of the channel. Thanks again for your help. I'm going to try programming it tomorrow!
          In an NT script, you would put it in the "Variables" section. I gave it a value of 20, because you did not specify what period you wanted to use. Use whatever it is that you want to use.

          Comment


            #6
            koganam,

            when I do this as a strategy it works, but when I copy this to onbarupdate of an indicator it doesn´t plot anything (I have simply backcoloring to see if it works. As strategy backcoloring is OK, as indicator nothing) Why?

            Thank you
            Tony

            Comment


              #7
              Originally posted by tonynt View Post
              koganam,

              when I do this as a strategy it works, but when I copy this to onbarupdate of an indicator it doesn´t plot anything (I have simply backcoloring to see if it works. As strategy backcoloring is OK, as indicator nothing) Why?

              Thank you
              Tony
              What is the error in your log?

              Comment


                #8
                Hello koganam,

                thank you for your reply. I added the code in an indicator again and now it works, must have made an error somewhere!

                Thanks again!
                Tony
                Last edited by tonynt; 03-29-2016, 06:50 AM.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                0 responses
                587 views
                0 likes
                Last Post Geovanny Suaza  
                Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                0 responses
                342 views
                1 like
                Last Post Geovanny Suaza  
                Started by Mindset, 02-09-2026, 11:44 AM
                0 responses
                103 views
                0 likes
                Last Post Mindset
                by Mindset
                 
                Started by Geovanny Suaza, 02-02-2026, 12:30 PM
                0 responses
                555 views
                1 like
                Last Post Geovanny Suaza  
                Started by RFrosty, 01-28-2026, 06:49 PM
                0 responses
                552 views
                1 like
                Last Post RFrosty
                by RFrosty
                 
                Working...
                X