I want to use the Heken Ashi indicator in my Back testing.
Please provide the Pro Real code that allows me to identify when the Heiken Ashi candles change from green to red, and from red to green.
tstephens Welcome to the forums.
Have you tried using the search box that can be found by hovering over your profile image at top right? There is a ton of Heiken Ashi code in the forums.
There you go:
// Heikin-Ashi definition
once xOpen = open
xClose = (open + close + high + low) / 4
if barindex > 0 then
xOpen = (xOpen + xClose[1]) / 2
endif
//xLow = min(low,min(xClose,xOpen))
//xHigh = max(high,max(xClose,xOpen))
//xTypic = (xHigh + xLow + xClose) / 3
//xMed = (xHigh + xLow) / 2
//xRange = xHigh - xLow
//
Bullish = xClose > xOpen
Bearish = xClose < xOpen
Red2Green = (Bullish AND Bearish[1])
Green2Red = (Bearish AND Bullish[1])
How would you add a MACD crossover to the Heiken Ashi? Robert you are a guru on here!
I appended the MACD lines:
// Heikin-Ashi definition
once xOpen = open
xClose = (open + close + high + low) / 4
if barindex > 0 then
xOpen = (xOpen + xClose[1]) / 2
endif
//xLow = min(low,min(xClose,xOpen))
//xHigh = max(high,max(xClose,xOpen))
//xTypic = (xHigh + xLow + xClose) / 3
//xMed = (xHigh + xLow) / 2
//xRange = xHigh - xLow
//
Bullish = xClose > xOpen
Bearish = xClose < xOpen
Red2Green = (Bullish AND Bearish[1])
Green2Red = (Bearish AND Bullish[1])
//
MyMACD = ExponentialAverage[12](xClose) - ExponentialAverage[26](xClose)
MySignalLine = ExponentialAverage[9](MyMACD)
MyHisto = MyMACD - MySignalLine
//
CrossOVER = MyMACD CROSSES OVER MySignalLine
CrossUNDER = MyMACD CROSSES UNDER MySignalLine