const predef = require('./tools/predef')
class tikiScalper {
init() {
this.isBuy = true
}
map(d, i, history) {
if (i < 5) {
return
}
const close = d.close()
const priorClose = history.get(i - 1).close()
const priorPriorClose = history.get(i - 2).close()
const priorPriorPriorClose = history.get(i - 3).close()
const isBuy = priorClose < close &&
(priorPriorClose < priorClose ||
priorPriorPriorClose < priorClose)
const isSell = priorClose > close &&
(priorPriorClose > priorClose ||
priorPriorPriorClose > priorClose)
if (isBuy) {
this.isBuy = true
} else if (isSell) {
this.isBuy = false
}
const {
upColor,
downColor
} = this.props
const color = this.isBuy ? upColor: downColor
return {
candlestick: {
color
}
}
}
}
module.exports = {
name: 'tikiScalper',
description: 'Tiki Scalper',
calculator: tikiScalper,
params: {
upColor: predef.paramSpecs.color('lime'),
downColor: predef.paramSpecs.color('red'),
},
tags: ['Tiki Tools']
}