Exit above day High

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #228815 quote
    prazirna.pledyprazirna.pledy
    Participant
    New

    Hello, could you please help me with this exit strategy? It’s not generating any exits for me. I want to exit on a close above the three-day High from entry. Here is the full code. Thank you.

    // definice
    atr5 = AverageTrueRange[5]
    indicatorValue = (highestHigh - close) / atr5
    
    // Logika
    IF indicatorValue CROSSES OVER 2 AND onmarket = 0 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // exit rules
    IF longonmarket THEN
    highestexit = Highest[3]
    IF close > highestexit THEN
    SELL AT MARKET
    ENDIF
    ENDIF
    #228823 quote
    Iván GonzálezIván González
    Moderator
    Legend

    Hi,

    In your exit rule the condition IF close > highestexit THEN will never happen.
    Iǜe defined the highestHigh as HHV3 = highest[3](high) because it was not defined.

    This should do more or less what you want.

    // definice
    HHV3 = highest[3](high)
    atr5 = AverageTrueRange[5]
    
    indicatorValue = (HHV3 - close) / atr5
    
    // Logika
    IF indicatorValue CROSSES OVER 2 AND onmarket = 0 THEN
    BUY 1 CONTRACT AT MARKET
    ENDIF
    
    // exit rules
    IF longonmarket and close > HHV3[1] THEN
    SELL AT MARKET
    ENDIF
    
    graphonprice HHV3 coloured("red")
    graph indicatorvalue coloured("red")
    graph 2 coloured("blue")
    prazirna.pledy thanked this post
    #228827 quote
    prazirna.pledyprazirna.pledy
    Participant
    New

    Hi,
    Yes that’s it, thanks so much for the help!

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

Exit above day High


ProBuilder: Indicators & Custom Tools

New Reply
Author
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by prazirna.pledyprazirna.pledy
2 years, 7 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 02/27/2024
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...