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!
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
NinjaTrader
Trailing Indicator
Collapse
X
-
Hello,
Hello,
Use DrawHorizontalLine() to draw lines representing your 3 day high and 3 day low values. I have included an example below of how to accomplish this.
Code:[COLOR=#000000][FONT=Tahoma]protected override void Initialize() { Add(PeriodType.Day, 1); }[/FONT][/COLOR] [COLOR=#000000][FONT=Tahoma][LEFT][FONT=Courier New][SIZE=2] [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000FF] protected[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000FF]override[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000FF]void[/COLOR][/SIZE][/FONT] [FONT=Courier New][SIZE=2]OnBarUpdate()[/SIZE][/FONT] [FONT=Courier New][SIZE=2] {[/SIZE][/FONT] [FONT=Courier New][SIZE=2] [/SIZE][/FONT] [FONT=Courier New][SIZE=2] stopPricehigh = High[[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]]; [/SIZE][/FONT] [FONT=Courier New][SIZE=2] [/SIZE][/FONT] [FONT=Courier New][SIZE=2] [/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000FF]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2](High[[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] <= HighestBar(Highs[[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]], [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]3[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]))[/SIZE][/FONT] [FONT=Courier New][SIZE=2] {[/SIZE][/FONT] [FONT=Courier New][SIZE=2] ExitLongStop(stopPricehigh);[/SIZE][/FONT] [FONT=Courier New][SIZE=2] } [/SIZE][/FONT] [FONT=Courier New][SIZE=2] [/SIZE][/FONT] [FONT=Courier New][SIZE=2] [/SIZE][/FONT] [FONT=Courier New][SIZE=2] [/SIZE][/FONT] [FONT=Courier New][SIZE=2] [/SIZE][/FONT] [FONT=Courier New][SIZE=2] [/SIZE][/FONT] [FONT=Courier New][SIZE=2] stopPrice = Low[[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]]; [/SIZE][/FONT] [FONT=Courier New][SIZE=2] [/SIZE][/FONT] [FONT=Courier New][SIZE=2] [/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#0000FF]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2](Low[[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] <= LowestBar(Lows[[/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]], [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]3[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]))[/SIZE][/FONT] [FONT=Courier New][SIZE=2] {[/SIZE][/FONT] [FONT=Courier New][SIZE=2] ExitLongStop(stopPrice);[/SIZE][/FONT] [FONT=Courier New][SIZE=2] } [/SIZE][/FONT] [FONT=Courier New][SIZE=2] [/SIZE][/FONT] [FONT=Courier New][SIZE=2] [/SIZE][/FONT] [FONT=Courier New][SIZE=2] DrawHorizontalLine([/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#800000]"HighLine"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] , stopPricehigh, Color.Black);[/SIZE][/FONT] [FONT=Courier New][SIZE=2] [/SIZE][/FONT] [FONT=Courier New][SIZE=2] DrawHorizontalLine([/SIZE][/FONT] [FONT=Courier New][SIZE=2][COLOR=#800000]"LowLine"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] , stopPrice, Color.Black);[/SIZE][/FONT][/LEFT] [/FONT][/COLOR]
Shawn B.NinjaTrader Customer Service
-
What you have attached is a Donchian Channel displaced by one bar.
Simply take the standard Donchian Channel and set the Displacement to +1.
Attached is a screenshot showing a displaced Donchian Channel for the section of the ES chart that you have posted.
It is my own version of the Donchian Channel, which has a trend filter added.
Comment
-
Originally posted by JT1230 View PostMay I know what does the () and [] mean in DonchianChannel? For example: DonchianChannel(1).Lower[10]
And can someone tell me whats the difference between period n bar? Thx
[10] indicates the bar which is used to perform calculations. A value of 10 indicates that the last bar used for calculations was 10 bars ago. 0 designs the current bar.
For example DonchianChannel(1).Lower[10] means the lower channel of a 1-period Donchian Channel (this would be just the low) calculated 10 bars ago. Therefore it will return the low of the bar 10 bars ago.
Comment
-
Hello JT1230,
Harry is correct. The () holds a value for the period or number of bars used in the calculation. The [] holds a int value specifying the number of bars ago.
I have included the Donchian Channel Help Guide to assist you further.Shawn B.NinjaTrader Customer Service
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by RookieTrader, Today, 09:37 AM
|
4 responses
17 views
0 likes
|
Last Post
by RookieTrader
Today, 12:46 PM
|
||
Started by PaulMohn, Today, 12:36 PM
|
0 responses
2 views
0 likes
|
Last Post
by PaulMohn
Today, 12:36 PM
|
||
Started by love2code2trade, 04-17-2024, 01:45 PM
|
4 responses
38 views
0 likes
|
Last Post Yesterday, 10:31 PM | ||
Started by alifarahani, Today, 09:40 AM
|
2 responses
14 views
0 likes
|
Last Post
by alifarahani
Today, 12:23 PM
|
||
Started by junkone, Today, 11:37 AM
|
3 responses
21 views
0 likes
|
Last Post Today, 12:23 PM |
Comment