Define a time stop

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

    Hi,

    I would like to define a time exit in a trading system where it sell the position after 5 days. How do I define that?

    I would also like to know how to define a sell of a postion at close of the first day with profit but with a maximum of 5 days. How would that be defined?

    Best regards,
    Sebastian B

    #147898 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    On a daily TF ?

    #147899 quote
    sebb9707sebb9707
    Participant
    Junior

    Hi,

    Yes, on a daily TF, please.

    Best regards,
    Sebastian B

    #147903 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Exit after N days:

    N = 5
    If OnMarket and ((BarIndex - TradeIndex) >= N) Then
       Sell at Market
       Exitshort at Market
    Endif
    #147905 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    Exit after N days or earlier if in profit:

    N = 5
    If OnMarket and (((BarIndex - TradeIndex) >= N) or (PositionPerf > 0)) Then
       Sell at Market
       Exitshort at Market
    Endif
    #147909 quote
    sebb9707sebb9707
    Participant
    Junior

    Thank you so much for the help!

    Best regards,
    Sebastian B

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

Define a time stop


ProBuilder: Indicators & Custom Tools

New Reply
Author
author-avatar
sebb9707 @sebb9707 Participant
Summary

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

Topic Details
Forum: ProBuilder: Indicators & Custom Tools
Language: English
Started: 10/20/2020
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...