Here’s another reader request. The three day rolling pivot range. The pivots are calculated using 24 hour data (vice normal hours) which appears to be a limitation of ThinkScript’s high() and low() functions. If anyone knows a workaround, I’d love to hear it.
The formulas for the high and low pivot range are as follows:
The Pivot= (3day High + 3day Low + Close)/3
The Midpoint= (3day High + 3 day Low)/2
Pivot Range= Absolute Value (Pivot – Midpoint)
Pivot High= Pivot + Range
Pivot Low= Pivot – Range
# THREEDAYPIVOTRANGE
# http://www.thinkscripter.com
# thinkscripter@gmail.com
# Last Update 22 Feb 2009
input timeFrame = {default DAY};
input showOnlyToday = no;
def day = getDay();
def lastDay = getLastDay();
def isToday = if(day >= lastDay, 1, 0);
def shouldPlot = if(showOnlyToday and isToday, 1, if(!showOnlyToday, 1, 0));
def HA = high(period = timeFrame)[1];
def HB = high(period = timeFrame)[2];
def HC = high(period = timeFrame)[3];
def LA = low(period = timeFrame)[1];
def LB = low(period = timeFrame)[2];
def LC = low(period = timeFrame)[3];
def C = close(period = timeFrame)[1];
def H3 = Max(Max(HA, HB), HC);
def L3 = Min(Min(LA, LB), LC);
def calc_PP = (H3 + L3 + C) / 3;
def calc_MP = (H3 + L3) / 2;
def calc_PR = AbsValue(calc_PP - calc_mp);
def calc_PH = Calc_PP + calc_PR;
def calc_PL = Calc_PP - calc_PR;
plot PH =if (shouldPlot , calc_PH, double.nan);
plot PL = if (shouldPlot , calc_PL, double.nan);
PH.setStyle(curve.POINTS);
PL.setStyle(curve.POINTS);
PH.SetDefaultColor(color.cyan);
PL.SetDefaultColor(color.yellow);
PH.SetStyle(Curve.POINTS);
PL.SetStyle(Curve.POINTS);






I have a workaround for only using market hours data. This would only work for a chart with the last 3 days and today on it, though. I’m pulling this code out of my head in thin air, so it may need debugging, but the gist is there:
def marketopen=0930;
def marketclose=1600;
def isopen=if secondsaftertime(marketopen)>=0 and secondsuntiltime(marketclose)>=0 then 1 else 0;
def markethourshigh=if isopen then high else 0;
def markethourslow=if isopen then low else 1000000;
#Then do your calcs as normal, but on your markethours versions instead:
def H3 = highestall(markethourshigh);
def L3 = lowestall(markethourslow);
hi, very nice to share . Could the rolling pivots be adjusted on a 1 minute chart for example to show a rolling pivot every half hour? ie pivots would move at top and bottom of the hour?
Yes, the Rolling Pivots indicator: http://www.thinkscripter.com/indicator/hourly-rolling-pivots/ can be adjusted for any time period.
Eric
Is there a script that will show an average of the pivpot points for the current day, the day before and the day before using non overnight session. For example say tomorrow is weds the 3rd tues the 2nd, and monday the 1st. calculating the PP(High +Low+Close/3) . This plots a price level similar to a pivot point.
So current days pivot ,yesterday,and day before average
http://www.thinkscripter.com/indicator/pivot-point-moving-average/
Thanks a lot for the quick response! Is there any way to get this to only calculate 9:30-4:15 EST. or 8:30-3:15 CT.? I dont use overnight action in my pivot studies
Unfortunately not.
-Eric