Jump to content
Jeffrey Pleiman

How to automatically adjust stop loss to number of shares

Recommended Posts

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

does it work in real time sim or not? it might be some limit of the replay feature only

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

it is because it does not know what is your 50% stop loss. i suggest you use the free roll hotkey for add ups with some smart eyballing mechanism to get what you need then move the stop to desired price

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.