Welcome to the Traders Laboratory.

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

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

Stock.Jock's Avatar

Join Date: Feb 2010
Posts: 44
Ignore this user

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);
Stock.Jock is offline  
Reply With Quote
Old 11-10-2017, 12:42 AM   #2

Join Date: Apr 2016
Posts: 97
Ignore this user

Thanks: 0
Thanked 3 Times in 3 Posts

Re: Need Help with ThinkOrSwim's ThinkScript

No idea about this script, for which purpose we use it?
CrazyCzarina is offline  
Reply With Quote

Reply

Tags
thinkorswim, thinkscript

Thread Tools
Display Modes Help Others By Rating This Thread
Help Others By Rating This Thread:

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can Anyone Code This Indicator in Thinkscript for Me? Jovani Trading Indicators 0 03-04-2015 02:10 PM
How to Lock Thinkscript at TOS Platform orangamurang Coding Forum 2 09-08-2014 03:26 AM
Support and Resistance Channels - ThinkScript Tradewinds Trading Indicators 6 02-18-2013 09:48 PM
ThinkScript Scan Code Stocks on Near Previous Day Low simmi196 Coding Forum 0 10-18-2012 09:37 PM
Thinkscript - Highlighting Reversal Periods stinkystank Coding Forum 1 11-23-2010 09:48 AM

All times are GMT -4. The time now is 12:17 AM.
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
CS to VB integration by DeskLancer
2006-2011 Traders Laboratory, All Rights Reserved.