Code for over XX bar and close

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #210777 quote
    AlfredAlfred
    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
    robertogozzirobertogozzi
    Moderator
    Legend

    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.
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

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 robertogozzirobertogozzi
3 years, 7 months ago.

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