Restrict daily entries to "x" in Options positional strategy

I have an options strategy where first entry is on Monday and exit is on Wednesday EOD. This is a positional strategy. On Monday, trade is initiated and if stoploss hits, it is re-entered again upto “x” times. The position is carried forward the next day and is again re-entered “x” times if stop loss is hit. This continues till Wednesday EOD when the positions are squared off.

How do I build a condition so as to restrict entry every day “x” times and apply the same condition next day. Please note this is not intraday, but a positional strategy.

Thank you in advance for helping !

I suppose the stoploss exits are taken through set exit?

You can do it this way.
Define a variable named say ExCount in “Initialise variables” and assign value Number(0) to it. (This step is also important as we are going to use this variable for condition check in Set entry, so before that the variable value must be assigned.)

Then in Set exit runtime variables increment variable ExCount by 1. For this in set exit Runtime variables enter same variable name and assign formula “Get Runtime(ExCount) + Number(1)”
Now for each exit taken the count will increase.

Now in Set 1 Entry condition you should add AND condition as “Get Runtime (ExCount) <= X”.

Then you need to reset the ExCount to zero everyday morning.
For this add a Repair Continuous. In that add condition
Time(NSE) <= 0916
AND
Get Runtime (ExCount) > 0
(make sure under Strategy advanced settings “Start Condition check after exchange open” is set to 1 second).
In Runtime variables of this Repair Continuous assign value zero to the variable ExCount.

Now Repair Continuous must have a position. But we don’t want that position to be executed actually. So add same instrument as in set 1, but in quantity(or lot) field chose Fx. And in that Fx give formula “Get Runtime (xyz)”. i.e. viarable name “xyz” here; which is not defined so it can’t be computed and no trade will be taken, but Runtime variable of the Repair Continuous gets executed. (it works I have done it.)

Please note that we are restricting Repair Continuous to be executed only once a day by having condition “Get Runtime (ExCount)” > 0 and setting it to zero in Runtime vairables of same Repair Continuous. If this is not done RC will keep on executing continuously, notification log will be full of this condition check until TT stops logging the notifications.

Hey Sharad, thanks for replying. I will apply your solution and check if that works. :slight_smile:

Hi Vishal, Did you try it?

Hey Sharad, yes I have applied it into the strategy and is under testing. But yet to encounter this scenario, so waiting for the trigger. I will update you on the results. Thanks.

Hi Sharad, the excount is not getting reset the next day. Repair continuous is not working I guess.

Hello Vishal,
I realised that if there is no any position, Repair Continuous will not work.
So instead of repair continuous add a new set and copy the Repair Continuous entry condition to the new set entry condition. Manually enter the Entry Runtime variable to assign zero value to ExCount. And don’t forget this - copy the position in RC in to the new set position. Then delete the RC.

(You must be knowing this but just in case: If you have only one set, then if you add new set your Universal Exit will become set exit of that set, and you will have to move it to UE manually.)

@Sharad Hey Sharad, thanks a lot. I had this figured out the day I replied to you as not working. Its working like a charm now. Thank you !

One trick I tried.

I define the “X” as Initialise Variable as Runtime.

So it’s got re-executed everyday at 9:15 AM.

And then I check the “Entry”, all, all all with this <= Get Runtime(X)