Jump to content
Justin

DAS - Stop Limit Order for Future Entry with Dynamic Share Calculation - Using $Risk with a Stop Loss

Recommended Posts

I'm using the following script to short sell at the bid with $25 (1R) risk and covers 60% at 1R target with one key:

CXL ALLSYMB;StopPrice=Price+0;DefShare=BP*0.925;Price=Price-Bid+0.00;SShare=25/Price;Share=DefShare-SShare;DefShare=DefShare+SShare;SShare=Share;Sshare=DefShare-SShare;Share=0.5*SShare;TogSShare;ROUTE=SMRTL;Price=Bid-0.05;TIF=DAY+;SELL=Send;DefShare=100;Price=StopPrice-Bid*1;Price=Bid-Price;TriggerOrder=RT:STOP STOPTYPE:RANGE LowPrice:Price HighPrice:StopPrice ACT:BUY QTY:POS*.6 TIF:DAY+

Based on the above script, I think, hopefully, we can modify the syntax of Part 2 (reproduced below) to create a range order (High = Stop Loss and Low = Profit Target).  I'm not a tech guy, so I need your opinions on this.

DefShare=BP*0.97;Price=StopPrice-Price;SShare=25/Price;Share=DefShare-SShare;DefShare=DefShare+SShare;SShare=Share;Sshare=DefShare-SShare;Share=0.5*SShare; SShare=Share;Share=Price*100; Price=StopPrice; DefShare=Price*100; Price=Share/100; Price=StopPrice-Price; StopPrice=Price; Share=SShare; TogSShare; Price=Price-.02;TIF=DAY+;Route=Stop;StopType=Limit; Sell=Send; Share=DefShare;Price=Share/100; StopPrice=Price; DefShare=100;TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice-0 ACT:BUY STOPPRICE:StopPrice QTY:Pos TIF:DAY+;

 

I really need this hotkey, as at the opening, I'm sending multiple orders (if they meet my setup rules), and I can't manage if I have to manually modify the stop loss order created by Part 2 to be a range order.  Thanks guys.

Share this post


Link to post
Share on other sites

Hi Justin,

For Short selling, is it possible to set trigger and sell limit prices above current price in Part 2 of the script?  I slightly changed (in bold) Part 2 below, but it doesn't populate Trigger Price field.  Only the Price field is filled with trigger price + the buffer.  Is that theoretically possible as usually Sell Limit is set below the current price.

DefShare=BP*0.97;Price=StopPrice-Price;SShare=25/Price;Share=DefShare-SShare;DefShare=DefShare+SShare;SShare=Share;Sshare=DefShare-SShare;Share=0.5*SShare; SShare=Share;Share=Price*100; Price=StopPrice; DefShare=Price*100; Price=Share/100; Price=StopPrice-Price; StopPrice=Price; Share=SShare; TogSShare; Price=Price+.05;TIF=DAY+;Route=Stop;StopType=Limit; Sell=Send; Share=DefShare;Price=Share/100; StopPrice=Price; DefShare=100;TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice-0 ACT:BUY STOPPRICE:StopPrice QTY:Pos TIF:DAY+;

The followings are my steps taken.

#1. Set the stop price ($137.50) by using Part 1 script.

image.png.9fe268c65f096975feb718c0edc25bc7.png

#2. Set the trigger price ($136.95) by using Part 2 script.  Currently, the stock is traded at $136.90.

image.png.0a6a0c39c44db40c60fead72e4884f6b.png

#3. Double click on the order sent, don't see Trigger Price.  Price field is filled with trigger price $136.95 + buffer $0.05 = $137.00.

image.png.32134b5cf48d581d9dcf64bd4bd04d24.png

Thanks a lot!

Share this post


Link to post
Share on other sites
On 3/4/2021 at 3:06 PM, evan said:

How would you script this?  I have a hotkey for manual entry that does this, but I'd love to be able to pre-select my entry price.

Hi all, just been catching up on this thread, thanks so much Justin, its outstanding work.  I was also just wondering three things please:

1.) The same query as Evan's above - what alteration would be needed to be made to the script in part two of this process to initiate a range order (for 2:1) rather than just a stop, once the position triggers

2.) Are any alterations to the script necessary to allow the orders to be placed in the pre-market, but without them being able to trigger until RTH start?  i.e. is that just switching 'Day+' to 'Day' or something similar? 

3.) Would this same script work if you place it to act as a buy/stop at a lower price than a stock is currently trading at? For example, if you have an entry point below where a stock is currently trading that you believe it will retrace to, and there is where you would want to enter.  Or would the script again need to be changed for that?

Sorry for all questions, trying to learn some of this on my own, but wondered if an easy way to confirm in meantime.

Many thanks!

Share this post


Link to post
Share on other sites

ok let me try to summarize

you want a future entry - use stop limit order set stop price and limit price, done
this is standard for all brokers

you want a future entry with static risk and automatic stop loss and profit target - not possible
it would require trading platform change so that the 3 stop orders do not interfere. remember the submitted orders are held at the broker so the broker will not do any additional calculations for you, just order and order type. done

you want a pre-market or post-market stop loss order - not possible
this is every broker i know limitation

unless DAS would allow some order playlist at a specific price trigger point the "not possibles" will never work with any broker

until then it is up to you traders to trigger the complex calculations order scripts at the precise time

Share this post


Link to post
Share on other sites

 @KyleK29 Say I'm already in a trade and I'd like to set a stop loss at a fixed dollar amount ... say, -$300.  Whatever my current position size is, the stop loss will trigger as soon as I'm down -$300.  I've tried the following script, but I get an "Invalid Operator" error.

ROUTE=STOP;StopType=Market;StopPrice=((Pos*AvgCost)-300)/Pos;Share=Pos; TIF=DAY; SELL=Send

The equation I have for the StopPrice is valid, but I suspect DAS doesn't like anything that complicated.  Could I modify your 'dynamic share calculation' script to make this work?

Share this post


Link to post
Share on other sites

i think you could use temporary variable instead of the parenthesis. like

tempprice=Pos*AvgCost;StopPrice=tempprice-300

i cant imagine a use case for this anyway. you will never get good stop loss like this you will be way off where you wanna be technically

 

Share this post


Link to post
Share on other sites

Thanks Peter, I'll give that a shot. Practical use is last ditch protection only during early morning volatility.

Share this post


Link to post
Share on other sites
7 hours ago, peterB said:

i think you could use temporary variable instead of the parenthesis. like


tempprice=Pos*AvgCost;StopPrice=tempprice-300

i cant imagine a use case for this anyway. you will never get good stop loss like this you will be way off where you wanna be technically

 

I was unaware that DAS added temporary variables. Is "tempprice" a specific command or can you name it whatever you want? Also, just curious when they added this...

Share this post


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

i am not sure but i think so. if not u can use the defshare variable for the calculation or any other non used variable from https://dastrader.com/documents/HotkeyCommandList.pdf

 

Hmmm I don't think that's a thing then; but I'm going to reach out to the engineer I know at DAS - last I heard they were still working on it.

And yes, I'm aware about defshare and the rest 😋 as you can see I used them in the hotkey I created in this thread.

Share this post


Link to post
Share on other sites
On 2/4/2021 at 5:16 AM, Justin said:

@James00trades

You can definitely do a 2:1 range order in the same "part-2" hotkey, but it would be a full exit at the stop loss and 2R.

There is an alternative... But it's not great.

In a 3rd hotkey (after you've entered a position), you can have it recalculate your position and place multiple range orders down at different price levels. Have a look below - one hotkey takes your full position (118 shares) and splits it between 5 range orders at 1R-5R. It's hard to see (as they are stacked on each other) but all 118 shares should stop out at the same price of 123.48.

unknown.png

Now I said "should"; here is the real problem with the script (also the main reason it's not released). Because your stop is actually 5 separate orders, in more volatile stocks you can have some bad slippage. It also can increase your commissions a bit (mainly on smaller positions).

image.png.d8221a453c5c0d28024b2af81c3493b5.png

I know Kyle has been working with DAS, I've been working with DAS.... If they simple can provide us with a few more variables, this stuff would be easy.

Hi @Justin, Could you please share the scripts for multiple stop orders once hit the entry. So the purpose of the script to generate a logic like,

For a long position,

If the profit hit: take partial, If the stop hit: sell all the position, Is this possible using your script? Really appropriate your input.

 

 

Share this post


Link to post
Share on other sites

Is there a way to do this with trailing stops instead? 

Even better, is there just a script to double-click on the chart to place a future order with a set trailing stop?

EDIT: Figured it out, this will allow you to double-click on the chart and press the hotkey for the below command to set a buy/long price at the share amount shown in the montage, and when triggered sets a 10c trailing stop. 

ROUTE=STOP;StopType=LIMIT;StopPrice=Price;TIF=DAY+;BUY=SEND;TriggerOrder=RT:STOP STOPTYPE:TRAILING STOPPRICE:0.10 ACT:SELL QTY:POS TIF:DAY+;

 

Edited by MiahX

Share this post


Link to post
Share on other sites

unfortunatelly there is not(yet). that would be a series of stop orders on the same stock because the future entry means its a stop order

Share this post


Link to post
Share on other sites

As i have started using these keys, 2 questions arose for me:

1. Is it possible to incorporate a route into the hotkey and thus leverage the SMART abilities from IB?

2. Why is the hotkey not working, when I already have an open position in that ticker and I am using the hotkey as an 'add'?

Seems the answers are as follows:

1.  The script uses a STOP route to be able to do the delayed entry and IB handles that internally (they don't offer a Smart Stop equivalent). As such, this is not possible with DAS' current capabilities.

2. This hotkey only works for initial entries.  If you want to scale into a position, or add if that's how you are looking at it, then you can consider Kyle's scale-in hotkeys from his hotkey spreadsheet.

I hope this information proves helpful for other people as they consider whether/how to use these awesome hotkeys.

All the best,

Hamish

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.