close position on heiken-ashi chart

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #161168 quote
    kevin12345
    Participant
    Average

    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

    #161170 quote
    robertogozzi
    Moderator
    Master

    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)
    #161171 quote
    Monochrome
    Participant
    Senior

    Your code is a normal close and open, not a hieken ashi close.

    Search the forum for the hieken ashi code

    #161172 quote
    Vonasi
    Moderator
    Master

    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.
    Insert-PRT-Code-Button-1.png Insert-PRT-Code-Button-1.png
    #161179 quote
    GraHal
    Participant
    Master

    Link to Roberto Code above added as Log 272 here …

    Snippet Link Library

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

close position on heiken-ashi chart


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
kevin12345 @kevin12345 Participant
Summary

This topic contains 4 replies,
has 5 voices, and was last updated by GraHal
5 years ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 02/12/2021
Status: Active
Attachments: 1 files
Logo Logo
Loading...