Referencing Previous Bars that Meet Certain Criteria - ThinkOrSwim Programming | futures io social day trading
futures io futures trading


Referencing Previous Bars that Meet Certain Criteria
Updated: Views / Replies:377 / 2
Created: by MisterT 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
 

Referencing Previous Bars that Meet Certain Criteria

  #1 (permalink)
Trading Apprentice
Parsippany, NJ
 
Futures Experience: Intermediate
Platform: ThinkOrSwim
Favorite Futures: Australian Dollar
 
Posts: 2 since May 2015
Thanks: 1 given, 0 received

Referencing Previous Bars that Meet Certain Criteria

In ThinkOrSwim's ThinkScript, I'm trying to create an indicator which displays an average of the past 5 bars which had a range of more than 10 ticks.

For example, lets say last 10 bars had the following ranges (in ticks): 20, 22, 25, 17, 10, 7, 8, 8, 9, 8.
I want my indicator to display a value of 18.8 (i.e, (20+22+25+17+10)/5 = 18.8).

I'm fairly new to ThinkScript and so far I've been able to program an indicator which displays the average of the last 5 bars but I want to make one which will only average those bars which fulfill a certain criteria.

Any help would be appreciated!

Reply With Quote
 
  #2 (permalink)
Trading Apprentice
pensacola florida
 
Futures Experience: Master
Platform: NinjaTrader, TradeStation, ThinkOrSwim
Favorite Futures: ES
 
Posts: 7 since Jul 2014
Thanks: 0 given, 6 received

Not sure this is of any value other than to see how the fold expression is used

input Threshold = 10;
input n = 10;

def Avg = (fold i = 0 to n
with p
do p + getValue(if close > Threshold then close else 0, i, n - 1)) / n;
addLabel(1, "Avg Value " + Avg, Color.White);
AddLabel(1, "Avg " + (Average(close, n)));

Reply With Quote
The following 2 users say Thank You to mobiusrts for this post:
 
  #3 (permalink)
Trading Apprentice
Parsippany, NJ
 
Futures Experience: Intermediate
Platform: ThinkOrSwim
Favorite Futures: Australian Dollar
 
Posts: 2 since May 2015
Thanks: 1 given, 0 received



mobiusrts View Post
Not sure this is of any value other than to see how the fold expression is used

input Threshold = 10;
input n = 10;

def Avg = (fold i = 0 to n
with p
do p + getValue(if close > Threshold then close else 0, i, n - 1)) / n;
addLabel(1, "Avg Value " + Avg, Color.White);
AddLabel(1, "Avg " + (Average(close, n)));

Thanks for the reply. But wouldn't the above code average the last 10 bars regardless of whether it had higher than 10 ticks? If the last 10 bars all had less than 10 ticks then the value returned by this code would be 0, would it not?

Reply With Quote

Reply



futures io > > > > > Referencing Previous Bars that Meet Certain Criteria

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
NinjaTrader previous bars OnBarUpdate problem Elenchus NinjaTrader 2 December 14th, 2014 10:44 PM
Ninjascript -- Setting stop loss based on previous bars bstzgr The Elite Circle 6 August 25th, 2014 08:40 AM
Automatically scanning market for stocks which meet criteria tradingblitz NinjaTrader 3 September 22nd, 2013 01:26 AM
Amend below Aroon strategy to incorporate ADX criteria and EOD exit criteria frugalmule Elite EasyLanguage Automated Trading 4 June 28th, 2013 05:33 PM
How to program price cross below a number of previous bars Twiddle NinjaTrader Programming 8 May 17th, 2011 05:58 PM


All times are GMT -4. The time now is 02:05 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-15 in 0.07 seconds with 19 queries on phoenix via your IP 54.82.56.95