First Script Help - ThinkOrSwim | futures trading

Go Back

> Futures Trading, News, Charts and Platforms > Platforms and Indicators > ThinkOrSwim

First Script Help
Started:July 5th, 2016 (11:05 AM) by samvent Views / Replies:172 / 0
Last Reply:July 5th, 2016 (11:05 AM) Attachments:0

Welcome to

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • 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, and we will never resell your private information.

-- Big Mike

Thread Tools Search this Thread

First Script Help

Old July 5th, 2016, 11:05 AM   #1 (permalink)
Trading Apprentice
Normal Il USA
Futures Experience: Beginner
Platform: ThinkorSwim
Favorite Futures: Bond Futures
Posts: 1 since Jul 2016
Thanks: 0 given, 0 received

First Script Help

I am attempting to write my first script and need some help. A simple indicator to follow trend changes.
I want to adjust the timeframe independent of the chart, but can't seem to figure out how to add the time period to my plot. Any help would be appreciated.

declare lower;
input TimeFrame1 = {default "5 min", "10 min", "15 min", "20 min"};
def Aggregation1;
def range = (hl2[5] + hl2[4] + hl2[3] + hl2[2] + hl2[1] + hl2) / 6;
def uptrend = (if close > range then 1 else 0);
def downtrend = if close <= range then 1 else 0;

switch (TimeFrame1) {
case "5 min":
Aggregation1 = AggregationPeriod.FIVE_MIN;
case "10 min":
Aggregation1 = AggregationPeriod.TEN_MIN;
case "15 min":
Aggregation1 = AggregationPeriod.FIFTEEN_MIN;
case "20 min":
Aggregation1 = AggregationPeriod.TWENTY_MIN;

def timeFrame = GetAggregationPeriod();
def testTimeFrames = if timeFrame < Aggregation1 then yes else no;
AddLabel(yes, if testTimeFrames then "Time Frames Are Correct" else "Time Frames Are Wrong", if testTimeFrames then Color.GREEN else Color.RED);

plot Trend1 = if uptrend then 1 else Double.NaN;
plot Trend2 = if downTrend then 1 else Double.NaN;

Reply With Quote

Reply > Futures Trading, News, Charts and Platforms > Platforms and Indicators > ThinkOrSwim > First Script Help

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

An Afternoon with FIO trader bobwest

Elite only

NinjaTrader 8: Programming Profitable Trading Edges w/Scott Hodson

Elite only

Anthony Drager: Executing on Intermarket Correlations & Order Flow, Part 2

Elite only

Adam Grimes: Five critically important keys to professional trading

Elite only

Machine Learning Concepts w/FIO member NJAMC

Elite only

MarketDelta Cloud Platform: Announcing new mobile features

Dec 1

NinjaTrader 8: Features and Enhancements

Dec 6

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with a think script problem johnzhou20 ThinkOrSwim 0 November 29th, 2015 05:53 AM
Can I get the script of this Indicator? khalid alshalan ThinkOrSwim 8 April 6th, 2014 02:19 PM
Option Script bobp ThinkOrSwim Programming 2 August 7th, 2012 06:42 PM
Need little help with a Ninjatrader script raindrop NinjaTrader Programming 9 April 20th, 2011 10:35 PM
script idea sharky NinjaTrader Programming 64 November 15th, 2009 05:05 PM

All times are GMT -4. The time now is 04:20 PM.

Copyright © 2016 by 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 2016-10-21 in 0.07 seconds with 19 queries on phoenix via your IP