Heiken Ashi confusion price to open orders

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #155148 quote
    verygrubby
    Participant
    Master

    Hello all. I’m trying to work out a strategy using Heiken Ashi candlesticks. In the strategy I’m using the usual code to generate the open and close of the bars  (eg Heiken Ashi close =  (Open+High+Low+Close)/4. Heiken Ashi open = (xOpen[1] + xClose[1])/2.

    Now, the trades are triggering at the expected bars (ie according to Heiken Ashi), but the trade levels are as per the normal candlestick levels for that bar, NOT the Heiken Ashi levels as expected.

    eg when I run the strategy & check the trades on the chart, the trade levels only match the opening of that bar when I switch the price chart style back to “Candlestick” rather than Heiken Ashi.

    Is this a bug, or am I misunderstanding how things are supposed to work when using Heiken Ashi charts?

    Many thanks

    #155150 quote
    robertogozzi
    Moderator
    Master

    Without the code it’s impossible to help.

    If you use a pending order to enter a trade at the high of the current candle you may use HIGH or xHIGH (or haHIGH):

    Buy 1 contract at High Stop
    Buy 1 contract at XHigh Stop

    the first uses regular japanese candlesticks, while the latter uses HA candlestick.

    Post the code so we can help.

    #155156 quote
    verygrubby
    Participant
    Master
    xClose = (Open+High+Low+Close)/4
    
    if(barindex>2) then
    xOpen = (xOpen[1] + xClose[1])/2
    endif
    
    c1 = xClose>xOpen AND xClose[1]<xOpen[1]
    
    
    if c1 AND Not LongOnMarket then
    BUY 1 SHARE AT MARKET
    endif
    
    
    
    SET TARGET pPROFIT 1000
    SET STOP pLOSS 1000
     
    

    So this just buys when the Heiken Ashi candle goes from red to green, on a 15m Dow chart. eg Look at the trade it opened  at 21:45 on 4th November 2020. The long opened at 27,964… but this price is the open of the normal candlestick bar for 21:45… the Heiken Ashi 21:45 candle opened at approx 27,903…  So, the bar at which it opens the trade is fine, but how do I get it to open at the Heiken Ashi level, rather than the normal candlestick bar level?

    Would your suggested solution work if I simply put “Buy 1 contract at Xclose Stop”?

    #155159 quote
    robertogozzi
    Moderator
    Master

    Heikin-Ashi is just an indicator, not the real price, that let’s you arrange price in a different way… so when you enter/exit at market, the real price is always used.

    If you want to avoid this you need to use pending orders using HA prices as entry/exit point, such as:

    BUY 1 CONTRACT AT xHigh STOP
    #155160 quote
    verygrubby
    Participant
    Master

    Thanks for your help on Christmas Eve, by the way!

    I tried using:

    Buy 1 contract at Xopen STOP

    …but it makes no difference. Still opens the trades at the normal candlestick levels, not the Heiken Ashi levels…

    #155161 quote
    robertogozzi
    Moderator
    Master

    xOpen is a better price to BUY so you should use LIMIT instead of STOP, otherwise it will BUY at market.

    #155164 quote
    verygrubby
    Participant
    Master

    Aha… that seems to be getting better results – thanks for your help, & Merry Christmas!

    robertogozzi thanked this post
Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.

Heiken Ashi confusion price to open orders


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
verygrubby @verygrubby Participant
Summary

This topic contains 6 replies,
has 2 voices, and was last updated by verygrubby
5 years, 2 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 12/24/2020
Status: Active
Attachments: No files
Logo Logo
Loading...