[FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]protected[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]override[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] OnBarUpdate() { Upper.Set(SMA(Period)[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] + NumStdDev * StdDev(Period)[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]]); Middle.Set(SMA(Period)[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]]); Lower.Set(SMA(Period)[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] - NumStdDev * StdDev(Period)[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]]);[/SIZE][/FONT] [FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] upperBand = Bollinger.Upper([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]2[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]14[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]); [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] lowerBand = Bollinger.Lower([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]2[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]14[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]);[/SIZE][/FONT] [FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// Paint a dot when price crosses Upper or Lower Bollinger band. [/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (Close[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] > upperBand) { [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// Paints a red dot on the current bar 1 tick above the high [/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]DrawDot([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"tag1"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/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]] + TickSize, Color.Red); } [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]else[/COLOR][/SIZE][/FONT][FONT=Courier New][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]if[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] (Close[[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]] < lowerBand) { [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008000]// Paints a blue dot on the current bar 1 tick below the low [/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2]DrawDot([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000]"tag2"[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff]true[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2], [/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]0[/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]] - TickSize, Color.Blue); } [/SIZE][/FONT]
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
Convert type void to double
Collapse
X
-
Convert type void to double
I am trying to display a dot above the high or below the low when the close[0] crosses the Bollinger bands. Here is example of the code I wrote:
Code:Tags: None
-
That will not compile. You need to do:
Code:[FONT=Courier New][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2] upperBand = Bollinger[/SIZE][/FONT][FONT=Courier New][SIZE=2]([/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]2[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2],[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080]14[/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2])[/SIZE][/FONT][FONT=Courier New][SIZE=2].Upper[0][/SIZE][/FONT][FONT=Courier New][SIZE=2];[/SIZE][/FONT]
Josh P.NinjaTrader Customer Service
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by ChartTourist, 04-27-2024, 08:22 AM
|
3 responses
55 views
0 likes
|
Last Post
by ChartTourist
Today, 07:32 AM
|
||
Started by r68cervera, Today, 04:45 AM
|
1 response
10 views
0 likes
|
Last Post Today, 07:26 AM | ||
Hi
by AveryFlynn
Started by AveryFlynn, 04-25-2024, 04:57 AM
|
2 responses
17 views
0 likes
|
Last Post
by RogerHall
Today, 07:23 AM
|
||
Started by NJA_MC, 01-03-2021, 10:34 PM
|
12 responses
158 views
0 likes
|
Last Post Today, 07:19 AM | ||
Started by ageeholdings, Today, 05:22 AM
|
1 response
12 views
0 likes
|
Last Post Today, 07:19 AM |
Comment