Reading indicator values in scripts
In DAS Trader Pro the indicators are called “studies,” so I will be using the name “studies” from now on.
Everybody knows the studies like moving averages or VWAP. Below I will describe how those studies can be read and used in DAS Trader Pro scripts.
To read the value of a study, there is a dedicated function called getstudyval()
getstudyval()
Get the last value of a study by name, or get the study’s info string by bar number or datetime. For example,
GetStudyVal(studyname, ByBarNum, -3)
will return the study info string at the third bar before the last bar. (The info string is the same as that displayed on the chart tip window when left clicked.)
GetStudyVal(studyname, ByDateTime, "2025/03/14 09:30:00")
will get the info string at 9:30 bar.
GetStudyVal(studyname)
will simply return a single value at the latest bar.
If your studies are ordered in this way, the info string box will show them in the same order

Reading the current/last value of a study
Use cases
- Conditional entries – allow entry only if a moving average is above VWAP
- Custom indicators or semaphores – This has been described in the previous post https://www.guardiantrading.com/das-trader-pro-a-simple-green-light-for-entries/
Example
// check if price is below or above vwap
if($montage.LAST<getstudyval("studyVWAP"))
{
// display message
msgbox("No longs if price is below VWAP");
// end the script (optional)
return;
}
else
// otherwise run the standard entry code
{
$MONTAGE=GetWindowObj("MONTAGE1");
$MONTAGE.CXL ALLSYMB;
$buyprice=$MONTAGE.Ask;
$risk=GetAccountObj($MONTAGE.ACCOUNT).openEQ/800;
$mystop=$MONTAGE.price;
setvar("STOP_"+SYMB,$MYSTOP);
$pricetostop=$buyprice-$mystop;
$target=3*$pricetostop+Ask;
$amount=$risk/$pricetostop;
$MONTAGE.Share=$amount;
$MONTAGE.ROUTE="LIMIT";
$MONTAGE.Price=Round($buyprice,2);
$MONTAGE.TIF=DAY+;
$MONTAGE.BUY;
$MONTAGE.TriggerOrder=RT:STOP STOPTYPE:RANGEMKT LowPrice:$mystop HighPrice:$target ACT:SELL QTY:POS TIF:DAY+;
}
Reading the studies by time from the past
Use cases
- Backtesting – looking at the situation in the past bar by bar
- Calculating custom indicators and studies – e.g. what is the average volume of the last 10 candles?
Example
This code will show you the VWAP value of the exact time and date
msgbox(GetStudyVal("StudyVWAP", ByDateTime, "2026/05/29 09:31:00"));
Note that the time can be defined in multiple formats. Valid formats are
- HH/MM/SS
- HH:MM:SS
- YYYY/MM/DD HH:MM:SS
- YYYY/MM/DD HH/MM/SS
- EPOCH TIME (e.g. 1780047060)
The epoch time is the one that is allowing us to jump the candles bar by bar, as we can easily add or substract the chart time from the epoch time – e.g. 60 for the next 1-min candle.
If the time format is wrong, the last value of the study is read.
Showing is not reading
Unfortunately, the historical values are read and shown as strings. Meaning that from the above example, the value you get is not the VWAP value, but it is the “VWAP: 125.315” as a whole string.
To get the value in a number format, we need to use some extraction techniques.
For this purpose I have written a simple function to extract the value of VWAP
// read the VWAP value
$VWAPEXTRACT=GetStudyVal("StudyVWAP", ByDateTime, "2026/05/29 09:31:00");
//determine length
$LENGTH=strlen($VWAPEXTRACT);
//exit if 0
if($LENGTH==0)
{return;}
$MATMP=SubString($VWAPEXTRACT,6,$LENGTH-1);
$EXTR_VWAP=ROUND($MATMP,3);
First I read the length of the string because VWAP: 125.315 is longer than VWAP:3.785.
Then I use a temporary variable MATMP which trims the text from position 6 until the end of the string, depending on its length. The -1 at the end is there because the string length is calculated from 1, while the position of the characters is calculated from 0, so a length of 10 ends at position 9.
The number 6 means that we are reading from position 6 – after the 5 characters of VWAP:.
While being trimmed, the value in MATMP is still a string/text so to convert it, it is passed to the ROUND() function, which converts it to a number, as explained in the previous post https://www.guardiantrading.com/das-trader-pro-rounding/
The resulting value in the EXTR_VWAP is a clean number 125.315, which can then be further used for calculations and comparisons.
