Staying on market at least x bars

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #135634 quote
    Francesco
    Participant
    Veteran

    Hello guys, here’s a function that closes the positions after x bars:

    IF OnMarket AND (BarIndex - TradeIndex) >=x THEN
    SELL      AT MARKET
    EXITSHORT AT MARKET
    ENDIF

    But what if i would like to implement a function that does not close the position for at least x bars? Then just after that x bars let the system works normally with sl/tp/ts etc…?

    Probably it’s more simple then i think, but i ask you for security.

    #135635 quote
    Francesco
    Participant
    Veteran

    Update: i managed to do that 🙂

    IF OnMarket AND (BarIndex - TradeIndex)<=x THEN
    set stop %loss 0
    ENDIF
    

    Yes, that was simple as i thought

    #135646 quote
    robertogozzi
    Moderator
    Master

    You will have to add an ELSE condition to set the SL after those X bars.

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

Staying on market at least x bars


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

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

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