I've been stabbing away at this for a while thinking I got it then I find the ATR is not correct. I would greatly appreciate any help with getting the correct ATR to print to the screen. Thank you for any time in advance. I know it is the holidays. Merry Christmas everyone.
Below is the script that I have. Thanks again for any time invested.
private double ScalpTarget;
private double SwingTarget;
private ATR ATR1;
private Gui.Tools.SimpleFont textFont;
private string scalptargetinfo;
private string swingtargetinfo;
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = @"Enter the description for your new custom Indicator here.";
Name = "TOTtargets";
Calculate = Calculate.OnBarClose;
IsOverlay = true;
DisplayInDataBox = true;
DrawOnPricePanel = true;
DrawHorizontalGridLines = true;
DrawVerticalGridLines = true;
PaintPriceMarkers = true;
ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
//Disable this property if your indicator requires custom values that cumulate with each new market data event.
//See Help Guide for additional information.
IsSuspendedWhileInactive = true;
BarPeriod = 20;
textFont = new Gui.Tools.SimpleFont("Arial", 14);
TextColor = Brushes.Red;
TextBackColor = Brushes.Yellow;
ShowScalpTarget = false;
ShowSwingTarget = true;
TextPosition = TextPosition.BottomRight;
}
else if (State == State.Configure)
{
}
else if (State == State.DataLoaded)
{
ATR1 = ATR(Close,(BarPeriod));
scalptargetinfo = ("Scalp Target: ") + Convert.ToInt32(ATR1[0]/2);
swingtargetinfo = ("Swing Target: ") + Convert.ToInt32(ATR1[0]);
}
}
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if (CurrentBars[0] < 1)
return;
if ((ATR1[0] > 0)
&& (ShowScalpTarget == true))
{
Draw.TextFixed(this, @"ScalpTarget", scalptargetinfo, TextPosition, TextColor, TextFont, Brushes.Transparent, TextBackColor, 100 );
}
if ((ATR1[0] > 0)
&& (ShowSwingTarget == true))
{
Draw.TextFixed(this, @"SwingTarget", swingtargetinfo, TextPosition, TextColor, TextFont, Brushes.Transparent, TextBackColor, 100 );
}
}

Comment