NexusFi: Find Your Edge


Home Menu

 





thinkscript definitions max


Discussion in ThinkOrSwim

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




 
Search this Thread

thinkscript definitions max

  #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?
Better Renko Gaps
The Elite Circle
Trade idea based off three indicators.
Traders Hideout
NT7 Indicator Script Troubleshooting - Camarilla Pivots
NinjaTrader
ZombieSqueeze
Platforms and Indicators
Quantum physics & Trading dynamics
The Elite Circle
 
  #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 Twitter 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 Twitter Reply With Quote
Thanked by:




Last Updated on May 4, 2015


© 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