replaced by post 6.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
bool to double
Collapse
X
-
Hello SJunior,
Thanks for your post.
QuantKey_Bruce is correct. To compare a plot to another value you would need to use == instead of =.
What exactly is the bool variable in the code you shared that the error message is referring to?
Plots created with the AddPlot() method are typically Series<double> values.<span class="name">Brandon H.</span><span class="title">NinjaTrader Customer Service</span><iframe name="sig" id="sigFrame" src="/support/forum/core/clientscript/Signature/signature.php" frameborder="0" border="0" cellspacing="0" style="border-style: none;width: 100%; height: 120px;"></iframe>
- Likes 1
Comment
-
QuantKey_Bruce, My knowledge in NT8 programming is very little and I need to add the following situation in the source code, but I have already tried some alternatives, but without success.
Would it be possible for you to help me write the code, as I already had the help of support that indicated technical documents, but I could not put it into practice in the indicator code.
Change the candlesticks/bars chains, when:
HS = (d18[0] > 0 && dO18[0] < 0 && d18[0] > d38[0] && dO18[0] < d38[0]);
color Lime
LS = (d18[0] < 0 && dO18[0] > 0 && d18[0] < d38[0] && dO18[0] > d38[0]);
color red
H = (d18[0] > 0 && dO18[0] < 0 && d18[0] > d38[0] && dO18[0] < d38[0] && d18[0] > d208[0] && dO18[0 ] < d208[0]);
color cyan
L = (d18[0] < 0 && dO18[0] > 0 && d18[0] < d38[0] && dO18[0] > d38[0] && d18[0] < d208[0] && dO18[0 ] > d208[0]);
color magenta
================================================== =====
Below is the complete and working code, but without the candles/bars coloring coding.
================================================== ===
//
region Using declarations
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Input;
using System.Windows.Media;
using System.Xml.Serialization;
using NinjaTrader.Cbi;
using NinjaTrader.Gui;
using NinjaTrader.Gui.Chart;
using NinjaTrader.Gui.SuperDom;
using NinjaTrader.Data;
using NinjaTrader.NinjaScript;
using NinjaTrader.Core.FloatingPoint;
using NinjaTrader.NinjaScript.DrawingTools;
#endregion
namespace NinjaTrader.NinjaScript.Indicators.mah_Indicators
{
public class Indicators : Indicator
{
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = "SJunior";
Name = "SJunior";
IsSuspendedWhileInactive = true;
AddPlot(new Stroke(Brushes.LightPink, 4), PlotStyle.Line, "d38");
AddPlot(new Stroke(Brushes.DarkGreen, 4), PlotStyle.Line, "d208");
AddPlot(new Stroke(Brushes.Cyan, 1), PlotStyle.Bar, "d18");
AddPlot(new Stroke(Brushes.Yellow, 1), PlotStyle.Bar, "dO18");
AddPlot(new Stroke(Brushes.LightCyan, 1), PlotStyle.Line, "osc");
AddPlot(new Stroke(Brushes.Goldenrod, 1), PlotStyle.Line, "srs");
AddPlot(new Stroke(Brushes.Goldenrod, 1), PlotStyle.Line, "sri");
AddPlot(new Stroke(Brushes.Yellow, 1), PlotStyle.Line, "nvel_0");
}
}
protected override void OnBarUpdate()
{
if (CurrentBar < 20) return;
d38[0] = (((SMA(1)[0]-SMA(8)[0])/SMA(8)[0])*100);
d208[0] = (((SMA(20)[0]-SMA(8)[0])/SMA(8)[0])*100);
d18[0] = (((SMA(1)[0]-SMA(8)[0])/SMA(8)[0])*100);
dO18[0] = (((SMA(1)[1]-SMA(8)[0])/SMA(8)[0])*100);
osc[0] = (d38[0]-d208[0]);
srs[0] = (((2*StdDev(8)[0])/SMA(8)[0])*100);
sri[0] = (((-2*StdDev(8)[0])/SMA(8)[0])*100);
nivel_0[0] = 0;
if (d208[0] <= 0 && d208[0] < d208[1])
PlotBrushes[1][0] = Brushes.Green;
else if (d208[0] >= 0 && d208[0] > d208[1])
PlotBrushes[1][0] = Brushes.Red;
else if (d208[0] <= 0 && d208[0] > d208[1])
PlotBrushes[1][0] = Brushes.Magenta;
else if (d208[0] >= 0 && d208[0] < d208[1])
PlotBrushes[1][0] = Brushes.Orange;
if (osc[0] >= 0 && osc[0] > osc[1])
PlotBrushes[4][0] = Brushes.Green;
else if (osc[0] <= 0 && osc[0] < osc[1])
PlotBrushes[4][0] = Brushes.Red;
else if (osc[0] >= 0 && osc[0] < osc[1])
PlotBrushes[4][0] = Brushes.Magenta;
else if (osc[0] <= 0 && osc[0] > osc[1])
PlotBrushes[4][0] = Brushes.Orange;
}
region Properties
[Browsable(false)]
[XmlIgnore]
public Series<double> d38
{
get { return Values[0]; }
}
[Browsable(false)]
[XmlIgnore]
public Series<double> d208
{
get { return Values[1]; }
}
[Browsable(false)]
[XmlIgnore]
public Series<double> d18
{
get { return Values[2]; }
}
[Browsable(false)]
[XmlIgnore]
public Series<double> dO18
{
get { return Values[3]; }
}
[Browsable(false)]
[XmlIgnore]
public Series<double> osc
{
get { return Values[4]; }
}
[Browsable(false)]
[XmlIgnore]
public Series<double> srs
{
get { return Values[5]; }
}
[Browsable(false)]
[XmlIgnore]
public Series<double> sri
{
get { return Values[6]; }
}
[Browsable(false)]
[XmlIgnore]
public Series<double> nivel_0
{
get { return Values[7]; }
}
[Browsable(false)]
[XmlIgnore]
public bool HiE
{
get; set;
}
[Browsable(false)]
[XmlIgnore]
public bool LoE
{
get; set;
}
[Browsable(false)]
[XmlIgnore]
public bool Hi
{
get; set;
}
[Browsable(false)]
[XmlIgnore]
public bool Lo
{
get; set;
}
#endregion
}
}
region NinjaScript generated code. Neither change nor remove.
namespace NinjaTrader.NinjaScript.Indicators
{
public partial class Indicator : NinjaTrader.Gui.NinjaScript.IndicatorRenderBase
{
private mah_Indicators.Indicators[] cacheIndicators;
public mah_Indicators.Indicators Indicators()
{
return Indicators(Input);
}
public mah_Indicators.Indicators Indicators(ISeries<double> input)
{
if (cacheIndicators != null)
for (int idx = 0; idx < cacheIndicators.Length; idx++)
if (cacheIndicators[idx] != null && cacheIndicators[idx].EqualsInput(input))
return cacheIndicators[idx];
return CacheIndicator<mah_Indicators.Indicators>(new mah_Indicators.Indicators(), input, ref cacheIndicators);
}
}
}
namespace NinjaTrader.NinjaScript.MarketAnalyzerColumns
{
public partial class MarketAnalyzerColumn : MarketAnalyzerColumnBase
{
public Indicators.mah_Indicators.Indicators Indicators()
{
return indicator.Indicators(Input);
}
public Indicators.mah_Indicators.Indicators Indicators(ISeries<double> input )
{
return indicator.Indicators(input);
}
}
}
namespace NinjaTrader.NinjaScript.Strategies
{
public partial class Strategy : NinjaTrader.Gui.NinjaScript.StrategyRenderBase
{
public Indicators.mah_Indicators.Indicators Indicators()
{
return indicator.Indicators(Input);
}
public Indicators.mah_Indicators.Indicators Indicators(ISeries<double> input )
{
return indicator.Indicators(input);
}
}
}
#endregionLast edited by SJunior; 06-28-2023, 06:05 AM.
Comment
Latest Posts
Collapse
| Topics | Statistics | Last Post | ||
|---|---|---|---|---|
|
Started by Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
601 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
347 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
103 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
559 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
558 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment