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 🙂
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.
Thanks Roberto I will try it !