Jump to content

We have moved to Discord. Please click here to join us in the Trading Terminal Discord server.



These forums are read-only.

Alex Dumitrache

Issue with Fixed Risk Hotkey in DAS — Not Buying Correct Share Size

Recommended Posts

Alex Dumitrache

Hey everyone, I need some help with a fixed risk hotkey I’m using in DAS.

My goal is:

  • Risk a fixed dollar amount (e.g., $100).

  • Buy (or short) the maximum number of shares based on:

    • My stop loss (selected by double‑clicking on the chart).

    • My available buying power.

Here’s the hotkey I’m currently using for long entries:

StopPrice=Price-0;
DefShare=BP*0.925;
Price=Ask-Price+0.00;
SShare=98/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+

and for Short:

StopPrice=Price+0; 
DefShare=BP*0.925; 
Price=Price-Bid+0.00; 
SShare=98/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+
 

The Problem

When my stop is very tight (usually less than $1 away from entry), DAS calculates the wrong share size.

Current Example (short trade):

  • Buying Power: $40,000

  • Entry: $320.33

  • Stop: $321.13 (double‑clicked)

  • Risk: $0.80 per share

  • Risk I want: $100

  • Shares DAS actually bought: 71

Math check:

  • 71 shares × $320.33 = $22,743 (almost half of my BP)

  • 71 shares × $0.80 = $56.8 risk

  • Should have been closer to 100 shares (to risk ~$100)

So instead of hitting my defined risk, DAS under‑allocates shares when the stop is tight.


What I Need Help With

I’m looking for a clean hotkey script that:

  • Risks a fixed dollar amount (e.g., $100).

  • Correctly sizes the position based on the distance to my stop (no matter how tight).

  • Respects available buying power.

Has anyone solved this issue or can help me rewrite the script correctly?

Thanks in advance!

Share this post


Link to post
Share on other sites
peterB
Share=0.5*SShare; 

the 0.5 means half. if you want whole size remove the 0.5* from the equation.

you have several steps that guarantee you will not risk $100 neither use 100% of the BP

for better hotkeys go here

Edited by peterB

Share this post


Link to post
Share on other sites

[[Template core/front/global/mobileNavigation is throwing an error. This theme may be out of date. Run the support tool in the AdminCP to restore the default theme.]]

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.