Hello Everyone!
I hope you are well! Once more I’d like to thanks all the participants that makes this website so useful…!
I am currently blocked, I’d like to make a condition that allows me to sell, for example, if the previous Heinkin Ashi candle was under the moving average 30
Does someone knows or has a clue? I can’t find the solution… @Nicolas?
Thanks! 😀
There are so many Heikin Ashi codes around that I think you haven’t search enough 🙂
Anyway, here is an example about looking for an heikin ashi candlestick below a moving average:
xClose = (Open+High+Low+Close)/4
test = xClose crosses under average[30]
Close of an Heikin Ashi candle is the same as “totalprice”.
Thank you @Nicolas!
Yes, I’ve seen some but none of them suits what I’m looking for.
In fact, I don’t understand why but when I implement such a strategy it does not take all the possible entries but only some of them and I don’t understand why
xClose = (Open+Close)/2
xCloseb = (Open[1]+Close[1])/2
test = open crossover average[30]
IF test AND xClose>xCloseb THEN
BUY 1 CONTRACT AT MARKET
ENDIF
Do you have an idea regarding this?
THANKS!!! 😀
Everytime you add a leading “@” to a nickname that user receives an email + he receives a further, duplicate, email because he subscribed (just answering) to a topic. So, please don’t abuse “@”!
For example, with the picture enclosed we can see that a green Heikin Ashi candle 1 crosses the blue line (MM30) and the following candle (2) is bigger than the previous one (slightly).
I’d like to write a code that allows me to buy on such conditions but I can’t manage why…
Can you help? 🙂
Try this: (not tested)
DEFPARAM CumulateOrders = false
//Heikin-Ashi
xClose = (Open+High+Low+Close)/4
if(barindex>2) then
xOpen = (xOpen[1] + xClose[1])/2
endif
Green = xClose>xOpen
harange = abs(xclose-xopen)
macross = xclose crosses over average[30]
if green[1] and macross[1] and green and harange>harange[1] then
buy at market
endif
For a better and complete understanding of how to use variables and their past values, I suggest to watch the ProRealTime programming training videos.
Thank you so much Nicolas, this is a great start but it still makes me strange entry… Do you have a clue with the enclosed picture?
This is not heikin ashi candlesticks. Do the moving average period the same as the one in the code?
It wasn’t Heikin Ashi but the moving average 30 but the HULL one and not the simple one. Is there a way to implement the hull?
I think that the problem is that I want to implement the hull one and I have no idea how to implement it within the code…
DEFPARAM CumulateOrders = false
//Heikin-Ashi
Period=30
inner = 2*weightedaverage[ round( Period/2 ) ](close)-weightedaverage[Period](close)
MMHULL=weightedaverage[ round( sqrt(Period) ) ]( inner )
xClose = (Open+High+Low+Close)/4
if(barindex>2) then
xOpen = (xOpen[1] + xClose[1])/2
endif
Green = xClose>xOpen
harange = abs(xclose-xopen)
macross = xclose crosses over MMHULL
if green[1] and macross[1] and green and harange>harange[1] then
buy at market
endif
Something like this would work?
DEFPARAM CumulateOrders = false
//Heikin-Ashi
Period=30
inner = 2*weightedaverage[ round( Period/2 ) ](close)-weightedaverage[Period](close)
MMHULL=weightedaverage[ round( sqrt(Period) ) ]( inner )
xClose = (Open+Close)/2
if(barindex>2) then
xOpen = (xOpen[1] + xClose[1])/2
endif
Green = xClose>xOpen
harange = abs(xclose-xopen)
macross = xclose crosses over MMHULL
if green[1] and macross[1] and green and harange>harange[1] then
buy at market
endif
I slightly modified it. What do you think about it? Is it the right way to implement the Hull 30?
Thanks
Yes but in this case you are calculating the Hull moving average on the real Close, not with the Heikin Ashi candlestick one.
Here is the modified code:
DEFPARAM CumulateOrders = false
//Heikin-Ashi
xClose = (Open+High+Low+Close)/4
if(barindex>2) then
xOpen = (xOpen[1] + xClose[1])/2
endif
Green = xClose>xOpen
harange = abs(xclose-xopen)
Period=30
inner = 2*weightedaverage[ round( Period/2 ) ](xclose)-weightedaverage[Period](xclose)
MMHULL=weightedaverage[ round( sqrt(Period) ) ]( inner )
macross = xclose crosses over MMHULL
if green[1] and macross[1] and green and harange>harange[1] then
buy at market
endif
set target pprofit 50
set stop ploss 25
Everything working as intended as per my tests.
Thank you so much Nicolas! I will test this evening! What do you think of such strategy?