NexusFi: Find Your Edge


Home Menu

 





thinkscript definitions max


Discussion in ThinkOrSwim

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




 
Search this Thread
  #1 (permalink)
kidvic
Los Angeles, CA
 
Posts: 92 since Mar 2015
Thanks Given: 13
Thanks Received: 3

Hi, I was wondering if you have the answer to my scripting question....
For thinkscript.
So I have several different defs,
and I want the one with highest value to be defined in another one...
def a = if true 1 else 0
def b = if true 2 else 0
def c = if true 3 else 0
def d = if true 4 else 0

def result = max(a b c d)

at this point we would get d because its got the highest value... as you know thinkscript will only do this with 2 values.
anyway you would know a workaround? Thanks.


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
Zytrade: Devin Brady, CEO - Ask Me Anything (AMA)
Brokers
White House Drops First Alien Files Today -- Market Says …
Prediction Markets & Event Contracts
ATFX Suspends Prop Trading Unit ATFunded -- Full Review …
Funded Trading Evaluation Firms
Powell in 48 Hours: Word Markets Give 78% on Inflation, …
Prediction Markets & Event Contracts
Peace Deal Forward Curve: May 22%, June 51%, December 81 …
Prediction Markets & Event Contracts
 
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
  #3 (permalink)
 growex 
Trubchevsk
 
Experience: Beginner
Platform: tos
Trading: stocks
Posts: 61 since May 2011
Thanks Given: 40
Thanks Received: 79



kidvic View Post
Hi, I was wondering if you have the answer to my scripting question....
For thinkscript.
So I have several different defs,
and I want the one with highest value to be defined in another one...
def a = if true 1 else 0
def b = if true 2 else 0
def c = if true 3 else 0
def d = if true 4 else 0

def result = max(a b c d)

at this point we would get d because its got the highest value... as you know thinkscript will only do this with 2 values.
anyway you would know a workaround? Thanks.

)
 
Code
                            
max(max(max(a,b),c),d); 


Follow me on X Reply With Quote
Thanked by:
  #4 (permalink)
kidvic
Los Angeles, CA
 
Posts: 92 since Mar 2015
Thanks Given: 13
Thanks Received: 3


growex View Post
)
 
Code
                            
max(max(max(a,b),c),d); 


Thanks growex, that answered my question. Only thing now, as we got D, how do I get the actual value for D? the def of D was given... but I didn't know the value would not be given. I wanted the number instead in this case we can see that the THEN value is 4. That is what I want...... the then part.
Thanks in advance!


Reply With Quote
  #5 (permalink)
 growex 
Trubchevsk
 
Experience: Beginner
Platform: tos
Trading: stocks
Posts: 61 since May 2011
Thanks Given: 40
Thanks Received: 79

def a = if true 1 else 0
def b = if true 2 else 0
def c = if true 3 else 0
def d = if true 4 else 0
def result = max(max(max(a,b),c),d);
the value of "result" variable will be 4, not "D";



just for information....to assign text values use ""
def a = "a";
def a = "/es"


also if you want to name your variables such as 1a,1b,1c (name starts witn a number) use "" also

def "1a" = 16434656;


Follow me on X Reply With Quote
Thanked by:




Last Updated on May 4, 2015


© 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