If possible, someone who can help me and write the code, because I already had the help of the support that indicated technical documents, but I couldn't 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);
}
}
}
#endregion

Comment