Jump to content
Justin

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

Recommended Posts

I can't seem to use the hotkey for some reason. I keep getting "ERROR: Can't get valid price!"

 

Edit: The hotkey only works for shorting, when I try to use the long hotkey it does not work at all. I copied the hotkey exactly as I saw it so I'm a bit confused on that...If there's a fix for that, please let me know. Also, when I try to use my cover or sell hotkeys, it does not work. It brings up this in the picture and I did manage to find a solution which was going into my montage and changing the type of order from "limit" to "market" and it worked. If there's another way to fix it without doing that, please let me know. I'm trying this in replay by the way.

needhelp.PNG

Edited by koreanwon97

Share this post


Link to post
Share on other sites
16 hours ago, koreanwon97 said:

I can't seem to use the hotkey for some reason. I keep getting "ERROR: Can't get valid price!"

 

Edit: The hotkey only works for shorting, when I try to use the long hotkey it does not work at all. I copied the hotkey exactly as I saw it so I'm a bit confused on that...If there's a fix for that, please let me know. Also, when I try to use my cover or sell hotkeys, it does not work. It brings up this in the picture and I did manage to find a solution which was going into my montage and changing the type of order from "limit" to "market" and it worked. If there's another way to fix it without doing that, please let me know. I'm trying this in replay by the way.

needhelp.PNG

This hotkey doesn't work in replay mode. You'll need to test it out in SIM when the market is open.

Share this post


Link to post
Share on other sites

Hi Justin & Kyle,

This script is very awesome!

Can you please provide the script for the flip side (i.e., Short situation)?  Thanks

Henry

 

Share this post


Link to post
Share on other sites
3 minutes ago, tamago168 said:

Hi Justin & Kyle,

This script is very awesome!

Can you please provide the script for the flip side (i.e., Short situation)?  Thanks

Henry

 

It's already there in the first post

Share this post


Link to post
Share on other sites

Hi Justin,

I think you were looking for a solution for Part 2 of the script to send 2 separate range orders.  I'm looking for a similar solution like below.

When my Buy Stop/Sell Stop is triggered and filled, 2 separate range orders are created.  The first one is 60% of shares with 1R target and the second one is 40% with 2R target.  Both of them have the same original stop loss.

That'll be very helpful if a script exists for this case.

 

Share this post


Link to post
Share on other sites

Peter,

I posted the same question under that topic, too.  I saw you responded over there as well.  It seems that currently there's no one key to accomplish this.  So, the workaround for now is to send 60% at 1R, and manually send another 40% at 2Rs.  Thank you for your time.

Share this post


Link to post
Share on other sites

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

 @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

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

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.