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,397 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?
requesting .nrd replay files from 2026 spy and qqq
The Elite Circle
RTH vs ETH: when your chart and Volume Profile trading h …
NinjaTrader
No book, only a stair: journaling fills where price move …
Cryptocurrency
Trump Media to sell instant access to market-moving soci …
Traders Hideout
EA
Platforms and Indicators
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Mes vs MNQ
6 thanks
NexusFi site changelog and issues/problem reporting
5 thanks
BERN ALGOS algo trading journal
3 thanks
TopStep Trader disappointment
2 thanks
Running trading strategies on a VPS
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