Posted by ThinkScripter in Indicator, Support and Resistance | 15 comments

I had a reader request an implementation of the Camarilla pivots. Rather than re-invent the wheel, I grabbed ToS’ new Person’s Pivots script, jammed in the Camarilla formulas, cut out some extra plumbing, and voilĂ . By default the pivot, H1, H2, L1, and L2 levels are hidden. My quick research of these pivots suggested the H3/H4, L3/L4 levels are where the heavy lifting is done. (There is a bug in ThinkScript that makes the dot size a bit large for my taste but until ToS fixes it we’re stuck.)

# CAMARILLAPIVOTS # (c) 2009 http://www.thinkscripter.com # thinkscripter@gmail.com # Last Update 08 Feb 2009 input timeFrame = {default DAY, WEEK, MONTH}; input showOnlyToday = no; def H = high(period = timeFrame)[1]; def L = low(period = timeFrame)[1]; def C = close(period = timeFrame)[1]; def R = H-L; def calc_PP = (H + L + C) / 3; def calc_H1 = C+(R*1.1/12); def calc_H2 = C+(R*1.1/6); def calc_H3 = C+(R*1.1/4); def calc_H4 = C+(R*1.1/2); def calc_L1 = C-(R*1.1/12); def calc_L2 = C-(R*1.1/6); def calc_L3 = C-(R*1.1/4); def calc_L4 = C-(R*1.1/2); plot H4; plot H3; plot H2; plot H1; plot PP; plot L1; plot L2; plot L3; plot L4; PP.hide(); H1.hide(); H2.hide(); L1.hide(); L2.hide(); 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 AggregationPeriod.MONTH) then { H1 = Double.NaN; H2 = Double.NaN; H3 = Double.NaN; H4 = Double.NaN; PP = Double.NaN; L1 = Double.NaN; L2 = Double.NaN; L3 = Double.NaN; L4 = double.NaN; } else { H1 = calc_H1; H2 = calc_H2; H3 = calc_H3; H4 = calc_H4; PP = calc_PP; L1 = calc_L1; L2 = calc_L2; L3 = calc_L3; L4 = calc_L4; } PP.SetPaintingStrategy(if timeframe == timeframe.DAY then PaintingStrategy.LINE_VS_POINTS else if timeframe == timeframe.WEEK then PaintingStrategy.LINE_VS_TRIANGLES else PaintingStrategy.LINE_VS_SQUARES); H1.SetPaintingStrategy(if timeframe == timeframe.DAY then PaintingStrategy.LINE_VS_POINTS else if timeframe == timeframe.WEEK then PaintingStrategy.LINE_VS_TRIANGLES else PaintingStrategy.LINE_VS_SQUARES); H2.SetPaintingStrategy(if timeframe == timeframe.DAY then PaintingStrategy.LINE_VS_POINTS else if timeframe == timeframe.WEEK then PaintingStrategy.LINE_VS_TRIANGLES else PaintingStrategy.LINE_VS_SQUARES); H3.SetPaintingStrategy(if timeframe == timeframe.DAY then PaintingStrategy.LINE_VS_POINTS else if timeframe == timeframe.WEEK then PaintingStrategy.LINE_VS_TRIANGLES else PaintingStrategy.LINE_VS_SQUARES); H4.SetPaintingStrategy(if timeframe == timeframe.DAY then PaintingStrategy.LINE_VS_POINTS else if timeframe == timeframe.WEEK then PaintingStrategy.LINE_VS_TRIANGLES else PaintingStrategy.LINE_VS_SQUARES); L1.SetPaintingStrategy(if timeframe == timeframe.DAY then PaintingStrategy.LINE_VS_POINTS else if timeframe == timeframe.WEEK then PaintingStrategy.LINE_VS_TRIANGLES else PaintingStrategy.LINE_VS_SQUARES); L2.SetPaintingStrategy(if timeframe == timeframe.DAY then PaintingStrategy.LINE_VS_POINTS else if timeframe == timeframe.WEEK then PaintingStrategy.LINE_VS_TRIANGLES else PaintingStrategy.LINE_VS_SQUARES); L3.SetPaintingStrategy(if timeframe == timeframe.DAY then PaintingStrategy.LINE_VS_POINTS else if timeframe == timeframe.WEEK then PaintingStrategy.LINE_VS_TRIANGLES else PaintingStrategy.LINE_VS_SQUARES); L4.SetPaintingStrategy(if timeframe == timeframe.DAY then PaintingStrategy.LINE_VS_POINTS else if timeframe == timeframe.WEEK then PaintingStrategy.LINE_VS_TRIANGLES else PaintingStrategy.LINE_VS_SQUARES); PP.SetDefaultColor(GetColor(0)); H1.SetDefaultColor(GetColor(5)); H2.SetDefaultColor(GetColor(5)); H3.SetDefaultColor(GetColor(5)); H4.SetDefaultColor(GetColor(5)); L1.SetDefaultColor(GetColor(6)); L2.SetDefaultColor(GetColor(6)); L3.SetDefaultColor(GetColor(6)); L4.SetDefaultColor(GetColor(6)); PP.SetStyle(Curve.POINTS); H1.SetStyle(Curve.POINTS); H2.SetStyle(Curve.POINTS); H3.SetStyle(Curve.POINTS); H4.SetStyle(Curve.POINTS); L1.SetStyle(Curve.POINTS); L2.SetStyle(Curve.POINTS); L3.SetStyle(Curve.POINTS); L4.SetStyle(Curve.POINTS);

This is a great blog, thank you for the work. I am trying to learn thinkscript and appreciate the work.

Hi,

Thanks for all this great stuff. I loaded this study … It doesn’t plot correctly on 1-20-08 for some reason. I am using a 5 min chart of bgu (20 days).

Thanks Again!

Alan,

That was a long weekend and my guess is that when the script queries the ToS data for the previous day’s high, low, and close, it gets garbage back in return. Their data works properly over normal weekends but apparently not for unusual weekends.

-TS

If you can remember which study you are looking, (day, week, month) then just “#” the SetPaintingStrategy instructions and pick your line style from the Plots Box. You get a nice thin line.

By the way, there is some great stuff at your site—many thanks.

Why is there a “SetPaintingStrategy” for all the plots AND a “SetStyle” setting at the end of the code. The two must overlap each other. The same plots are being given two different styles at the same time.

Do you know if anyone has written the thinkscript formulas for TOS for Chandlier Stops?

Regards

Gary Deckert

Why yes Gary – Me!

The ThinkScripter Multi-Stops is a combination of Average True Range, Wilder’s Average, Chandelier, Elder SafeZone, and Fibonacci stops. You choose which type of stop you want, set the volatility coefficient and look-back length and you’re set.

-Eric

Wow! Worked straight away! Those lines sure are sharpie-thick. Very cool, I’m getting my donate $$ together, thank you!

Hi: This is a great site! Just what I’ve been looking for. I hope it is still being monitored. This indicator works great for the day timeframe, but when I plot it on EOD data it just shows one dot (per line I’m guessing) on each bar. It doesn’t plot at all on the weekly timeframe.

Is it possible to get someone to help me correct/modify to plot on daily, weekly, monthly timeframes?

Don,

I just ran this on a chart and it works fine. There is no such thing as daily pivots on a daily chart – only weekly and monthly which work fine. The daily pivots are for intraday charts.

-Eric

Eric…

Signed up last week…

Loaded Camarilla Pivots with (DAY, Yes) parameters.

My plots show today’s and tomorrow’s pivots (which update every tick).

Any ideas on how to turn off tomorrow’s plots.

Best Regards,

JMcW

There is no way currently to do that. The code would have to be modified to exclude the “developing” pivots.

-Eric

Yes, there is at least one way. I added 6 lines of code to your study and fixed the problem. No need to exclude the “developing” pivots. Solution takes advantage of TOS’s funky indexing scheme. Overall I am pleased with your products/service.

Best Regards,

JMcW

Great. I didn’t mean to imply it was impossible just that it was not possible without first modifying the original code.

As I stated above, this is a hacked version of ToS’ Person’s Pivots study. I don’t like the extraneous lines between the pivot levels that you get with the ToS code, so I modified the code to suit me.