s1 = currentClose - (currentHigh - currentLow) * 1.1 / 12;
r1 = currentClose + (currentHigh - currentLow) * 1.1 / 12;
s2 = currentClose - (currentHigh - currentLow) * 1.1 / 6;
r2 = currentClose + (currentHigh - currentLow) * 1.1 / 6;
s3 = currentClose - (currentHigh - currentLow) * 1.1 / 4;
r3 = currentClose + (currentHigh - currentLow) * 1.1 / 4;
s4 = currentClose - (currentHigh - currentLow) * 1.1 / 2;
r4 = currentClose + (currentHigh - currentLow) * 1.1 / 2;
something like that
s1 = currentClose - 1*Percent
r1 = currentClose + 1*Percent
s2 = currentClose - 2*Percent
r2 = currentClose + 2*Percent
s3 = currentClose - 3*Percent
r3 = currentClose + 3*Percent
s4 = currentClose - 4*Percent
r4 = currentClose + 4*Percent
the code begin is
AddPlot(Brushes.DodgerBlue, NinjaTrader.Custom.Resource.PivotsR1);
AddPlot(Brushes.DodgerBlue, NinjaTrader.Custom.Resource.PivotsR2);
AddPlot(Brushes.DodgerBlue, NinjaTrader.Custom.Resource.PivotsR3);
AddPlot(Brushes.DodgerBlue, NinjaTrader.Custom.Resource.PivotsR4);
AddPlot(Brushes.Crimson, NinjaTrader.Custom.Resource.PivotsS1);
AddPlot(Brushes.Crimson, NinjaTrader.Custom.Resource.PivotsS2);
AddPlot(Brushes.Crimson, NinjaTrader.Custom.Resource.PivotsS3);
AddPlot(Brushes.Crimson, NinjaTrader.Custom.Resource.PivotsS4);
}
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;
}
if (!Bars.BarsType.IsIntraday && BarsPeriod.BarsPeriodType != BarsPeriodType.Day && (BarsPeriod.BarsPeriodType != BarsPeriodType.HeikenAshi && BarsPeriod.BarsPeriodType != BarsPeriodType.PriceOnVolume && BarsPeriod.BarsPeriodType != BarsPeriodType.Volumetric || BarsPeriod.BaseBarsPeriodType != BarsPeriodType.Day))
{
Draw.TextFixed(this, "NinjaScriptInfo", NinjaTrader.Custom.Resource.PiviotsDailyBarsError, TextPosition.BottomRight);
Log(NinjaTrader.Custom.Resource.PiviotsDailyBarsEr ror, LogLevel.Error);
}
if ((BarsPeriod.BarsPeriodType == BarsPeriodType.Day || ((BarsPeriod.BarsPeriodType == BarsPeriodType.HeikenAshi || BarsPeriod.BarsPeriodType == BarsPeriodType.PriceOnVolume || BarsPeriod.BarsPeriodType == BarsPeriodType.Volumetric) && BarsPeriod.BaseBarsPeriodType == BarsPeriodType.Day)) && pivotRangeType == PivotRange.Daily)
{
Draw.TextFixed(this, "NinjaScriptInfo", NinjaTrader.Custom.Resource.PiviotsWeeklyBarsError , TextPosition.BottomRight);
Log(NinjaTrader.Custom.Resource.PiviotsWeeklyBarsE rror, LogLevel.Error);
}
if ((BarsPeriod.BarsPeriodType == BarsPeriodType.Day || ((BarsPeriod.BarsPeriodType == BarsPeriodType.HeikenAshi || BarsPeriod.BarsPeriodType == BarsPeriodType.PriceOnVolume || BarsPeriod.BarsPeriodType == BarsPeriodType.Volumetric) && BarsPeriod.BaseBarsPeriodType == BarsPeriodType.Day)) && BarsPeriod.Value > 1)
{
Draw.TextFixed(this, "NinjaScriptInfo", NinjaTrader.Custom.Resource.PiviotsPeriodTypeError , TextPosition.BottomRight);
Log(NinjaTrader.Custom.Resource.PiviotsPeriodTypeE rror, LogLevel.Error);
}
if ((priorDayHlc == HLCCalculationMode.DailyBars &&
(pivotRangeType == PivotRange.Monthly && BarsArray[1].GetTime(0).Date >= BarsArray[1].GetTime(BarsArray[1].Count - 1).Date.AddMonths(-1)
|| pivotRangeType == PivotRange.Weekly && BarsArray[1].GetTime(0).Date >= BarsArray[1].GetTime(BarsArray[1].Count - 1).Date.AddDays(-7)
|| pivotRangeType == PivotRange.Daily && BarsArray[1].GetTime(0).Date >= BarsArray[1].GetTime(BarsArray[1].Count - 1).Date.AddDays(-1)))
|| pivotRangeType == PivotRange.Monthly && BarsArray[0].GetTime(0).Date >= BarsArray[0].GetTime(BarsArray[0].Count - 1).Date.AddMonths(-1)
|| pivotRangeType == PivotRange.Weekly && BarsArray[0].GetTime(0).Date >= BarsArray[0].GetTime(BarsArray[0].Count - 1).Date.AddDays(-7)
|| pivotRangeType == PivotRange.Daily && BarsArray[0].GetTime(0).Date >= BarsArray[0].GetTime(BarsArray[0].Count - 1).Date.AddDays(-1)
)
{
Draw.TextFixed(this, "NinjaScriptInfo", NinjaTrader.Custom.Resource.PiviotsInsufficentData Error, TextPosition.BottomRight);
Log(NinjaTrader.Custom.Resource.PiviotsInsufficent DataError, LogLevel.Error);
}
}
}
protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;
if ((priorDayHlc == HLCCalculationMode.DailyBars && BarsArray[1].DayCount <= 0)
|| (!Bars.BarsType.IsIntraday && BarsPeriod.BarsPeriodType != BarsPeriodType.Day && (BarsPeriod.BarsPeriodType != BarsPeriodType.HeikenAshi && BarsPeriod.BarsPeriodType != BarsPeriodType.PriceOnVolume && BarsPeriod.BarsPeriodType != BarsPeriodType.Volumetric || BarsPeriod.BaseBarsPeriodType != BarsPeriodType.Day))
|| ((BarsPeriod.BarsPeriodType == BarsPeriodType.Day || ((BarsPeriod.BarsPeriodType == BarsPeriodType.HeikenAshi || BarsPeriod.BarsPeriodType == BarsPeriodType.PriceOnVolume || BarsPeriod.BarsPeriodType == BarsPeriodType.Volumetric) && BarsPeriod.BaseBarsPeriodType == BarsPeriodType.Day)) && pivotRangeType == PivotRange.Daily)
|| ((BarsPeriod.BarsPeriodType == BarsPeriodType.Day || ((BarsPeriod.BarsPeriodType == BarsPeriodType.HeikenAshi || BarsPeriod.BarsPeriodType == BarsPeriodType.PriceOnVolume || BarsPeriod.BarsPeriodType == BarsPeriodType.Volumetric) && BarsPeriod.BaseBarsPeriodType == BarsPeriodType.Day)) && BarsPeriod.Value > 1)
|| ((priorDayHlc == HLCCalculationMode.DailyBars && (pivotRangeType == PivotRange.Monthly && BarsArray[1].GetTime(0).Date >= BarsArray[1].GetTime(BarsArray[1].Count - 1).Date.AddMonths(-1)
|| pivotRangeType == PivotRange.Weekly && BarsArray[1].GetTime(0).Date >= BarsArray[1].GetTime(BarsArray[1].Count - 1).Date.AddDays(-7)
|| pivotRangeType == PivotRange.Daily && BarsArray[1].GetTime(0).Date >= BarsArray[1].GetTime(BarsArray[1].Count - 1).Date.AddDays(-1)))
|| pivotRangeType == PivotRange.Monthly && BarsArray[0].GetTime(0).Date >= BarsArray[0].GetTime(BarsArray[0].Count - 1).Date.AddMonths(-1)
|| pivotRangeType == PivotRange.Weekly && BarsArray[0].GetTime(0).Date >= BarsArray[0].GetTime(BarsArray[0].Count - 1).Date.AddDays(-7)
|| pivotRangeType == PivotRange.Daily && BarsArray[0].GetTime(0).Date >= BarsArray[0].GetTime(BarsArray[0].Count - 1).Date.AddDays(-1)))
return;
RemoveDrawObject("NinjaScriptInfo");
if (PriorDayHlc == HLCCalculationMode.DailyBars && CurrentBars[1] >= 0)
{
// Get daily bars like this to avoid situation where primary series moves to next session before previous day OHLC are added
if (cacheTime != Times[0][0])
{
cacheTime = Times[0][0];
cacheBar = BarsArray[1].GetBar(Times[0][0]);
}
dailyBarHigh = BarsArray[1].GetHigh(cacheBar);
dailyBarLow = BarsArray[1].GetLow(cacheBar);
dailyBarClose = BarsArray[1].GetClose(cacheBar);
}
else
{
dailyBarHigh = double.MinValue;
dailyBarLow = double.MinValue;
dailyBarClose = double.MinValue;
}
double high = (dailyBarHigh == double.MinValue) ? Highs[0][0] : dailyBarHigh;
double low = (dailyBarLow == double.MinValue) ? Lows[0][0] : dailyBarLow;
double close = (dailyBarClose == double.MinValue) ? Closes[0][0] : dailyBarClose;
DateTime lastBarTimeStamp = GetLastBarSessionDate(Times[0][0], pivotRangeType);
if ((currentDate != Globals.MinDate && pivotRangeType == PivotRange.Daily && lastBarTimeStamp != currentDate)
|| (currentWeek != Globals.MinDate && pivotRangeType == PivotRange.Weekly && lastBarTimeStamp != currentWeek)
|| (currentMonth != Globals.MinDate && pivotRangeType == PivotRange.Monthly && lastBarTimeStamp != currentMonth))
{
s1 = currentClose - (currentHigh - currentLow) * 1.1 / 12;
r1 = currentClose + (currentHigh - currentLow) * 1.1 / 12;
s2 = currentClose - (currentHigh - currentLow) * 1.1 / 6;
r2 = currentClose + (currentHigh - currentLow) * 1.1 / 6;
s3 = currentClose - (currentHigh - currentLow) * 1.1 / 4;
r3 = currentClose + (currentHigh - currentLow) * 1.1 / 4;
s4 = currentClose - (currentHigh - currentLow) * 1.1 / 2;
r4 = currentClose + (currentHigh - currentLow) * 1.1 / 2;
currentClose = (priorDayHlc == HLCCalculationMode.UserDefinedValues) ? UserDefinedClose : close;
currentHigh = (priorDayHlc == HLCCalculationMode.UserDefinedValues) ? UserDefinedHigh : high;
currentLow = (priorDayHlc == HLCCalculationMode.UserDefinedValues) ? UserDefinedLow : low;
}
else
{
currentClose = (priorDayHlc == HLCCalculationMode.UserDefinedValues) ? UserDefinedClose : close;
currentHigh = (priorDayHlc == HLCCalculationMode.UserDefinedValues) ? UserDefinedHigh : Math.Max(currentHigh, high);
currentLow = (priorDayHlc == HLCCalculationMode.UserDefinedValues) ? UserDefinedLow : Math.Min(currentLow, low);
}

Im going to test right now
Comment