Take profit after n days

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #221593 quote
    rob.esrob.es
    Participant
    New

    Hi how can I optimize taking profit after n days. For example If my condition then exit after n days and I want to see what n days has  the best winrate to exit the trade.

    #221624 quote
    robertogozzirobertogozzi
    Moderator
    Legend

    If you are working on a Daily chart, you can compare the elapsed bars:

    IF OnMarket AND (BarIndex - TradeIndex) = 8 THEN
       SELL AT MARKET
       EXITSHORT AT MARKET
    ENDIF

    if you want to exit the trade PROVIDED it’s profitable, this is the modified code:

    IF OnMarket AND (BarIndex - TradeIndex) = 8 AND PositionPerf > 0 THEN
       SELL AT MARKET
       EXITSHORT AT MARKET
    ENDIF
    #221633 quote
    rob.esrob.es
    Participant
    New

    Thank you

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

Take profit after n days


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
rob.es @rob-es Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by rob.esrob.es
2 years, 11 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 09/26/2023
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...