Jump to content
KyleK29

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

Recommended Posts

It's been a while since I used a hard stop but I believe that that is what I found as well. 


---------------------------------------------------------------------------------------------------------------------------------------------------------------------
People that spend their time telling others what can't be done only annoy those of us out there doing it.

 

Share this post


Link to post
Share on other sites
55 minutes ago, 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.

You technically don't need to cancel and reset the stop loss, but if you don't and the price goes against you, you'll suddenly be in a flipped position. This scenario will happen:

You are 100 shares long at $15
You have a stop loss sell order set for 100 shares at $14.90
You partial 50 shares at $15.50
It goes back to your stop loss, and you're suddenly 50 shares short.
 
This will cancel your stop loss and reset it to breakeven with the correct remaining shares:
 
CXL ALLSYMB;Route=Stop;Price=AvgCost;StopType=MARKET;STOPPRICE=AvgCost;StopPrice=Round2;Share=Pos;TIF=DAY+;Send=Reverse;
Edited by Justin
  • Like 1

Share this post


Link to post
Share on other sites
3 hours ago, Justin said:

You technically don't need to cancel and reset the stop loss, but if you don't and the price goes against you, you'll suddenly be in a flipped position. This scenario will happen:

You are 100 shares long at $15
You have a stop loss sell order set for 100 shares at $14.90
You partial 50 shares at $15.50
It goes back to your stop loss, and you're suddenly 50 shares short.
 
This will cancel your stop loss and reset it to breakeven with the correct remaining shares:
 
CXL ALLSYMB;Route=Stop;Price=AvgCost;StopType=MARKET;STOPPRICE=AvgCost;StopPrice=Round2;Share=Pos;TIF=DAY+;Send=Reverse;

Thanks for responding  Justin,  do you know know the scaling hotkeys should work with the stops?  Im tracking on what you said with the flipped positions, thanks. I just would like to scale in and out if without taking the stop out if i can.

Share this post


Link to post
Share on other sites
19 minutes ago, Throne said:

Thanks for responding  Justin,  do you know know the scaling hotkeys should work with the stops?  Im tracking on what you said with the flipped positions, thanks. I just would like to scale in and out if without taking the stop out if i can.

So you're asking If you are long and want to scale out 50% without touching your Stop Loss?

That could be something like this:

Route=LIMIT;Share=Pos*0.5;Price=Bid-0.05;TIF=DAY+;SELL=Send;

Short would be:

Route=LIMIT;Share=Pos*0.5;Price=Ask+0.05;TIF=DAY+;BUY=Send

 

Share this post


Link to post
Share on other sites
16 minutes ago, Justin said:

So you're asking If you are long and want to scale out 50% without touching your Stop Loss?

That could be something like this:

Route=LIMIT;Share=Pos*0.5;Price=Bid-0.05;TIF=DAY+;SELL=Send;

Short would be:

Route=LIMIT;Share=Pos*0.5;Price=Ask+0.05;TIF=DAY+;BUY=Send

 

THanks Justin I try these and see if I can get them working.

  • Like 1

Share this post


Link to post
Share on other sites
1 minute ago, Throne said:

THanks Justin I try these and see if I can get them working.

Great. Note that you can change the Route to Market and Price to Bid, for whatever your preference is on getting out of a position.

Share this post


Link to post
Share on other sites
22 minutes ago, Justin said:

Great. Note that you can change the Route to Market and Price to Bid, for whatever your preference is on getting out of a position.

FYI  Justin this is the script I was trying to use out of the spreadsheet, Im with CMEG.

Scale- In POS % 50% Long:

DefShare=BP*0.97;Share=Pos;SShare=Share *0.5;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;

Scale-Out POS % 50% SHort:

Route=LIMIT;Share=Pos*0.5;Price=Ask+0.05;TIF=DAY;BUY=Send

 

Share this post


Link to post
Share on other sites
4 minutes ago, Throne said:

FYI  Justin this is the script I was trying to use out of the spreadsheet, Im with CMEG.

Scale- In POS % 50% Long:

DefShare=BP*0.97;Share=Pos;SShare=Share *0.5;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;

Scale-Out POS % 50% SHort:

Route=LIMIT;Share=Pos*0.5;Price=Ask+0.05;TIF=DAY;BUY=Send

 

Ah yes, I do believe you remove the + on DAY for CMEG.

But if you are using that script for Long, you need to use the other script I gave you to Scale out and sell 50% of your position:

Route=LIMIT;Share=Pos*0.5;Price=Bid-0.05;TIF=DAY;SELL=Send;

Also note, if you are trying to use the hotkey right now, it doesn't work well (or at all) during the market close or in the Replay function 😕

Share this post


Link to post
Share on other sites

Hi, I'm about 3 days into my DAS demo and I want to make sure I'm understanding this correctly...

I setup my HotKey and this is what I got:

StopPrice=Price-0.01;DefShare=BP*1;Share=DefShare*1*Price*0.05;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=LIMIT;Price= Ask+0.05;TIF=1min;BUY=Load;DefShare=100;TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice-0.3 ACT:SELL STOPPRICE:StopPrice QTY:Pos TIF:DAY+;

I just had a couple questions.

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?

 

Share this post


Link to post
Share on other sites
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

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.