Help with heikin ashi Algo please

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #237787 quote
    @AlgoHunter1@AlgoHunter1
    Participant
    New

    Hi there,

    I wondered if I could have some help coding an algo idea that I have,  I’m trying to get PRT to take a trade on the open of the red candle (with the red arrow) on the attached.

    This is the trade entry criteria for the order;

    For a short
    Close < VWAP

    close < close[1]
    close[1] > close[2]
    close[2] > close[3]
    Open = High (No wick on top of candle)

    Stop = High[1]
    Target = 2 x Stop

    Any help would be greatly appreciated.

    AH

    Test-HA.png Test-HA.png
    #237792 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Your screenshot doesn’t seem to have HA candlesticks plotted?

    Here is the code using HA candlesticks:

    once xOpen = open
    xClose     = (open + close + high + low) / 4
    if barindex > 0 then
       xOpen   = (xOpen[1] + xClose[1]) / 2
    endif
    //xLow     = min(low,min(xClose,xOpen))
    xHigh      = max(high,max(xClose,xOpen))
    myVWAP, my1, my11, my2, my21, my3, my31 = CALL "VWAP - SMF"
    c1 = xClose < myVwap
    c2 = xClose < xClose[1]
    c3 = xClose[1] > xClose[2]
    c4 = xClose[2] > xClose[3]
    c5 = xOpen = xHigh
    Cond = c1 AND c2 AND c3 AND c4 AND c5 AND Not OnMarket
    SL = xHigh[1]
    TP = SL * 2
    IF Cond THEN
       SELLSHORT 1 CONTRACT AT MARKET
       SET STOP   PRICE SL
       SET TARGET PRICE TP
    ENDIF
    #237795 quote
    MaoRai54MaoRai54
    Participant
    Master

    @Roberto

    could we kindly have also the opposite in order to send a BUY order ?

    many thanks in advance

    #237808 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    First of all I noticed a bug in the code, regarding the TP calculations. This is the amended code:

    once xOpen = open
    xClose     = (open + close + high + low) / 4
    if barindex > 0 then
       xOpen   = (xOpen[1] + xClose[1]) / 2
    endif
    //xLow     = min(low,min(xClose,xOpen))
    xHigh      = max(high,max(xClose,xOpen))
    myVWAP, my1, my11, my2, my21, my3, my31 = CALL "VWAP - SMF"
    c1 = xClose < myVwap
    c2 = xClose < xClose[1]
    c3 = xClose[1] > xClose[2]
    c4 = xClose[2] > xClose[3]
    c5 = xOpen = xHigh
    Cond = c1 AND c2 AND c3 AND c4 AND c5 AND Not OnMarket
    SL = xHigh[1]
    TP = xClose - (abs(xClose - SL) * 2)
    IF Cond THEN
       SELLSHORT 1 CONTRACT AT MARKET
       SET STOP   PRICE SL
       SET TARGET PRICE TP
    ENDIF

    then here is the code with both entries:

    once xOpen = open
    xClose     = (open + close + high + low) / 4
    if barindex > 0 then
       xOpen   = (xOpen[1] + xClose[1]) / 2
    endif
    xLow       = min(low,min(xClose,xOpen))
    xHigh      = max(high,max(xClose,xOpen))
    myVWAP, my1, my11, my2, my21, my3, my31 = CALL "VWAP - SMF"
    //
    b1 = xClose > myVwap
    b2 = xClose > xClose[1]
    b3 = xClose[1] < xClose[2]
    b4 = xClose[2] < xClose[3]
    b5 = (xOpen = xLow)
    //
    c1 = xClose < myVwap
    c2 = xClose < xClose[1]
    c3 = xClose[1] > xClose[2]
    c4 = xClose[2] > xClose[3]
    c5 = (xOpen = xHigh)
    //
    CondB = b1 AND b2 AND b3 AND b4 AND b5 AND Not OnMarket  //LongOnMarket  for S&R
    CondC = c1 AND c2 AND c3 AND c4 AND c5 AND Not OnMarket  //ShortOnMarket for S&R
    //
    IF CondB THEN
       BUY 1 CONTRACT AT MARKET
       SL = xLow[1]
       TP = xClose + (abs(xClose - SL) * 2)
       SET STOP   PRICE SL
       SET TARGET PRICE TP
    ENDIF
    //
    IF CondC THEN
       SELLSHORT 1 CONTRACT AT MARKET
       SL = xHigh[1]
       TP = xClose - (abs(xClose - SL) * 2)
       SET STOP   PRICE SL
       SET TARGET PRICE TP
    ENDIF
    //graphonprice SL coloured("Red")
    //graphonprice TP coloured("Blue")
    Iván González thanked this post
    #237907 quote
    GraHalGraHal
    Participant
    Master

    Is the VWAP – SMF Indicator in the Library please (under another name?)?

    #237914 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Yes, I used the f symbol to automatically insert the CALL instruction and the code of the indicator was not visible as it’s a built-in proprietary code.

    In any case a different VWAP indicator can be used, despite some differences in the returned data. But VWAP is almost impossible to replicate exactly.

    Just CALL another one.

    GraHal thanked this post
Viewing 6 posts - 1 through 6 (of 6 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

Help with heikin ashi Algo please


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 5 replies,
has 4 voices, and was last updated by robertogozzirobertogozzi
1 year, 12 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/18/2024
Status: Active
Attachments: 1 files
ProRealCode ProRealCode
Loading...