@Antares66 I added R4, R5, S4 and S5 pivot points. I'm using here TradingView's traditional pivot point formula.
Code:
# WeeklyMonthlyPivots_TS
# http://thinkscripter.wordpress.com
# [email protected]
# Slightly modified by durruha @ useThinkScript
input timeFrame = {default DAY, WEEK, MONTH, QUARTER, YEAR};
input showOnlyToday = yes;
DefineGlobalColor("DAY", CreateColor(255, 255, 255));
DefineGlobalColor("WEEK", CreateColor(144, 191, 143));
DefineGlobalColor("MONTH", CreateColor(19, 240, 207));
DefineGlobalColor("QUARTER", CreateColor(31, 30, 108));
DefineGlobalColor("YEAR", CreateColor(0, 0, 0));
def H = high(period = timeFrame)[1];
def L = low(period = timeFrame)[1];
def C = close(period = timeFrame)[1];
def calc_PP = (H + L + C) / 3;
def calc_R1 = calc_PP * 2 - L;
def calc_S1 = calc_PP * 2 - H;
def calc_R2 = calc_PP + (H - L);
def calc_S2 = calc_PP - (H - L);
def calc_R3 = calc_PP * 2 + (H - 2 * L);
def calc_S3 = calc_PP * 2 - (2 * H - L);
def calc_R4 = calc_PP * 3 + (H - 3 * L);
def calc_S4 = calc_PP * 3 - (3 * H - L);
def calc_R5 = calc_PP * 4 + (H - 4 * L);
def calc_S5 = calc_PP * 4 - (4 * H - L);
plot R5;
plot R4;
plot R3;
plot R2;
plot R1;
plot PP;
plot S1;
plot S2;
plot S3;
plot S4;
plot S5;
if (showOnlyToday and !IsNaN(close(period = timeFrame)[-1])) or
(GetAggregationPeriod() > if timeframe == timeframe.DAY then AggregationPeriod.DAY
else if timeframe == timeframe.WEEK then AggregationPeriod.WEEK
else if timeframe == timeframe.MONTH then AggregationPeriod.MONTH
else if timeframe == timeframe.QUARTER then AggregationPeriod.QUARTER
else AggregationPeriod.YEAR)
then {
R5 = Double.NaN;
R4 = Double.NaN;
R3 = Double.NaN;
R2 = Double.NaN;
R1 = Double.NaN;
PP = Double.NaN;
S1 = Double.NaN;
S2 = Double.NaN;
S3 = Double.NaN;
S4 = Double.NaN;
S5 = Double.NaN;
}
else {
R5 = calc_R5;
R4 = calc_R4;
R3 = calc_R3;
R2 = calc_R2;
R1 = calc_R1;
PP = calc_PP;
S1 = calc_S1;
S2 = calc_S2;
S3 = calc_S3;
S4 = calc_S4;
S5 = calc_S5;
}
R1.SetDefaultColor(GlobalColor(timeframe));
R2.SetDefaultColor(GlobalColor(timeframe));
R3.SetDefaultColor(GlobalColor(timeframe));
R4.SetDefaultColor(GlobalColor(timeframe));
R5.SetDefaultColor(GlobalColor(timeframe));
S1.SetDefaultColor(GlobalColor(timeframe));
S2.SetDefaultColor(GlobalColor(timeframe));
S3.SetDefaultColor(GlobalColor(timeframe));
S4.SetDefaultColor(GlobalColor(timeframe));
S5.SetDefaultColor(GlobalColor(timeframe));
PP.SetDefaultColor(GlobalColor(timeframe));
R1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
R5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S1.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S2.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S3.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S4.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
S5.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
PP.SetLineWeight(2);
PP.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
Last edited: