Trade Restriction for Certain Time Period After Stopping Out
First post here! I am trying to write a piece of EasyLanguage code intended for risk mitigation in my automated strategy, and I'm stumped. What I'm trying to do is: If a stop order is executed, I would like to have a "blackout period" during which no trade entries in that same direction will be made.
For example, say I am using a 15-min chart and my strategy is long 3 ES contracts. Then, the price drops and triggers my stop loss order for the 3 contracts, so I am now flat. I would like the strategy to not be permitted to enter into any new long positions for the next hour.
I think the best way to do this would be to have a condition that evaluates to "true" if the strategy has been stopped out of a long trade in the past hour, and have the "new orders" command be conditional on that condition being "false".
However, I have not been able to figure out a way to check if a stop order has been triggered in the past hour (and if there is a way to determine this, how to differentiate between a "sell" stop order and a "buy to cover" stop order).
Please let me know if you have encountered a similar problem before or know of a solution.
Last edited by el oso; July 22nd, 2015 at 08:26 AM.
sorry for the confusion, I wasn't interested in your whole strategy, only the part you did so far for the feature you are asking for.
I would try something along the lines of this:
- use a boolean variable that you check before you enter long (something like "newLongsAllowed" for example)
- when the market position changes from long to short/flat, check if the trade was a loser and was exited at your stop price
- if this is the case set the variable newLongsAllowed to false and store the time of the bar in a second variable
- the last thing to do is check if the time of the current bar is later than the stored time + 1 hour
- at that moment you set the newLongsAllowed back to true so the system can take a new long entry
This should get you going.
The following 2 users say Thank You to ABCTG for this post:
Thank you, ABCTG! This is very helpful, and I will try it out. Yeah, I had not written any code yet for this feature, as I was not sure where to start / what is possible, so this is what I was looking for.