Close after X minutes

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #100059 quote
    OMXet
    Participant
    Junior

    Hi

    I’m sure the answer is somewhere at this forum but I can’t find it so:

    How to code “Close after X minutes”

    #100064 quote
    robertogozzi
    Moderator
    Master

    What TF are you using?

    Close after X minutes from…. the opening of a trade,  no matter whether it’s gaining or losing?

    #100131 quote
    OMXet
    Participant
    Junior

    At the moment 5 sec.

    Yep, X minutes after opening whatever the result is.

    #100137 quote
    robertogozzi
    Moderator
    Master

    This should work (not tested):

    IY MyConditions THEN
       BUY/SELLSHORT....
       MyMinute = OpenMinute
    ENDIF
    x = OpenMinute - MyMinute
    IF x < 0 THEN
       x = x + 60
    ENDIF
    IF x >= 5 THEN
       SELL/EXITSHORT....
    ENDIF
    
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.

Close after X minutes


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
OMXet @omxet Participant
Summary

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

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