Heiken Ashi Long/Short

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #68888 quote
    TRezin
    Participant
    Junior

    Hello,

    How can I write a code for buying Heiken ashi candles when close green. Also the code to short when close red?

    Or where can I find this info.

    Thanks

    Tony

    #68890 quote
    TRezin
    Participant
    Junior

    Can someone tell me how to code to buy long when Heiken ashi close green only. I know how to set my sell code and indicators. I just dont know the code for buy using Heiken ashi.

     

    Thanks

    Tony

    #68920 quote
    Inertia
    Participant
    Master

    TRezin,

    Kindly try first the search engine of this site. It is quite an efficient tool were you’ll find everthing you need..

    A simple Heiken Ashi Trading Strategy

    Thank you.

    robertogozzi thanked this post
    #69100 quote
    TRezin
    Participant
    Junior

    Thanks for the help.

    #69104 quote
    TRezin
    Participant
    Junior

    Hello Inertia,

    Sorry but the code you provide dose not quite enter on the green and red. Could you help me again and adjust the code as follows:

    Buy on close of Green Hieken Ashi candle

    Sell when the Red Hieken Ashi candle closes below the 13EMA

    I dont want a short position.

    Thanks

    Tony

    #69112 quote
    Inertia
    Participant
    Master

    Hi TRezin,

    I just helped you out on how to search on this great forum.

    Kindly note that  I am not a coder but I have done the following according to your request.

    To be verified 😉

    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
     
    indicator1 = ExponentialAverage[13](close)
    c2 = (close CROSSES UNDER indicator1)
    
    IF c2 THEN
    SELL AT MARKET
    ENDIF
    #69163 quote
    TRezin
    Participant
    Junior

    Hello,

    Thanks for your help again.

    I have added some codes to your system that are proven to show good back testing now.

    I have attached for you.

    Thanks

    Tony

    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
     
    indicator1 = ExponentialAverage[20](close)
    c2 = (close CROSSES UNDER indicator1)
    indicator2 = RSI[30](open)
    c3 = (indicator2 >50)
    indicator3 = CCI[65](open)
    c4 = (indicator3 >75)
    
    
    
    IF c2 and c3 and c4 THEN
    SELL AT MARKET
    ENDIF
    
    // stops and targets
    atr = averagetruerange[14](close)
    set stop ploss atr*2.5
    
    #69171 quote
    TRezin
    Participant
    Junior
    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]
    indicator2 = RSI[30](open)
    c3 = (indicator2 >51)
    indicator3 = CCI[65](open)
    c4 = (indicator3 >10)
    
    if c1 and c3 and c4 and Not LongOnMarket then
    BUY 1 SHARE AT MARKET
    endif
     
    indicator1 = ExponentialAverage[20](close)
    c2 = (close CROSSES UNDER indicator1)
    
    
    
    IF c2 THEN
    SELL AT MARKET
    ENDIF
    
    // stops and targets
    atr = averagetruerange[25](close)
    set stop ploss atr*2.5

    Sorry thats it sorted.

     

    Thanks

    #69172 quote
    Inertia
    Participant
    Master

    Good.

    FYI: For the DAX I do not find any edge in any UT.

    #69174 quote
    TRezin
    Participant
    Junior

    Inertia,

    If you have time

    One more thing. Do you know why this code is not shorting the market?

     //conditions to enter long positions
    c1 = Close<Open[5] and Close>Close[3]
    indicator2 = RSI[30](close)
    c3 = (indicator2 >50)
    indicator3 = CCI[65](close)
    c4 = (indicator3 >65)
    indicator4 = exponentialaverage[20](close)
    c5 = (close >indicator4)
    
    if c1 and c3 and c4 and c5 and Not LongOnMarket then
    BUY 1 SHARE AT MARKET
    endif
     
    // conditions to exit long positions
    indicator1 = ExponentialAverage[50](close)
    c2 = (close CROSSES UNDER indicator1)
    
    
    IF c2 THEN
    SELL AT MARKET
    ENDIF
    
    
    //conditions to enter short positions
    c6 = Close>Open[5] and Close<Close[1]
    indicator2 = RSI[30](close)
    c7 = (indicator2 <50)
    indicator3 = CCI[65](close)
    c8 = (indicator3 <-10)
    indicator4 = exponentialaverage[20](close)
    c9 = (close >indicator4)
    
    if c6 and c7 and c8 and c9 and Not shortOnMarket then
    BUY 1 SHARE AT MARKET
    endif
     
    // conditions to exit long positions
    indicator1 = ExponentialAverage[50](close)
    c10 = (close CROSSES over indicator1)
    
    IF c10 THEN
    SELL AT MARKET
    ENDIF
    
    
    // stops and targets
    atr = averagetruerange[14](close)
    set stop ploss atr*2.5

    Thanks

    #69178 quote
    Eric
    Participant
    Master

    Inertia,

    If you have time

    One more thing. Do you know why this code is not shorting the market?

    Thanks

    https://www.prorealcode.com/topic/journey-prt/#post-68453

    #69181 quote
    Vonasi
    Moderator
    Master

    Do you know why this code is not shorting the market?

    Because there is no SELLSHORT instruction in the code.

    Inertia thanked this post
    #69187 quote
    Inertia
    Participant
    Master

    Hi Eric,

    from #post69174,

    line 34, sellshort instead of buy

    and in that case, line 42 exitshort.

    #69189 quote
    TRezin
    Participant
    Junior

    Thanks for the fix. Its working now.

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

Heiken Ashi Long/Short


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
TRezin @trezin Participant
Summary

This topic contains 13 replies,
has 4 voices, and was last updated by TRezin
7 years, 10 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/20/2018
Status: Active
Attachments: No files
Logo Logo
Loading...