thinkscript to "exit trade after X number of bars" - futures io
futures io

thinkscript to "exit trade after X number of bars"

Discussion in ThinkOrSwim

    1. trending_up 1,994 views
    2. thumb_up 0 thanks given
    3. group 3 followers
    1. forum 2 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

thinkscript to "exit trade after X number of bars"

(login for full post details)
  #1 (permalink)
philadelphia pa usa
Posts: 1 since May 2013
Thanks: 0 given, 0 received

Does anyone know the script to add onto TOS thinkscript strategies so one could back-test a strategy for number of bars that have elapsed.

For example...After stochastics "buy" signal arrow is generated on a chart...then, a "sell" arrow would appear after the fifth bar or seventh bar or whatever the input is. Thanks in advance

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
35 thanks
futures io site changelog and issues/problem reporting
26 thanks
(login for full post details)
  #2 (permalink)
San Francisco + CA/USA
Posts: 2 since Jun 2019
Thanks: 0 given, 0 received

Try "def sell = long from 4 bars ago;" where <long> was trigger for long position such as

def long = RSI() > 30;

Reply With Quote
(login for full post details)
  #3 (permalink)
Seattle, WA/USA
Experience: Intermediate
Platform: TOS, TS
Trading: Forex, crude
Posts: 90 since Sep 2016
Thanks: 7 given, 32 received

Maybe something like:

input barexit = 5;
def trigger = stoch crosses above 30;
def sell = trigger[-barexit];

Follow me on Twitter Reply With Quote

futures io Trading Community Platforms and Indicators ThinkOrSwim > thinkscript to "exit trade after X number of bars"

Last Updated on June 13, 2019

Upcoming Webinars and Events

NinjaTrader Indicator Challenge!


Journal Challenge w/$1,800 in prizes!


Copyright © 2021 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432,
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