Jump to content
Matt

The R target calculation in hotkey

Recommended Posts

Posted (edited)

Hello,

I saw in one of @peterB's posts on is Blog that it's possible to add lines with hotkeys in DAS. I would like to add target lines for my 1R and 2R target dynamically when I take a position.

I tried adding code to Kyle's Hotkey without success.

Can someone tell me what's wrong with this code?

If you have any suggestions for improvement, that would be great.

Thank you!

 

StopPrice=Price-0.01;
$STOP=Price-0.01;
DefShare=BP*0.97;
Price=Ask-Price+0.01;
SShare=600/Price;
Share=DefShare-SShare;
DefShare=DefShare+SShare;
SShare=Share;
Sshare=DefShare-SShare;
Share=0.5*SShare;
TogSShare;
ROUTE=LIMIT;
Price= Ask+0.05;
$PRICE = Ask;
TIF=DAY;
BUY=Send;DefShare=400;
TriggerOrder=RT:STOP STOPTYPE:MARKET PX:StopPrice-0.3 ACT:SELL STOPPRICE:StopPrice QTY:Share TIF:DAY;

$TARGETR=$PRICE-$STOP;
$RISKONE=$PRICE+$TARGETR;
$RISKTWO=$PRICE+($TARGETR*2);
FocusWidow TRADEFIVEMINUTES;
DrawHorzLineWithPrice($RISKONE);
DrawHorzLineWithPrice($RISKTWO);

 

Edited by Matt

Share this post


Link to post
Share on other sites
Posted (edited)
$PRICE+($TARGETR*2);

this is not possible in DASTrader as it dooes not know the mathematical logics and brackets

you need to do

$PRICE+$TARGETR+$TARGETR

instead

see the log for the errors you get. there will be an error about route not being "LIMIT" etc.

overall you should switch to the new syntax and forget the old one as the calculations done in the old syntax are now useless and it will be easier for you to understand what is going on rather than studying why the switches between SShare and Share are there

Edited by peterB
  • Like 1

Share this post


Link to post
Share on other sites

Ok! Thz @peterB  It help a lot.

I did not find on the DAS website any documentation on the new syntax. Do you have anything?

I will use your blog for reference for now.

Share this post


Link to post
Share on other sites
Posted (edited)

I use the "BBT 3 month SIM" subscribtion. I try some of the hotkeys on your blog and this is not working. I will have to stay with the old syntax.

 

image.png.75610f35dca062eb72f48d7e65dac97d.png

Edited by Matt

Share this post


Link to post
Share on other sites

you can use the new syntax for orders but specifically this line drawing has been fixed in 5.7.9.3 only

Share this post


Link to post
Share on other sites

Hi PeterB , is there a way one can test to see if the current symbol is a stock or an option for example with the Advanced hotkeys?  where can one find some literature on the commands plz ?

Share this post


Link to post
Share on other sites

SYMBOL is a symbol it does not matter what it is for the order preparation on montage so i think there is no way to determine it (now)

documentation is very vague in the application itself in the hotkeys section. better documentation with some explanation and examples is here https://traderpeter.substack.com/s/dastrader-hotkeys

Share this post


Link to post
Share on other sites
Posted (edited)

Hello Matt and Peter, 
I had the exact same question. Thanks for posting it. I saw your script and tried to duplicate it. But I'm having trouble with the DrawHorzLineWithPrice() script. No matter what I do, I can't get this script to draw a line. the one without the parentheses works okay, but it's limited. Any advice? For example, does it not work in Replay mode? I did check the box in Other Configuration, to enable Advanced Hot Key Scripts, but that didn't work either. Thanks for any insight you can give.

Edited by Daniel Blue

Share this post


Link to post
Share on other sites
15 hours ago, Daniel Blue said:

Hello Matt and Peter, 
I had the exact same question. Thanks for posting it. I saw your script and tried to duplicate it. But I'm having trouble with the DrawHorzLineWithPrice() script. No matter what I do, I can't get this script to draw a line. the one without the parentheses works okay, but it's limited. Any advice? For example, does it not work in Replay mode? I did check the box in Other Configuration, to enable Advanced Hot Key Scripts, but that didn't work either. Thanks for any insight you can give.

well it depends on what and how you do.

the function can be called only when your chart window is in focus so if you do it as a hot button you need to change focus in the hot button first with

FocusWindow MYDAILY;

for that your chart window needs to be named first as by default the chart windows do not have names

by the way from the latest beta 5.7.9.7 we can use colors for the lines as well

DrawHorzLineWithPrice($YOUR_DESIRED_PRICE,color(190,254,152));

 

Share this post


Link to post
Share on other sites
On 6/11/2024 at 8:53 PM, ITO said:

Hi PeterB , is there a way one can test to see if the current symbol is a stock or an option for example with the Advanced hotkeys?  where can one find some literature on the commands plz ?

in the last beta 5.7.9.3 there is a function

IsOptSymbol(symbol) but i am not sure how it is supposed to be used as i do not trade options with DAStrader

Share this post


Link to post
Share on other sites

Thanks Peter, I tried it with the focuswindow, and I do see that window taking the focus, but the trendline still isn't being drawn. Nothing I do makes the trendline drawn. So strange. If i put a round number in there for the variable, it works. But if i use 'last' or any variable, it doesn't work.

$TPRICE=Last; DrawHorzLineWithPrice ($TPRICE);

FocusWindow ActiveTradingWindow; $TPRICE=Last; DrawHorzLineWithPrice ($TPRICE);

Neither of them work.  Any thoughts?

Share this post


Link to post
Share on other sites
Posted (edited)

which version of dastrader you have?

is your $tprice populated with last or not? 

see the log file in the log folder for any errors

also note that you need to try it when the market is open (including pre and post market) otherwise LAST will be 0 

Edited by peterB

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.