Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Changing DrawRegion?
Collapse
X
-
Nope. Please refer to my previous post. If you want alternating color ranges you need to manually submit all the different regions. Check the syntax on DrawRegion(). You are constantly overriding the complete range. CurrentBar all the way to bar 0. This is why the whole range is being colored.Josh P.NinjaTrader Customer Service
-
I've setup the following code:
if(BLUE_ZONE == -1){BLUE_ZONE = CurrentBar; YELLOW_ZONE = -1;} Print("BLUE_ZONE: = " + BLUE_ZONE);
DrawRegion("MYREGION", BLUE_ZONE, 0, Bollinger(2, 14).Upper, Bollinger(2, 14).Lower, Color.Empty, Color.Blue, 2);
I'm sure the logic and syntax are correct, however it is still painting going back from the first bar on the chart. I'm sure this is because the value for "BLUE_ZONE" is being set by using the "CurrentBar" command...as this will instruct to start at first bar on chart. My question is how to get around this? Is there some other command to use to substitute for "CurrentBar" in situations like these that involve "Bars Ago" instrucitons?
Comment
-
Converting double to IDataSeries for DrawRegion()
Hello.
I'm calculating the upper and lower bounds of Bollinger Bands using the following code :
Values[3].Set(EMA(MACD(fastLen, slowLen, smooth),smooth)[0] + stDv * StdDev(MACD(fastLen, slowLen, smooth),smooth)[0]);
Values[4].Set(EMA(MACD(fastLen, slowLen, smooth),smooth)[0] - stDv * StdDev(MACD(fastLen, slowLen, smooth),smooth)[0]);
When I try to use those values in DrawRegion() I run into problems because its looking for two iDataSeries values. The compiler complains that the above values are 'double', which they are.
DrawRegion("Area", CurrentBar, 0, EMA(MACD(...))[0], EMA(MACD(...))[0], Color.Empty, Color.Blue, 2)
Question. How do I convert the calculated 'double' values into idataseries values so it will be accepted in DrawRegion() by the compiler ?
Regards,
R. C. Singleton
Comment
-
DrawRegion()
Hello again.
I got this to compile :
Values[3].Set(EMA(MACD(fastLen, slowLen, smooth),smooth)[0] + stDv * StdDev(MACD(fastLen, slowLen, smooth),smooth)[0]);
Values[4].Set(EMA(MACD(fastLen, slowLen, smooth),smooth)[0] - stDv * StdDev(MACD(fastLen, slowLen, smooth),smooth)[0]);
DrawRegion("Area", CurrentBar, 0, Values[3],Values[4],Color.Empty,Color.Gray, 6);
But its not drawing in the area between the BB bands. It looks like its not doing anything.
Also, if I replace Values[3] and Values[4] with your suggestion in the last post, I get compiler error CS109. Can't use '*' operator with int stDV and function StdDev.
Regards,
R. C. Singleton
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
558 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
324 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
101 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
545 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
547 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment