thanks
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
Drawing a smooth band
Collapse
X
-
Drawing a smooth band
Hello, to draw a band off of the EMA, I am using the "DrawRegion" command. For example, I will draw 10 ticks above and 10 ticks below the EMA, creating the band. This works ok but I would like for the outer edges of my band to be smooth. Using the DrawRegion command causes the edges to be jagged. Is there a way I can achieve this?
thanksTags: None
-
Originally posted by pman777 View PostSure, see attached. Not sure what you mean by 'series' ... sorry.
Comment
-
thank you for your feedback. I understand what you are saying but being sort of new to ninjascrpt, I'm not sure how to modify my code to get the desired result. Below are my DrawRegion statements, which are executed OnBarUpdate. The upper and lower boundaries are calculated from the center EMA for that given bar. Can you suggest any modifications? thanks in advance.
DrawRegion("tag1" + CurrentBar , 0, 1, EMA(myEMA), (EMA(myEMA)[0] + (myBand * TickSize)) , Color.Transparent, trendColorUp, 3);
DrawRegion("tag2" + CurrentBar , 0, 1, EMA(myEMA), (EMA(myEMA)[0] - (myBand * TickSize)) , Color.Transparent, trendColorUp, 3);
Comment
-
Originally posted by pman777 View Postthank you for your feedback. I understand what you are saying but being sort of new to ninjascrpt, I'm not sure how to modify my code to get the desired result. Below are my DrawRegion statements, which are executed OnBarUpdate. The upper and lower boundaries are calculated from the center EMA for that given bar. Can you suggest any modifications? thanks in advance.
DrawRegion("tag1" + CurrentBar , 0, 1, EMA(myEMA), (EMA(myEMA)[0] + (myBand * TickSize)) , Color.Transparent, trendColorUp, 3);
DrawRegion("tag2" + CurrentBar , 0, 1, EMA(myEMA), (EMA(myEMA)[0] - (myBand * TickSize)) , Color.Transparent, trendColorUp, 3);
Code:Plot1.Set(EMA(myEMA)[0] + (myBand * TickSize)); Plot2.Set(EMA(myEMA)[0] - (myBand * TickSize)); DrawRegion("RegionTag", CurrentBar, 0, Plot1, Plot2, Color.Empty, trendColorUp, 3);
Comment
-
Ok ... I was able to get the band to be smooth! However, I'm having one issue regarding the color of the band. If the EMA is rising, I want the band color to be green; conversely when the EMA is falling, I want the band color to be red. Below is my code. Currently it only paints the band one color regardless of the direction of the EMA. What am I doing wrong?
thanks again!
Plot0.Set(EMA(myEMA)[0] + (myBand * TickSize));
Plot1.Set(EMA(myEMA)[0] - (myBand * TickSize));
if (Rising(EMA(myEMA))) DrawRegion("RegionTag", CurrentBar, 0, Plot0, Plot1, Color.Empty, trendColorUp, 3);
else DrawRegion("RegionTag", CurrentBar, 0, Plot0, Plot1, Color.Empty, trendColorDn, 3);
Comment
-
Hello pman777,
If you try the below code then are you able to get the correct color.
Code:if (CurrentBar < 1 ) return; Plot0.Set(EMA(myEMA)[0] + (myBand * TickSize)); Plot1.Set(EMA(myEMA)[0] - (myBand * TickSize)); if (Rising(EMA(myEMA))) DrawRegion("RegionTag" + CurrentBar, 0, 1, Plot0, Plot1, Color.Empty, Color.Blue, 3); else DrawRegion("RegionTag" + CurrentBar, 0, 1, Plot0, Plot1, Color.Empty, Color.Red, 3);
JoydeepNinjaTrader Customer Service
Comment
-
Originally posted by pman777 View PostOk ... I was able to get the band to be smooth! However, I'm having one issue regarding the color of the band. If the EMA is rising, I want the band color to be green; conversely when the EMA is falling, I want the band color to be red. Below is my code. Currently it only paints the band one color regardless of the direction of the EMA. What am I doing wrong?
thanks again!
Plot0.Set(EMA(myEMA)[0] + (myBand * TickSize));
Plot1.Set(EMA(myEMA)[0] - (myBand * TickSize));
if (Rising(EMA(myEMA))) DrawRegion("RegionTag", CurrentBar, 0, Plot0, Plot1, Color.Empty, trendColorUp, 3);
else DrawRegion("RegionTag", CurrentBar, 0, Plot0, Plot1, Color.Empty, trendColorDn, 3);
Comment
-
Originally posted by NinjaTrader_Joydeep View PostHello pman777,
If you try the below code then are you able to get the correct color.
Code:if (CurrentBar < 1 ) return; Plot0.Set(EMA(myEMA)[0] + (myBand * TickSize)); Plot1.Set(EMA(myEMA)[0] - (myBand * TickSize)); if (Rising(EMA(myEMA))) DrawRegion("RegionTag" + CurrentBar, 0, 1, Plot0, Plot1, Color.Empty, Color.Blue, 3); else DrawRegion("RegionTag" + CurrentBar, 0, 1, Plot0, Plot1, Color.Empty, Color.Red, 3);
Comment
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by SantoshXX, Today, 03:09 AM
|
0 responses
6 views
0 likes
|
Last Post
by SantoshXX
Today, 03:09 AM
|
||
Started by DanielTynera, Today, 01:14 AM
|
0 responses
2 views
0 likes
|
Last Post
by DanielTynera
Today, 01:14 AM
|
||
Started by yertle, 04-18-2024, 08:38 AM
|
9 responses
41 views
0 likes
|
Last Post
by yertle
Today, 01:00 AM
|
||
Started by techgetgame, Yesterday, 11:42 PM
|
0 responses
12 views
0 likes
|
Last Post
by techgetgame
Yesterday, 11:42 PM
|
||
Started by sephichapdson, Yesterday, 11:36 PM
|
0 responses
2 views
0 likes
|
Last Post Yesterday, 11:36 PM |
Comment