See the other posts about DASTrader hotkeys too: Part1 Part2 Part3 Part4
Static risk with 1% of your Account and attached range (OCO) orders of 3R target
This requires DASTrader 5.7.9.3 or newer
To accomplish static 1% risk per trade I read the Account object
$myACC=GetAccountObj(“YOUR_ACCOUNT_NAME_HERE”);
and then count 1% of it, dividing it by 100.
$risk=$myACC.Equity/100;
You can read any account name you have in DASTrader then use that risk for trading other account. This is useful to mimic the risk based on real account while trading the demo account as it will open position based on the real account value.
For risking 0.5% of your account size, use division by 200. (100/0.5=200)
For risking 2% of your account size, use division by 50. (100/2=50)
For more clarity I set few variables which are not necessary for the functionality, but it is easier to understand what is going on in the hotkey.
!!!Do not forget to change the text YOUR_ACCOUNT_NAME_HERE for your account name!!!
For a long position, double-click on the chart where the desired stop loss price is and press the hotkey:
CXL ALLSYMB;
$buyprice=Ask;
$myACC=GetAccountObj(“YOUR_ACCOUNT_NAME_HERE”);
$risk=$myACC.Equity/100;
$mystop=price;
$pricetostop=$buyprice-$mystop;
$target=3*$pricetostop+Ask;
$amount=$risk/$pricetostop;
StopPrice=$mystop;
StopPrice=ROUND2;
SShare=$amount;
Share=$amount;
TogSShare;
ROUTE=LIMIT;
Price=$buyprice;
Price=ROUND2;
TIF=DAY+;
BUY=Send;
TriggerOrder=RT:STOP STOPTYPE:RANGEMKT LowPrice:$mystop HighPrice:$target ACT:SELL QTY:POS TIF:DAY+;
$buyprice=Ask;
$myACC=GetAccountObj(“YOUR_ACCOUNT_NAME_HERE”);
$risk=$myACC.Equity/100;
$mystop=price;
$pricetostop=$buyprice-$mystop;
$target=3*$pricetostop+Ask;
$amount=$risk/$pricetostop;
StopPrice=$mystop;
StopPrice=ROUND2;
SShare=$amount;
Share=$amount;
TogSShare;
ROUTE=LIMIT;
Price=$buyprice;
Price=ROUND2;
TIF=DAY+;
BUY=Send;
TriggerOrder=RT:STOP STOPTYPE:RANGEMKT LowPrice:$mystop HighPrice:$target ACT:SELL QTY:POS TIF:DAY+;
For a short position, double-click on the chart where the desired stop loss price is and press the hotkey:
CXL ALLSYMB;
$buyprice=Bid;
$myACC=GetAccountObj(“YOUR_ACCOUNT_NAME_HERE”);
$risk=$myACC.Equity/100;
$mystop=price;
$pricetostop=$mystop-$buyprice;
$target=Bid-$pricetostop-$pricetostop-$pricetostop;
$amount=$risk/$pricetostop;
ROUND2;
StopPrice=$mystop;
SShare=$amount;
Share=$amount;
TogSShare;
ROUTE=LIMIT;
Price=$buyprice;
TIF=DAY+;
SELL=Send;
TriggerOrder=RT:STOP STOPTYPE:RANGEMKT LowPrice:$target HighPrice:$mystop ACT:BUY QTY:POS TIF:DAY+;
$buyprice=Bid;
$myACC=GetAccountObj(“YOUR_ACCOUNT_NAME_HERE”);
$risk=$myACC.Equity/100;
$mystop=price;
$pricetostop=$mystop-$buyprice;
$target=Bid-$pricetostop-$pricetostop-$pricetostop;
$amount=$risk/$pricetostop;
ROUND2;
StopPrice=$mystop;
SShare=$amount;
Share=$amount;
TogSShare;
ROUTE=LIMIT;
Price=$buyprice;
TIF=DAY+;
SELL=Send;
TriggerOrder=RT:STOP STOPTYPE:RANGEMKT LowPrice:$target HighPrice:$mystop ACT:BUY QTY:POS TIF:DAY+;
Note: for the demo account you might need to use the account name without the quotes.
Read any indicator value and display it in a window.
This can be useful if you want to know the exact number of an indicator that you want to use as your stop loss.
we need to name the indicator in a chart
the indicators have default names for each chart, and they are the same across charts, so let’s rename the StudyVWAP to 5minVWAP
Read the indicator value into a variable
This needs to be done on the same chart window
In the chart configure, scroll down to the Update script section and add
$MYVWAP=GetStudyVal("5minVWAP");
4. Use the variable in any hotkey you want. If you want to use it for a stop loss order, use the newly created variable $MYWAP as the input for your order.
TriggerOrder=RT:STOP STOPTYPE:RANGEMKT LowPrice:$target HighPrice:$MYVWAP ACT:BUY QTY:POS TIF:DAY+;
Remember this will be static so, at the time of the hotkey press, the value will be set and not changed. I will cover the topic of the dynamically changing stop orders in one of the next articles.
Show the numeric distance to an indicator
Let’s say you want to calculate some distance to an indicator. For this example, I will use VWAP I used in the example above
Use the variable in any calculation you want.
To calculate the distance of last price to vwap use the following formula
$MYDISTANCE=$MYVWAP-LAST;
Display the calculation
MsgBox($MYDISTANCE);
Obviously, you can do directly the calculation in the MsgBox function
MsgBox($MYVWAP-LAST);
You can also read your variable name in a Variables window which can be now part of your saved desktop too.
If you find yourself in any trouble dealing with the hotkeys, do not hesitate to ask in the comments under this post or PM me.