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 3,723 views
    2. thumb_up 0 thanks given
    3. group 2 followers
    1. forum 1 posts
    2. attach_file 0 attachments




 
Search this Thread

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

  #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?
REcommedations for programming help
Sierra Chart
What broker to use for trading palladium futures
Commodities
Trade idea based off three indicators.
Traders Hideout
Cheap historycal L1 data for stocks
Stocks and ETFs
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
 
  #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


© 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