-
Notifications
You must be signed in to change notification settings - Fork 26
/
VIX_FGMR.txt
91 lines (78 loc) · 2.42 KB
/
VIX_FGMR.txt
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#
# $VIX Fear & Greed Mean Reversion Study (VIX_FGMR)
#
# This script adapted from posts from @kerberos007
# https://twitter.com/kerberos007
#
# Want the latest version of this script?
# https://github.com/korygill/technical-analysis
#
# Use on thinkorswim and thinkscript
# author @korygill
#
script GetBollingerBandPercent
{
input price = close;
input upper = 2;
input lower = -2;
input averageType = AverageType.SIMPLE;
input displace = 0;
input length = 20;
def upperBand = BollingerBands(price, displace, length, lower, upper, averageType).UpperBand;
def lowerBand = BollingerBands(price, displace, length, lower, upper, averageType).LowerBand;
plot BBPercent = (price - lowerBand) / (upperBand - lowerBand) * 100;
}
declare lower;
input sym = "VIX";
def price = close(sym);
input averageType = AverageType.SIMPLE;
input displace = 0;
input length = 20;
input signalType = {default CALL, PUT};
plot PB20 = GetBollingerBandPercent(price, 2.0, -2.0);
plot PB15 = GetBollingerBandPercent(price, 1.5, -1.5);
plot PB12 = GetBollingerBandPercent(price, 1.2, -1.2);
plot PB10 = GetBollingerBandPercent(price, 1.0, -1.0);
#plot symPlot = price;
plot ZeroLine = 0;
plot HalfLine = 50;
plot UnitLine = 100;
ZeroLine.SetDefaultColor(Color.GREEN);
HalfLine.SetDefaultColor(GetColor(8));
UnitLine.SetDefaultColor(Color.RED);
def callput;
switch (signalType)
{
case CALL:
callput = 1;
default:
callput = 0;
}
# -----------------
AddVerticalLine(
Crosses(PB20, ZeroLine, CrossingDirection.BELOW) and callput == 0,
"--- (OS - Cover Puts) ---", Color.MAGENTA, curve.SHORT_DASH
);
AddVerticalLine(
Crosses(PB12, UnitLine, CrossingDirection.BELOW) and callput == 0,
"--- (OB - Buy Puts) ---", Color.YELLOW, curve.SHORT_DASH
);
# -----------------
AddVerticalLine(
Crosses(PB15, ZeroLine, CrossingDirection.ABOVE) and callput == 1,
"+++ OS - Buy Calls +++", Color.GREEN, curve.SHORT_DASH
);
AddVerticalLine(
Crosses(PB15, UnitLine, CrossingDirection.ABOVE) and callput == 1,
"+++ OB - Cover Calls +++", Color.RED, curve.SHORT_DASH
);
AddLabel(yes, sym, COLOR.CYAN);
AddLabel(yes, signalType, COLOR.YELLOW);
PB20.SetdefaultColor(GetColor(0));
PB15.SetdefaultColor(GetColor(1));
PB12.SetdefaultColor(GetColor(2));
PB10.SetdefaultColor(GetColor(3));
AddLabel(yes, "%BB20: "+PB20, GetColor(0));
AddLabel(yes, "%BB15: "+PB15, GetColor(1));
AddLabel(yes, "%BB12: "+PB12, GetColor(2));
AddLabel(yes, "%BB10: "+PB10, GetColor(3));