Heikin Ashi candlestick body and moving average condition

Viewing 15 posts - 1 through 15 (of 24 total)
  • Author
    Posts
  • #80715 quote
    Tanou
    Participant
    Senior

    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! 😀

    #80734 quote
    Nicolas
    Keymaster
    Master

    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”.

    #80753 quote
    Tanou
    Participant
    Senior

    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!!! 😀

    #80754 quote
    robertogozzi
    Moderator
    Master

    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 “@”!

    #80755 quote
    Tanou
    Participant
    Senior

    Oh! Ok! I’m sorry!

    #80766 quote
    Tanou
    Participant
    Senior

    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? 🙂

    #80769 quote
    Nicolas
    Keymaster
    Master

    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.

    #80804 quote
    Tanou
    Participant
    Senior

    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?

    #80814 quote
    Nicolas
    Keymaster
    Master

    This is not heikin ashi candlesticks. Do the moving average period the same as the one in the code?

    #80815 quote
    Tanou
    Participant
    Senior

    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?

    #80816 quote
    Tanou
    Participant
    Senior

    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…

    #80817 quote
    Tanou
    Participant
    Senior
    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?

    #80850 quote
    Tanou
    Participant
    Senior
    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

    #80868 quote
    Nicolas
    Keymaster
    Master

    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.

    #80874 quote
    Tanou
    Participant
    Senior

    Thank you so much Nicolas! I will test this evening! What do you think of such strategy?

Viewing 15 posts - 1 through 15 (of 24 total)
  • You must be logged in to reply to this topic.

Heikin Ashi candlestick body and moving average condition


ProOrder support

New Reply
Author
author-avatar
Tanou @tanou Participant
Summary

This topic contains 23 replies,
has 3 voices, and was last updated by Nicolas
7 years, 4 months ago.

Topic Details
Forum: ProOrder support
Language: English
Started: 09/17/2018
Status: Active
Attachments: 2 files
Logo Logo
Loading...