Exit above day High

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #228815 quote
    prazirna.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ález
    Moderator
    Master

    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.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.

Exit above day High


ProBuilder support

New Reply
Author
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by prazirna.pledy
1 year, 11 months ago.

Topic Details
Forum: ProBuilder support
Language: English
Started: 02/27/2024
Status: Active
Attachments: No files
Logo Logo
Loading...