Exit conditions, either profitable or timestop

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #223838 quote
    sebb9707sebb9707
    Participant
    Junior

    Hi,

    I’m trying to write exit conditions that either closes the position at close if it is profitable OR closes the positions after N days. How would that look in code?

    Best Regards,
    Sebastian

    #223846 quote
    JSJS
    Participant
    Master

    Hi,

    If LongOnMarket and (Close - TradePrice(1)) > X then
    
    Sell at Market
    
    EndIf
    
    If ShortOnMarket and (TradePrice(1) – Close) > X then
    
    ExitShort at Market
    
    EndIf
    
    If NOT OnMarket[1] and OnMarket then
    
    xStartBar = BarIndex
    
    EndIf
    
    If BarIndex – xStartBar > X then
    
    Sell at Market
    
    ExitShort at Market
    
    EndIf
    #223877 quote
    sebb9707sebb9707
    Participant
    Junior

    Thanks for your assistance!

    Best regards,
    Sebastian

    JS thanked this post
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 conditions, either profitable or timestop


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
sebb9707 @sebb9707 Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by sebb9707sebb9707
2 years, 10 months ago.

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 11/16/2023
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...