-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathRankLevels.ThinkScript
More file actions
44 lines (29 loc) · 1.59 KB
/
RankLevels.ThinkScript
File metadata and controls
44 lines (29 loc) · 1.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
declare lower;
declare hide_on_intraday;
#IVRank
def vol = imp_volatility();
input DisplayIVRank = yes;
input DisplayImpVolatility= yes;
input DisplayDaily1StandardDev = yes;
input DisplayWeekly1StandardDev = yes;
input DisplayMonthly1StandardDev = yes;
input TimePeriod = 252;
def data = if !isNaN(vol) then vol else vol[-1];
def hi = highest(data, TimePeriod);
def lo = lowest(data, TimePeriod);
plot Rank = (data - lo) / (hi - lo) * 100;
def lowend = Rank < 25;
def highend = Rank > 50;
#Labels
addlabel(DisplayIVRank , concat("IV Rank: ",aspercent(Rank /100)), if lowend then color.red else if highend then color.green else color.yellow);
addlabel(DisplayImpVolatility, concat("ImpVolatility: ",aspercent(vol)), if lowend then color.red else if highend then color.green else color.yellow);
def ImpPts = (vol / Sqrt(252)) * close;
AddLabel(DisplayDaily1StandardDev , Concat("Daily 1 SD +/- $", Astext( ImpPts, NumberFormat.TWO_DECIMAL_PLACES)), if lowend then color.red else if highend then color.green else color.yellow); ;
def ImpPts2 = (vol / Sqrt(52)) * close;
AddLabel(DisplayWeekly1StandardDev, Concat("Weekly 1 SD +/- $", Astext( ImpPts2, NumberFormat.TWO_DECIMAL_PLACES)), if lowend then color.red else if highend then color.green else color.yellow); ;
def ImpPts3 = (vol / Sqrt(12)) * close;
AddLabel(DisplayMonthly1StandardDev, Concat("Monthly 1 SD +/- $", Astext( ImpPts3, NumberFormat.TWO_DECIMAL_PLACES)), if lowend then color.red else if highend then color.green else color.yellow); ;
plot LowVol = 25;
plot HighVol = 50;
LowVol.SetDefaultColor(GetColor(5));
HighVol.SetDefaultColor(GetColor(6));