forked from hwrdprkns/ThinkOrSwim
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJAWS.txt
More file actions
43 lines (35 loc) · 1.49 KB
/
JAWS.txt
File metadata and controls
43 lines (35 loc) · 1.49 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
# JAWS
# Drew Griffith
#hint: Mean Reversion Strategy published by PJ Sutherland: https://blog.sutherlandresearch.com/index.php/2017/05/26/a-simple-mean-reversion-strategy/
declare lower;
input ma1 = 2;
input ma2 = 5;
input pct_diff = 5.0;
input price = close;
def movavg1 = expAverage(length = ma1, data = price);
#movavg1.SetLineWeight(3);
#movavg1.SetDefaultColor(Color.CYAN);
def movavg2 = expAverage(length = ma2, data = price);
#movavg2.SetLineWeight(3);
#movavg2.SetDefaultColor(Color.MAGENTA);
plot pctdiff = (AbsValue(movavg1 - movavg2) / ((movavg1 + movavg2) / 2)) * 100;
plot extSE = if close > movavg1 and close > movavg2 and pctdiff >= pct_diff then pctdiff else Double.NaN;
extSE.SetLineWeight(3);
extSE.SetDefaultColor(Color.ORANGE);
extSE.SetPaintingStrategy(PaintingStrategy.POINTS);
plot extLE = if close < movavg1 and close < movavg2 and pctdiff >= pct_diff then pctdiff else Double.NaN;
extLE.SetLineWeight(3);
extLE.SetDefaultColor(Color.YELLOW);
extLE.SetPaintingStrategy(PaintingStrategy.POINTS);
plot ext = pct_diff;
ext.SetLineWeight(1);
ext.SetDefaultColor(Color.GRAY);
ext.SetPaintingStrategy(PaintingStrategy.LINE);
plot LE = if movavg1 crosses above movavg2 and pctdiff < 2 then pctdiff else double.NaN;
LE.AssignValueColor(Color.GREEN);
LE.SetPaintingStrategy(PaintingStrategy.POINTS);
LE.SetLineWeight(5);
plot LX = if movavg1 crosses below movavg2 then pctdiff else double.NaN;;
LX.AssignValueColor(Color.RED);
LX.SetPaintingStrategy(PaintingStrategy.POINTS);
LX.SetLineWeight(5);