Max number of trades in a period

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #176776 quote
    LoveTheCode!
    Participant
    Junior

    hi there,

    i am trying to figure out how to have a rule that limits the number of trades in a given time period, e.g. maximum number of trades in each new month, or week, or day is one?

    i have the rule that limits mulitple trades DEFPARAM CumulateOrders = False, that is useful to avoid duplicate trades / orders simultaneously – however this does not help once a trade is stopped out or hits profit, then new orders are placed in the same tim period which i am hoping to eliminate!

    is there any way to acheive this in PRT? Thanks in advance 🙂

    #176779 quote
    robertogozzi
    Moderator
    Master

    You can use this (not tested):

    // MaxTrades yearly, daily, weekly, monthly
    //
    Once MaxTrades  = 1 //max 1 trade allowed
    Once TradeOn    = 1
    Once TradeCount = 0
    If TradeCount = MaxTrades then
      TradeOn       = 0
    Endif
    //If IntraDayBarIndex = 0 then   //enable trading each Day
    //If Month <> Month[1] then      //enable trading each Month
    //If Year <> Year[1] then        //enable trading each Year
    If DayOfWeek < DayOfWeek[1] then //enable trading each Week
       TradeOn      = 1
       TradeCount   = 0
    Endif
    If MyLongConditions and not OnMarket and TradeOn then
       Buy 1 contract at Market
       TradeCount   = TradeCount + 1
    Endif

    it defaults to a weekly reset, but you can comment out/uncomment the desired lines to easily switch to Daily, Monthly or Yearly reset.

    Brad and ysgurjar thanked this post
    #176829 quote
    LoveTheCode!
    Participant
    Junior

    Thanks Roberto I will try it !

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

Max number of trades in a period


ProOrder: Automated Strategies & Backtesting

New Reply
Author
Summary

This topic contains 2 replies,
has 2 voices, and was last updated by LoveTheCode!
4 years, 5 months ago.

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