[CODE
//This namespace holds Indicators in this folder and is required. Do not change it.
namespace NinjaTrader.NinjaScript.Indicators
{
[TypeConverter("NinjaTrader.NinjaScript.Indicators. PivotsTypeConverter")]
public class Pivot : Indicator
{
private DateTime cacheMonthlyEndDate = Globals.MinDate;
private DateTime cacheSessionDate = Globals.MinDate;
private DateTime cacheSessionEnd = Globals.MinDate;
private DateTime cacheTime;
private DateTime cacheWeeklyEndDate = Globals.MinDate;
private DateTime currentDate = Globals.MinDate;
private DateTime currentMonth = Globals.MinDate;
private DateTime currentWeek = Globals.MinDate;
private DateTime sessionDateTmp = Globals.MinDate;
private HLCCalculationMode priorDayHlc;
private PivotRange pivotRangeType;
private SessionIterator storedSession;
private double currentClose;
private double currentHigh = double.MinValue;
private double currentLow = double.MaxValue;
private double dailyBarClose = double.MinValue;
private double dailyBarHigh = double.MinValue;
private double dailyBarLow = double.MinValue;
private double pp;
private double r1;
private double r2;
private double r3;
private double s1;
private double s2;
private double s3;
private double userDefinedClose;
private double userDefinedHigh;
private double userDefinedLow;
private int cacheBar;
private int width = 20;
private readonly List<int> newSessionBarIdxArr = new List<int>();
protected override void OnStateChange()
{
if (State == State.SetDefaults)
{
Description = "\r\nThe Daily Pivots indicator can be used to display floor pivots, Globex pivots and the high, low and close of the prior day.";
Name = "Pivot";
Calculate = Calculate.OnBarClose;
DisplayInDataBox = true;
DrawOnPricePanel = false;
IsAutoScale = false;
IsOverlay = true;
PaintPriceMarkers = true;
ScaleJustification = ScaleJustification.Right;
// AddPlot(Brushes.Goldenrod, NinjaTrader.Custom.Resource.PivotPP);
AddPlot(new Stroke(Brushes.White,3), PlotStyle.Hash,"PP");
// AddPlot(Brushes.DodgerBlue, NinjaTrader.Custom.Resource.PivotR1);
AddPlot(new Stroke(Brushes.Red,3), PlotStyle.Hash,"R1");
// AddPlot(Brushes.DodgerBlue, NinjaTrader.Custom.Resource.PivotR2);
AddPlot(new Stroke(Brushes.Red,3), PlotStyle.Hash,"R2");
// AddPlot(Brushes.DodgerBlue, NinjaTrader.Custom.Resource.PivotR3);
AddPlot(new Stroke(Brushes.Red,3), PlotStyle.Hash,"R3");
// AddPlot(Brushes.Crimson, NinjaTrader.Custom.Resource.PivotS1);
AddPlot(new Stroke(Brushes.Lime,3), PlotStyle.Hash,"S1");
// AddPlot(Brushes.Crimson, NinjaTrader.Custom.Resource.PivotS2);
AddPlot(new Stroke(Brushes.Lime,3), PlotStyle.Hash,"S2");
// AddPlot(Brushes.Crimson, NinjaTrader.Custom.Resource.PivotS3);
AddPlot(new Stroke(Brushes.Lime,3), PlotStyle.Hash,"S3");
}
else if (State == State.Configure)
{
if (priorDayHlc == HLCCalculationMode.DailyBars)
AddDataSeries(BarsPeriodType.Day, 1);
}
else if (State == State.DataLoaded)
{
storedSession = new SessionIterator(Bars);
}
else if (State == State.Historical)
{
if (priorDayHlc == HLCCalculationMode.DailyBars && BarsArray[1].DayCount <= 0)
{
Draw.TextFixed(this, "NinjaScriptInfo", NinjaTrader.Custom.Resource.PiviotsDailyDataError, TextPosition.BottomRight);
Log(NinjaTrader.Custom.Resource.PiviotsDailyDataEr ror, LogLevel.Error);
return;
}
[/CODE]
Looks like there's a limit on the number of characters - which sucks. Let me know if this is enough or if I need to do something else to show more/all of the code.
Comment