Moxie Indicator for ThinkorSwim

I am trying to create a scan which identifies when the Moxie stairstep reverses direction. When I create a scan asking to show mw when the current moxie direction reversed direction from the prior day I get an error message that states ""secondary period not allowed Week. Any suggestions how to get around this?

@Herbee Take the time to read this topic and most all of your questions will be answered... Part of the reason this topic is long is because other members before you also failed to read before questioning...
 

Volatility Trading Range

VTR is a momentum indicator that shows if a stock is overbought or oversold based on its Weekly and Monthly average volatility trading range.

Download the indicator

I am trying to create a scan which identifies when the Moxie stairstep reverses direction. When I create a scan asking to show mw when the current moxie direction reversed direction from the prior day I get an error message that states ""secondary period not allowed Week. Any suggestions how to get around this?

There are scans in this thread you can modify. The scans I created have comments at the top explaining how to work around the secondary time period issue. For instance, take the trigger scan I linked above for the other person asking about scans today and change the last 2 lines to fit your criteria.
 
On Moxie Smooth, How do I make the value of Moxiesecondline appear on the llegend on the lowrer indicator and therefore in the data box.
 
On Moxie Smooth, How do I make the value of Moxiesecondline appear on the llegend on the lowrer indicator and therefore in the data box.

I'm guessing you just need to check the box for Title on that plot. I disabled the titles and bubbles by default so TOS has less things on screen to redraw.
 
I no longer use Moxie. TG focuses mostly on the 1H chart. Moxie on the 1H chart is MACD histogram of 1D chart. I prefer to focus on 1D chart so it made more sense for me to just use MACD histogram and switch it to draw as a line. Moxie on 1D, in my opinion, is too slow to use alone and I think that's why TG focuses so much on the 1H chart. I think that hurts his trading because he misses the bigger picture the 1D provides. I mean, he has the 1D chart up but it's like he ignores it when he's looking to enter a trade. At one point I was using a composite indicator I created that had both timeframes in one. Eventually, I abandoned Moxie, MACD and TG's strategy. I still think the strategy and indicator can be used successfully. I just prefer something simpler and more objective.

After quitting Moxie Mastery, almost 2 months ago, I still get push notifications for TG's alerts. So if you guys want it try it you might get alerts forever after you quit. I find TG's alerts useless and I uninstalled the app yesterday to stop getting them. And it's irritating to receive his weekly email spam telling me about how he makes consistent profits and blah blah blah while I know he's consistently losing.

I'm still in the process of finding a strategy that works and fits me. What I'm playing with currently is a combination of Raghee's 34 ema stuff and the VMA from TOSIndicator's MarketPulse. If I get something working well I'll probably post it here. Either that or I'll join Simpler Trading and sell it to all of you. Not really. I'll post it here.
 
Here's an example where the "smooth" Moxie and the "real" Moxie are doing very different things. I'll try to remember to follow up in a few days to see which seems more helpful.

2021-03-03-21-14-48-Window.png
@Slippage where can we get the labels! :)
 
Hi everyone, complete newbie here but I was wondering if somebody can help me. I currently have time labels for the code below (Moxie) but they only display on certain time frames & once I switch to another time frame they disappear on me. I need the 15m, 1h, & Daily time frame labels to remain visible across any time frame I go to. How do I do this? The labels show if Moxie is above/below zero line by painting green/red labels for these 3 time frames. Thank you for any help and guidance you can offer!
The timeframes will only be visible when they are a higher aggregation than the chart you placed them on.
You can read more here:
https://usethinkscript.com/threads/... aggregation.-,Having Problems?,-Does the MTF
 
Hi, I'm trying to add this moxie indicator to my scans. The condition I'm trying to set it to is moxie is greater than the zero line, but I get the following "The secondary period now allowed: Week". Can someone help/show how to set this up?
 
The timeframes will only be visible when they are a higher aggregation than the chart you placed them on.
You can read more here:
https://usethinkscript.com/threads/answers-to-commonly-asked-questions.6006/#post-58016:~:text=the higher aggregation.-,Having Problems?,-Does the MTF
Thank you for your response MerryDay! The forum was helpful but the problem is my labels don't even show the higher aggregation timeframe labels when I'm on the lower ones. Any advice on how I can fix this? Any help from anybody is very much appreciated. Thank you.
 
Last edited:
Thank you for your response MerryDay! The forum was helpful but the problem is my labels don't even show the higher aggregation timeframe labels when I'm on the lower ones. Any advice on how I can fix this? Any help from anybody is very much appreciated. Thank you.

[Edit: the link in this originally did not work properly when I checked back here. The one below is correct]

Without knowing what code you are using for your labels, perhaps what I posted in this might help

https://usethinkscript.com/threads/...rsi-indicator-for-thinkorswim.616/post-120928
 
Last edited:
can anyone code a strategy that backtest Moxie indicator, go long when Moxie line goes above 0, and go short when it goes below 0? Thanks! No idea how to code this backtest strategy
 
can anyone code a strategy that backtest Moxie indicator, go long when Moxie line goes above 0, and go short when it goes below 0? Thanks! No idea how to code this backtest strategy
The moxie is just the macd...literally nothing else. Its the macd histogram one time aggregation higher. I. even saw their coding and they put fake lines of code and formulas in to throw people off the scent of the fact that its just plotting the macd hist as a line... No need to backtest, you either like using the macd or you dont.
 
Hopefully this will be the final code. The code for the scans have not changed since they were posted earlier. I just wanted to bring all the pieces together in this post as the (hopefully) final and complete package.

1. This resolves a bug for 15m. It should use close price rather than high price.
2. This makes it so the second line is shown by default on 15m and no other timeframes. I changed this to stop the confusion some members ran into with why the second line didn't appear automatically on 15m.

Moxie Upper:
Ruby:
declare upper;

def currentAggPeriod = GetAggregationPeriod();
def higherAggPeriod =
  if currentAggPeriod <= AggregationPeriod.TWO_MIN then AggregationPeriod.FIVE_MIN
  else if currentAggPeriod <= AggregationPeriod.THREE_MIN then AggregationPeriod.TEN_MIN
  else if currentAggPeriod <= AggregationPeriod.FIVE_MIN then AggregationPeriod.FIFTEEN_MIN
  else if currentAggPeriod <= AggregationPeriod.TEN_MIN then AggregationPeriod.THIRTY_MIN
  else if currentAggPeriod <= AggregationPeriod.FIFTEEN_MIN then AggregationPeriod.HOUR
  else if currentAggPeriod <= AggregationPeriod.THIRTY_MIN then AggregationPeriod.TWO_HOURS
  else if currentAggPeriod <= AggregationPeriod.TWO_HOURS then AggregationPeriod.DAY
  else if currentAggPeriod <= AggregationPeriod.FOUR_HOURS then AggregationPeriod.TWO_DAYS
  else if currentAggPeriod <= AggregationPeriod.DAY then AggregationPeriod.WEEK
  else if currentAggPeriod <= AggregationPeriod.WEEK then AggregationPeriod.MONTH
  else AggregationPeriod.QUARTER
;

script MoxieFunc {
  input price = close;
  def vc1 = ExpAverage(price, 12) - ExpAverage(price , 26);
  def va1 = ExpAverage(vc1, 9);
  plot data = (vc1 - va1) * 3;
}

def Moxie = MoxieFunc(close(period = higherAggPeriod));

def longTrigger = if Moxie > 0 and Moxie[1] <= 0 then Moxie else Double.NaN;
def longArrowPosition =
  # first arrow
  if Moxie == longTrigger and Moxie != Moxie[1] then low
  # consecutive arrows at same position
  else if Moxie == longTrigger and Moxie == Moxie[1] then longArrowPosition[1]
  else Double.NaN;
plot long = longArrowPosition;
long.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
long.SetDefaultColor(Color.GREEN);
long.SetLineWeight(3);
long.HideBubble();
long.HideTitle();

def shortTrigger = if Moxie < 0 and Moxie[1] >= 0 then Moxie else Double.NaN;
def shortArrowPosition =
  # first arrow
  if Moxie == shortTrigger and Moxie != Moxie[1] then high
  # consecutive arrows at same position
  else if Moxie == shortTrigger and Moxie == Moxie[1] then shortArrowPosition[1]
  else Double.NaN;
plot short = shortArrowPosition;
short.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
short.SetDefaultColor(Color.LIGHT_RED);
short.SetLineWeight(3);
short.HideBubble();
short.HideTitle();

Moxie Lower:
Ruby:
declare lower;

input showVerticalLines = yes;
input showTrampolines = yes;
input showSqueezeDots = no;

plot ZeroLine = if !IsNaN(open) and !showSqueezeDots then 0 else Double.NaN;
ZeroLine.SetDefaultColor(Color.GRAY);
ZeroLine.SetLineWeight(2);
ZeroLine.HideBubble();
ZeroLine.HideTitle();

def currentAggPeriod = GetAggregationPeriod();
def higherAggPeriod =
  if currentAggPeriod <= AggregationPeriod.TWO_MIN then AggregationPeriod.FIVE_MIN
  else if currentAggPeriod <= AggregationPeriod.THREE_MIN then AggregationPeriod.TEN_MIN
  else if currentAggPeriod <= AggregationPeriod.FIVE_MIN then AggregationPeriod.FIFTEEN_MIN
  else if currentAggPeriod <= AggregationPeriod.TEN_MIN then AggregationPeriod.THIRTY_MIN
  else if currentAggPeriod <= AggregationPeriod.FIFTEEN_MIN then AggregationPeriod.HOUR
  else if currentAggPeriod <= AggregationPeriod.THIRTY_MIN then AggregationPeriod.TWO_HOURS
  else if currentAggPeriod <= AggregationPeriod.TWO_HOURS then AggregationPeriod.DAY
  else if currentAggPeriod <= AggregationPeriod.FOUR_HOURS then AggregationPeriod.TWO_DAYS
  else if currentAggPeriod <= AggregationPeriod.DAY then AggregationPeriod.WEEK
  else if currentAggPeriod <= AggregationPeriod.WEEK then AggregationPeriod.MONTH
  else AggregationPeriod.QUARTER
;

script MoxieFunc {
  input price = close;
  def vc1 = ExpAverage(price, 12) - ExpAverage(price , 26);
  def va1 = ExpAverage(vc1, 9);
  plot data = (vc1 - va1) * 3;
}

plot Moxie = MoxieFunc(close(period = higherAggPeriod));
Moxie.SetLineWeight(2);
Moxie.DefineColor("Up", Color.GREEN);
Moxie.DefineColor("Down", Color.RED);
def lastChange = if Moxie < Moxie[1] then 1 else 0;
Moxie.AssignValueColor(
  if lastChange == 1 then Moxie.Color("Down")
  else Moxie.Color("Up")
);

# Watkins uses a different setup for Moxie on his 15 minute charts.
# He uses two lines derived from two higher timeframes.
# For timeframes other than 15 minutes we'll use the same data as
# first Moxie line to reduce data requested from the server and
# improve performance.
def secondAggPeriod =
  if currentAggPeriod == AggregationPeriod.FIFTEEN_MIN
  then AggregationPeriod.TWO_HOURS
  else currentAggPeriod
;

plot MoxieSecondLine =
  if currentAggPeriod == AggregationPeriod.FIFTEEN_MIN
  then MoxieFunc(close(period = secondAggPeriod))
  else Double.NaN
;

MoxieSecondLine.SetLineWeight(2);
MoxieSecondLine.DefineColor("Up", Color.GREEN);
MoxieSecondLine.DefineColor("Down", Color.RED);
def lastChangeSecondLine = if MoxieSecondLine < MoxieSecondLine[1] then 1 else 0;
MoxieSecondLine.AssignValueColor(
  if lastChangeSecondLine == 1 then MoxieSecondLine.Color("Down")
  else MoxieSecondLine.Color("Up")
);
MoxieSecondLine.SetHiding(currentAggPeriod != AggregationPeriod.FIFTEEN_MIN);

# Show vertical lines at crossovers
AddVerticalLine(showVerticalLines and Moxie[1] crosses above 0, "", CreateColor(0,150,0), Curve.SHORT_DASH);
AddVerticalLine(showVerticalLines and Moxie[1] crosses below 0, "", CreateColor(200,0,0), Curve.SHORT_DASH);

# Indicate the Trampoline setup
def sma50 = Average(close, 50);
plot Trampoline =
  if showTrampolines and ((Moxie < -.01 and close > sma50) or (Moxie > .01 and close < sma50))
  then 0
  else Double.NaN
;
Trampoline.SetPaintingStrategy(PaintingStrategy.SQUARES);
Trampoline.DefineColor("Bullish", Color.LIGHT_GREEN);
Trampoline.DefineColor("Bearish", Color.PINK);
Trampoline.AssignValueColor(if close > sma50 then Trampoline.Color("Bearish") else Trampoline.Color("Bullish"));
Trampoline.HideBubble();
Trampoline.HideTitle();

# show squeeze dots on zero line
def bb = reference BollingerBands.LowerBand;
def squeezeLevel =
  if bb > KeltnerChannels(factor = 1.0).Lower_Band then 3
  else if bb > KeltnerChannels(factor = 1.5).Lower_Band then 2
  else if bb > KeltnerChannels(factor = 2.0).Lower_Band then 1
  else 0
;

plot Squeeze = if !showSqueezeDots then Double.NaN else if !IsNaN(open) then 0 else Double.NaN;
Squeeze.SetPaintingStrategy(PaintingStrategy.POINTS);
Squeeze.SetDefaultColor(Color.GRAY);
Squeeze.DefineColor("Loose Squeeze", Color.UPTICK);
Squeeze.DefineColor("Squeeze", Color.RED);
Squeeze.DefineColor("Tight Squeeze", Color.YELLOW);
Squeeze.DefineColor("No Squeeze", Color.GRAY);
Squeeze.AssignValueColor(
  if squeezeLevel == 3 then Squeeze.Color("Tight Squeeze")
  else if squeezeLevel == 2 then Squeeze.Color("Squeeze")
  else if squeezeLevel == 1 then Squeeze.Color("Loose Squeeze")
  else Squeeze.Color("No Squeeze")
);
Squeeze.SetLineWeight(2);
Squeeze.HideTitle();
Squeeze.HideBubble();

AddLabel(
  yes,
  if currentAggPeriod == AggregationPeriod.WEEK then " W "
  else if currentAggPeriod == AggregationPeriod.Day then " D "
  else if currentAggPeriod == AggregationPeriod.HOUR then " H "
  else if currentAggPeriod == AggregationPeriod.FIFTEEN_MIN then " 15 "
  else if currentAggPeriod == AggregationPeriod.FIVE_MIN then " 5 "
  else if currentAggPeriod == AggregationPeriod.TWO_MIN then " 2 "
  else " ",
  if Moxie < 0 then Color.RED else Color.GREEN
);

Trigger scan:
Ruby:
# because Moxie calculates from higher time frame
# to find daily entries, run this scan on weekly
# to find hourly entries, run this on daily
script Moxie {
    input priceC = close;
    def vc1 = ExpAverage(priceC , 12) - ExpAverage(priceC , 26);
    def va1 = ExpAverage(vc1, 9);
    plot sData = (vc1 - va1) * 3;
}
def m = Moxie();
def moxieUpArrow = m > 0 and m[1] <= 0;
plot scan = moxieUpArrow within 1 bars;

Trampoline scan from @Sneaky_Swings earlier in this thread:
Ruby:
# because Moxie calculates from higher time frame
# to find daily entries, run this scan on weekly
# to find hourly entries, run this on daily

def ap1 = close;

script MoxieFunc {
    input priceC = close;
    def vc1 = ExpAverage(priceC , 12) - ExpAverage(priceC , 26);
    def va1 = ExpAverage(vc1, 9);
    plot sData = (vc1 - va1) * 3;
}

def price = close;
def s2 = MoxieFunc(price);

def ZeroLine = 0;
def Moxie = s2;

# Indicate the Trampoline setup
def sma50 = SimpleMovingAvg(close, 50);

plot trampoline = (Moxie > 0.1 and close < sma50);

EDIT 3/1/21 to add squeeze dots on zero line
Wondering if anyone can modify this code to work in the mobile app version of TOS
Been looking everywhere and no luck
 

New Indicator: Buy the Dip

Check out our Buy the Dip indicator and see how it can help you find profitable swing trading ideas. Scanner, watchlist columns, and add-ons are included.

Download the indicator

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
303 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top