-
Notifications
You must be signed in to change notification settings - Fork 47
/
HurstCOGSTUDY.ts
85 lines (70 loc) · 2.57 KB
/
HurstCOGSTUDY.ts
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
# HurstCOG
# DREWGRIFFITH15 (C) 2015
declare upper;
# Daily settings / 15 minute chart
input price = close;
input COGlength = 10;
input InnerValue = 1.6; # 0.40
input OuterValue = 2.6; # 0.65
input ExtremeValue = 4.2; # 1.05
input showClosingPriceLine = NO;
input showPriceBar = YES;
input smooth = 1;
def displacement = (-COGlength / 2) + 1;
def dPrice = price[displacement];
def CMA = if !IsNaN(dPrice) then Average(dPrice, AbsValue(COGlength)) else
CMA[1] + (CMA[1] - CMA[2]);
plot CenteredMA = if !IsNaN(dPrice) then CMA else Double.NaN;
CenteredMA.DefineColor("CMA", GetColor(1));
CenteredMA.SetLineWeight(2);
CenteredMA.Hide();
plot CenterLine = if !IsNaN(price) then CMA else Double.NaN;
CenterLine.DefineColor("CMA", GetColor(1));
CenterLine.DefineColor("Extrapolated", GetColor(0));
CenterLine.AssignValueColor(if !IsNaN(dPrice) then CenterLine.color("CMA")
else
CenterLine.color("Extrapolated"));
CenterLine.SetLineWeight(2);
CenterLine.Hide();
CenterLine.SetStyle(Curve.SHORT_DASH);
def ExtremeBand = CMA * ExtremeValue / 100;;
def OuterBand = CMA * OuterValue / 100;
def InnerBand = CMA * InnerValue / 100;
plot UpperExtremeBand = if !IsNaN(price) then CMA + ExtremeBand else
Double.Nan;
plot LowerExtremeBand = if !IsNaN(price) then CMA - ExtremeBand else
Double.Nan;
plot UpperOuterBand = if !IsNaN(price) then CMA + OuterBand else
Double.Nan;
plot LowerOuterBand = if !IsNaN(price) then CMA - OuterBand else
Double.Nan;
plot UpperInnerBand = if !IsNaN(price) then CMA + InnerBand else
Double.Nan;
plot LowerInnerBand = if !IsNaN(price) then CMA - InnerBand else
Double.Nan;
UpperExtremeBand.SetDefaultColor(GetColor(4));
UpperExtremeBand.SetLineWeight(1);
LowerExtremeBand.SetDefaultColor(GetColor(4));
LowerExtremeBand.SetLineWeight(1);
UpperExtremeBand.hide();
LowerExtremeBand.hide();
UpperOuterBand.SetDefaultColor(GetColor(5));
UpperOuterBand.SetLineWeight(2);
LowerOuterBand.SetDefaultColor(GetColor(6));
LowerOuterBand.SetLineWeight(2);
UpperInnerBand.SetDefaultColor(GetColor(9));
UpperInnerBand.SetLineWeight(1);
UpperInnerBand.Hide();
UpperInnerBand.SetStyle(Curve.SHORT_DASH);
LowerInnerBand.SetDefaultColor(GetColor(9));
LowerInnerBand.SetLineWeight(1);
LowerInnerBand.Hide();
LowerInnerBand.SetStyle(Curve.SHORT_DASH);
# Turn AddClouds off by putting a #-sign at the first position of the lines
AddCloud(UpperOuterBand, UpperInnerBand, color.red);
AddCloud(LowerInnerBand, LowerOuterBand, color.green);
plot FlowPrice = if showClosingPriceLine then Average(price, smooth)
else double.nan;
FlowPrice.SetDefaultColor(GetColor(9));
FlowPrice.SetLineWeight(2);
hidePricePlot(!showPriceBar);