Heikin Ashi Smoothed code help (Color) - futures io
futures io futures trading



Heikin Ashi Smoothed code help (Color)


Discussion in ThinkOrSwim

Updated by rmejia
    1. trending_up 7,384 views
    2. thumb_up 3 thanks given
    3. group 2 followers
    1. forum 3 replies
    2. attach_file 1 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 100,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

(If you already have an account, login at the top of the page)

 
Search this Thread
 

Heikin Ashi Smoothed code help (Color)

(login for full post details)
  #1 (permalink)
New York, New York / United States
 
Experience: Beginner
Platform: ThinkOrSwim
Trading: CL, ES, Currencies
 
Posts: 38 since Feb 2015
Thanks: 13 given, 22 received

I recently found a code for smoothed heiken ashi bars, however for some reason all the bars are red (down trend). I'm pretty sure I should be putting some if else statements at the end there. Any ideas?? Thanks!

Source 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);

Reply With Quote
The following user says Thank You to afoxperson for this post:

Can you help answer these questions
from other members on futures io?
IB Bracker Order
Platforms and Indicators
OPEN_CLOSE_DOTS
ThinkOrSwim
EQIX - Digital REITs - any experiences?
Stocks and ETFs
T​​​​​​radestation datafeed (real time and historical) to NT8
NinjaTrader
Times and Sales more data to be displayed
TradeStation
 
 
(login for full post details)
  #2 (permalink)
Puerto Rico
 
Experience: Intermediate
Platform: thinkorswim
Broker: TD Ameritrade
Trading: ES
 
rmejia's Avatar
 
Posts: 377 since Oct 2010
Thanks: 3,600 given, 432 received

The last part is an unsupported feature, it's not documented anywhere. With the last update to the platform it stopped working. The growColor is being ignored. It used to work fine before the last update, hopefully they will fix it in the future but since it is a hidden feature who knows.

AddChart(high = haHigh, low = haLow, open = o, close = haclose, type = ChartType.CANDLE, growColor = GlobalColor("RisingMA"), fallColor = GlobalColor("FallingMA"), neutralColor = color.gray);

Reply With Quote
The following user says Thank You to rmejia for this post:
 
(login for full post details)
  #3 (permalink)
New York, New York / United States
 
Experience: Beginner
Platform: ThinkOrSwim
Trading: CL, ES, Currencies
 
Posts: 38 since Feb 2015
Thanks: 13 given, 22 received



rmejia View Post
The last part is an unsupported feature, it's not documented anywhere. With the last update to the platform it stopped working. The growColor is being ignored. It used to work fine before the last update, hopefully they will fix it in the future but since it is a hidden feature who knows.

AddChart(high = haHigh, low = haLow, open = o, close = haclose, type = ChartType.CANDLE, growColor = GlobalColor("RisingMA"), fallColor = GlobalColor("FallingMA"), neutralColor = color.gray);

Thanks for the comment! I figured this out last night. Do you think there's a way around it? Pseudocode looks something like:
AssignPriceColor(
if haclose > haopen then color.GREEN,
if haopen > close then color.RED,
else then color.GREY);

I'm not quite sure if anything like this is possible but it seems plausible. I just don't know enough about thinkscript, or coding, or pretty much trading in general.

Thanks again!

Reply With Quote
 
(login for full post details)
  #4 (permalink)
Puerto Rico
 
Experience: Intermediate
Platform: thinkorswim
Broker: TD Ameritrade
Trading: ES
 
rmejia's Avatar
 
Posts: 377 since Oct 2010
Thanks: 3,600 given, 432 received

Unfortunately I don't know of anything that can be done. I use the addchart on a lower study where the candles used to be red and green but after this broke I just changed it to black. At least the candles are different by fill so there is contrast from that, tho not as clear as using 2 colors.


Reply With Quote
The following user says Thank You to rmejia for this post:


futures io Trading Community Platforms and Indicators ThinkOrSwim > Heikin Ashi Smoothed code help (Color)


February 19, 2015


Upcoming Webinars and Events
     



Copyright © 2020 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts