How to limit the number of buys per day when operating on short time frames?
I am developing a system for the E-mini S&P and I am having some troubles limiting the number of trades per day. I have searched in the forum and i have found that there are some functions and reserved words such as entriestoday or entrydate which could be useful to limit the number of trades per day. However, they are limited to 10 positions ago and I would like to set the maximum number of buys to 25 or 30 per day.
Has anyone made a script that sets a limit on how many buys or trades can be traded per day? Anyone could give me some advice on how I could do it?
use a simple counter. Each time your signal enters a new position, you increment the counter. When you evaluate your entry conditions you use this counter to check that it's smaller than the number of trades per day that you allow.
On the first tick of the new day you reset the counter. This should get you what you want while being more flexible.
The following 2 users say Thank You to ABCTG for this post:
I have tried to code a counter following your instructions but it seems like it doesn't limit the buys. Here is my code, maybe i have committed some mistakes and that is why it doesn't work well.
you reset the counter on every code cycle and not just on the first tick of the day. The second thing I noticed is that you increment the counter when you send the order, but as you use a limit order you will run into situations where you increment the counter although the signal didn't enter.
The following user says Thank You to ABCTG for this post: