technicallydreaming
Member
@$fusionboy16 Even so, I am able to change the color overall ,but still can't have different colors between rising / falling candles
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
# Heikin Ashi Smoothed
# HoboTheClown / blt
# 9.15.2016
# HoboTheClown: I recently found a code for smoothed heiken ashi bars,
# however for some reason all the bars are displayed as one color (going up or down).
#
# blt: Modified the code and replaced the addchart code at the bottom,
# you should now see proper coloring. This is how that was coded to plot
# as an overlay to the chart candlesticks. That is two sets of candles,
# with different coloring for each. If you have the heikin ashi candle
# coloring code on your chart, then they will likely appear the same color.
#Update that "fixes" the green candles.
#JTP
#02/7/2021
input period = 20;
input hideCandles = Yes; #Now functional - JTP
input candleSmoothing = {default Valcu, Vervoort};
DefineGlobalColor("RisingMA", color.green);
DefineGlobalColor("FallingMA", color.red);
input movingAverageType = {Simple, default Exponential, Weighted, Hull, Variable, TEMA};
def openMA;
def closeMA;
def highMA;
def lowMA;
switch (movingAverageType) {
case Simple:
openMA = compoundValue(1, Average(open, period), open);
closeMA = compoundValue(1, Average(close, period), close);
highMA = compoundValue(1, Average(high, period), high);
lowMA = compoundValue(1, Average(low, period), low);
case Exponential:
openMA = compoundValue(1, ExpAverage(open, period), open);
closeMA = compoundValue(1, ExpAverage(close, period), close);
highMA = compoundValue(1, ExpAverage(high, period), high);
lowMA = compoundValue(1, ExpAverage(low, period), low);
case Weighted:
openMA = compoundValue(1, WMA(open, period), open);
closeMA = compoundValue(1, WMA(close, period), close);
highMA = compoundValue(1, WMA(high, period), high);
lowMA = compoundValue(1, WMA(low, period), low);
Case Hull:
openMA = compoundValue(1, HullMovingAvg(open, period), open);
closeMA = compoundValue(1, HullMovingAvg(close, period), close);
highMA = compoundValue(1, HullMovingAvg(high, period), high);
lowMA = compoundValue(1, HullMovingAvg(low, period), low);
case variable:
openMA = compoundValue(1, VariableMA(open, period), open);
closeMA = compoundValue(1, VariableMA(close, period), close);
highMA = compoundValue(1, VariableMA(high, period), high);
lowMA = compoundValue(1, VariableMA(low, period), low);
case TEMA:
openMA = compoundValue(1, TEMA(open, period), open);
closeMA = compoundValue(1, TEMA(close, period), close);
highMA = compoundValue(1, TEMA(high, period), high);
lowMA = compoundValue(1, TEMA(low, period), low);
}
hidePricePlot(hideCandles);
def haOpen;
def haClose;
switch(candleSmoothing) {
case Valcu:
haOpen = CompoundValue(1, ( (haOpen[1] + (openMA[1] + highMA[1] + lowMA[1] + closeMA[1]) /4.0)/2.0), open);
haClose = ((OpenMA + HighMA + LowMA + CloseMA)/4.0) ;
case Vervoort:
haOpen = CompoundValue(1, ( (haOpen[1] + (openMA[1] + highMA[1] + lowMA[1] + closeMA[1]) /4.0)/2.0), open);
haClose = ((((OpenMA + HighMA + LowMA + CloseMA)/4.0) + haOpen + Max(HighMA, haOpen) + Min(LowMA, haOpen))/4.0);
}
plot o = haOpen + 0;
o.hide();
### Wicks and Shadows
def haLow = min(lowMA, haOpen);
def haHigh = max(highMA,haOpen);
### NO LONGER SUPPORTED BY TOS
###
### AddChart(high = haHigh, low = haLow, open = o, close = haclose, type = ChartType.CANDLE, growColor = GlobalColor("RisingMA"), fallColor = GlobalColor("FallingMA"), neutralColor = color.gray);
#Red Candlesticks -----------------------------------------------------------------|
input charttype = ChartType.CANDLE;
def haOpen_fall = if haOpen>haClose
then haOpen
else double.nan;
def haHigh_fall = if haOpen>=haClose
then haHigh
else double.nan;
def haLow_fall = if haOpen>=haClose
then haLow
else double.nan;
def haClose_fall = if haOpen>=haClose
then haClose
else double.nan;
AddChart(growColor = Color.red, fallColor = Color.green, neutralColor = Color.current, high = haHigh_fall, low = haLow_fall, open = haOpen_fall, close = haClose_fall , type = ChartType.CANDLE);
#Green Candlesticks -----------------------------------------------------------------|
#Removed and/or replaced - JTP
#def HAclose1 = if haOpen<=haClose
# then hahigh
# else double.nan;
#def HAclose1 = ohlc4 -1;
#def HAopen1 = if haopen<=haclose
# then haclose
# then CompoundValue(1, (HAopen[1] + HAclose[1]) /2, (open[1] + close[1]) / 2)
# else double.nan;
def haOpen_rise = if haOpen<haClose
then haClose
else double.nan;
def haHigh_rise = if haOpen<=haClose
then haHigh
else double.nan;
def haLow_rise = if haOpen<=haClose
then haLow
else double.nan;
def haClose_rise = if haOpen<=haClose
then haOpen
else double.nan;
AddChart(growColor = Color.green, fallColor = Color.red, neutralColor = Color.current, high = haHigh_rise, low = haLow_rise, open = haOpen_rise, close = HAclose_rise, type = ChartType.CANDLE);
# End Study
##############################################################################
I worked it out -
How to code Sound Bell if Bullish or Bearish Change - Please see screenshot and code below
Thank you for your help
Can someone please help to plot the price Bars on the Heikin ashi? price line can be added, I wanted to see the price daily bars on the Heikin ashi. ThanksWondering if anyone has or has come across the smoothed Heiken Ashi code for TOS. I found the below but the constant problem I have seen is that it will not color the down candles to red. It all remains green. Anyone have any insight? I cannot remember where I came across the original code. Thanks
Rich (BB code):input period = 6; input hideCandles = YES; input candleSmoothing = {default Valcu, Vervoort}; DefineGlobalColor("RisingMA", color.green); DefineGlobalColor("FallingMA", color.red); input movingAverageType = {default Simple, Exponential, Weighted, Hull, Variable, TEMA}; def openMA; def closeMA; def highMA; def lowMA; switch (movingAverageType) { case Simple: openMA = compoundValue(1, Average(open, period), open); closeMA = compoundValue(1, Average(close, period), close); highMA = compoundValue(1, Average(high, period), high); lowMA = compoundValue(1, Average(low, period), low); case Exponential: openMA = compoundValue(1, ExpAverage(open, period), open); closeMA = compoundValue(1, ExpAverage(close, period), close); highMA = compoundValue(1, ExpAverage(high, period), high); lowMA = compoundValue(1, ExpAverage(low, period), low); case Weighted: openMA = compoundValue(1, WMA(open, period), open); closeMA = compoundValue(1, WMA(close, period), close); highMA = compoundValue(1, WMA(high, period), high); lowMA = compoundValue(1, WMA(low, period), low); Case Hull: openMA = compoundValue(1, HullMovingAvg(open, period), open); closeMA = compoundValue(1, HullMovingAvg(close, period), close); highMA = compoundValue(1, HullMovingAvg(high, period), high); lowMA = compoundValue(1, HullMovingAvg(low, period), low); case variable: openMA = compoundValue(1, VariableMA(open, period), open); closeMA = compoundValue(1, VariableMA(close, period), close); highMA = compoundValue(1, VariableMA(high, period), high); lowMA = compoundValue(1, VariableMA(low, period), low); case TEMA: openMA = compoundValue(1, TEMA(open, period), open); closeMA = compoundValue(1, TEMA(close, period), close); highMA = compoundValue(1, TEMA(high, period), high); lowMA = compoundValue(1, TEMA(low, period), low); } hidePricePlot(hideCandles); def haOpen; def haClose; switch(candleSmoothing) { case Valcu: haOpen = CompoundValue(1, ( (haOpen[1] + (openMA[1] + highMA[1] + lowMA[1] + closeMA[1]) /4.0)/2.0), open); haClose = ((OpenMA + HighMA + LowMA + CloseMA)/4.0) ; case Vervoort: haOpen = CompoundValue(1, ( (haOpen[1] + (openMA[1] + highMA[1] + lowMA[1] + closeMA[1]) /4.0)/2.0), open); haClose = ((((OpenMA + HighMA + LowMA + CloseMA)/4.0) + haOpen + Max(HighMA, haOpen) + Min(LowMA, haOpen))/4.0); } plot o = haopen; o.hide(); def haLow = min(lowMA, haOpen); def haHigh = max(highMA,haOpen); AddChart(high = haHigh, low = haLow, open = o, close = haclose, type = ChartType.CANDLE, growColor = GlobalColor("RisingMA"), fallColor = GlobalColor("FallingMA"), neutralColor = color.gray);
Thanks for your help.From a chart in ThinkorSwim: Settings > Appearance > Chart type: select "Heikin Ashi."
I don't like the way it paints the candles.
I just add the smoothed line by using the study: HeikinAshiSmoothed
I turn the plot (and off the bubble.) That shows the smoothed line without painting the candles.
Thanks for your help!Last contribution... https://tos.mx/vTZFLND
you must adjust this, play with it... add the candlesticks....somehow...
How did you get this arrows ? I am using the code from post #44 and I don't see them
How to code Sound Bell if Bullish or Bearish Change - Please see screenshot and code below
Thank you for your help
for some reason it didnt show on my chart, any ideas?
I moved your questions to this thread. Read through it. It provides a better understanding of the complexities of using this indicator on your charts.It might have to do with chart settings, I imported it as a study and a strategy, and it hid everything else on my chart, but when I changed the setting for "Show Smoothed Candles Only" to no, my chart data was no longer hidden but still couldn't see the Heiken Ashi study. tried a few different changes with settings but no dice. Guess we'll wait
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
P | Heikin-Ashi Candles Lower Chart For ThinkorSwim (assorted versions) | Indicators | 27 | |
V | Heikin Ashi For ThinkOrSwim | Indicators | 19 | |
C | RSI-Heiken Ashi For ThinkOrSwim | Indicators | 24 | |
MA Colored Heiken Ashi Trend with PaintBars for ThinkorSwim | Indicators | 17 | ||
Heiken-Ashi Moving Average (HAMA) for ThinkorSwim | Indicators | 45 |
Start a new thread and receive assistance from our community.
useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.
We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.
If you are new, or just looking for guidance, here are some helpful links to get you started.