Coding Forum Collaborate, receive help, or discuss indicators and other coding-related topics

11-20-2016, 12:13 PM   #1

Join Date: Feb 2010
Posts: 44

Thanks: 0
Thanked 7 Times in 7 Posts

Need Help with ThinkOrSwim's ThinkScript

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);

11-10-2017, 12:42 AM   #2

Join Date: Apr 2016
Posts: 97

Thanks: 0
Thanked 3 Times in 3 Posts

Re: Need Help with ThinkOrSwim's ThinkScript

 Thread Tools Display Modes Help Others By Rating This Thread Linear Mode Help Others By Rating This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 ∧ Similar Threads Thread Thread Starter Forum Replies Last Post Jovani Trading Indicators 0 03-04-2015 02:10 PM orangamurang Coding Forum 2 09-08-2014 03:26 AM Tradewinds Trading Indicators 6 02-18-2013 09:48 PM simmi196 Coding Forum 0 10-18-2012 09:37 PM stinkystank Coding Forum 1 11-23-2010 09:48 AM

### Website Terms

All times are GMT -4. The time now is 12:17 AM.