Here is some code to calculate the simple pivot levels for any symbols. You can choose the timeframe to decide if you want to calculate daily, weekly or monthly pivots. By default, the code only shows the pivot, S1 and R1. You can remove the hide() lines and show all the levels if you want.
input timeFrame = {default DAY, WEEK, MONTH};
def period_high = high(period = timeFrame)[1];
def period_low = low(period = timeFrame)[1];
def period_close = close(period = timeFrame)[1];
plot pivot = (period_high + period_low + period_close)/3;
pivot.SetDefaultColor(Color.YELLOW);
plot R1 = pivot * 2 - period_low;
R1.SetDefaultColor(Color.GREEN);
plot S1 = pivot * 2 - period_high;
S1.SetDefaultColor(Color.GREEN);
plot R2 = pivot + R1 - S1;
R2.SetDefaultColor(Color.LIGHT_GRAY);
R2.hide();
plot S2 = pivot - (R1-S1);
S2.SetDefaultColor(Color.LIGHT_GRAY);
S2.hide();
plot R3 = period_high + 2*(pivot-period_low);
R3.SetDefaultColor(Color.LIGHT_GREEN);
R3.hide();
plot S3 = period_low - 2*(period_high - pivot);
S3.SetDefaultColor(Color.LIGHT_GREEN);
S3.hide();
Subscribe to:
Post Comments (Atom)
1 comment:
I'm intrigued that the high + low + close / 3 calculation actually works as a key support and resistance level, but after adding it my chart it is pretty evident that it does in some cases. Is this a common pivot level that a lot of traders look at? I had made a couple of thinkscripts myself that plot the OHLC for daily, weekly, and monthly charts on lower timeframes, and also one that plots the pre-market highs and lows on the regular hours as a reference point. I've found these to be pretty useful, but I've never tried the HLC/3 calculation.
Post a Comment