Is it possible to have an overlay indicator created to change the color of a candle when it forms a particular way?
I want to be able to control the color of Heikin Ashi candle when it is considered strongly directional. when price movement is strong Heikin Ashi candles only print a wick on one side of the candle, when price is more indecisive it prints wicks on both sides of the candle. When the Candle prints with one wick on one side i want to be able to control the color for quick glance clarity. Unless you are zoomed in on Heikin Ashi charts you can miss Candles with small double wicks.
Yes, you should be able to. I didn’t implement your logic, but I have other candle coloring indicator and it seems to work on a Heikin Ashi chart. Here is a snippet you can use modify at the end of your map() function:
// return a blank object as default
let rtn = {};
// put your conditions for coloring
if (!d.isLast() && (buy || sell)) {
// if conditions are met, set you color
const color = buy ? this.props.BuyColor : this.props.SellColor;
// this is where the coloring of the candlestick actually happens
rtn["candlestick"] = { color: color };
}
return rtn;
Hi.
I was looking to do something similar to what you outlined here. I was trying to change the color of a Heikin Ashi candle when I have MA lines go through it during the same period ( ex: 2min or 5 min candle). Can you give a suggestion?
You would obviously need to copy or create an indicator that calculates the MA. Then in the map() function and using the previous code snippet as a model, you would just have to check for the conditions you care about. Here is an incomplete example:
// TODO: Calculate the mavg here. See the moving average indicators
let rtn = {};
let candleColor = undefined;
if (d.open() < d.close() && mavg > d.open() && mavg < d.close()) {
// mavg is between the body of a bullish candle
candleColor = "dodgerBlue";
} else if (d.open() > d.close() && mavg < d.open() && mavg > d.close()) {
// mavg is between the body of a bearish candle
candleColor = "pink";
} else if (mavg > d.low() && mavg < d.high()) {
// mavg is between the high and lows of the candle
candleColor = "gray";
}
// Remove the !d.isLast() if you want to also change the color on the current bar
if (!d.isLast() && candleColor) {
rtn["candlestick"] = { color: candleColor };
}
return rtn;
I have a few MAs, (3 SMA & 1 WMA). Is the below code that I added sufficient to account for all the MAs so that it can turn the candle a different color when all of them intersect the same candle time frame.
When completed, do I just add this as a expression in worksheets?
Thanks for taking the time to assist
// TODO: Calculate the mavg here. See the moving average indicators
class simpleMovingAverage {
init() {
this.sma = SMA(this.props.period);
}
map(d) {
return this.sma(d.value());
}
}
let rtn = {};
let candleColor = undefined;
if (d. open () < d.close() && mavg > d. open () && mavg < d.close()) {
// mavg is between the body of a bullish candle
candleColor = “dodgerBlue”;
} elseif (d. open () > d.close() && mavg < d. open () && mavg > d.close()) {
// mavg is between the body of a bearish candle
candleColor = “pink”;
} elseif (mavg > d.low() && mavg < d.high()) {
// mavg is between the high and lows of the candle
candleColor = “gray”;
}
// Remove the !d.isLast() if you want to also change the color on the current bar
can I ask what software you use to create and export tools into Code Explorer? I wanted to add a wma.js to a indicators tools but it won’t allow me so it looks like I have to try and create a new indicator.
You can create a new file in Code Explorer and name it wma.js or whatever you like. Then copy the code from from the file you have into that new file in Code Explorer. Just first delete all the default code that Code Explorer puts there.
Then you can just reference that file by using a require statement in your indicator.
First thanks for your help…
Is it hard to either have a Candle change color or add a arrow or dot above the the candle if multiple moving averages intersect the same time frame candle (2 min chart 3 sma lines go through the same candle during the 11:11am time frame)?
I needed to add another moving average line to a indicator but this is what I’m trying to accomplish.
Thanks