DAS Trader Pro Advanced Hotkeys part 55
Function to extract the past value of any moving average

Since the version 5.8.1.3 there is a possibility to extract the study value from the past.
This is very good news because we can now script (some limited) automated back testing mechanisms.
It is very limited and contains some bugs and imperfections, but it is possible to use it to retrieve useful data for further use which I am going to show you how.
The current limits are
it can still retrieve only studies that return a single number values (like MA, EMA, ATR, PSAR)
the last value is always a decimal
while the back in the time returned value is always a string which needs further data extraction mechanisms (this very post is going to show)
the returned string value differs with each study (which needs study specific approach for data extraction)
the time cannot be specified in epoch time, so calculations are quite hard and require even more complex data manipulation (this is a generic problem of the whole DAS Trader Pro today, not just this function)
the bar needs to be displayed on the chart
I have reported them all to DAS so hopefully they will accept my notes and implement fixes in the future releases.
The basic functionality
As shown already in my previous post
GetStudyVal() usage is
GetStudyVal("MY_MOVING_AVERAGE_NAME")
To show me the value of a moving average named “MYEMA11” I need to name the study and the chart window which is showing the study.
getwindowobj("MY1MIN").getstudyval("MYEMA11");
is the code that reads my moving average from my chart.
To display it I can do
MsgBox(getwindowobj("MY1MIN").getstudyval("MYEMA11"));
to show the value of the red line or just simply store it in a variable like this:
$MYVARIABLE=getwindowobj("MY1MIN").getstudyval("MYEMA11");
Which will retrieve the study value as a decimal (number)
"XX.XXX"
Back in time usage
A little bit of explanation first. If you click on the candle you will get info like this
Notice the AVG and VWAP values which correspond to the studies placed to your chart. They are displayed in the very same order, so the first one is MYEMA11, then my SMA(200) etc.
The values shown on the candle are the ones we can read with the newly added function.
How to read the data from the past
the basic usage is
getstudyval("STUDY_NAME",ByDateTime, "20250808 14:11:00");
Which will retrieve the study name from the time specified in a string (text)
" AVG:XX.XXX "
The function to automate the extraction.
The data extraction function consists of
cleanup variables
addressing the candle by time
addressing the study by name
extracting the value of the study
extracting the study value as a text
converting the study value to a decimal number
storing the number in a variable
It assumes the existence of the montage object $MONTAGE as described before
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.