Jump to content
KyleK29

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

Recommended Posts

1 hour ago, Romell Roberts said:

1. For "Send a stop trigger order" I selected True. If I do this, does it automatically setup a stoploss without me needing to double click anywhere? for example, an automatic stoploss at 2% below my entry point?

2. I selected 1250$ as my dollar risk, does this mean it will take my stoploss into account and buy as many shares as possible with ~1250$ being the most I can lose?Or do I have to select the number of shares?

 

1. No, setting this to true is what enables a stop loss to be triggered by double clicking on the chart. Not having it enabled with still send your order with the correct shares and risk based on where you double click, but no stop will be placed. This hotkey doesn't do stop losses by percentage points.

2. If your risk is set to $1250, and you enable "Send a stop trigger order", then technically what you will lose is around $1250. There are a few other things to consider that will make that number a bit larger, such as commissions and slippage. Also you would be wise to use a Market stop order - The slippage can be larger, but if you choose a Limit stop and the stock suddenly jumps outside your Limit range, your loss could technically be infinite until you exit out manually.

A side note, it's not recommend to risk much more than 1% of your account, so I hope your equity (not your margin) is $125,000+.

  • Like 1

Share this post


Link to post
Share on other sites
1 hour ago, Justin said:

1. No, setting this to true is what enables a stop loss to be triggered by double clicking on the chart. Not having it enabled with still send your order with the correct shares and risk based on where you double click, but no stop will be placed. This hotkey doesn't do stop losses by percentage points.

2. If your risk is set to $1250, and you enable "Send a stop trigger order", then technically what you will lose is around $1250. There are a few other things to consider that will make that number a bit larger, such as commissions and slippage. Also you would be wise to use a Market stop order - The slippage can be larger, but if you choose a Limit stop and the stock suddenly jumps outside your Limit range, your loss could technically be infinite until you exit out manually.

A side note, it's not recommend to risk much more than 1% of your account, so I hope your equity (not your margin) is $125,000+.

Thanks for your response, that clears up a few things for me, I do plan on just using a cash account when I first start but that could change depending on how things go.  

 

In theory, could I put in more than 1% of my total equity, but have an automatic stoploss (market stop order?) that'll stop me out if I make the wrong choice and lose more than 2%? Like, what if my spending power is 25,000$, and I put in 1250 with a stoploss 2% below my point of entry, doesn't it become approximately a 25$ risk? I know it won't equal exactly 25$ if I'm stopped out due to commissions and slippage, but I think a hotkey setup like this would still keep my potential losses far below 1% (250$) of my total equity while giving me significantly higher potential gains. 

Ideally, the way the hotkey would work would be for it to allow me to edit in the amount of money I'm willing to spend, and have it divide the cost of shares into that amount, and buy as many as I can afford, then automatically add a market stop order at a predetermined percentage when I make the trade. Would something like that be possible?



 

Share this post


Link to post
Share on other sites

Thanks a lot for the Hotkeys. They have been really helpful. I am using flat $50 stop loss and it calculates the position accordingly and sets stop loss. Then I can partial out if it goes in my favour and stop loss moves to breakeven. And finally I use a hotkey to exit all. 

I want to understand, how to scale-in a position. Say its long that I wanna target. And I have taken a position with $20 risk and then it starts to go in my favour and I want to top it up. So overall risk may now be 40.  But I think, in my current setup, it would add another order with another $20 risk rather than averaging out. Here are the keys I am using:

Long:

Step 1: Long with $20 risk per trade WITH Stop Loss
StopPrice=Price-0;DefShare=BP*0.925;Price=Ask-Price+0.00;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=200;TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice-0.05 ACT:SELL STOPPRICE:StopPrice QTY:Pos TIF:DAY+;
 
Step 2: Sell 25% of your position when long and cancel the current stop, and reset it with remaining position at break even.
CXL ALLSYMB;ROUTE=LIMIT;Price=BID-0.05;Price=Round2;Share=Pos*.25;TIF=DAY+;SELL=Send;ROUTE=STOP;StopType=Market;StopPrice=AvgCost;Share=Pos-share;TIF=GTC;SELL=SEND
 
Can repeat Step 2. multiple times.
 
Step3: Last Step: Sell all + cancel all the orders for the current ticker
CXL ALLSYMB;ROUTE=LIMIT;Price=BID-0.05;Price=Round2;Share=Pos;TIF=DAY+;SELL=Send
 
 
Short:
Step 1: Short with $20 risk per trade WITH Stop Loss
StopPrice=Price+0;DefShare=BP*0.925;Price=Price-Bid+0.00;SShare=20/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=200;TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice+0.05 ACT:BUY STOPPRICE:StopPrice QTY:Pos TIF:DAY+;
 
Step 2: Cover 25% of your position when short and cancel the current stop, and reset it with remaining position at break even.
CXL ALLSYMB;ROUTE=LIMIT;Price=ASK+0.05;Price=Round2;Share=Pos*.25;TIF=DAY+;BUY=Send;ROUTE=STOP;StopType=Market;StopPrice=AvgCost;Share=Pos+share;TIF=GTC;BUY=SEND
 
Step3: Last Step: Cover all and cancel all the orders for the current ticker
CXL ALLSYMB;ROUTE=LIMIT;Price=ASK+0.05;Price=Round2;Share=Pos;TIF=DAY+;BUY=Send

Share this post


Link to post
Share on other sites
On 3/6/2020 at 9:21 PM, Atomspapa said:

Hey Kyle and community,

 

SOOOOO. I have installed the scripts for your hotkeys and the With BP at 97% of equity with a stop of $150. It is calculating 6 shares and on long buy button (hotkey) iand the short is triggering buys at like 3 shares. One time it did calculates the position correctly at 1666 shares of AMD but that seemed to be a fluke.  I copied and pasted both scripts so I am not sure where the error is. Can somebody give a looksee and tell me what I am missing? 

Here is the long:

DefShare=BP*0.97;Price=Ask-Price+0.01;SShare=150/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=400;

 

Here is the short:

DefShare=BP*0.97;Price=Price-Bid+0.01;SShare=150/Price;Share=DefShare-SShare;DefShare=DefShare+SShare;SShare=Share;Sshare=DefShare-SShare;Share=0.5*SShare;TogSShare;ROUTE=LIMIT;Price=Bid-0.05;TIF=DAY+;SELL=Send;DefShare=400;

 

Also can I add some code to ensure this executes on my live rather than my demo account? 

Shannon

I'm not sure if you're still around Shannon, but those hotkeys look correct. Did you generate them via the Excel or use them from somewhere else? Miscalculations can happen usually from two things -- 1) Accidentally fired a long order with a short hotkey (double-clicked above the price action on a long order) or 2)  The estimated Buying Power factor isn't correct for your broker. IBCO and DEMO are 4:1, but CMEG can be as high as 6:1 or sometimes 3:1 .. it's why it's important to use the Excel sheet for those scenarios. 

I'd need the log files to properly see what's happening on that.

 

On 3/7/2020 at 12:58 PM, Yann said:

Hi Marek and Kyle,

Have you found a solution to this?  Because this is exactly what I'd like to be able to do too.

I'm using Kyle's hotkey script to buy a number of shares at market calculated on risk defined in the script and stop defined by double-click on the chart.

Now if there was a way to place a limit order by using an additional double-click in this process, anywhere, or split the process in 2 hotkeys to make it work, that would be just perfect.

Thanks!

 

I have an assortment of requests in with DAS to address stuff like this, they were accepted, but I don't know when development would begin.

 

On 3/23/2020 at 10:03 AM, Throne said:

Guys the hotkeys are working flawless for me, but I got a silly question when Im using the scaling in and out hotkeys do I need to cancel the the stop lost in order for them to take? I cant get the scale out hotkey specifically to work  properly.

 

I'll be doing a video set on using the Scale-In hotkeys since a (currently in testing) update will add a few of them (Refactor Risk Scale-In, and Thor's Free Roll Scale-In) and I know users could use a little more guidance on their usage. In general, if you change the position (scale-in or scale-out/take-profit), you have to update the Stop. There currently isn't an option for DAS to do this for you. I've requested additions to be added to make this much easier in the future.

 

16 hours ago, Girish Kumar said:

 

LONG
Step 2: Sell 25% of your position when long and cancel the current stop, and reset it with remaining position at break even.
CXL ALLSYMB;ROUTE=LIMIT;Price=BID-0.05;Price=Round2;Share=Pos*.25;TIF=DAY+;SELL=Send;ROUTE=STOP;StopType=Market;StopPrice=AvgCost;Share=Pos-share;TIF=GTC;SELL=SEND
 
 
SHORT
Step 2: Cover 25% of your position when short and cancel the current stop, and reset it with remaining position at break even.
CXL ALLSYMB;ROUTE=LIMIT;Price=ASK+0.05;Price=Round2;Share=Pos*.25;TIF=DAY+;BUY=Send;ROUTE=STOP;StopType=Market;StopPrice=AvgCost;Share=Pos+share;TIF=GTC;BUY=SEND
 

 

You're better off using a Trigger Order for the second portion of that, they have the distinct advantage of being able to get data values in the future. Like this:

LONG:

CXL ALLSYMB; ROUTE=LIMIT; PRICE=BID-0.05; PRICE=Round2; Share=Pos*0.25; TIF=DAY+; SELL=Send; TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice+0.3 ACT:SELL STOPPRICE:AvgCost QTY:Pos TIF:DAY+;


SHORT:

CXL ALLSYMB;ROUTE=LIMIT;Price=ASK+0.05;Price=Round2;Share=Pos*.25;TIF=DAY+;BUY=Send; TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice+0.3 ACT:BUY STOPPRICE:AvgCost QTY:Pos TIF:DAY+;

As a note, this Trigger order doesn't use the PX value at all, but it's there to prevent some errors in certain versions. Also, there's specific hotkeys for adding additional risk to an existing position. They'll be covered in a video when I finish the new hotkey for Thor and I'll go over how to scale-in.

 

On 5/2/2020 at 7:24 PM, Justin said:

....

Special thanks to Justin and the other members who have been helping in this thread. I don't always make it back in a timely manner, so I really appreciate it! 

Edited by KyleK29
  • Like 1

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

Share this post


Link to post
Share on other sites
24 minutes ago, KyleK29 said:

Special thanks to Justin and the other members who have been helping in this thread. I don't always make it back in a timely manner, so I really appreciate it! 

Anything to ease your work load Kyle. You are not allowed to leave this community! 😂

  • Like 1

Share this post


Link to post
Share on other sites
48 minutes ago, KyleK29 said:

Special thanks to Justin and the other members who have been helping in this thread. I don't always make it back in a timely manner, so I really appreciate it! 

Cross-posting a bug that may be in v2.1-

 

  • Like 1

Share this post


Link to post
Share on other sites

Hi @KyleK29.  First of all thank you so much for not just the syntax but the cumbersome data assembly in excel.  I really appreciate it and I'm sure that everyone else does too. 

I'm having an elementary problem here trying to replicate the fixed $risk hotkey with a live stop.  I keep getting !Invalid Shares error.  I apologize if someone else has solved this same problem - I checked the other two instances of people experiencing similar !Share issues but their problems didn't seem a bit different.  I hope you can give me some direction.  Thank you so much. 

 

Assumptions:

Cash balance: $1,000

Risk per trade: $5 or ½%

Leverage multiplier: 3.3333333

 

Output from Excel:

;CXL ALLSYMB;StopPrice=Price+0.01; DefShare=1000*3.3333333*0.97;Price=Price-Bid+0.01;SShare=5/Price;Share=DefShare-SShare;DefShare=DefShare+SShare;SShare=Share;Sshare=DefShare-SShare;Share=0.5*SShare;TogSShare;ROUTE=LIMIT;Price=Bid-0;TIF=DAY+;SELL=Send;DefShare=100;TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice+0 ACT:BUY STOPPRICE:StopPrice QTY:Pos TIF:DAY+;

 

Broken down:

1

;CXL ALLSYMB;

Cancels existing stops in case this hotkey is used to add to an existing position (that already has a live stop) so that it can wrap up the new position in a new stop at the end.

Side note: I did manually add this one line to the original excel output. 

2

StopPrice=Price+0.01;

 

3

DefShare=5100*3.3333333*0.97;

Discounts 3% intentionally.

4

Price=Price-Bid+0.01;SShare=5/Price;

Assuming ‘SShare=5’ here means $5 risk per trade.

5

Share=DefShare-SShare;

 

6

DefShare=DefShare+SShare;

 

7

SShare=Share;

 

8

Sshare=DefShare-SShare;

 

9

Share=0.5*SShare;

 

10

TogSShare;

 

11

ROUTE=LIMIT;

 

12

Price=Bid-0;

 

13

TIF=DAY+;

 

14

SELL=Send;

 

15

DefShare=100;

 

16

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

Now the only stop order should reflect not just this entry but the whole position. 

 

Share this post


Link to post
Share on other sites

Hey @forkey, something is wrong with your hotkey if you got that from Kyle’s spreadsheet. 
 

The DefShare=1000*3.3333333*0.97 portion of your hotkey should look like this: 

DefShare=BP*0.97;Share=DefShare*0.333*Price*0.005

I’m not sure what’s going wrong, but I’d go back to the first post and download it again.

Share this post


Link to post
Share on other sites

Hi @Justin.  I followed your recommendations and downloaded the spreadsheet again. 

My intention is to take Kyle’s buy order with a 1.0% max risk live stop, and make it 1. add liquidity, 2. on ARCAL, and 3. cancel any existing orders on the symbol beforehand.  In what step did I go wrong?

Step

Hotkey

Notes

1

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

Spreadsheet output

2

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

Now routes to ARCA

 

 

3

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

Now adds liquidity on bid

4

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

 

Now cancels existing orders beforehand

 

 

This below 4:1 profit taker order also generated an error.  Does anything look obvious?

Step

Hotkey

Notes

1

Route=Limit;Share=Pos*0.25;Price=AvgCost-StopPrice;Price=Price*1.25;Price=Price+AvgCost;Price=Round2;TIF=DAY+;SELL=Send

Spreadsheet output

2

Route=ARCAL;Share=Pos*0.25;Price=AvgCost-StopPrice;Price=Price*1.25;Price=Price+AvgCost;Price=Round2;TIF=DAY+;SELL=Send

Now routes to ARCA

3

Route=ARCAL;Share=Pos*1.00;Price=AvgCost-StopPrice;Price=Price*1.25;Price=Price+AvgCost;Price=Round2;TIF=DAY+;SELL=Send

Now sells the whole position

4

Route=ARCAL;Share=Pos*1.00;Price=AvgCost-StopPrice;Price=Price*4.00;Price=Price+AvgCost;Price=Round2;TIF=DAY+;SELL=Send

Now sells at 4:1

 

1.     Can the above entry and 4:1 profit taker hotkeys be combined into one single hotkey?  Can it become an OCO?

2.     Does !Invalid shares mean that the syntax is good but the account does not contain sufficient BP to execute?

 

 

Thank you so much @KyleK29, @Justin & community.

Edited by forkey
misspelling
  • Like 1

Share this post


Link to post
Share on other sites

@forkey  The layout is awesome...makes learning for ppl reading very easy....thks 

i will let the experts answer the questions.

Share this post


Link to post
Share on other sites

Hi fellow traders,

I'm very interested in using these hotkeys.

Can anyone tell me where to find the spreadsheet? 

Thx!

Share this post


Link to post
Share on other sites
3 hours ago, Peter de Beir said:

Hi fellow traders,

I'm very interested in using these hotkeys.

Can anyone tell me where to find the spreadsheet? 

Thx!

Hi @Peter de BeirKyle generously posted the downloadable link on the first page of this thread.  At the bottom of the page it will let you navigate to the first page of this thread.  I hope this helps. 

Share this post


Link to post
Share on other sites
On 5/23/2020 at 9:20 AM, forkey said:

1.     Can the above entry and 4:1 profit taker hotkeys be combined into one single hotkey?  Can it become an OCO?

2.     Does !Invalid shares mean that the syntax is good but the account does not contain sufficient BP to execute?

1. Maybe.... I’d have to stare at my screen and think for a good few hours 😛 Will have to wait until the markets are open to give it a shot. I’ll let you know.

2. It’s possible. The hotkey looks good now. Have you tried cranking your BP to something extreme in SIM to test?

Edited by Justin

Share this post


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

Hi @Peter de BeirKyle generously posted the downloadable link on the first page of this thread.  At the bottom of the page it will let you navigate to the first page of this thread.  I hope this helps. 

Thanks, it works!

Share this post


Link to post
Share on other sites

Thanks @Justin


 

I think the original problem derived from DAS assuming BP leverage is 4:1 and IB is 3.3333:1 so I will just discount the BP in the syntax to 75% or something like I denoted in the first post: DefShare=BP*0.75; 

 

If I wanted to hard code in the SIM account into these hotkeys, would it twice throughout the syntax because there are two orders like below in red?

 

CXL ALLSYMB; StopPrice=Price-0.01;DefShare=BP*0.75;Share=DefShare*0.99*Price*0.01;Price=Ask-Price+0.01;SShare=Share/Price;Share=DefShare-SShare;DefShare=DefShare+SShare;SShare=Share;Sshare=DefShare-SShare;Share=0.5*SShare;TogSShare;ROUTE=ARCAL;Price= Bid+0;TIF=DAY+; ACCOUNT=ABCDEFG ;BUY=Send;DefShare=100;TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice-0 ACT:SELL STOPPRICE:StopPrice QTY:Pos TIF:DAY+; ACCOUNT=ABCDEFG;

 

Edited by forkey

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.