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 fx.practic, 10-15-2013, 12:53 AM
|
5 responses
5,404 views
0 likes
|
Last Post
by Bidder
Today, 12:22 AM
|
||
Started by Shai Samuel, 07-02-2022, 02:46 PM
|
4 responses
95 views
0 likes
|
Last Post
by Bidder
Today, 12:11 AM
|
||
Started by DJ888, Yesterday, 10:57 PM
|
0 responses
8 views
0 likes
|
Last Post
by DJ888
Yesterday, 10:57 PM
|
||
Started by MacDad, 02-25-2024, 11:48 PM
|
7 responses
159 views
0 likes
|
Last Post Yesterday, 10:23 PM | ||
Started by Belfortbucks, Yesterday, 09:29 PM
|
0 responses
8 views
0 likes
|
Last Post
by Belfortbucks
Yesterday, 09:29 PM
|
Comment