Welcome to the Traders Laboratory.

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

Reply
Old 11-20-2016, 11:13 AM   #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

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 01:10 PM
How to Lock Thinkscript at TOS Platform orangamurang Coding Forum 2 09-08-2014 02:26 AM
Support and Resistance Channels - ThinkScript Tradewinds Trading Indicators 6 02-18-2013 08:48 PM
ThinkScript Scan Code Stocks on Near Previous Day Low simmi196 Coding Forum 0 10-18-2012 08:37 PM
Thinkscript - Highlighting Reversal Periods stinkystank Coding Forum 1 11-23-2010 08:48 AM

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