Support Board
Date/Time: Fri, 27 Dec 2024 09:25:22 +0000
Post From: adx to color bars
[2022-10-24 21:20:08] |
User411320 - Posts: 291 |
I use the following indicator on tradeovate that allows me to have the candles colored based off the ADX, how can this be done here? const predef = require("./tools/predef"); const meta = require("./tools/meta"); const MMA = require("./tools/MMA"); class tikiADX { init() { const period = this.props.period; this.smoothedTR = MMA(period); this.smoothedDMP = MMA(period); this.smoothedDMM = MMA(period); this.smoothedDX = MMA(period); } map(d, i, history) { const { smoothedTR, smoothedDMP, smoothedDMM, smoothedDX, props } = this; const curH = d.high(); const curL = d.low(); if (i === 0) { return { tr: curH - curL }; } const prior = history.prior(); const priorC = prior.close(); const priorH = prior.high(); const priorL = prior.low(); const tr = Math.max(curH - curL, Math.max(Math.abs(curH - priorC), Math.abs(curL - priorC))); const hDiff = curH - priorH; const lDiff = priorL - curL; const dmP = hDiff > lDiff ? Math.max(0, hDiff) : 0; const dmM = lDiff > hDiff ? Math.max(0, lDiff) : 0; const result = { tr, dmP, dmM, sm_tr: smoothedTR(tr), sm_dmp: smoothedDMP(dmP), sm_dmm: smoothedDMM(dmM) }; if (i >= props.period) { if (result.sm_tr === 0) { result.dip = 0; result.dim = 0; result.dx = 0; } else { result.dip = (result.sm_dmp / result.sm_tr) * 100; result.dim = (result.sm_dmm / result.sm_tr) * 100; const sum = result.dip + result.dim; if (sum === 0) { result.dx = 0; } else { result.dx = (100 * Math.abs(result.dip - result.dim)) / sum; } } const adx = smoothedDX(result.dx); if (i >= (2 * props.period) - 1) { result.adx = adx; } } result.signal = this.props.signal result.candlestick = { color: result.dip > result.dim ? this.props.upColor : this.props.downColor }; return result; } filter(d) { return predef.filters.isNumber(d.adx); } } module.exports = { name: "tikiADX", description: "Tiki ADX", calculator: tikiADX, params: { signal: predef.paramSpecs.number(25, 0, 1), period: predef.paramSpecs.period(14), upColor: predef.paramSpecs.color('green'), downColor: predef.paramSpecs.color('red') }, inputType: meta.InputType.BARS, areaChoice: meta.AreaChoice.NEW, plots: { adx: { title: "ADX" }, dip: { title: "+DI" }, dim: { title: "-DI" }, signal: { title: "Signal" } }, tags: ['Tiki Tools'], schemeStyles: { dark: { signal: predef.styles.plot({ color: "white", lineStyle: 2 }), adx: predef.styles.plot({ color: 'white', lineWidth: 2 }), dip: predef.styles.plot("green"), dim: predef.styles.plot("red") }, light: { signal: predef.styles.plot({ color: "black", lineStyle: 2 }), adx: predef.styles.plot({ color: 'black', lineWidth: 2 }), dip: predef.styles.plot("green"), dim: predef.styles.plot("red") } } }; |
Screenshot 2022-10-24 171929.png / V - Attached On 2022-10-24 21:19:53 UTC - Size: 114.33 KB - 224 views Attachment Deleted. |