close position on heiken-ashi chart

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #161168 quote
    kevin12345kevin12345
    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
    robertogozzirobertogozzi
    Moderator
    Legend

    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
    MonochromeMonochrome
    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
    VonasiVonasi
    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
    GraHalGraHal
    Participant
    Legend

    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.
ProRealAI ProRealAI New

Stuck on this ProBuilder code?

Describe what this topic is trying to build, in plain English, and ProRealAI writes the ProRealTime™ indicator, screener or system for you.

Available in 7 languages
Try ProRealAI

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 GraHalGraHal
5 years, 8 months ago.

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