Exit Breakout trade

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #157251 quote
    Pellejons
    Participant
    Average

    Hi I have a little problem if anyone can help me!

    I would like to know how to code an exit from a trade based on a new lower low in the current trade.
    For an ex then latest bar is lower than the last 30 bars then sell position

    // Breakout strategy with new Higher high for go long and new lower low for go short
    
    highh = highest[50](high) // when the price is higher than the last 50 bars i want to go long
    lowl = lowest[30](low) //  When the price is lower than the last 30 bars want to exit my long trade
    
    Size = 1 //position size
    Condlong = highh > close
    Condexitlong = barindex-tradeindex(1)<=lowl            // " Here is something wrong i can´t figure  out how to get it right for exit ??? "
    Condshort= lowl < close
    
    IF not onmarket and condlong THEN
    buy size shares at market
    endif
    
    IF longonmarket and condexitlong THEN
    sell size shares at market
    endif
    
    //

     

    Best Regards! =)

    #157254 quote
    Pellejons
    Participant
    Average

    ex from image

    breakout_exit.png breakout_exit.png
    #157271 quote
    Vonasi
    Moderator
    Master

    Pellejons  – Welcome to the forums. Your post has been edited as you did not follow the forum rules regarding using the ‘Insert PRT Code’ button:

    • Always use the ‘Insert PRT Code’ button when putting code in your posts to make it easier for others to read.
    Insert-PRT-Code-Button-1.png Insert-PRT-Code-Button-1.png
    #157275 quote
    Vonasi
    Moderator
    Master

    Change line 8 to:

    Condexitlong = low = lowl
    Pellejons thanked this post
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Exit Breakout trade


General Trading: Market Analysis & Manual Trading

New Reply
Author
author-avatar
Pellejons @pellejons Participant
Summary

This topic contains 3 replies,
has 2 voices, and was last updated by Vonasi
5 years, 2 months ago.

Topic Details
Forum: General Trading: Market Analysis & Manual Trading
Language: English
Started: 01/11/2021
Status: Active
Attachments: 2 files
Logo Logo
Loading...