Simplify script conditions: IsNaN and double.NaN

CharlesTow

New member
Hey guys,

I'm new to thinkscript so would appreciate if you could help me simplify the following script. Instead of typing in new values for a= 32, b= 21, etc. I would like (if possible) a function where i could paste in my values as parameters,
something like:

JavaScript:
function Values(a,b,c,d, D, E, F, G, H , I) {
                                   return  a,b,c,d, D, E, F, G, H , I;
                       }

                        Values(36.4, 34, 23,etc)

or some other solution making it easier to change values.

Thanks in advance.

Ruby:
def a = 36.4;
def b = 47.5;
def c = 54.4;
def D = 64.3;
def E = 74.2;
def F = 42.3;
def G = 34.1;
def H = 30.2;
def I = 28.1;

#determines where lines will be drawn

plot aa = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then a else Double.NaN);
plot bb = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then b else Double.NaN);
plot cc = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then c else Double.NaN);
plot dd = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then D else Double.NaN);
plot ee = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then E else Double.NaN);
plot ff = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then F else Double.NaN);
plot gg = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then G else Double.NaN);
plot hh = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then H else Double.NaN);
plot ii = HighestAll(if IsNaN(close[-1]) and !IsNaN(close) then I else Double.NaN);



aa.SetDefaultColor(color = Color.gray);
bb.SetDefaultColor(color = Color.orange);
cc.SetDefaultColor(color = Color.yellow);
dd.SetDefaultColor(color = Color.ORANGE);
ee.SetDefaultColor(color = Color.red);
ff.SetDefaultColor(color = Color.orange);
gg.SetDefaultColor(color = Color.yellow);
hh.SetDefaultColor(color = Color.orange);
ii.SetDefaultColor(color = Color.green);

Available syntax: https://usethinkscript.com/resources/double-nan-function-in-thinkorswim.14/
 
Last edited by a moderator:

Similar threads

Top