Alera Forum

Full Version: Time stop
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi there, 

Is there a way I can implement a time stop based on new buy orders? 

For example. I generate 10 new buy signals. Alera also knows to close them 5 days later etc?

Not sure how to go about this. I see profit target and loss stops available on the strategy tab but nothing for time stops.

Any help would be appreciated,

Brad
A good way to approach this would be to use delayed signals. See https://aleratrading.com/forum/showthread.php?tid=413
It would not be automated like the target and loss stops in the strategy tab, but it would essentially function as a time stop.

For example, suppose you want to open AAPL and close it after 5 days. Then you can place the signal
LONG AAPL 100 SHARES LMT 150
CLOSE AAPL AFTER 20220114 09:00:00 EST

This would automatically place a CLOSE order on January 14th and close your AAPL position if it's open, or cancel the limit order if it's still in the market.
This will not work if you attempt to place orders every day for AAPL when you already own the position, since the delayed order will be constantly updated. Instead, you would need to only place orders for AAPL when you don't own it -- this would require you to check your portfolio through the Alera API.

Another solution would be to use the Alera API to get the "days in market" of a position and close it if that value is larger than 5. 
Using the /strategies/<id>/portfolio/json you can get this information. See https://aleratrading.com/forum/showthread.php?tid=89
It's not too difficult to write a Python script to do this Smile

We could also add a feature for custom timed exits in signals. We do something similar for custom stop/target signals https://aleratrading.com/forum/showthread.php?tid=404, so it should be possible to attach a close datetime + a limit price to close at to orders. We will consider adding this feature in the future.
A time stop or Nbar stop would be a very useful feature. You have my vote for it!