Heikin Ashi Auto buy/sell based on collor change

Viewing 15 posts - 1 through 15 (of 23 total)
  • Author
    Posts
  • #110265 quote
    classick
    Participant
    Junior

    Hi.

    Does anybody know the code for automated system based only on Heikin ashi changing collors buy and sell.

    I want to automate my heikin ashi strategi.

    It might have allready been discussed here on the forums, but i cant seem to find it.

    Thank you

    #110278 quote
    robertogozzi
    Moderator
    Master

    There you go:

    // Heikin Ashi setup
    once xOpen = open
    xClose     = (open + close + high + low) / 4
    if barindex > 0 then
        xOpen  = (xOpen + xClose[1]) / 2
    endif
    xLow       = min(low,min(xClose,xOpen))
    xHigh      = max(high,max(xClose,xOpen))
    //
    Bullish = xClose > xOpen
    Bearish = xClose < xOpen
    // LONG  trades when switching from bearish to bullish
    IF Bullish AND Bearish[1] THEN
       BUY 1 CONTRACT AT MARKET
    ENDIF
    // SHORT trades when switching from bullish to bearish
    IF Bearish AND Bullish[1] THEN
       SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    classick thanked this post
    #110281 quote
    classick
    Participant
    Junior

    Thank you alot robertogozzi.

    Is it possible to create this code from prorealtime simplified creation?

    #110285 quote
    robertogozzi
    Moderator
    Master

    No, it’s not possible. The set up for  the Heikin Ashi candlesticks cannot be dealt with automatically.

    #110286 quote
    classick
    Participant
    Junior

    No, it’s not possible. The set up for the Heikin Ashi candlesticks cannot be dealt with automatically.

    Ok thanks.   I still cant get my head arround that code you shared.  i tried to prompt it in as whole and promt it in as bullish by deleting som of the code, but still it does not work.

    I would be very gratefull if you can do one separate bullish. with conditions when heikin is positiv go long 1 contract next bar open and exit that contract on heiking going negative, exit next bar open.

     

    and then do the same one separate to bearish if you know what i mean.

    Thank you alot mr.

    #110288 quote
    robertogozzi
    Moderator
    Master

    The last line (line 19) was to be read ENDIF.

    Bullish version:

    // Heikin Ashi setup
    once xOpen = open
    xClose     = (open + close + high + low) / 4
    if barindex > 0 then
        xOpen  = (xOpen + xClose[1]) / 2
    endif
    xLow       = min(low,min(xClose,xOpen))
    xHigh      = max(high,max(xClose,xOpen))
    //
    Bullish = xClose > xOpen
    Bearish = xClose < xOpen
    // LONG  trades when switching from bearish to bullish
    IF Bullish AND Bearish[1] THEN
       BUY 1 CONTRACT AT MARKET
    ENDIF
    // exit LONG trade on a Bearish candlestick
    IF Bearish AND LongOnMarket THEN
       SELL AT MARKET
    ENDIF

    Bearish version:

    // Heikin Ashi setup
    once xOpen = open
    xClose     = (open + close + high + low) / 4
    if barindex > 0 then
        xOpen  = (xOpen + xClose[1]) / 2
    endif
    xLow       = min(low,min(xClose,xOpen))
    xHigh      = max(high,max(xClose,xOpen))
    //
    Bullish = xClose > xOpen
    Bearish = xClose < xOpen
    // SHORT trades when switching from bullish to bearish
    IF Bearish AND Bullish[1] THEN
       SELLSHORT 1 CONTRACT AT MARKET
    ENDIF
    // exit SHORT trade on a Bullish candlestick
    IF Bullish AND ShortOnMarket THEN
       EXITSHORT AT MARKET
    ENDIF
    cfta thanked this post
    #110289 quote
    Vonasi
    Moderator
    Master

    classick – Welcome to the forums. 🙂

    You have posted the same reply three times. I have deleted two of the posts. Please try not to post the same thing multiple times!

    Also it is not necessary to quote the person that you are replying to in every reply – especially when only two people are discussing a subject! Please only quote if you want to highlight a certain bit of text or if you need to make it clear who you are replying to.

    robertogozzi thanked this post
    #110291 quote
    classick
    Participant
    Junior

    It still says code is invalid when i prompt in one of those above.

    So confused :/

    #110293 quote
    Vonasi
    Moderator
    Master

    classick – please stop quoting Roberto’s replies – especially if they include code! I have edited your last reply to remove the unnecessary quote.

    #110294 quote
    robertogozzi
    Moderator
    Master

    Compare your code and mine to spot differences.

    #110295 quote
    classick
    Participant
    Junior

    yeah sorry, my last qoute to roberto was before i saw your first warning:)

    #110296 quote
    Vonasi
    Moderator
    Master

    Not a warning! Just a friendly suggestion to keep the forums a little bit tidier! 🙂

    #110297 quote
    classick
    Participant
    Junior

    thank you Robertogozzi for helping me out

    i compared the codes and they are identical.

    I just ctrl+c   and then paste on to my prorealtime.  Then go thrue visually on any spaces that differ. everything looks fine. but still not valid.

    i must be doing something wrong.  Damn i need those learning courses in coding

    #110298 quote
    robertogozzi
    Moderator
    Master

    Please post the error message you have been reported.

    #110299 quote
    classick
    Participant
    Junior

    This is how it looks when i copy paste.   I even tried to modify that third  = sign     so it does not ofshoot to the right as much.

    heikin-ashi-bull.png heikin-ashi-bull.png
Viewing 15 posts - 1 through 15 (of 23 total)
  • You must be logged in to reply to this topic.

Heikin Ashi Auto buy/sell based on collor change


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
classick @classick Participant
Summary

This topic contains 22 replies,
has 4 voices, and was last updated by robertogozzi
6 years, 4 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 10/15/2019
Status: Active
Attachments: 2 files
Logo Logo
Loading...