Dynamic variables - multiple trades using same hotkey scripts
If you are following the DAS Trader Advanced hotkeys series, you probably understood how messy it can get and how things are going to be complicated once you need to have more trades opened at the same time.
In my previous posts, I have been using the variables like $STOP for toggling the stop loss functionality or $MPRICE for reading the actual price.
Let’s say I want to trade AMD 0.00%↑ long and AAPL 0.00%↑ short at the same time.
If I trade AMD 0.00%↑ in a separate montage window, I can distinguish the variables by the montage number. e.g. $MPRICE_MONTAGE1 or $STOP_MONTAGE1
But this requires to rewrite all the scripts to use the new variables, and if you introduce a new hotkey you have to copy it to the 2nd montage. If you use more than 2 it can get pretty messy and exhausting as the syntax is always critical, and any syntax error can make the thing not work, requires time for troubleshooting etc.
Luckily, we can use dynamic variables too. Instead of simple $STOP we can have
$STOP_AMD or $STOP_AAPL or $STOP_ANYTHING based on any other variable we can read.
In the above example it is Symbol that makes the dynamic part, but it can be also a window name like $STOP_MONTAGE1 or even a trade direction like $STOP_LONG or $STOP_SHORT.
Dynamic variables functions
there are three functions that we can use, one is for setting the variable name, another one is for retrieving it. The third function is to delete them. Actually all the functions can be used for normal variables as well.
SetVar() GetVar() DelVar()
The description of these functions by DAS is like this
The problem is that the documentation is not correct and contains typo and the provided example usage does not work.
Keep reading with a 7-day free trial
Subscribe to Peter’s Substack to keep reading this post and get 7 days of free access to the full post archives.