Jump to content
Jeffrey Pleiman

How to automatically adjust stop loss to number of shares

Recommended Posts

Hi All, 

I am having a hard time to get my stop loss to adjust automatically to the number of shares that I have when I am scaling out.  If I have a stop loss set and scale out of a trade the number of shares in my stop loss remains at the original amount, and then if it hits that stop loss it will actually flip my position.  For example, I buy 100 shares at xyz at $50 and scale out by selling half my position when the stock reaches $52, leaving me with 50 shares out of my original 100 shares.  Now I move my stop loss up on the chart to break even.  The stock drops and hits my stop loss but it sells the full amount (100 shares) and now I have 50 shares short, which I didn't want.  

Is there any way to have my stop loss automatically adjust to the number of shares I have when scaling out?  I contacted DAS support and they said there is not and recommended using the script Share=Pos;Replace.   I am hoping they are incorrect. The problem with the script is that I need to double click on my open orders to do so, and then that pulls up my STOP position on the montage window, then I hit the hot key, but then my montage window is now on my STOP on my STOP position and I need to manually toggle back to my original position to get my default montage window back before I can start scaling out again.  All of which takes a lot of time and is subject to error.  

Appreciate any answers! 

  • Like 1

Share this post


Link to post
Share on other sites

You can't do it programmatically / automatic at the moment. I have a feature request in with the developers to allow us to do this with a new set of hotkeys. There *is* a legacy feature in DAS that does it for you, but it's very odd in how you have to set the initial order and doesn't always work (at least for me), so I wouldn't recommend using that.

The only other way is the way peterB mentioned and that is by Canceling out the orders and then putting a new one in.

Edited by KyleK29

---------------------------------------------------------
Profile / Project Pages (Dynamic Hotkeys, StreamDeck Files, and other contributions are located here)

Share this post


Link to post
Share on other sites

@KyleK29 Thanks for the great work you have done! Are there any updates on this DAS features?

Share this post


Link to post
Share on other sites
2 hours ago, Jad said:

@KyleK29 Thanks for the great work you have done! Are there any updates on this DAS features?

Hey Jad,

There are some interesting changes coming in the next release, but I'm not sure this will be one of them.

That being said, did you see peterB's comment? It does exactly what you need it to do all in one hotkey. Sells x amount of your position and resets your stop loss to the remaining amount of shares.

Long:
CXL ALLSYMB;Route=LIMIT;Share=Pos*0.5;Price=Bid-0.05;TIF=DAY+;SELL=Send;ROUTE=STOP;StopType=Market;StopPrice=AvgCost;Share=Pos-share;TIF=DAY+;SELL=SEND

Short:
CXL ALLSYMB;Route=LIMIT;Share=Pos*0.5;Price=Ask+0.05;TIF=DAY+;BUY=Send;ROUTE=STOP;StopType=Market;StopPrice=AvgCost;Share=Pos+share;TIF=DAY+;BUY=SEND

  • Thanks 1

Share this post


Link to post
Share on other sites

@Justin Thank you for your response. I am looking to dynamically update the size of stop as I scale without changing the Price. It is a separate process at the moment, which works well through updating the order. It would be nice to have though to be able to dynamically update the size. I am aware of the above and I will consider how it fits in my playbook. Thanks again!

Share this post


Link to post
Share on other sites
1 hour ago, Jad said:

I am looking to dynamically update the size of stop as I scale without changing the Price.

Unless I'm misunderstanding you, and I'm very sorry if I am, but this can also be done in one single hotkey.

CXL ALLSYMB;Route=LIMIT;Share=Pos*0.5;Price=Bid-0.05;TIF=DAY+;SELL=Send;ROUTE=STOP;StopType=Market;StopPrice=StopPrice;Share=Pos-share;TIF=DAY+;SELL=SEND

This will allow you to take a 50% partial, and it will update the size of your stop without changing it's price.

(Colors match what I said with what it references in the script)

Share this post


Link to post
Share on other sites

Thanks @Justin So if I understand correctly, the StopPrice variable is saved from the initial order where we set it to Price. Then, as we scale, we are cancelling the current stop order and replacing it with one, using the same stop price at the updated position size, right? I will try it in my SIM. 

  • Like 1

Share this post


Link to post
Share on other sites

Thanks @peterB You're absolutely right for scaling out.

What about scaling in? would this (setting price to initial stop) make sense to avoid being stopped too early, or are there a better approach?

Edited by Jad

Share this post


Link to post
Share on other sites

Hi Guys, 

Thanks for the replies thus far in this thread.  My thoughts for originally posting this was for longer term trades.  I would like to be able to set my profit targets and stop and then walk away.  As it stands right now, if one profit target hits (if I am short for example) and then hits my stop, I will now have a long position.  This is what I am trying to avoid and the cancel/replace hotkey doesn't really accomplish this as I would have to be in front of the computer. 

  • Like 1

Share this post


Link to post
Share on other sites
4 hours ago, Jeffrey Pleiman said:

Hi Guys, 

Thanks for the replies thus far in this thread.  My thoughts for originally posting this was for longer term trades.  I would like to be able to set my profit targets and stop and then walk away.  As it stands right now, if one profit target hits (if I am short for example) and then hits my stop, I will now have a long position.  This is what I am trying to avoid and the cancel/replace hotkey doesn't really accomplish this as I would have to be in front of the computer. 

Hey Jeffrey, this is actually coming in the new DAS beta. It will allow for multiple price targets to be set and when they are hit it will auto update your stop loss position!

Edited by Justin

Share this post


Link to post
Share on other sites

Hello everyone!

I'm a little late to this party.  This post seems to address EXACTLY what I was looking for, but something's not quite working for me.

NOTE: I should likely add I'm testing this hotkey out in Replay quote mode!

I copied & pasted in the script provided by @peterB back on 2/20 (the "ROUTE=LIMIT" version).  The 'CXL ALLSYMB' part works just fine, as does the liquidation of half my position (originally 600).  However, it seems like the attempt to create a new STOP order is failing.  Here's a snippet from the log in the order window.  Note the "Error: Invalid Shares!" message.  Once I get this, half my position is gone, but I no longer have a STOP:

Error:Invalid Shares!
Execute Shrt 300 NTNX 24.37 --SMAT--12:36:24--
Accept Shrt 300 NTNX 24.27 --SMAT--12:36:24--
Sent 1 cancel orders
Canceled Shrt Stop 600 NTNX 23.54 --SMAT--12:36:24--Canceled
Accept Shrt Stop 600 NTNX 23.54 --SMAT--12:34:16--

Any advise for what I'm doing wrong? If it helps, my order window style is currently set to 'Stop Order'.

Thanks!

Edited by Earl Damron

Share this post


Link to post
Share on other sites

I think that's it @peterB!  It worked on a test trade with MU just a few minutes ago.  I also tested out @Justin's SHORT version, and it worked as well.

Thanks guys!

Edited by Earl Damron

Share this post


Link to post
Share on other sites

@peterB@Justin I'm trying to create a single hotkey that lets me add 50% to my position and then re-sets my stop loss to the new breakeven spot. I have the hotkey for adding to my position, and I have the hotkey for setting my SL to b/e, but when I combine the two, it appears that the SL is set at the original b/e spot with the original number of shares, not accounting for the 50% add at a new price. I'm guessing it's because the stop loss part of the script is running before I can get filled on my 50% add.

Is there a way to add a minor delay between the add and the set SL to b/e so that my SL will be set to the new b/e once I get filled on the add?

Here's my current script to add 50% then set SL to the new B/E that puts my B/E at the original instead of new B/E spot: 

CXL ALLSYMB;ROUTE=LIMIT;Price=Ask+0.02;Share=Pos*.5;TIF=DAY;BUY=Send;Route=Stop;Price=AvgCost;StopType=MARKET;STOPPRICE=AvgCost;StopPrice=Round2;Share=Pos-share;TIF=DAY;Send=Reverse;

Thanks!

EDIT: @Bryan W Hooked me up in the chat support tab! The hotkeys are:

CXL ALLSYMB;ROUTE=LIMIT;Price=Ask+0.02;Share=Pos*.5;TIF=DAY;BUY=Send;TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice-0.3 ACT:SELL STOPPRICE:AvgCost QTY:Pos TIF:DAY+


CXL ALLSYMB;ROUTE=LIMIT;Price=Bid-0.02;Share=Pos*.5;TIF=DAY;SELL=Send;TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice+0.3 ACT:BUY STOPPRICE:AvgCost QTY:Pos TIF:DAY+

BUT one caveat, if I exceed my BP, then not only does it not add to my position, but it doesn't keep a SL at b/e. If anyone knows how to edit the script so that I can't exceed BP, would love to hear your thoughts, including @KyleK29!

Edited by Eric Dubs

Share this post


Link to post
Share on other sites

I see value in selling stocks and adjust the initial breakeven to the remaining quantity in the scenario that the price goes against me and once passes my cost, I sell the shares (adjusting the quantity of the initial stop loss). That way, if I lose, it will not be -1 R. Yes, it may rebound and I have less 50% of the shares but if went against me, it is not my initial trade anymore. This way I assure a better profit factor.

Edited by Nuno

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.