Help with very basic ThinkScript Strategy - ThinkOrSwim Programming |...
1 of 4
User Name
Forums
Password
Register
Log in
Downloads / Indicators
Elite Members
Forgot
[Link]
New User Signup (free)
Trading Webinars / Videos
Today's Posts
Wiki
Big Mike's Trading Forum > Trading Forums > Platforms and Indicators > ThinkOrSwim > ThinkOrSwim Programming
Help with very basic ThinkScript Strategy
Notices
AMP FUTURES vs BIG MIKE TRADING
This is a public notice that AMP GLOBAL CLEARING aka AMP FUTURES has filed a lawsuit against BMT regarding posts on BMT.
Help with very basic ThinkScript Strategy
Started:
November 28th, 2011 (02:55 PM) by snipsta
Views / Replies:
2,530 / 6
Last Reply:
August 6th, 2013 (09:52 PM)
Attachments:
Welcome to Big Mike's Trading Forum.
Welcome, Guest!
This forum was established to help traders by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.
BMT is fundamentally different than most other trading forums:
We
We
We
We
work extremely hard to keep things positive on our forums.
do not tolerate rude behavior, trolling, or vendor advertising in posts.
firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
expect our members to participate and become a part of the community. Help yourself by helping others.
You'll need to register in order to view the content of the threads and start contributing to our community. It's free and simple, and we will never resell your
private information.
-- Big Mike
Thread Tools
Search this Thread
Help with very basic ThinkScript Strategy
November 28th, 2011, 02:55 PM
#1 (permalink)
snipsta
Help with very basic ThinkScript Strategy
Trading Apprentice
Tampa,Florida
Hello,
Trading Experience: Intermediate
Platform: ThinkorSwim
Favorite Instrument: Stocks/Options
Posts: 2 since Nov 2011
Thanks: 0 given, 0 received
I am new to this forum and thinkscript but I am picking it up quick as I have prior programming experience. I'm trying to create a
basic strategy with the criteria shown below. I created the code off a modified version of the parabolicsarcrossover study so I am
confused why this is not working. No plot is being shown even though I can see this criteria occurring by manually looking at the
daily. My code to date is shown below each criteria. Any assistance is appreciated. Thank you
Long Entry (Daily chart, market hours)
----Parabolic SAR(.02,.2) becomes bullish
-MACD(12,26,9,EMA) crosses above 0
4/20/2014 11:08 PM
Help with very basic ThinkScript Strategy - ThinkOrSwim Programming |...
2 of 4
[Link]
Code
###########
declare LONG_ENTRY;
input opentime = 0930;
input closetime = 1600;
# Only enter during market hours:
#
def AP = getAggregationPeriod();
def daily = if AP >= [Link] then 1 else 0;
def isopen = if daily then 1 else if secondsFromTime(opentime) >= 0 and secondsTillTime(closetime) >= 0 then 1 else 0;
input accelerationFactor = 0.02;
input accelerationLimit = 0.2;
input crossingType = {default Bullish, Bearish};
def sar = ParabolicSAR(accelerationFactor=accelerationFactor, accelerationLimit=accelerationLimit);
def psarcrossover = if crosses(sar, close, CrossingType == [Link]) then 1 else 0;
def macdCrossover = if Crosses(MACDHistogram(12, 26, 9, "EMA"), 0, [Link]) then 1 else 0;
def total = psarcrossover + macdCrossover;
def trigger = if total == 2 then 1 else 0;
def price = close;
addOrder(trigger, price);
# Formatting:
#
SetColor([Link]);
Long Close (Daily chart, market hours)
--Parabolic SAR(.02,.2) becomes bearish
-MACD(12,26,9,EMA) crosses below 0
Code
###########
declare LONG_EXIT;
input opentime = 0930;
input closetime = 1600;
# Only enter during market hours:
#
def AP = getAggregationPeriod();
def daily = if AP >= [Link] then 1 else 0;
def isopen = if daily then 1 else if secondsFromTime(opentime) >= 0 and secondsTillTime(closetime) >= 0 then 1 else 0;
input accelerationFactor = 0.02;
input accelerationLimit = 0.2;
input crossingType = {default Bearish, Bullish};
def sar = ParabolicSAR(accelerationFactor=accelerationFactor, accelerationLimit=accelerationLimit);
def psarcrossover = if crosses(sar, close, CrossingType == [Link]) then 1 else 0;
def macdCrossover = if Crosses(MACDHistogram(12, 26, 9, "EMA"), 0, [Link]) then 1 else 0;
def total = psarcrossover + macdCrossover;
def trigger = if total == 2 then 1 else 0;
def price = close;
addOrder(trigger, price);
# Formatting:
#
SetColor([Link]);
November 28th, 2011, 03:05 PM
Cloudy
trade2winmils
desert CA
#2 (permalink)
Last I checked which was about a few months ago, strategies, while being able to be parsed in Thinkscript, still doesn't work on
TOS. The development resources seemed to have moved on to Prodigio.
Trading Experience: Beginner
Platform: NT7, ThinkOrSwim
Broker/Data: AMP/Commodity Quote
Graphics (CQG), TDAmeritrade
Favorite Instrument: CL, 6E, 6J, stock
options
Posts: 1,771 since Jul 2011
Thanks: 1,848 given, 1,273 received
4/20/2014 11:08 PM
Help with very basic ThinkScript Strategy - ThinkOrSwim Programming |...
3 of 4
[Link]
November 28th, 2011, 03:09 PM
#3 (permalink)
snipsta
Trading Apprentice
Tampa,Florida
Trading Experience: Intermediate
Platform: ThinkorSwim
Favorite Instrument: Stocks/Options
Cloudy
Last I checked which was about a few months ago, strategies, while
being able to be parsed in Thinkscript, still doesn't work on TOS. The
development resources seemed to have moved on to Prodigio.
Posts: 2 since Nov 2011
Thanks: 0 given, 0 received
First off, thanks for the extremely quick reply. While I am new to TOS I have
created/modified some other very basic strategies and they seem to work fine. I
believe my problem is with the syntax of the parabolic sar as I have created
strategies with the MACD with no problems.
November 29th, 2011, 05:55 AM
Cloudy
#4 (permalink)
Your welcome. Nice to hear strategies are working now, thanks. I may take a look sometime and try out what you posted.
trade2winmils
desert CA
Last edited by Cloudy; November 29th, 2011 at 06:09 AM.
Trading Experience: Beginner
Platform: NT7, ThinkOrSwim
Broker/Data: AMP/Commodity Quote
Graphics (CQG), TDAmeritrade
Favorite Instrument: CL, 6E, 6J, stock
options
Posts: 1,771 since Jul 2011
Thanks: 1,848 given, 1,273 received
January 13th, 2013, 06:58 PM
abooter69
#5 (permalink)
might try adding these....
Trading Apprentice
Las Vegas, nv
Trading Experience: Beginner
Platform: thinkorswim
Favorite Instrument: Free Money
AddOrder(OrderType.BUY_AUTO,trigger name, no, tickcolor = GetColor(1), arrowcolor = GetColor(6), name = "BUY");
AddOrder(OrderType.SELL_AUTO,trigger name, no, tickcolor = GetColor(1), arrowcolor = GetColor(5), name = "SELL");
Posts: 1 since Dec 2012
Thanks: 0 given, 0 received
March 23rd, 2013, 05:31 AM
RedK
Knowledge Seeker
Dubai, UAE
Trading Experience: Intermediate
Platform: TOS, TradeStation
Broker/Data: OX, TradeStation
Favorite Instrument: Stocks & Basic
Options
#6 (permalink)
took a quick look and I don't like this line:
def psarcrossover = if crosses(sar, close, CrossingType == [Link]) then 1 else 0;
CrossingType is an enumerated variable (like an array basically), you assign its value in the study settings, but then pass it to the
crosses() function.. and it will not mean anything to it, where it expects an actual direction (Above, Below)? would be surprised if
that line doesn't produce a script error.. but that's where I would look to change. the next line to it sounds OK.
hope this helps,
K
Posts: 167 since May 2012
Thanks: 44 given, 127 received
August 6th, 2013, 09:52 PM
#7 (permalink)
4/20/2014 11:08 PM
Help with very basic ThinkScript Strategy - ThinkOrSwim Programming |...
4 of 4
[Link]
Cloudy
trade2winmils
desert CA
Cloudy
Trading Experience: Beginner
Platform: NT7, ThinkOrSwim
Broker/Data: AMP/Commodity Quote
Graphics (CQG), TDAmeritrade
Favorite Instrument: CL, 6E, 6J, stock
options
Your welcome. Nice to hear strategies are working now, thanks. I may take a look sometime and try out what you
posted.
my post later
Posts: 1,771 since Jul 2011
Thanks: 1,848 given, 1,273 received
Top of Page
Tags
array, auto trade, basic, change, chart, close, code, color, create, daily, day, development, direction, ema, enter, entry, error, exit, format, function, limit, line, lot, macd, market,
market hours, open, parabolic, parabolic sar, period, platform, plot, price, prodigio, programming, sar, script, settings, strategies, strategy, syntax, tax, thank you, think or swim,
thinkorswim, thinkscript, time, tos, trade, variable
Big Mike's Trading Forum > Trading Forums > Platforms and Indicators > ThinkOrSwim > ThinkOrSwim Programming > Help with very basic ThinkScript Strategy
ATR percentage | Accessing current row value in volume profile?
Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
ThinkScript studies
c0ol2
ThinkOrSwim
April 8th, 2014 12:50 PM
ThinkScript (TOS) Programming Question
Curbfeeler
ThinkOrSwim Programming
April 23rd, 2012 06:43 PM
ThinkScript: Three Line Break
StockJock
ThinkOrSwim Programming
December 16th, 2010 11:10 AM
Thinkscript Volatility Indicator
tosmonkey
ThinkOrSwim Programming
November 29th, 2010 04:29 PM
All times are GMT -4. The time now is 12:03 AM.
Register an account (free)
BMT Charities and Contests
Big Mike's Day Trading Blog
FuturePath Trading (Broker)
FXCM App Store
Jigsaw Trading (Trading Software)
Optimus Futures (Broker)
Kinetick (Data Feed Provider)
IQFeed (Data Feed Provider)
NinjaTrader (Trading Platform)
CTS T4 (Trading Platform)
New MT4 (Trading Platform)
Powered by vBulletin
Copyright 2000 - 2014, Jelsoft Enterprises Ltd.
SEO by vBSEO 2011, Crawlability, Inc.
Copyright 2014 by Big Mike Trading. All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
Contact Us - Disclaimer, Terms of Use, and Terms and Conditions - Privacy Policy - Downloads - Top
Page generated 2014-04-21 in 0.26 seconds with 19 queries on phoenix via your IP [Link]
4/20/2014 11:08 PM