NexusFi: Find Your Edge


Home Menu

 





ThinkOrSwim Count Number of Days Range Larger than a Value


Discussion in ThinkOrSwim

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




 
Search this Thread

ThinkOrSwim Count Number of Days Range Larger than a Value

  #1 (permalink)
 JVP3122 
Newark, NJ United States
 
Experience: Beginner
Platform: ThinkOrSwim
Trading: /ES, /CL, /NQ
Posts: 1 since Oct 2014
Thanks Given: 0
Thanks Received: 0

I'm trying to create a very simple label that displays the number of days (or bars, whichever you prefer) that the range has been larger than a prescribed value. I'm attaching a code that I'm trying to check to see how many days in the last 252 saw the TrueRange be larger than 5 as an example.
 
Code
input RangeSize = 5;

def numberofdays = fold i = 0 to 252 with resultVal = 0 do if TrueRange(high[i],close[i],low[i]) > RangeSize then resultVal = resultVal + 1;
I've never tried using fold before but I'm not seeing, just based on the ThinkScript examples online, what I've screwed up here and would appreciate any help.

Started this thread Reply With Quote




Last Updated on April 9, 2016


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts