TOS def statement in DarvasBox study


Category:
0
0

Pete: I came cross a confusing def statement in the source code of DarvasBox, a TOS study  .

First line def defines “state” with a few alternatives

The second line merely indiactes  variable names “upper” and “lower” in the statement without assigning anything

and the third def statement already uses the prior bar values of upper and lower which were not assigned to anything so far.

Is it possible to help me understand how these work and what they are doing.

Thanks

SourceCode DarvasBox Study

def state = {default state_1, state_2, state_3, state_4, state_5};

def upper;
def lower;

def prevLower = CompoundValue(1, lower[1], low);
def prevUpper = CompoundValue(1, upper[1], high);

….

Thanks

Arun Rao

Marked as spam
Posted by (Questions: 11, Answers: 16)
Asked on October 25, 2018 10:38 am
681 views
0
Private answer

You left out all the important parts. This is a very advanced technique used in several studies in Thinkorswim.

def state = {default state_1, state_2, state_3, state_4, state_5};

That is what’s termed “an enumerated variable”. I didn’t find an example in Thinkorswim’s language reference but I did find an example using an “enumerated input”: http://toslc.thinkorswim.com/center/reference/thinkScript/Reserved-Words/input/enum.html

The values for:

def upper;
def lower;

Are assigned within the switch/case statement. The switch/case statement reads and sets the value of the enumerated variable “state”. Read more about the switch/case statement here: http://toslc.thinkorswim.com/center/reference/thinkScript/Reserved-Words/switch.html

If this explanation left you more confused than when you started than just drop it for now. This is far to complex a topic to fully explain in the Q&A forum.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on October 25, 2018 11:22 am
0

Thanks Pete. I will follow the links you provided above and see if I can understand.

( at October 27, 2018 7:34 pm)