♥ 0 |
Hey Pete, Thanks a bunch for your help in the past with thinkscript! I recently switched to Tradestation and was wondering if you had a way to convert a CompoundValue code from thinkscript into Easy Language (see below): def Date = GetYYYYMMDD(); if (DayRoll) { This is a component of thinkscript’s VWAP study that I’m trying to incorporate into a strategy on tradestation that rolls VWAP on a 1min chart to show new statistics off of the opening of each trading session. Thanks in advance for your help! -Zach
Marked as spam
|
Private answer
I can show you how to convert one as an example. Let's take this line of code from the section of code you provided:
We can get all the details about how this function works here: https://toslc.thinkorswim.com/center/reference/thinkScript/Functions/Others/CompoundValue All it really does is to initialize the variable with a value at the bar number listed in the first parameter. The second parameter is the value for every bar after that. The third parameter is the value used to initialize at the bar number in the first parameter. Confused? You should be. But in plain English, CompoundValue() is merely the tool thinkScript uses to initialize a recursive variable. In practice, you will find it is rarely needed. You can create a recursive variable without it. And in 99.9% of cases it will work just fine. Experience tells you when that 0.1% comes into play. But for those that work with more standardized computer language the EasyLanguage version will actually make things much more clear. All we do is create an if/then/else statement. First checking if the BarNumber is the first bar on the chart. Then we initialize the variable with a value of our choosing. In the else section of that statement we assign the value we want to use for every bar after BarNumber 1. Here is is in EasyLanguage:
Once you get used to the thinkScript method of initializing recursive variables you realize how efficient that structure is, compared to it's equivalent in other languages. Try writing that EasyLanguage form in a single line of code. It can be done but it's a real mess. Marked as spam
|
Please log in to post questions.