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
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

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.