I'm trying to scan for stocks/options that checks the past 4 TTM Histogram bars to make sure the following conditions are true:
1) TTM_Squeeze().Histogram 3 and 4 are below 0 and histogram 3 is closer to 0 than 4 (so histogram [3] > histogram [4])
2) histogram 1 is greater than histogram 2 and both of them are above 0 line
3) plot if 1 and 2 are true.
I had the code more joined together before but thinkorswim complained that it was too complex (not sure why seems pretty simple conditions). I rewrote it like this which I'm sure is not the best way, could someone look at it and make sure I did it right and perhaps fix whatever I did wrong.
Here is my snipped of code
def negToPos = TTM_Squeeze().Histogram [4] is less than 0 and TTM_Squeeze().Histogram [3] is less than 0;
def bullStart = TTM_Squeeze().Histogram [2] and TTM_Squeeze().Histogram [1] is greater than 0;
def bullRun = TTM_Squeeze().Histogram [1] > TTM_Squeeze().Histogram [2] and TTM_Squeeze().Histogram [3] > TTM_Squeeze().Histogram [4];
plot signal = negToPos and bullStart and bullRun;
1) TTM_Squeeze().Histogram 3 and 4 are below 0 and histogram 3 is closer to 0 than 4 (so histogram [3] > histogram [4])
2) histogram 1 is greater than histogram 2 and both of them are above 0 line
3) plot if 1 and 2 are true.
I had the code more joined together before but thinkorswim complained that it was too complex (not sure why seems pretty simple conditions). I rewrote it like this which I'm sure is not the best way, could someone look at it and make sure I did it right and perhaps fix whatever I did wrong.
Here is my snipped of code
def negToPos = TTM_Squeeze().Histogram [4] is less than 0 and TTM_Squeeze().Histogram [3] is less than 0;
def bullStart = TTM_Squeeze().Histogram [2] and TTM_Squeeze().Histogram [1] is greater than 0;
def bullRun = TTM_Squeeze().Histogram [1] > TTM_Squeeze().Histogram [2] and TTM_Squeeze().Histogram [3] > TTM_Squeeze().Histogram [4];
plot signal = negToPos and bullStart and bullRun;