Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
What needs to be done to implement plot signal from custom indicator
Collapse
X
-
What needs to be done to implement plot signal from custom indicator
Hi i would like to add a condition to my strategy to enter when signal is in red, blue, yellow or green for example. I am not sure what needs to be done to call that indicator in the strategy..
Tags: None
-
Hello, thanks for writing in. All indicator have the PlotBrushes property where the plot color can be read/set per bar:
https://ninjatrader.com/support/help...lotbrushes.htm //e.g. PlotBrushes[0][0] is the latest bar of the first added plot.
Typically the color changes based on some underlying condition, so you could also replicate the condition that is changing the color of the plot rather than reading the color e.g.
if(Close[0] > Close[1])
PlotBrushes[0][0] = Brushes.Green;
-
Thank you. I am still confused if i put if how will strategy know how these plots coming from this particular custom indicator?
Do you have an example where strategy uses indicators values?
(Close[0] > Close[1])
PlotBrushes[0][0] = Brushes.Green;
Ok Update.
I am trying to get signals from trend magic indicator. I added this but its compalining no overload method trenmagic takes 0 arguments. I just want buy when gree, sell when red logic in strategy
The Trend Magic indicator is an ATR-based trend line that uses CCI to control its upward and downward movement. It was once a popular indicator in the Forex trading world. When the CCI is greater than zero the line is only able to move upwards, and conversely, when the CCI is less than or equal […]
else if (State == State.DataLoaded)
{
{
ClearOutputWindow(); //Clears Output window every time strategy is enabled
}
AddChartIndicator(TrendMagic());Last edited by tkaboris; 03-02-2023, 10:05 AM.
Comment
-
NinjaTrader_ChrisL
i have
private TrendMagic myTM;
myTM = TrendMagic();
In my strategy on BarUpdate i am trying to access BullBrush to see if it can access it but it get "canno immplicitly convert type System.windows.media.brush to bool
if(myTM.BullBrush)
{
Print("bull brush is true");
}Last edited by tkaboris; 03-02-2023, 11:38 AM.
Comment
-
I found someone already implemented plotting for trendmagic indicator for strategy. However he didnt implement plotting for when CCI is used. can someone help me to plot those as well?
Code:protected override void OnStateChange() { if (State == State.SetDefaults) { Description = @"An ATR based trendline regulated by the position of CCI and its zero line."; Name = "TrendMagic"; IsOverlay = true; IsSuspendedWhileInactive = true; cciPeriod = 20; atrPeriod = 14; atrMult = 1.0; useCciTrendColor = false; BullBrush = Brushes.Lime; BearBrush = Brushes.Red; AddPlot(new Stroke(Brushes.Orange, 2), PlotStyle.Line, Name); [B] AddPlot(Brushes.Transparent, "Trend Output"); AddPlot(Brushes.Transparent, "Buy/Sell Output");[/B] } else if (State == State.DataLoaded) { Trend[0] = 0; lineColor = new Series<double>(this); } } protected override void OnBarUpdate() { if (CurrentBar < cciPeriod || CurrentBar < atrPeriod) return; cciVal = CCI(Close, cciPeriod)[0]; atrVal = ATR(Close, atrPeriod)[0]; upTrend = Low[0] - atrVal * atrMult; downTrend = High[0] + atrVal * atrMult; if (cciVal >= 0) if (upTrend < Trend[1]) Trend[0] = Trend[1]; else Trend[0] = upTrend; else if (downTrend > Trend[1]) Trend[0] = Trend[1]; else Trend[0] = downTrend; [B] TrendOutput[0] = Trend[0] > Trend[1] ? 1 : Trend[0] < Trend[1] ? -1 : TrendOutput[1]; BuySellOutput[0] = TrendOutput[0] == 1 && TrendOutput[1] != 1 ? 1 : TrendOutput[0] == -1 && TrendOutput[1] != -1 ? -1 : 0;[/B] if (useCciTrendColor) lineColor[0] = cciVal > 0 ? 1 : -1; else lineColor[0] = TrendOutput[0]; PlotBrushes[0][0] = lineColor[0] == 1 ? BullBrush : BearBrush; }
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by NullPointStrategies, Yesterday, 05:17 AM
|
0 responses
62 views
0 likes
|
Last Post
|
||
|
Started by argusthome, 03-08-2026, 10:06 AM
|
0 responses
134 views
0 likes
|
Last Post
by argusthome
03-08-2026, 10:06 AM
|
||
|
Started by NabilKhattabi, 03-06-2026, 11:18 AM
|
0 responses
75 views
0 likes
|
Last Post
|
||
|
Started by Deep42, 03-06-2026, 12:28 AM
|
0 responses
45 views
0 likes
|
Last Post
by Deep42
03-06-2026, 12:28 AM
|
||
|
Started by TheRealMorford, 03-05-2026, 06:15 PM
|
0 responses
50 views
0 likes
|
Last Post
|

Comment