windowshopr
Member
What I'm looking for is a way to restrict my number of trades placed per day to a limit of 3, no more. I have most of the logic for this done already, but the last thing I'm missing is a way to determine what "day number" the current day is.
Example, let's say we're on the 1 minute (or any intraday) chart, and we scroll all the way to the left, roughly 30 days ago. That would be considered "day 1" on the chart, and if my "total trades placed" was 3, and we divided that by the day number of 1, we would get 3, so no more trades are allowed for that day. When the new day starts after midnight, that should be considered "day 2", and when we place another 3 trades totalling the count to 6 total trades, divided by "day 2" = 3, no more trades for that day, etc etc.
What I thought you could do is something like this assuming you're on the 1 minute chart with 30 days of history showing:
...where today's date - 30 would make 0, +1 to get an appropriate divisor.
Any ideas?
I should reiterate, this is to be used for a strategy, not an indicator. Also that formula doesn't really make sense as it'll end up with negative numbers, but I have no clue how to subtract ints from datetimes in thinkscript...
Example, let's say we're on the 1 minute (or any intraday) chart, and we scroll all the way to the left, roughly 30 days ago. That would be considered "day 1" on the chart, and if my "total trades placed" was 3, and we divided that by the day number of 1, we would get 3, so no more trades are allowed for that day. When the new day starts after midnight, that should be considered "day 2", and when we place another 3 trades totalling the count to 6 total trades, divided by "day 2" = 3, no more trades for that day, etc etc.
What I thought you could do is something like this assuming you're on the 1 minute chart with 30 days of history showing:
Code:
def currentDayNumber = DaysFromDate(GETYYYYMMDD() - 30) + 1;
...where today's date - 30 would make 0, +1 to get an appropriate divisor.
Any ideas?
I should reiterate, this is to be used for a strategy, not an indicator. Also that formula doesn't really make sense as it'll end up with negative numbers, but I have no clue how to subtract ints from datetimes in thinkscript...