Heikin-Ashi coding

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #19177 quote
    BCBC
    Participant
    Master

    Hi

    Anyone can help on below coding about Heikin-Ashi candle?

    Long: two consecutive green candles, after a series of red candles.

    Short: two red consecutive candles after a series of green candles.

    xClose = (Open+High+Low+Close)/4
    if(barindex>2) then
    xOpen = (xOpen[1] + xClose[1])/2
    endif
    green= xClose>xOpen AND xClose[1]<xOpen[1]
    red= xClose<xOpen AND xClose[1]>xOpen[1]

    Thanks.

    #19209 quote
    NicolasNicolas
    Keymaster
    Legend

    Based on the code you provided about finding bullish and bearish heikin ashi candlesticks, the code of the strategy would be as follows:

    xClose = (Open+High+Low+Close)/4
    if(barindex>2) then
    xOpen = (xOpen[1] + xClose[1])/2
    endif
    green= xClose>xOpen AND xClose[1]<xOpen[1]
    red= xClose<xOpen AND xClose[1]>xOpen[1]
    
    long = green=1 and green[1]=1 and green[2]=0
    short = red=1 and red[1]=1 and red[2]=0
    
    if long then 
     buy 1 share at market 
    endif 
    
    if short then 
     sell 1 share at market 
    endif 

    Here, I do not test a “series of red candles” or a “series of green candles” but only 1, you’ll have to define what you consider as a “series”.

Viewing 2 posts - 1 through 2 (of 2 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

Heikin-Ashi coding


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
BC @robin_chan Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by NicolasNicolas
9 years, 9 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 12/27/2016
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...