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,246 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?
Kharg Island at 6%, Regime Fall at 1.5% -- The Black Swa …
Prediction Markets & Event Contracts
Trump Truth Social Fires Hormuz From 10% to 59% -- Arsen …
Prediction Markets & Event Contracts
One Wallet Made $200K in Hours: AP Probes Polymarket Cea …
Prediction Markets & Event Contracts
Iran Lebanon Problem Kills Switzerland Talks, Brent at $ …
Prediction Markets & Event Contracts
CFTC Opens First COT Report Review in 20 Years -- Asks W …
Traders Hideout
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
205 thanks
Sober Journey With S&P
21 thanks
30 Sessions
20 thanks
Volume Indicators
8 thanks
Thanks Mike. Godspeed.
7 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