hi,
can anybody help me with coding for a closing trade?
if i am going long and i want to close a trade when a red/bear candle showing on the heiken-ashi chart.
my codes right now
bearcandle = (close <= open)
if longonmarket and bearcandle then
sell at market
endif
right now its been buying and selling on every candle.
please help
thank you
That’s a regular Japanese candlestick.
Heikin-Ashi candlesticks are an indicator by themselves and need to be coded, their seup is:
once xOpen = open //initial OPEN
xClose = (open + close + high + low) / 4 //CLOSE
if barindex > 0 then
xOpen = (xOpen + xClose[1]) / 2 //OPEN after the first bar
endif
xLow = min(low,min(xClose,xOpen)) //LOW
xHigh = max(high,max(xClose,xOpen)) //HIGH
xTypic = (xHigh + xLow + xClose) / 3 //Typical HA price
xMed = (xHigh + xLow) / 2 //Median HA price
xRange = xHigh - xLow //HA range
you can comment out all definitions you don’t plan to used.
To check if a HA candlestick is bearish then you have to use:
bearcandle = (xClose <= xOpen)
Your code is a normal close and open, not a hieken ashi close.
Search the forum for the hieken ashi code
kevin12345 – Welcome to the forums. Please read the forum rules before posting any further topics. Your post has been edited.
- Always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read.
Link to Roberto Code above added as Log 272 here …
Snippet Link Library