[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 frankthearm, Today, 09:08 AM
|
7 responses
30 views
0 likes
|
Last Post Today, 01:30 PM | ||
Started by NRITV, Today, 01:15 PM
|
1 response
6 views
0 likes
|
Last Post Today, 01:25 PM | ||
Started by maybeimnotrader, Yesterday, 05:46 PM
|
5 responses
25 views
0 likes
|
Last Post Today, 01:19 PM | ||
Started by quantismo, Yesterday, 05:13 PM
|
2 responses
18 views
0 likes
|
Last Post
by quantismo
Today, 01:07 PM
|
||
Started by adeelshahzad, Today, 03:54 AM
|
5 responses
33 views
0 likes
|
Last Post Today, 11:29 AM |
Comment