Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
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 for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
Creating custom conditional orders using thinkscript
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.
Can you help answer these questions from other members on NexusFi?
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:
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).