Close losing trades after x bars, leave winning trades open

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #191322 quote
    RaspberriRaspberri
    Participant
    New

    Hi all,

    is there a way to close losing trades after x amount of bars whereas the trade would remain open when in profit?

    I know how to theoretically close all trades after x amount of bars, but am struggling to find a way to include running P/L into the condition.

    Thanks!

    #191324 quote
    nonethelessnonetheless
    Participant
    Master
    IF longonmarket and barindex-tradeindex(1)>= b1 and positionperf<0 then
    sell at market
    endif
    IF shortonmarket and barindex-tradeindex(1)>= b2 and positionperf<0 then
    exitshort at market
    endif
    Raspberri and Nicolas thanked this post
    #191325 quote
    RaspberriRaspberri
    Participant
    New

    Awesome, thanks! šŸ™‚

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

Close losing trades after x bars, leave winning trades open


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Raspberri @raspberri Participant
Summary

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

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 04/06/2022
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...