Hi,
I've been using thinkorswim for charts for my trading and I found it incredibly frustrating that the Camarilla Pivot Points in ToS is just wrong and weird.
So I fixed it.
The issues with the original ToS Camarilla Pivot Points
Doesnt use After Market data - for closing value and High and Low
Doesnt show R1 and S1 natively
Without these, well it's pretty useless.
So here is my script, I hope this helps everyone trade better on ToS.
To use this ThinkScript follow the directions
Open up Studies in ToS chart
Create a new Script (Click on the big "Create" button)
Write in Title for Script, I suggest Kevin'sCamPivots
Remove the default code, something to do with plot
Copy and Paste my code in.
Press 'Ok' button
now add it to your chart
This script also allows you to manually overide the Close High and Low values in the settings. This is because the values may still differ from DAS and you can have the flexibility to manually change the values.
#
# Kevin Gong - Camarilla Pivot Points
# Email me for support -
[email protected]
# Copy Right - Do not distribute this code without my consent.
#
input aggregationPeriod = {default "DAY", "WEEK", "MONTH"};
input length = 1;
input SetClose = 0.00;
input PreMaketHigh = 0.00;
input PreMaketLow = 0.00;
Assert(length > 0, "'length' should be positive: " + length);
def yyyymmdd = GetYYYYMMDD();
def month = GetYear() * 12 + GetMonth();
def day_number = DaysFromDate(First(yyyymmdd)) + GetDayOfWeek(First(yyyymmdd));
def Today = GetDay() == GetLastDay();
def Yesterday = GetDay() == GetLastDay() - 1;
def period;
switch (aggregationPeriod) {
case DAY:
period = CountTradingDays(Min(First(yyyymmdd), yyyymmdd), yyyymmdd) - 1;
case WEEK:
period = Floor(day_number / 7);
case MONTH:
period = Floor(month - First(month));
}
def prevHigh = if YesterDay and !YesterDay[1]
then high
else if Yesterday and
high > prevHigh[1]
then high
else prevHigh[1];
def prevLow = if Yesterday and !Yesterday[1]
then low
else if Yesterday and
low < prevLow[1]
then low
else prevLow[1];
def camhighValue = if PreMaketHigh == 0 then prevHigh else PreMaketHigh;
def camlowValue = if PreMaketLow == 0 then prevLow else PreMaketLow;
def last = if Today and !Today[1]
then close[1]
else last[1];
def camClose = if SetClose == 0 then last else SetClose;
def range = camhighValue - camlowValue;
plot R5 = (camhighValue / camlowValue) * camClose;
plot R4 = camClose + range * (1.1) / 2;
plot R3 = camClose + range * (1.1) / 4;
plot R2 = camClose + range * (1.1) / 6;
plot R1 = camClose + range * (1.1) / 12;
plot S1 = camClose - range * (1.1) / 12;
plot S2 = camClose - range * (1.1) / 6;
plot S3 = camClose - range * (1.1) / 4;
plot S4 = camClose - range * (1.1) / 2;
plot S5 = (camClose - (R5 - camClose));
R5.SetDefaultColor(GetColor(5));
R4.SetDefaultColor(GetColor(5));
R3.SetDefaultColor(GetColor(5));
R2.SetDefaultColor(GetColor(5));
R1.SetDefaultColor(GetColor(5));
S1.SetDefaultColor(GetColor(6));
S2.SetDefaultColor(GetColor(6));
S3.SetDefaultColor(GetColor(6));
S4.SetDefaultColor(GetColor(6));
S5.SetDefaultColor(GetColor(6));
def paintingStrategy = if aggregationPeriod == aggregationPeriod.DAY then PaintingStrategy.POINTS else if aggregationPeriod == aggregationPeriod.WEEK then PaintingStrategy.TRIANGLES else PaintingStrategy.SQUARES;
R5.SetPaintingStrategy(paintingStrategy);
R4.SetPaintingStrategy(paintingStrategy);
R3.SetPaintingStrategy(paintingStrategy);
R2.SetPaintingStrategy(paintingStrategy);
R1.SetPaintingStrategy(paintingStrategy);
S1.SetPaintingStrategy(paintingStrategy);
S2.SetPaintingStrategy(paintingStrategy);
S3.SetPaintingStrategy(paintingStrategy);
S4.SetPaintingStrategy(paintingStrategy);
S5.SetPaintingStrategy(paintingStrategy);