This quick study allows you to alter the color of your candles (or bars) based upon the candle's position vs. the Exponential Moving Average you select. See the screenshot example, which uses the 50 EMA. This study should work for all chart types.
To add it to a chart, select and copy the script below. Then on a thinkorswim chart, right click on a chart, choose Studies then Edit Studies. Then in the lower left hand corner, choose New Study. Give the study a name, like My_EMA_Paintbars then paste the code below into the main window. Then click ok. The study should be on your chart now.
# Simple ema price bar painting
# Change the following options as you want
input length = 20;
input price = close;
input displace = 0;
plot ema = ExpAverage(close, length);
plot signal = if(IsNaN(ema), 0, if(close < ema, -1, if(close > ema, 1, 0)));
AssignPriceColor(if signal == 1 then color.dark_GREEN else if signal == -1 then color.red else color.gray);
Posted via email from danrobbins’s posterous
How to Change Candle/Bar Colors on Thinkorswim Charts for Moving Averages
This quick study allows you to alter the color of your candles (or bars) based upon the candle's position vs. the Exponential Moving Average you select. See the screenshot example, which uses the 50 EMA. This study should work for all chart types.
Posted via email from danrobbins’s posterous