I previously responded to your question via the comments section above. Since I received no response to that comment I am including that response here in addition to my answer below.
Please do not use those share links. They have an expiration date and can be revoked by the user. This post will be around for many years and it's important to include the entire code instead of a link to it. If the code is too long to post with the question you can save it to a plain text file and include it as an attachment.
The simple answer to your question, is to adjust your chart to display 1 month of daily candles. This will average about 21 bars on the chart and make it very easy to see if your code is accurate. This will also create the ideal environment to troubleshoot your code to correct any errors.
Since you provided your code via a share link to Thinkorswim I am including your code here for the benefit of our viewers. The only changes I have made were to correct minor imperfections in the way you wrote the code. I have not tried to check it for accuracy or made any changes that impact it's computations:
plot ttmTrend = TTM_Trend();
ttmTrend.hide();
def totalBars = if SimpleMovingAvg() != SimpleMovingAvg()[1] then totalBars[1] + 1 else totalBars[1];
def trend = if ttmTrend != ttmTrend[1] then trend[1] + 1 else trend[1];
def upTrend = if ttmTrend == 1 then + 1 + upTrend[1] else upTrend[1];
def downTrend = if ttmTrend == 0 then + 1 + downTrend[1] else downTrend[1];
def trendUp = Round(upTrend / totalBars) * 100 > 50;
def trendDown = Round(downTrend / totalBars) * 100 > 50;
def trendUpAvg = Round(upTrend / (trend / 2));
def trendDownAvg = Round(downTrend / (trend / 2));
Addlabel(yes, "ttmTrend", Color.WHITE);
Addlabel(yes, "trend Up " + Round(upTrend / totalBars) * 100 + "%", if trendUp then CreateColor(150, 150, 255) else Color.WHITE);
Addlabel(yes, "trend Down " + Round(downTrend / totalBars) * 100 + "%", if trendDown then Color.RED else Color.WHITE);
Addlabel(yes, "trend Up Avg :" + Round(upTrend / (trend / 2)), if trendUpAvg > trendDownAvg then CreateColor(150, 150, 255) else Color.WHITE);
Addlabel(yes, "trend Down Avg :" + Round(downTrend / (trend / 2)), if trendDownAvg > trendUpAvg then Color.RED else Color.WHITE);