Jump to content
KyleK29

DAS - Dynamically Calculate Shares on %Risk or $Risk - Hot Key + Configuration, Updated 9/10/19, v2.1

Recommended Posts

@Martin G

Thanks Martin for your amazing help. By the way, what’s your DAS SIM version. The one I downloaded from DAS website was .31.

I like your buttons on Montage. How did you create them?

Edited by ragycpa

Share this post


Link to post
Share on other sites

@KyleK29

Thanks for your help Kylek. I signed for two weeks trail on DAS website and they sent me a link to download the platform. When I went to Help——-About it shows the version which is .31. Is it because of the simulator?

Share this post


Link to post
Share on other sites

This spreadsheet is brilliant! This is the only place on the Internet that I could find that helps traders build hot keys for DAS, and teaches how to use advanced DAS features (like account risk settings). Without BBT, I would never have realized the power of DAS, which I am now convinced is the best trading platform out there for day trading (tried most of them without success). This spreadsheet is another example of BBT's leadership in the day trading community. I have struggled for years with how to rapidly compute  position sizing in seconds for a developing setup before I enter a trade; and here it is, in a simple spreadsheet. Now I can double-click where I want my stop loss, send my hot key, and I risk precisely what I specified in the spreadsheet that defined the hot key. Amazing! Thank you BBT! For the first time ever, I have a trading edge; I have accurate defined risk for every trade I take.

Share this post


Link to post
Share on other sites
On 12/4/2018 at 8:18 PM, ragycpa said:

@KyleK29

Thanks for your help Kylek. I signed for two weeks trail on DAS website and they sent me a link to download the platform. When I went to Help——-About it shows the version which is .31. Is it because of the simulator?

That's the official release version. The beta branch is located here: https://www.dastrader.com/download/fixes/DASInstallDEMO.5.2.0.34.exe

I'd recommend making a copy of your current DAS folder before installing that, just as a precaution.


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

Share this post


Link to post
Share on other sites
On 12/4/2018 at 5:33 PM, Martin G said:

@ragycpa

With a 20 cent risk on a $150 stock, you cannot afford the 500 shares.  In this situation the script should calculate the number of shares you can afford to buy at 95% (or other percentage if you changed this on the first sheet in the workbook) of your buying power and send the order for that.  When I tested this for $50 and $100 risk on NVDA with ASK as shown below just now and it worked correctly.  Interestingly, when the hotkey was pressed and the order loaded, the price then changed to 158.27 which apparently would be my average price for the purchase with the ASK offers pictured.

 

ASK AvgPrice.JPG

 

The price you see in the montage is going to be the portion of the script that is used for your limit order, you won't actually see the other values as they occur too quickly.

So what is circled is the calculation of ask + 0.05 --> 158.22 + 0.05 = 158.27.

Re: Your prior example for $50 risk, I was slightly off in my calculation. 

Stop Distance Calculation Portion: Ask - Price + 0.01 --> 21.09 - 20.99 + 0.01 --> .11 --> .11 * 416 = $45.76 risk

However, if you double clicked a fractional (e.g. 20.985), that would have populated 20.98 into the price field, on hotkey execution that would be .11 stop distance + 0.01 offset = $50 / .12 = 416 shares (416.66 with the .66 lopped off).


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

Share this post


Link to post
Share on other sites
On 12/3/2018 at 4:53 PM, Robert H said:

@KyleK29 Thanks for adding the STOP order feature! I will test in simulator and report back. Awesome work on the Stop Order Modifiers, too.

I ran into an issue today while having multiple positions opened. Note I am using the % Equity Risk version of the hotkeys. I believe using the Dollar Risk version may avoid this.

So I opened position 1, risking 1% of my account. My buying power is now reduced by what is used by position 1. All is well.

I open position 2 using the same hotkey as above. However, I am now risking much less than 1% since the calculation is based off available buying power (of course).  This leads to a much smaller position than what was intended. It gets worst if you open a third or fourth position. Note that my buying power is never fully consumed. Each subsequent position is just calculated based off the decreasing available BP.

I'm going to manually calculate 1% of my equity and use the Dollar Risk version. Will report back on results.

I finally got around to testing this today. Yes, it uses the available Buying Power to try and refactor the available equity. This can cause it to be smaller and smaller on subsequent orders. Ideally, we'd want an EQUITY variable to calculate the 1% for all trades equally (those without subsequent buying power would be reduced in the MIN equation), using the BP variable makes it so that it gets inaccurate pretty quickly. 

I've switched all of mine to a flat dollar risk. It helps psychologically as well, since I know in my head what my $risk is. Just have to be more cognizant of your account balance (if live) and update your hotkeys accordingly (so you don't start risking more than 1% unintentionally).

 

I did notice an issue with the automatic STOP order when long on an SSR stock, DAS may block you from scaling out with the stop in place. I went long on AMD today (it was SSR) w/ automatic stop trigger, when I tried to scale out 25% I got rejected for "Short Marketable Limit Order disabled due to SSR!" - DAS calculates that the position size is going to drop below the pending stop order and rejects it because if not updated, the STOP order can convert to a short order (for the balance offset) if triggered. You have to clear the order the order to work around. 

I wish there was a STOP order that did not convert (e.g. do not cross position 0, change with current position).


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

Share this post


Link to post
Share on other sites

Thanks, Kyle.

I found that even using the dollar risk version, the diminishing available BP was still an issue. I'm assuming this is because it still contains the DefShare=BP*X variable.

I've since switched to a more simple version based on @fjmocke original hotkey:

Price=Ask-Price + 0.02;Share=100 / Price;ROUTE=SMRTL;Price=Ask+0.05;TIF=DAY+;BUY=Send

As we know, the downside is being rejected based on insufficient BP. I manage this by copy/pasting my Withhold BP from DAS to Excel.

For some reason I couldn't get the STOP orders to work at all. Maybe I'm doing something wrong.

On behalf of the BBT Team: thanks again for all the work!

Share this post


Link to post
Share on other sites

@KyleK29, this spread sheet is amazing! How did you even come up with codes like these?

Quick Question though. The trigger order for stop loss seems not working. These is no stop loss order sent afterwards. I've tried to set up a hotkey for stop loss orders, but the only post I can find is 

This code is setting the stop trigger price to a set value which is $.30 below the cost, but what if I want to double click the mouse on the chart, and then press the hotkey to set the stop price right there? Can we do that? In that case we can keep changing our stop losses as the price moves.

Please assist.

Thank you.

Share this post


Link to post
Share on other sites

@Sean S, I have no trouble getting the stop orders to trigger using the spreadsheet macros. I found that they work if the Montage is set to style "STOP", and do not work if set to "DEFAULT". Give that a try.

 

montage.png

Share this post


Link to post
Share on other sites
On 12/10/2018 at 1:19 PM, Robert H said:

Thanks, Kyle.

I found that even using the dollar risk version, the diminishing available BP was still an issue. I'm assuming this is because it still contains the DefShare=BP*X variable.

I've since switched to a more simple version based on @fjmocke original hotkey:

Price=Ask-Price + 0.02;Share=100 / Price;ROUTE=SMRTL;Price=Ask+0.05;TIF=DAY+;BUY=Send

As we know, the downside is being rejected based on insufficient BP. I manage this by copy/pasting my Withhold BP from DAS to Excel.

For some reason I couldn't get the STOP orders to work at all. Maybe I'm doing something wrong.

On behalf of the BBT Team: thanks again for all the work!

 

The portion that uses BP in the $Risk is just calculating the maximum affordable shares. Can you do me a favor and post the hotkey, and the DAS version #? I'll poke around it some more to see if I can replicate the issue.

As for the stop, GaryD might be right. I may need to add that to the instructions, I'll test it in a bit.

18 hours ago, Sean S said:

@KyleK29, this spread sheet is amazing! How did you even come up with codes like these?

Quick Question though. The trigger order for stop loss seems not working. These is no stop loss order sent afterwards. I've tried to set up a hotkey for stop loss orders, but the only post I can find is 

This code is setting the stop trigger price to a set value which is $.30 below the cost, but what if I want to double click the mouse on the chart, and then press the hotkey to set the stop price right there? Can we do that? In that case we can keep changing our stop losses as the price moves.

Please assist.

Thank you.

Try GaryD's suggestion. If not, I'll look at it. I know the Trigger order hotkey is very tempermental on whether it'll work or not. So I need to try and replicate the scenarios where it doesn't.

8 hours ago, GaryD said:

@Sean S, I have no trouble getting the stop orders to trigger using the spreadsheet macros. I found that they work if the Montage is set to style "STOP", and do not work if set to "DEFAULT". Give that a try.

 


Good suggestion, forgot about that. I'll test it and update instructions if it's required.


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

Share this post


Link to post
Share on other sites

@KyleK29 and @GaryD,

Thank you for the response. Mine is still not working. Below is the link I got from the spread sheet. The share sizes were calculated accurately, just no stop loss order was sent afterwards.

FocusWindow MONTAGE;StopPrice=Price-0;DefShare=BP*0.99;Share=DefShare*0.25*Price*0.02;Price=Ask-Price+0;SShare=Share/Price;Share=DefShare-SShare;DefShare=DefShare+SShare;SShare=Share;Sshare=DefShare-SShare;Share=0.5*SShare;TogSShare;ROUTE=LIMIT;Price= Ask+0.05;TIF=DAY+;BUY=Send;DefShare=1000;TriggerOrder=ROUTE:STOP;STOPTYPE:MARKET PX:StopPriceSTOPPRICE:StopPrice;Share=Pos;TIF:DAY+ ACT:SELL;

Please assist.

Thank you.

Share this post


Link to post
Share on other sites

@Sean S Yours looks different from mine. Here is mine for "Long with 50% buying power and $20 risk":

StopPrice=Price-0;DefShare=BP*0.5;Price=Ask-Price+0.01;SShare=20/Price;Share=DefShare-SShare;DefShare=DefShare+SShare;SShare=Share;Sshare=DefShare-SShare;Share=0.5*SShare;TogSShare;ROUTE=SMRTL;Price= Ask+0.05;TIF=DAY+;BUY=Send;DefShare=100;TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice STOPPRICE:StopPrice QTY:Pos TIF:DAY+ ACT:SELL;

I simply double-click on the chart (connected to my Montage) where I want my stop, and send the Hot Key. Order is filled and Stop is entered. I found I had to have the Montage set to type "Stop". 

I do not have any FocusWindow command. Also, I am using the fixed $ risk version from the spreadsheet.

Share this post


Link to post
Share on other sites

@GaryD Hi Gary 

I tried changing the Montage style to Stop but the hotkey only sends stop loss on the long side and doesn’t do the same for the short side. Did you experience the hotkey on short and still sent stop order?

Share this post


Link to post
Share on other sites
18 hours ago, Sean S said:

@KyleK29 and @GaryD,

Thank you for the response. Mine is still not working. Below is the link I got from the spread sheet. The share sizes were calculated accurately, just no stop loss order was sent afterwards.

FocusWindow MONTAGE;StopPrice=Price-0;DefShare=BP*0.99;Share=DefShare*0.25*Price*0.02;Price=Ask-Price+0;SShare=Share/Price;Share=DefShare-SShare;DefShare=DefShare+SShare;SShare=Share;Sshare=DefShare-SShare;Share=0.5*SShare;TogSShare;ROUTE=LIMIT;Price= Ask+0.05;TIF=DAY+;BUY=Send;DefShare=1000;TriggerOrder=ROUTE:STOP;STOPTYPE:MARKET PX:StopPriceSTOPPRICE:StopPrice;Share=Pos;TIF:DAY+ ACT:SELL;

Please assist.

Thank you.

Did the spreadsheet create that command, or did you make edits (just need to know if I need to make a fix for the spreadsheet)? The TriggerOrder section shouldn't have ";" as it's technically one command.

Here is what the TriggerOrder portion should look like:

TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice STOPPRICE:StopPrice QTY:Pos TIF:DAY+ ACT:SELL;

Fixed command:

FocusWindow MONTAGE;StopPrice=Price-0;DefShare=BP*0.99;Share=DefShare*0.25*Price*0.02;Price=Ask-Price+0;SShare=Share/Price;Share=DefShare-SShare;DefShare=DefShare+SShare;SShare=Share;Sshare=DefShare-SShare;Share=0.5*SShare;TogSShare;ROUTE=LIMIT;Price= Ask+0.05;TIF=DAY+;BUY=Send;DefShare=1000;TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice STOPPRICE:StopPrice QTY:Pos TIF:DAY+ ACT:SELL;

 

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

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.