Take profit after n days

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #221593 quote
    rob.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
    robertogozzi
    Moderator
    Master

    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.es
    Participant
    New

    Thank you

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.

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.es
2 years, 4 months ago.

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