Hi All,
I am just beginning to get into ThinkScript and wanted to create a multiple average order check that I can add as a column on my TOS watchlist. I am having some issues with getting it to work properly.
If I do a check of just ema 1 > ema 2 this seems to work fine on different time frame selections as I confirm back to a chart.
When I attempt to mix ema and sma together such as below ema1 > ema2 > sma1 > sma2, it doesn't seem to work. I am using "AAPL" as my symbol which should be a "YES"(darkgreen) on the daily chart, but shows up as "NO"(darkred).
Is there something else required? How can I use both exponential and simple moving averages together to tell me if they are in alignment or not?
Thanks for any community assistance with this.
I am just beginning to get into ThinkScript and wanted to create a multiple average order check that I can add as a column on my TOS watchlist. I am having some issues with getting it to work properly.
If I do a check of just ema 1 > ema 2 this seems to work fine on different time frame selections as I confirm back to a chart.
When I attempt to mix ema and sma together such as below ema1 > ema2 > sma1 > sma2, it doesn't seem to work. I am using "AAPL" as my symbol which should be a "YES"(darkgreen) on the daily chart, but shows up as "NO"(darkred).
Is there something else required? How can I use both exponential and simple moving averages together to tell me if they are in alignment or not?
Thanks for any community assistance with this.
Code:
input ema1_len = 8;
input ema2_len = 21;
input sma1_len = 50;
input sma2_len = 200;
def ema1 = MovAvgExponential(length=ema1_len);
def ema2 = MovAvgExponential(length=ema2_len);
def sma1 = SimpleMovingAvg(length=sma1_len);
def sma2 = SimpleMovingAvg(length=sma2_len);
def multi_good = ema1 > ema2 > sma1 > sma2;
def multi_bad = ema1 < ema2 < sma1 < sma2;
AddLabel(yes, if multi_good then "YES" else if multi_bad then "NO" else "~");
AssignBackgroundColor(if multi_good then Color.DARK_GREEN else if multi_bad then Color.DARK_RED else Color.DARK_ORANGE);