Help with very basic ThinkScript Strategy - ThinkOrSwim Programming | futures io social day trading
futures io futures trading


Help with very basic ThinkScript Strategy
Updated: Views / Replies:6,184 / 6
Created: by snipsta Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 90,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We 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.

-- Big Mike, Site Administrator

Reply
 
Thread Tools Search this Thread
 

Help with very basic ThinkScript Strategy

  #1 (permalink)
Trading Apprentice
Tampa,Florida
 
Futures Experience: Intermediate
Platform: ThinkorSwim
Favorite Futures: Stocks/Options
 
Posts: 2 since Nov 2011
Thanks: 0 given, 0 received

Help with very basic ThinkScript Strategy

Hello,

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

 
Code
###########
declare LONG_ENTRY;
input opentime = 0930;
input closetime = 1600;

# Only enter during market hours:
#
def AP = getAggregationPeriod();
def daily = if AP >= aggregationPeriod.DAY 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 == CrossingType.Bullish) then 1 else 0;

def macdCrossover = if Crosses(MACDHistogram(12, 26, 9, "EMA"), 0, crossingdirection.above) 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(color.green);
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 >= aggregationPeriod.DAY 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 == CrossingType.Bearish) then 1 else 0;

def macdCrossover = if Crosses(MACDHistogram(12, 26, 9, "EMA"), 0, crossingdirection.below) 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(color.red);

Reply With Quote
 
  #2 (permalink)
Elite Member
desert CA
 
Futures Experience: Intermediate
Platform: NT7, TOS
Broker/Data: AMP/wCQG, TDA
Favorite Futures: CL,YM
 
Posts: 2,027 since Jul 2011
Thanks: 2,211 given, 1,551 received

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.

Reply With Quote
 
  #3 (permalink)
Trading Apprentice
Tampa,Florida
 
Futures Experience: Intermediate
Platform: ThinkorSwim
Favorite Futures: Stocks/Options
 
Posts: 2 since Nov 2011
Thanks: 0 given, 0 received



Cloudy View Post
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.

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.

Reply With Quote
 
  #4 (permalink)
Elite Member
desert CA
 
Futures Experience: Intermediate
Platform: NT7, TOS
Broker/Data: AMP/wCQG, TDA
Favorite Futures: CL,YM
 
Posts: 2,027 since Jul 2011
Thanks: 2,211 given, 1,551 received

Your welcome. Nice to hear strategies are working now, thanks. I may take a look sometime and try out what you posted.


Last edited by Cloudy; November 29th, 2011 at 07:09 AM.
Reply With Quote
 
  #5 (permalink)
Trading Apprentice
Las Vegas, nv
 
Futures Experience: Beginner
Platform: thinkorswim
Favorite Futures: Free Money
 
Posts: 1 since Dec 2012
Thanks: 0 given, 0 received

might try adding these....


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

Reply With Quote
 
  #6 (permalink)
Knowledge Seeker
Dubai, UAE
 
Futures Experience: Intermediate
Platform: TOS, TradeStation
Broker/Data: OX, TradeStation
Favorite Futures: Stocks & Basic Options
 
RedK's Avatar
 
Posts: 171 since May 2012
Thanks: 44 given, 138 received

took a quick look and I don't like this line:
def psarcrossover = if crosses(sar, close, CrossingType == CrossingType.Bearish) 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

Reply With Quote
 
  #7 (permalink)
Elite Member
desert CA
 
Futures Experience: Intermediate
Platform: NT7, TOS
Broker/Data: AMP/wCQG, TDA
Favorite Futures: CL,YM
 
Posts: 2,027 since Jul 2011
Thanks: 2,211 given, 1,551 received


Cloudy View Post
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

Reply With Quote

Reply



futures io > > > > > Help with very basic ThinkScript Strategy

Thread Tools Search this Thread
Search this Thread:

Advanced Search



Upcoming Webinars and Events (4:30PM ET unless noted)

Jigsaw Trading: TBA

Elite only

FuturesTrader71: TBA

Elite only

NinjaTrader: TBA

Jan 18

RandBots: TBA

Jan 23

GFF Brokers & CME Group: Futures & Bitcoin

Elite only

Adam Grimes: TBA

Elite only

Ran Aroussi: TBA

Elite only
     

Similar Threads
Thread Thread Starter Forum Replies Last Post
ThinkScript (TOS) Programming Question Curbfeeler ThinkOrSwim Programming 10 March 8th, 2016 04:19 PM
ThinkScript studies c0ol2 ThinkOrSwim 5 April 8th, 2014 01:50 PM
ThinkScript: Three Line Break StockJock ThinkOrSwim Programming 0 December 16th, 2010 12:10 PM
Thinkscript Volatility Indicator tosmonkey ThinkOrSwim Programming 4 November 29th, 2010 05:29 PM


All times are GMT -4. The time now is 01:15 PM.

Copyright © 2017 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432, info@futures.io
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.
no new posts
Page generated 2017-12-16 in 0.10 seconds with 19 queries on phoenix via your IP 54.91.38.173