-
Notifications
You must be signed in to change notification settings - Fork 2
/
strategies.js
96 lines (95 loc) · 2.83 KB
/
strategies.js
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
92
93
94
95
96
const strategies = {
/*
example: {
baseSymbols: ['BTC', 'USDT'],
configIndicators: {
fast: {
identifier: 'sma',
options: {
period: 50
}
},
slow: {
identifier: 'sma',
options: {
period: 200
}
}
},
limit: 200, // amount of candles required for this strategy to work
skipPairs: ['BTCUSDT'],
timeframes: ['4h', '1d'],
trigger: chart => {
const lastCandle = chart[chart.length - 1] // live candle, use chart[chart.length - 2] for last closed candle
return lastCandle.indicators.fast.sma < lastCandle.indicators.slow.sma && lastCandle.top >= lastCandle.indicators.fast.sma
}
},
*/
bands: {
// Triggers when price touched lower Bollinger band
baseSymbols: ['USDT'],
configIndicators: {
bb: {
identifier: 'bbands',
options: {
period: 20,
stddev: 2
}
}
},
limit: 20,
timeframes: ['4h'],
trigger: chart => chart[chart.length - 1].low <= chart[chart.length - 1].indicators.bb.bbands_lower || chart[chart.length - 2].low <= chart[chart.length - 2].indicators.bb.bbands_lower
},
taz: {
// https://www.swing-trade-stocks.com/traders-action-zone.html
baseSymbols: ['BTC'],
configIndicators: {
fast: {
identifier: 'ema',
options: {
period: 30
}
},
slow: {
identifier: 'sma',
options: {
period: 10
}
}
},
limit: 30,
timeframes: ['4h'],
trigger: chart => chart[chart.length - 2].low > chart[chart.length - 2].indicators.fast.ema && chart[chart.length - 2].low < chart[chart.length - 2].indicators.slow.sma
},
vsa: {
// VSA's stopping volume
baseSymbols: ['BTC', 'USDT'],
configIndicators: {
range: {
identifier: 'atr',
options: {
period: 1
}
}
},
limit: 20,
timeframes: ['4h', '1d'],
trigger: chart => {
const candle = chart[chart.length - 2] // last closed candle
// check if candle is a local low (12 candles)
if (candle.low === Math.min(...chart.slice(chart.length - 13, chart.length - 1).map(candle => candle.low))) {
// check if volume is larger than previous 5 candles
if (candle.volume === Math.max(...chart.slice(chart.length - 6, chart.length - 1).map(candle => candle.volume))) {
// check if range is larger than previous 3 candles
if (candle.indicators.range.atr === Math.max(...chart.slice(chart.length - 4, chart.length - 1).map(candle => candle.indicators.range.atr))) {
// check if price is rejected (close above 60% of candle's range)
return (candle.close - candle.low) / (candle.high - candle.low) >= 0.6
}
}
}
return false
}
}
}
export default strategies