Code for over XX bar and close

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #210777 quote
    Alfred
    Participant
    Average

    Dear All

    I would like to insert a code for very long time trade. Some trades are over many days (such as, 5 days or 300 bar)

    Any code can exit the trade? such as if longonmarket over 200 bar, then exit long market?

    Thanks.

    #210780 quote
    robertogozzi
    Moderator
    Master

    Yes:

    IF OnMarket AND (BarIndex - TradeIndex) > 200 THEN //close any trade after 200 bars
       SELL      AT Market
       EXITSHORT AT Market
    ENDIF
    Alfred thanked this post
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.

Code for over XX bar and close


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
Alfred @kin08180213 Participant
Summary

This topic contains 1 reply,
has 2 voices, and was last updated by robertogozzi
2 years, 11 months ago.

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