I'm very new to thinkscript but have tons of experience coding for TradeStation. I am trying to convert a study to thinkscript.
plot my_pos_1 = my_upper_boll > my_upper_boll [1]
and my_middle_boll > my_middle_boll [1]
and my_lower_boll > my_lower_boll [1];
plot my_neg_1 = my_upper_boll < my_upper_boll [1]
and my_middle_boll < my_middle_boll [1]
and my_lower_boll < my_lower_boll [1];
I tried using the reserved word def to give value to my_pos_1 but I have four different scenarios which can take place, and using a case statement or if statement was not working out well for four scenarios when it meant four different plot statements, and I could not get a single plot statement to work either in a case or in an if. I suppose the only conditional test is like this, from one of the canned indicators:
plot "ZZT$" = if state == state.uptrend and !IsNan(close) then 1 else if state == state.downtrend and !IsNan(close) then -1 else Double.NaN;
Could not code that right either.
So I ended up trying the plot statement in the code above, but that gives me four plots when I can get by with one or two.
Another issue is I am trying to display this as a histogram, where the the positive test above would generate a green histogram going from 0 up to 1, while the negative test above would generate a red histogram going from 0 down to -1. However, my_pos_1 appears to come out as 1, and it's the same with my_neg_1. Comes out as 1. Boolean. I have tried multiplying by -1 but no success. Furthermore, I should be able to change my_pos_1 to anything I want it to be. This is really a simple indicator which I could do in my sleep in TradeStation.
After many hours of work, I have been able to get at least the positive logic to work right, with two plots instead of one, one of them a full histogram and one of them half that size, but they overlap each other. Help with either getting the negative side to work or the overlapping issue for the two positives gone (the half one is not displayed above) would be much appreciated.
Here is the logic I would like to use, if only the software were easy to understand:
if my_upper_boll > my_upper_boll [1]
and my_middle_boll > my_middle_boll [1]
and my_lower_boll > my_lower_boll [1]
then
plot plot1 (1 histogram green width2)
else
if my_upper_boll < my_upper_boll [1]
and my_middle_boll < my_middle_boll [1]
and my_lower_boll < my_lower_boll [1]
then
plot plot1 (-1 histogram red width2)
It's actually that easy in TradeStation.
plot my_pos_1 = my_upper_boll > my_upper_boll [1]
and my_middle_boll > my_middle_boll [1]
and my_lower_boll > my_lower_boll [1];
plot my_neg_1 = my_upper_boll < my_upper_boll [1]
and my_middle_boll < my_middle_boll [1]
and my_lower_boll < my_lower_boll [1];
I tried using the reserved word def to give value to my_pos_1 but I have four different scenarios which can take place, and using a case statement or if statement was not working out well for four scenarios when it meant four different plot statements, and I could not get a single plot statement to work either in a case or in an if. I suppose the only conditional test is like this, from one of the canned indicators:
plot "ZZT$" = if state == state.uptrend and !IsNan(close) then 1 else if state == state.downtrend and !IsNan(close) then -1 else Double.NaN;
Could not code that right either.
So I ended up trying the plot statement in the code above, but that gives me four plots when I can get by with one or two.
Another issue is I am trying to display this as a histogram, where the the positive test above would generate a green histogram going from 0 up to 1, while the negative test above would generate a red histogram going from 0 down to -1. However, my_pos_1 appears to come out as 1, and it's the same with my_neg_1. Comes out as 1. Boolean. I have tried multiplying by -1 but no success. Furthermore, I should be able to change my_pos_1 to anything I want it to be. This is really a simple indicator which I could do in my sleep in TradeStation.
After many hours of work, I have been able to get at least the positive logic to work right, with two plots instead of one, one of them a full histogram and one of them half that size, but they overlap each other. Help with either getting the negative side to work or the overlapping issue for the two positives gone (the half one is not displayed above) would be much appreciated.
Here is the logic I would like to use, if only the software were easy to understand:
if my_upper_boll > my_upper_boll [1]
and my_middle_boll > my_middle_boll [1]
and my_lower_boll > my_lower_boll [1]
then
plot plot1 (1 histogram green width2)
else
if my_upper_boll < my_upper_boll [1]
and my_middle_boll < my_middle_boll [1]
and my_lower_boll < my_lower_boll [1]
then
plot plot1 (-1 histogram red width2)
It's actually that easy in TradeStation.