```
##################################################
declare lower;
input period = AggregationPeriod.DAY;
input length = 14;
input calcLength = 5;
input smoothLength = 3;
DefineGlobalColor("Long", Color.Green);
DefineGlobalColor("Short", Color.RED);
DefineGlobalColor("Neutral", Color.Yellow);
DefineGlobalColor("arrow Buy", Color.Cyan);
DefineGlobalColor("arrow Sell", Color.Orange);
Script SymbolTMO{
input period = AggregationPeriod.DAY;
def OP = Open(period= period);
def CP = Close(Period= period);
input length = 14;
input calcLength = 5;
input smoothLength = 3;
def data = fold i = 0 to length
with s
do s + (if cp > getValue(op, i)
then 1
else if cp < getValue(op, i)
then - 1
else 0);
def EMA5 = ExpAverage(data, calcLength);
Def Main = ExpAverage(EMA5, smoothLength);
Def Signal = ExpAverage(Main, smoothLength);
Plot Result = If main > Signal then 1 else if Main < Signal then -1 else 0;}
Script SymbolTMOArrow{
input period = AggregationPeriod.DAY;
def OP = Open(period= period);
def CP = Close(Period= period);
input length = 14;
input calcLength = 5;
input smoothLength = 3;
def data = fold i = 0 to length
with s
do s + (if cp > getValue(op, i)
then 1
else if cp < getValue(op, i)
then - 1
else 0);
def EMA5 = ExpAverage(data, calcLength);
Def Main = ExpAverage(EMA5, smoothLength);
Def Signal = ExpAverage(Main, smoothLength);
Plot Result = If main Crosses Above Signal then 1 else if Main Crosses Below Signal then -1 else 0;}
def currentPeriod = GetAggregationPeriod();
def s1;
def h1;
if period >= currentPeriod {
s1 = SymbolTMO(period = period ,Length = Length, calclength = calcLength,SmoothLength = smoothLength);
h1 = SymbolTMOArrow(period = period ,Length = Length, calclength = calcLength,SmoothLength = smoothLength);
} else {
s1 = Double.NaN;
h1 = DOuble.Nan;
}
AddLabel(!IsNaN(s1), "TMO:" + (if period == AggregationPeriod.MONTH then "M"
else
if period == AggregationPeriod.WEEK then "W"
else
if period == AggregationPeriod.FOUR_DAYS then "4D"
else
if period == AggregationPeriod.THREE_DAYS then "3D"
else
if period == AggregationPeriod.TWO_DAYS then "2D"
else
if period == AggregationPeriod.DAY then "D"
else
if period == AggregationPeriod.FOUR_HOURS then "4H"
else
if period == AggregationPeriod.TWO_HOURS then "2H"
else
if period == AggregationPeriod.HOUR then "60m"
else
if period == AggregationPeriod.THIRTY_MIN then "30m"
else
if period == AggregationPeriod.TWENTY_MIN then "20m"
else
if period == AggregationPeriod.FIFTEEN_MIN then "15m"
else
if period == AggregationPeriod.TEN_MIN then "10m"
else
if period == AggregationPeriod.FIVE_MIN then "5m"
else
if period == AggregationPeriod.FOUR_MIN then "4m"
else
if period == AggregationPeriod.THREE_MIN then "3m"
else
if period == AggregationPeriod.TWO_MIN then "2m"
else
if period == AggregationPeriod.MIN then "1m"
else ""), if s1 == 1 then GlobalColor("Long") else if s1 == -1 then GlobalColor("Short") else GlobalColor("Neutral"));
AddLabel(!IsNaN(h1) and h1 != 0, If h1 == 1 then "B" else if h1 == -1 then "S" else "-", if h1 == 1 then GlobalColor("arrow Buy") else if h1 == -1 then GlobalColor("arrow Sell") else color.gray);
```