Creating custom conditional orders using thinkscript - futures io
futures io



Creating custom conditional orders using thinkscript


Discussion in ThinkOrSwim

Updated
    1. trending_up 1,559 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 1 posts
    2. attach_file 0 attachments




Welcome to futures io: the largest futures trading community on the planet, with well over 125,000 members
  • Genuine reviews from real traders, not fake reviews from stealth vendors
  • Quality education from leading professional traders
  • We are a friendly, helpful, and positive community
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts
  • We are here to help, just let us know what you need
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

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

 
Search this Thread
 

Creating custom conditional orders using thinkscript

(login for full post details)
  #1 (permalink)
skivis
Taipei, Taiwan
 
 
Posts: 1 since May 2019
Thanks: 0 given, 0 received

Hi guys,

I am trying to create a custom conditional order using thinkscript. The idea is to sell an existing positon if the latest closing price is lower than the lowest price in the previous bar.

The code I currently have is pretty straightforward:
close < low from 1 bar ago

It appears that if I don't define the aggregation period, the system uses daily aggregation per bar. However, I would like to be able use this conditional order in other time frames such as 15 minute, 30 minute...etc., but I'm confused about how to set the aggregation period.

Using 15 minute as the aggregation period as an example, I'm assuming I have to put the code "AggregationPeriod.FIFTEEN_MIN" somewhere, but I keep getting errors in the thinkscript editor.

Any help would be appreciated, thanks.

Reply With Quote

Journal Challenge April 2021 results (now extended!):
Competing for $1800 in prizes from Jigsaw
looks_oneMaking a Living with the Microsby sstheo
(182 thanks from 22 posts)
looks_twoSalao's Journalby Salao
(51 thanks from 11 posts)
looks_3Deetee’s DAX Trading Journal (time based)by Deetee
(38 thanks from 18 posts)
looks_4Learning to Profit - A journey in algorithms and optionsby Syntax
(15 thanks from 13 posts)
looks_5Maybe a little bit different journalby Malykubo
(14 thanks from 15 posts)
 
Best Threads (Most Thanked)
in the last 7 days on futures io
Big Mike in Ecuador
76 thanks
The Crude Dude Oil Trading System
63 thanks
Would You Sell Your System?
51 thanks
Help improve the FIO community
36 thanks
futures io site changelog and issues/problem reporting
26 thanks
 
(login for full post details)
  #2 (permalink)
 kjhosken 
Seattle, WA/USA
 
Experience: Intermediate
Platform: TOS, TS
Trading: Forex, crude
 
Posts: 90 since Sep 2016
Thanks: 7 given, 32 received

The default time is whatever your chart is, unless this is a scan, in which case, yes the default is daily. You can customize scans to use timeframes other than daily without writing script for it, but the data is wonky, so I'd caution against it if you need it for reliability. But back to how to use aggregation period, here is an example:

 
Code
input aggperiod = aggregationPeriod.FIFTEEN_MIN;

def c = close(period = aggperiod);
def l = low(period = aggperiod);
def condition = c < l[1]; 

addOrder(OrderType.Sell_to_close, condition);
One other thing to note on using the aggregation function you must use a chart in a lower time frame than what your calling for (you can't aggregate a 15 minute candle from a daily, for instance, but you can aggregate a daily from many 15s).


skivis View Post
Hi guys,

I am trying to create a custom conditional order using thinkscript. The idea is to sell an existing positon if the latest closing price is lower than the lowest price in the previous bar.

The code I currently have is pretty straightforward:
close < low from 1 bar ago

It appears that if I don't define the aggregation period, the system uses daily aggregation per bar. However, I would like to be able use this conditional order in other time frames such as 15 minute, 30 minute...etc., but I'm confused about how to set the aggregation period.

Using 15 minute as the aggregation period as an example, I'm assuming I have to put the code "AggregationPeriod.FIFTEEN_MIN" somewhere, but I keep getting errors in the thinkscript editor.

Any help would be appreciated, thanks.


Follow me on Twitter Reply With Quote


futures io Trading Community Platforms and Indicators ThinkOrSwim > Creating custom conditional orders using thinkscript


Last Updated on June 22, 2019


Upcoming Webinars and Events
 

NinjaTrader Indicator Challenge!

Ongoing
 

Journal Challenge w/$1,800 in prizes!

April
     



Copyright © 2021 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