Sell after x amount of bars?

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #8051 quote
    dajvopdajvop
    Participant
    Master

    Hello! Need help with code to let me sell or exitshort (if on market) after x amount of bars.

    Thanks!

    #8062 quote
    NicolasNicolas
    Keymaster
    Legend

    Hello, you need the TRADEINDEX instruction which save the BARINDEX number when the trade were launched.

    For example, if you want to exit a trade that have at least 5 bars elapsed since it were launched:

    if onmarket and BARINDEX-TRADEINDEX(1)>5 then 
      SELL AT MARKET 
      EXITSHORT AT MARKET 
    endif
    #8089 quote
    dajvopdajvop
    Participant
    Master

    Thank you Nicolas!

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

Sell after x amount of bars?


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
dajvop @dajvop Participant
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by dajvopdajvop
10 years, 3 months ago.

Topic Details
Forum: ProOrder: Automated Strategies & Backtesting
Language: English
Started: 05/26/2016
Status: Active
Attachments: No files
ProRealCode ProRealCode
Loading...