Define trade waiting period

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #122348 quote
    deletedaccount14122020
    Participant
    New

    Hello,

    After closing a trade I would like my system to wait two periods before it can open a new trade in the same market.

    At the moment it can open a new trade at the same time it closes the old.

    Any help would be appreciated.

    #122350 quote
    robertogozzi
    Moderator
    Master

    To close an open trade to start a new one:

    IF MyLongConditions  THEN          //LONG
       IF LongOnMarket  THEN
          SELL AT MARKET               //close any open LONG  position
       ENDIF
       BUY 1 CONTRACT AT MARKET        //close any SHORT open position and enter a new LONG one
    ENDIF
    IF MyShortConditions THEN          //SHORT
       IF ShortOnMarket THEN
          EXITSHORT AT MARKET          //close any open SHORT position
       ENDIF
       SELLSHORT 1 CONTRACT AT MARKET  //close any LONG open position and enter a new SHORT one
    ENDIF
    #122352 quote
    Nicolas
    Keymaster
    Master

    To make a pause between orders, add a condition with BARINDEX-TRADEINDEX>x , where x is the bars quantity. It has been discussed many times with a lot of examples.

    First link I found: Do not take a trade for x bars after trade closed

    #122354 quote
    robertogozzi
    Moderator
    Master

    To count X periods before entering a new trade:

    ONCE Count    = 0
    ONCE MinCount = 2
    IF (Not OnMarket AND OnMarket[1]) OR (StrategyProfit <> StrategyProfit[1]) THEN  //check thare was a trade open the previous bar and not any longer....
       Count = 1                                                                     //... to start counting periods (bars)
    ELSE
       Count = Count + 1                                                             //increment Count at each new period (bar)
    ENDIF
    IF OnMarket THEN
       Count = 0
    ENDIF
    IF MyLongConditions  AND Not OnMarket AND ((Count = 0) OR Count > MinCount)) THEN
       BUY 1 CONTRACT AT MARKET                                                      //LONG
    ENDIF
    IF MyShortConditions AND Not OnMarket AND ((Count = 0) OR Count > MinCount)) THEN
       SELLSHORT 1 CONTRACT AT MARKET                                                //SHORT
    ENDIF
    #122358 quote
    deletedaccount14122020
    Participant
    New

    Many thanks Nicolas and robertogozzi for your help.

    This is now working correctly in my system

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

Define trade waiting period


ProOrder: Automated Strategies & Backtesting

New Reply
Summary

This topic contains 4 replies,
has 3 voices, and was last updated by deletedaccount14122020
5 years, 11 months ago.

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