BCParticipant
Master
Hi
Anyone can help on below coding about Heikin-Ashi candle?
Long: two consecutive green candles, after a series of red candles.
Short: two red consecutive candles after a series of green candles.
xClose = (Open+High+Low+Close)/4
if(barindex>2) then
xOpen = (xOpen[1] + xClose[1])/2
endif
green= xClose>xOpen AND xClose[1]<xOpen[1]
red= xClose<xOpen AND xClose[1]>xOpen[1]
Thanks.
Based on the code you provided about finding bullish and bearish heikin ashi candlesticks, the code of the strategy would be as follows:
xClose = (Open+High+Low+Close)/4
if(barindex>2) then
xOpen = (xOpen[1] + xClose[1])/2
endif
green= xClose>xOpen AND xClose[1]<xOpen[1]
red= xClose<xOpen AND xClose[1]>xOpen[1]
long = green=1 and green[1]=1 and green[2]=0
short = red=1 and red[1]=1 and red[2]=0
if long then
buy 1 share at market
endif
if short then
sell 1 share at market
endif
Here, I do not test a “series of red candles” or a “series of green candles” but only 1, you’ll have to define what you consider as a “series”.