Visitors Now:
Total Visits:
Total Stories:
Profile image
By Traders Laboratory
Contributor profile | More stories
Story Views

Now:
Last Hour:
Last 24 Hours:
Total:

Need Help with ThinkOrSwim’s ThinkScript

Sunday, November 20, 2016 10:06
% of readers think this story is Fact. Add your two cents.

(Before It's News)

I’m attempting to learn and apply the fold command in TOS, but my code is not plotting correctly. Could someone take a look at it and get it to work? I know how to code DO LOOPS in basic language and I’m having trouble doing it in TS. One problem that I have with this is controlling the increments in the iteration. I don’t get any syntax errors, but this code does not plot correctly and I cannot figure out why. It should plot horizontal lines at different levels.

************************* ************************* ***
def HAV = HighestAll(High);
def LAV = LowestAll(Low);

input Direction = {default GridUp, GridDown};
input n = 4;

#
# ========================= ========================= ==========
# SWITCH BETWEEN DIRECTIONS
# ========================= ========================= ==========
#
def Mode;

switch (Direction)
{
case GridUp:
Mode = 1;
case GridDown:
Mode = 0;
}

def StartPoint = if Mode == 1 then LAV else HAV;

plot GannLine = fold i = 1 to n
with j = 45
do if Mode == 1 then Sqrt(StartPoint) + ((i * j)/180)
else Sqrt(StartPoint) – ((i * j)/180);

Report abuse

Comments

Your Comments
Question   Razz  Sad   Evil  Exclaim  Smile  Redface  Biggrin  Surprised  Eek   Confused   Cool  LOL   Mad   Twisted  Rolleyes   Wink  Idea  Arrow  Neutral  Cry   Mr. Green

Top Stories
Recent Stories

Register

Newsletter

Email this story
Email this story

If you really want to ban this commenter, please write down the reason:

If you really want to disable all recommended stories, click on OK button. After that, you will be redirect to your options page.