Open and Close at start and end of same bar

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #8766 quote
    K12AN
    Participant
    Junior

    Hello

    I would like to Open a trade at the start of a bar and close it at the end of the same bar i.e. my exit criteria is the end of the time period.

    Example:

    I wish to go long on a 15 min bar – I would like to buy 1 lot at 11:00 and exit my position at 11:15.

    Thanks

    K12an

    #8768 quote
    Adolfo
    Participant
    Senior

    Hi K12AN, do you want something like this?

    IF TIME=110000 THEN
    BUY AT MARKET
    ENDIF
    IF TIME=111500 THEN
    SELL AT MARKET
    ENDIF

    Or

    IF LONGONMARKET THEN // Next bar will be closed no matter what time
    SELL AT MARKET
    ENDIF
    #8769 quote
    Adolfo
    Participant
    Senior
    IF YOURCONDITIONS THEN
    BUY AT MARKET NEXTBAROPEN
    ENDIF
    
    IF LONGONMARKET THEN
    SELL AT MARKET
    ENDIF
    
    

    Hope it helps you 😉

    #8771 quote
    K12AN
    Participant
    Junior

    Thanks Adolfo – will give it a try 🙂

    #8775 quote
    Nicolas
    Keymaster
    Master

    NEXTBAROPEN is depreciated. Each conditions are tested at close of the bar and then trade are launched at the next bar open.

    Adolfo thanked this post
    #8899 quote
    K12AN
    Participant
    Junior

    Not having much luck with this I’m afraid.

    I wanted to open a trade every day at 7am and close it at 5pm – but haven’t been able to make it work.

    Even when using the function in beta version 10.3 it doesn’t generate any trades in backtesting

    #8906 quote
    Nicolas
    Keymaster
    Master

    What is the timeframe used for your conditions? May I ask you to put here your entire code for a better comprehension? Thanks! 🙂

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

Open and Close at start and end of same bar


ProOrder: Automated Strategies & Backtesting

New Reply
Author
author-avatar
K12AN @k12an Participant
Summary

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

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