NexusFi: Find Your Edge


Home Menu

 





How to get the highest of all the bars BUT the first one.


Discussion in ThinkOrSwim

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




 
Search this Thread
  #1 (permalink)
 
jorshhh's Avatar
 jorshhh 
Kettering
 
Experience: Intermediate
Platform: ThinkOrSwim
Posts: 1 since Apr 2019
Thanks Given: 0
Thanks Received: 0

I want to get the highest of the last n bars; n is a variable. Unfortunately, thinkscript won't let me do Highest(high[1],n) because n should be a constant. Do you know a workaround or a different way to accomplish the same thing? Essentially, I just want to get the highestAll minus the first bar, so i figured highest(high[1],BarNumber()-1) would do, but it doesn't...


Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
CFTC Opens First COT Report Review in 20 Years -- Asks W …
Traders Hideout
Weekend Update: First Qatari LNG Transit Attempted -- IR …
Traders Hideout
Warsh Drops Easing Bias, December Hike Now Above 50% -- …
Prediction Markets & Event Contracts
Memorandum Watch: How the 60-Day MOU Framework Makes May …
Prediction Markets & Event Contracts
Iran Forward Curve: June 30 at 56% vs June 15 at 28% -- …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
NexusFi site changelog and issues/problem reporting
10 thanks
Darmok and Jalad at Tanagra
3 thanks
Big Mike in Ecuador
1 thanks
30 Sessions
1 thanks
  #2 (permalink)
 JayC 
San Diego, CA
 
Experience: Beginner
Platform: TOS, Sierra
Trading: Emini ES, Crude CL
Posts: 55 since Mar 2019
Thanks Given: 9
Thanks Received: 43

You are probably looking for something like this. Its evaluating each bar based on the previous high and keeps increasing the result if it finds a new high value. It avoids the last bar by referencing high[1] rather than the current high. This will operate on all chart data, but if you want to only go back to a certain point you'll need to add more conditions.

 
Code
def highest = if high[1] > highest[1] then high[1] else highest[1];
plot b = highest;

If you want more examples of this and many other helpful tips, check out this link. I found it very helpful in learning thinkscript. TOS and Thinkscript Snippet Collection


Reply With Quote




Last Updated on May 2, 2019


© 2026 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 - Downloads - Top
no new posts