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 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 cre8able, Today, 03:20 PM
                0 responses
                5 views
                0 likes
                Last Post cre8able  
                Started by Fran888, 02-16-2024, 10:48 AM
                3 responses
                47 views
                0 likes
                Last Post Sam2515
                by Sam2515
                 
                Started by martin70, 03-24-2023, 04:58 AM
                15 responses
                114 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by The_Sec, Today, 02:29 PM
                1 response
                7 views
                0 likes
                Last Post NinjaTrader_Jesse  
                Started by jeronymite, 04-12-2024, 04:26 PM
                2 responses
                31 views
                0 likes
                Last Post NinjaTrader_BrandonH  
                Working...
                X