Jump to content
KyleK29

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

Recommended Posts

Thanks Kyle for all the work you put into this.

 

Is there a way to create a script that throws on a dollar amount stop loss, say $100, onto any open positions?

 

Thanks in advance 

Share this post


Link to post
Share on other sites
37 minutes ago, Atomspapa said:

Thanks Kyle for all the work you put into this.

 

Is there a way to create a script that throws on a dollar amount stop loss, say $100, onto any open positions?

 

Thanks in advance 

I use Kyle's keys to put a $ stop loss on a position before I enter it, you shouldnt put a stop on an already open position, too easy to have imaginary stop loss 😄 

Share this post


Link to post
Share on other sites

@KyleK29 Thank you for this man! I am wondering if you could point me in the right direction for changing the stop limits to trailing stop. I'd like to see how the trailing stop strategy works for me. Any tips would be appreciated. Thanks Kyle. 

Share this post


Link to post
Share on other sites

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? 

20200307_141932.thumb.png.91eb69412ea2e56acdd467cc1cd00704.png20200306_212312.thumb.png.71b938a61d2a1f339a1498a7d0c6a883.pngHere 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

Edited by Atomspapa
needed pic

Share this post


Link to post
Share on other sites
On 12/25/2019 at 4:08 PM, Marek Liyanage said:

Hi Kyle,

I love your scripts and started using them a few days ago  in SIM and expect to use them in my hot account some time soon. Great stuff!

Would it be possible to place limit orders at a user defined level using any other price entry fields to define a risk level?

I looked a little bit into this with the help of my son who has a little programming/scripting knowledge....since there's 2 price variables we need to define (risk, entry levels) to perform the calculations out idea was to store price in an intermediary field using a master hot key (e.g. risk level) and then using a second double-click for the entry price which would be used to perform the limit order at a user defined entry level. The problem he had with this was that while he could use the Share field as an intermediary it's not really practical because of the lack of INTEGER to FLOAT convertibility when moving that number back to the price field.

Not sure whether this makes sense....but that was the best we could come up with...maybe Kyle or someone else versed in scripting has some idea to get around this issue or has an independent way of defining such an order.

 

Thanks

 

Marek

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!

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

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.