forked from bingit2/TradingView-to-ThinkorSwim
-
Notifications
You must be signed in to change notification settings - Fork 0
/
MACD_VXI
35 lines (28 loc) · 1.04 KB
/
MACD_VXI
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
# MACD_VXI
# Assembled by BenTen at useThinkScript.com
# Converted from https://www.tradingview.com/script/WMxf5UKW-MACD-VXI/
declare lower;
input source = close;
input fastLength = 13;
input slowLength = 21;
input signalLength = 8;
def fastMA = expAverage(source, fastLength);
def slowMA = expAverage(source, slowLength);
def macd = fastMA - slowMA;
def signal = simpleMovingAvg(macd, signalLength);
def hist = macd - signal;
plot diff = hist;
plot signal1 = signal;
plot signal2 = macd;
plot ZeroLine = 0;
plot UpSignal = if Diff crosses above ZeroLine then ZeroLine else Double.NaN;
plot DownSignal = if Diff crosses below ZeroLine then ZeroLine else Double.NaN;
Diff.SetDefaultColor(GetColor(9));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
signal1.setDefaultColor(getColor(0));
signal2.setDefaultColor(getColor(1));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);