Heikin Ashi Candle Strategy


Category:
0
0

Hi Pete,

I was interested in developing a strategy that included when heikin ashi candles changed from red to green, and green to red.  I’m having trouble with that code, and I’m assuming the problem is something relating to the compounded value.  Is there anything that strikes you as wrong about this?

def haclose = (open + high + low + close) / 4;
def haopen = compoundValue(1, (haopen[1] + haclose[1]) / 2, (open[1] + close[1]) / 2);

def Yesterday_haclose = (open from 1 bar ago + high from 1 bar ago + low from 1 bar ago + close from 1 bar ago) / 4 ;
def Yesterday_haopen = compoundValue(1, (Yesterday_haopen[1] + Yesterday_haclose[1]) / 2, (open[1] + close[1]) / 2);

def buy =
Yesterday_haclose < Yesterday_haopen
and haopen < haclose;

def sell =
Yesterday_haclose > Yesterday_haopen
haopen > haclose; #This is the code that doesn’t work

AddOrder(OrderType.BUY_AUTO, buy, tickcolor = Color.GREEN, arrowcolor = Color.GREEN, name = “Buy”);
AddOrder(OrderType.SELL_AUTO, sell, tickcolor = Color.RED, arrowcolor = Color.RED, name = “Sell”);

 

 

Marked as spam
Posted by (Questions: 8, Answers: 3)
Asked on October 6, 2018 3:41 pm
296 views
0
Private answer

You left out the word “and” in your sell statement

def sell = Yesterday_haclose > Yesterday_haopen haopen > haclose;

Should be:

def sell = Yesterday_haclose > Yesterday_haopen and haopen > haclose;

Marked as spam
Posted by (Questions: 37, Answers: 4084)
Answered on October 6, 2018 4:37 pm
0

Haha, ahh, well that’s embarrassing…. Thanks for your help..!

( at October 6, 2018 5:06 pm)