# TMO with Higher Agg_Mobius @ TSL

T

#### trouble56

##### New member
VIP
@BenTen Thats the indicator I used to create the arrows I provided above. what I am struggling with it creating a strategy from this or a study from this which signals correctly. The problem is that if one arrow shows a signal (up or down), I need to hold that signal until it signals the opposite signal and this is where I think I am running into a problem with my code. I confirmed I am doing this by plotting the alert and it is not matching the arrows. I need to write something where if there is a cross the value is 1 and it stays one until this is another cross in the opposite direction.

Last edited:

#### BenTen

Staff
VIP
@trouble56 Are you saying that the signals you see manually don't match the signals that the indicator generated? If so, can you share some screenshots?

T

#### trouble56

##### New member
VIP
@BenTen The signals I am seeing from Maya's study is not matching the study I created, which I posted above. here is a picture showing the problems

#### BenTen

Staff
VIP
@trouble56 Can you define the condition for the signal that you're hoping to generate?

T

#### trouble56

##### New member
VIP
@BenTen here are the 2 conditions:

Def LongUP = Crosses(main, signal, CrossingDirection.ABOVE);
Def ShortDOWN = Crosses(main, signal, CrossingDirection.BELOW);

I am looking for the value of ALERT to equal 1 when LongUP occurs and have it keep that value until ShortDOWN occurs then when that happens I want the value of ALERT to be equal to -1 and then I want it to keep that value until LongUP occurs and on and on

#### BenTen

Staff
VIP
@trouble56 Here you go:

Code:
``````# My version of so called "blackFLAG FTS PLATINUM Ver. 5.0" @Maya
# TMO ((T)rue (M)omentum (O)scillator) With Higher Aggregation
# Mobius
# V01.05.2018
#hint: TMO calculates momentum using the DELTA of price. Giving a much better picture of trend, tend reversals and divergence than momentum oscillators using price.

declare lower;

input length = 14;
input calcLength = 5;
input smoothLength = 3;
input agg = AggregationPeriod.HOUR;

def o = open(period = agg);
def c = close(period = agg);
def data = fold i = 0 to length
with s
do s + (if c > getValue(o, i)
then 1
else if c < getValue(o, i)
then - 1
else 0);
def EMA5 = ExpAverage(data, calcLength);
def Main = ExpAverage(EMA5, smoothLength);
def Signal = ExpAverage(Main, smoothLength);
# End Code TMO with Higher Aggregation

def bullish = Main crosses above Signal;
def bearish = Main crosses below Signal;

plot bullish_signal = if bullish then 1 else 0;
plot bearish_signal = if bearish then -1 else 0;``````

T

#### trouble56

##### New member
VIP
@BenTen I am looking for the signal to remain 1 until it crosses back. I need it to do this so I can create what I am looking to do

A

#### Art

##### Member
Hi Everyone,

I'm having some difficulties with the following codes and hoping someone can offer a suggestion.

I have the following label code added to a script for the momentum change.

AddLabel (yes, "Mom Change ", if main > main from 1 bars ago then color.GREEN else if main < main from 1 bars ago then color.RED else color.YELLOW);

Then I have the following one added to my watchlist as a column
main.assignValueColor(if main > main from 1 bars ago then color.GREEN else if main < main from 1 bars ago then color.RED else color.YELLOW);

The aggregation time is set to daily for both, but the colors don't match. Please, can someone tell me where I'm going wrong?

#### BenTen

Staff
VIP
Please post the entire code so we can better assist you.

A

#### Art

##### Member
@BenTen I'm s=using the TMO https://usethinkscript.com/threads/true-momentum-oscillator-for-thinkorswim.15/ script and simply adding the label code to it.

I think I found the issue. I was using the daily aggregation on 4HR chart, I tested the 4hr on 4hr chart and the label works. But when I change the aggregation to daily the label goes yellow which doesn't match the direction of the trend.