Login Page - Create Account

Support Board


Date/Time: Thu, 26 Dec 2024 18:24:34 +0000



adx to color bars

View Count: 999

[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")
}
}
};
imageScreenshot 2022-10-24 171929.png / V - Attached On 2022-10-24 21:19:53 UTC - Size: 114.33 KB - 223 views
Attachment Deleted.
[2022-10-25 14:36:02]
John - SC Support - Posts: 36867
You would want to use the Color Bar Based on Alert Condition study:
Color Bar Based on Alert Condition
For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing
[2022-10-25 14:38:47]
User411320 - Posts: 291
would i combine it with another study?
[2022-10-25 16:19:22]
John - SC Support - Posts: 36867
You would also need the ADX study, of course. Refer to the following:
ADX

Not sure what else you may be looking for.
For the most reliable, advanced, and zero cost futures order routing, use the Teton service:
Sierra Chart Teton Futures Order Routing

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account