Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Donchian channel entry?
Collapse
X
-
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. -
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.Originally posted by kringle427 View PostHey. 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.
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.
-
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
-
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
-
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.Originally posted by kringle427 View PostThanks 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
-
What is the error in your log?Originally posted by tonynt View Postkoganam,
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
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
601 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
347 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
103 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
559 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
558 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|


Comment