Thank you
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Modify RSI plots
Collapse
X
-
Hello guidoisot,
Thank you for your post.
You could achieve this by utilizing Draw.Region() to draw in the panel.
I noticed a number of the Lines added did not show up until I gave them separate names, so something like this (note the code in bold):
Basically what this does is to fill in the green region between 40 and 50. We take our line values and create a new Series<double> for each to hold the values so the y-coordinates are set for each bar. Then in OnBarUpdate, we make sure we have the Series<double> values assigned for the current bar and draw our region. Make sure you've set DrawOnPricePanel as false or it won't show up correctly. This should give you a jumping off point to color the remaining areas.Code:[B]private Series<double> upperGreen1; private Series<double> lowerGreen1;[/B] protected override void OnStateChange() { if (State == State.SetDefaults) { Description = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDescriptionRSI; Name = "aaRSIZones"; IsSuspendedWhileInactive = true; BarsRequiredToPlot = 20; Period = 14; Smooth = 3; [B]DrawOnPricePanel = false; //this makes sure our drawing object isn't drawn on the same panel as the data series[/B] AddPlot(Brushes.DodgerBlue, NinjaTrader.Custom.Resource.NinjaScriptIndicatorNameRSI); AddPlot(Brushes.Goldenrod, NinjaTrader.Custom.Resource.NinjaScriptIndicatorAvg); [B] AddLine(Brushes.Red, 20, "LowerRed20"); AddLine(Brushes.Red, 30, "LowerRed30"); AddLine(Brushes.Green, 40, "UpperGreen40"); AddLine(Brushes.Green, 50, "UpperGreen50"); AddLine(Brushes.Red, 55,"LowerRed55"); AddLine(Brushes.Red, 65, "LowerRed65"); AddLine(Brushes.Green, 80, "UpperGreen80"); AddLine(Brushes.Green, 90, "UpperGreen90");[/B] } else if (State == State.Configure) { // removed for simplicity } else if (State == State.DataLoaded) { //other variables removed [B] upperGreen1 = new Series<double>(this, MaximumBarsLookBack.Infinite); lowerGreen1 = new Series<double>(this, MaximumBarsLookBack.Infinite);[/B] } } protected override void OnBarUpdate() { //removed for simplicity [B] upperGreen1[0] = 50; lowerGreen1[0] = 40; Draw.Region(this, "tag1", CurrentBar, 0, lowerGreen1, upperGreen1, null, Brushes.Green, 100);[/B] //rest of logic removed for space reasons }
Here's a link to our help guide regarding Draw.Region:
Please let us know if we may be of further assistance to you.
- Likes 1
-
Hello KateOriginally posted by NinjaTrader_Kate View Post
the Lines added did not show up until I gave them separate names,
...
Make sure you've set DrawOnPricePanel as false or it won't show up correctly.
.
thank you for your reply.
Yes I did not know/thought that the plots needed their names.
I tentatively ... set the false value for the DrawOnPricePanel in the State.SetDefaults and it appeared as doing ok.
My end goal here is being able to set conditions on the SB when there are rsi reversals in either one of the two zones around the 50 level.
Thank you so much for your help.
gt
Last edited by guidoisot; 06-21-2019, 01:27 AM.
Comment
-
Hello Guidoisot,
Thank you for your reply.
You have two options here:
You could either hard code the values into the strategy since they're always the same, or you could expose the Series<double> values so they would be usable in the Strategy Builder. The latter is preferable since then if you want to use it in multiple strategies you don't have to hard code the values again each time.
For example, I could add this to the #region Properties section of the indicator to expose the upperGreen1 line value:
There's an example in our help guide here that goes over exposing values that are not plots of an indicator so they are usable in the Strategy Builder:Code:[Browsable(false)] [XmlIgnore] public Series<double> UpperGreen1 // note this is uppercase "U" when our series in the indicator itself starts with a lowercase "u" { get { return upperGreen1; } // Allows our public upperGreen1 Series<double> to access and expose our internal upperGreen1 Series<double> }
https://ninjatrader.com/support/help...alues_that.htm
Please let us know if we may be of further assistance to you.
- Likes 1
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
576 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
334 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
553 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
551 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment