Exit code

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #50935 quote
    Frank
    Participant
    Junior

    Hi,

    Can someone please help me the code if I want to exit a position after X bars..?

    #50937 quote
    robertogozzi
    Moderator
    Master
    IF OnMarket AND ((BarIndex - TradeIndex) >= 50) THEN
       SELL      AT MARKET   //Exit LONG  trades, if any
       EXITSHORT AT MARKET   //Exit SHORT trades, if any
    ENDIF

    This code will exit any open position after 50 bars have elapsed. You may change this number to suit your needs.

    Roberto

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

Exit code


Platform Support: Charts, Data & Broker Setup

New Reply
Author
author-avatar
Frank @framul Participant
Summary

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

Topic Details
Forum: Platform Support: Charts, Data & Broker Setup
Language: English
Started: 10/30/2017
Status: Active
Attachments: No files
Logo Logo
Loading...