Moxie Indicator for ThinkorSwim

BenTen's Watchlist + Setup + Trade Recaps

Get access to Ben's watchlist, swing trading strategy, ThinkorSwim setup, and trade examples.

Learn more

@Slippage What are the Moxie settings for the 1 and 2 minute charts?
Moxie's creator doesn't trade timeframes below 15m, which he uses for entries to swings that last days or weeks. He mentioned he has customers who use it on 5m and 2m charts but he didn't give any indication of different settings. In the code. I set it to use 5m as the higher timeframe it looks at when you're on a 1m or 2m chart. You shouldn't need to change anything but of course you can experiment with this line and to try other higher timeframes. This line controls it on both 1m and 2m charts.

Ruby:
if currentAggPeriod <= AggregationPeriod.TWO_MIN then AggregationPeriod.FIVE_MIN

You'll find Moxie repaints. It looks like a great signal when you're looking at charts but the truth is the signal doesn't show up until the higher timeframe triggers it which may be a few candles later than it looks like later and it may untrigger/retrigger many times before the higher timeframe candle closes and you have a final answer. Even then its creator doesn't trade it by going long/short from the trigger. It's more like a bias indication than a trigger.
 
Here's my final code all cleaned up. Since Watkins only uses the second line on 15m charts, in order to avoid impacting performance on other timeframes I made it use the current timeframe's data to calculate the second line. The second line is useless now on other timeframes. It will be the same as first line. If we're following the Moxie strategy we don't need the second line on other timeframes anyway.

When you're switching through symbols and trying to scan with your eyes across multiple charts quickly the zero line can be hard to notice when it's at the top or bottom. I added a label to the lower study so it's easier to see, at a glance, if a particular timeframe is above (green) or below (red) zero. I was thinking about also creating an MTF study to add labels for higher timeframes so if you're maximized on the 1H chart you can still see if Moxie is above zero on D and W charts.

That said, I'm setting Moxie aside for now while I do some testing with a Squeeze Pro clone. I'm keeping the Moxie lower study on my charts for now as the only visible momentum indicator since I've customized Squeeze Pro to give signal arrows when both its built in momentum and the TTM_Wave move together in the same direction. I may or may not keep Moxie along with Squeeze Pro depending on if it's redundant or if it's later to correctly signal direction changes.

Here's the Moxie upper study for the arrows
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 price =
  if currentAggPeriod == AggregationPeriod.FIFTEEN_MIN then high(period = higherAggPeriod)
  else close(period = higherAggPeriod)
;
def Moxie = MoxieFunc(price);

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();

And here's the Moxie lower study
Ruby:
declare lower;

input showVerticalLines = yes;
input showTrampolines = yes;

plot ZeroLine = 0;
ZeroLine.SetDefaultColor(Color.GRAY);
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;
}

# Watkins uses the high for 15m charts and the close for other timeframes
def price =
  if currentAggPeriod == AggregationPeriod.FIFTEEN_MIN
  then high(period = higherAggPeriod)
  else close(period = higherAggPeriod)
;

plot Moxie = MoxieFunc(price);
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.
# We'll hide the second Moxie line by default. You should enable it
# on 15 minute charts.
# 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
  # on the next line it seems like we should be able to use AggregationPeriod.TWO_HOURS
  # instead of the secondAggPeriod variable holding that value but for some reason that
  # causes the main Moxie plot on 1 hour chart to render nothing.
  then MoxieFunc(high(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.Hide();

# Show vertical lines at crossovers
AddVerticalLine(showVerticalLines and Moxie[1] <= 0 and Moxie > 0, "", CreateColor(0,150,0), Curve.SHORT_DASH);
AddVerticalLine(showVerticalLines and Moxie[1] >= 0 and Moxie < 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();

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 Moxie < 0 then Color.RED else Color.GREEN
);
Apologies - noob question here. I copied both upper and lower code into a *STUDY.ts file and imported it in TOS, but to no avail. Is this code supposed to work as a study or something else?

Great content on the site so far.
 
Apologies - noob question here. I copied both upper and lower code into a *STUDY.ts file and imported it in TOS, but to no avail. Is this code supposed to work as a study or something else?

Great content on the site so far.

Quick question... Why don't you simply use Copy & Paste and avoid the drama and extra work...???
 
Quick question... Why don't you simply use Copy & Paste and avoid the drama and extra work...???
Thanks for the prompt response, @rad14733 . I wasn't sure where to copy and paste directly, but I think I got it. Under Edit Studies->Create->Declarations I see upper and lower, and pasted the corresponding code blocks under both sections. I think it works now.

New to the platform, so still figuring it out. Thanks.
 
I've got the 15m two lines thing figured out.

He's using the same calculations but getting them from 2 different timeframes -- the 1-hour and the 2-hour. He's also using the high rather than the close. I noticed his study name in the video is Moxie_15_High so that's what tipped me off for that part. I've got the code updated as well as a general cleanup/reformatting of the entire thing and I made the trampoline and the vertical lines configurable. Sorry to add code churn for those following along.

Now this will access two additional timeframes on every chart instead of just one. We probably should split this into two scripts like Simpler did, for performance reasons. I don't have time/ambition to do that right now but maybe before the weekend.

Anyway, here's the latest code. The second moxie line is hidden by default. You need to enable it on your 15m charts.
Ruby:
declare lower;

input showVerticalLines = yes;
input showTrampolines = yes;

plot ZeroLine = 0;
ZeroLine.SetDefaultColor(Color.GRAY);

def currentAggPeriod = GetAggregationPeriod();
def higherAggPeriod = if currentAggPeriod == AggregationPeriod.MIN then AggregationPeriod.FIVE_MIN
  else if currentAggPeriod == AggregationPeriod.THREE_MIN then AggregationPeriod.FIVE_MIN
  else if currentAggPeriod == AggregationPeriod.FIVE_MIN then AggregationPeriod.FIFTEEN_MIN
  else if currentAggPeriod == AggregationPeriod.FIFTEEN_MIN then AggregationPeriod.HOUR
  else if currentAggPeriod == AggregationPeriod.THIRTY_MIN then AggregationPeriod.HOUR
  else if currentAggPeriod == AggregationPeriod.HOUR then AggregationPeriod.DAY
  else if currentAggPeriod == AggregationPeriod.TWO_HOURS then AggregationPeriod.DAY
  else if currentAggPeriod == AggregationPeriod.FOUR_HOURS then AggregationPeriod.DAY
  else if currentAggPeriod == AggregationPeriod.DAY then AggregationPeriod.WEEK
  else if currentAggPeriod == AggregationPeriod.WEEK then AggregationPeriod.MONTH
  else AggregationPeriod.DAY
;

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

# Watkins uses the high for 15m charts and close for other timeframes
def price = if currentAggPeriod == AggregationPeriod.FIFTEEN_MIN then high(period = higherAggPeriod) else close(period = higherAggPeriod);

plot Moxie = MoxieFunc(price);
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 2 different higher timeframes.
# We'll hide the second Moxie line by default
def secondAggPeriod = if currentAggPeriod == AggregationPeriod.MIN then AggregationPeriod.FIFTEEN_MIN
  else if currentAggPeriod == AggregationPeriod.THREE_MIN then AggregationPeriod.FIFTEEN_MIN
  else if currentAggPeriod == AggregationPeriod.FIVE_MIN then AggregationPeriod.THIRTY_MIN
  else if currentAggPeriod == AggregationPeriod.FIFTEEN_MIN then AggregationPeriod.TWO_HOURS
  else if currentAggPeriod == AggregationPeriod.THIRTY_MIN then AggregationPeriod.TWO_HOURS
  else if currentAggPeriod == AggregationPeriod.HOUR then AggregationPeriod.TWO_DAYS
  else if currentAggPeriod == AggregationPeriod.TWO_HOURS then AggregationPeriod.TWO_DAYS
  else if currentAggPeriod == AggregationPeriod.FOUR_HOURS then AggregationPeriod.TWO_DAYS
  else if currentAggPeriod == AggregationPeriod.DAY then AggregationPeriod.MONTH
  else AggregationPeriod.YEAR
;

plot MoxieSecondLine = MoxieFunc(high(period = secondAggPeriod));
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.Hide();

# Show vertical lines at crossovers
AddVerticalLine(showVerticalLines and Moxie[1] <= 0 and Moxie > 0, "", Color.GREEN, Curve.SHORT_DASH);
AddVerticalLine(showVerticalLines and Moxie[1] >= 0 and Moxie < 0, "", Color.LIGHT_RED, Curve.SHORT_DASH);

# Indicate the Trampoline setup
def sma50 = SimpleMovingAvg(close, 50);
plot Trampoline = if showTrampolines and ((Moxie < -0.1 and close > sma50) or (Moxie > 0.1 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"));
Hi is there a way to scan for divergence in the MOXIE to PRICE ?
 
Other Coders, Please tell me what you think of my attempt to mimic with this Mooxie #2 Time frames. Only to be used on the 15 minute time frame? I would love to send the code to someone who can add a couple of things like the 15 minute Arrows for the signal. I will finish cleaning it up and post it shortly. Sorry TG, I just cannot justify buying yet another indicator... And Imitation is one of the best forms of flattery :)

BG7vxO.jpg
 
Last edited:
Other Coders, Please tell me what you think of my attempt to mimic with this Mooxie #2 Time frames. Only to be used on the 15 minute time frame? I would love to send the code to someone who can add a couple of things like the 15 minute Arrows for the signal. I will finish cleaning it up and post it shortly. Sorry TG, I just cannot justify buying yet another indicator... And Imitation is one of the best forms of flattery :)

BG7vxO.jpg

The second line for 15m timeframe is already included in the code I posted. You just need to check the box to turn on that plot on 15m charts.

Yours looks like it's drawing fine. On 15m Watkins uses two higher timeframes to draw two different Moxie lines, 1-hour and 2-hour. And he's using the high instead of closing price only on 15m timeframe. So if that's what you implemented then it's correct.
 
Last edited:
Hi is there a way to scan for divergence in the MOXIE to PRICE ?

No, it's not possible. I doubt the real Moxie indicator has such a scan either since it has no visual to cues for divergence. I played with visuals for a few minutes weeks ago using code I stole from a Mobius RSI Divergence study but it didn't work very well so I scrapped it.
 
The second line for 15m timeframe is already included in the code I posted. You just need to check the box to turn on that plot on 15m charts.

Yours looks like it's drawing fine. On 15m Watkins uses two higher timeframes to draw two different Moxie lines, 1-hour and 2-hour. And he's using the high instead of closing price only on 15m timeframe. So if that's what you implemented then it's correct.
Hi Slippage, thank u very much on the indicator. i have installed and set the chart to 15mins but i do not see the second line in the lower studies. I wanted to insert a picture of my chart for purview but didnt know how to. Is there certain settings i need to set for the second line to appear? Thank u in advance
 
Hi Slippage, thank u very much on the indicator. i have installed and set the chart to 15mins but i do not see the second line in the lower studies. I wanted to insert a picture of my chart for purview but didnt know how to. Is there certain settings i need to set for the second line to appear? Thank u in advance

In the settings for the lower study, on the MoxieSecondLine tab, check the box that says "Show plot".
 
@Slippage...excellent reproduction of Moxie. I have a question. I have noticed the arrows ranging from one to eight when they appear, is there any significance to this? Does it indicate the strength of the signal or something else?
 
@Slippage...excellent reproduction of Moxie. I have a question. I have noticed the arrows ranging from one to eight when they appear, is there any significance to this? Does it indicate the strength of the signal or something else?

The number of arrows depends on how many of your current timeframe fit into the higher timeframe Moxie is using to calculate its plot. On daily you'll get 5 arrows for the week. On hourly, you'll get 8 arrows for the day, etc.
 
Here's my final code all cleaned up. Since Watkins only uses the second line on 15m charts, in order to avoid impacting performance on other timeframes I made it use the current timeframe's data to calculate the second line. The second line is useless now on other timeframes. It will be the same as first line. If we're following the Moxie strategy we don't need the second line on other timeframes anyway.

When you're switching through symbols and trying to scan with your eyes across multiple charts quickly the zero line can be hard to notice when it's at the top or bottom. I added a label to the lower study so it's easier to see, at a glance, if a particular timeframe is above (green) or below (red) zero. I was thinking about also creating an MTF study to add labels for higher timeframes so if you're maximized on the 1H chart you can still see if Moxie is above zero on D and W charts.

That said, I'm setting Moxie aside for now while I do some testing with a Squeeze Pro clone. I'm keeping the Moxie lower study on my charts for now as the only visible momentum indicator since I've customized Squeeze Pro to give signal arrows when both its built in momentum and the TTM_Wave move together in the same direction. I may or may not keep Moxie along with Squeeze Pro depending on if it's redundant or if it's later to correctly signal direction changes.

Here's the Moxie upper study for the arrows
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 price =
  if currentAggPeriod == AggregationPeriod.FIFTEEN_MIN then high(period = higherAggPeriod)
  else close(period = higherAggPeriod)
;
def Moxie = MoxieFunc(price);

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();

And here's the Moxie lower study
Ruby:
declare lower;

input showVerticalLines = yes;
input showTrampolines = yes;

plot ZeroLine = 0;
ZeroLine.SetDefaultColor(Color.GRAY);
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;
}

# Watkins uses the high for 15m charts and the close for other timeframes
def price =
  if currentAggPeriod == AggregationPeriod.FIFTEEN_MIN
  then high(period = higherAggPeriod)
  else close(period = higherAggPeriod)
;

plot Moxie = MoxieFunc(price);
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.
# We'll hide the second Moxie line by default. You should enable it
# on 15 minute charts.
# 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
  # on the next line it seems like we should be able to use AggregationPeriod.TWO_HOURS
  # instead of the secondAggPeriod variable holding that value but for some reason that
  # causes the main Moxie plot on 1 hour chart to render nothing.
  then MoxieFunc(high(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.Hide();

# Show vertical lines at crossovers
AddVerticalLine(showVerticalLines and Moxie[1] <= 0 and Moxie > 0, "", CreateColor(0,150,0), Curve.SHORT_DASH);
AddVerticalLine(showVerticalLines and Moxie[1] >= 0 and Moxie < 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();

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 Moxie < 0 then Color.RED else Color.GREEN
);
Hi Slippage,
Just noticed your contributions as I had recently seen a Simpler Trading / TG marketing video and was curious as to what Moxie indi really was...

So thanks very much for all your effort in sleuthing and coding and testing...

You may be aware of this, but just for the general knowledge, in looking at your code, MoxieFunc() seems really just to be a slight variant on MACD Histogram, otherwise known as OsMA or Oscillator of Moving Averages using the standard OsMA periods (12, 26, 9) and MA methods (Exp, Exp, Sma), but instead using the next Higher Time Frame to give the staircase effect (and make the changes more visually dramatic and reflective of the HTF MACD C/D's) and 2 colored line rather than single/dual or 4 color histograms which are generally used. And on 15min (and lower) TF uses next 2 HTFs (and price of High rather than Close as you have discovered).

The unique Moxie parts seem to be identifying the HTF "trampoline" OsMA and 50/200 MA relationships and use of HTF slope colored line to make easy to quickly see trend direction and crosses.

A few minor things I notice in your code:
  • uses Exp MA method for the MACD smoothing/signal (ie def va1 = ExpAverage(vc1, 9); should it be Sma?)
  • only uses the 2 HTFs for the 15min TF ( ie if currentAggPeriod == AggregationPeriod.FIFTEEN_MIN; should it be 15min and lower TFs?)

Nicely done!
 
Last edited:
Lol just because they cherry-picked a few examples for you, that doesn't mean it works. Did they show you their account or P/L statements? Of course not.
Hi all, I actually own the original Moxie indicator and I'm in his paid trading room. He HAS shown his account balances. He is very transparent about that stuff. He is also honest when things don't work and where he is wrong. He teaches us what to look for.

The point I'm trying to make is that his indicator works, but you should study his strategy. He doesn't enter trades when his indicator fires. There is a set of rules that have to be met before a trade is taken. The indicator is just a guide.
 
Newbie here, thanks for the great work on Moxie, is there a final version of the shareable link for TOS?

There's no shareable link. The owners of this site prefer things be shared via code. I do as well so I have better control of what I'm importing into TOS.
 
A few minor things I notice in your code:
  • uses Exp MA method for the MACD smoothing/signal (ie def va1 = ExpAverage(vc1, 9); should it be Sma?)
  • only uses the 2 HTFs for the 15min TF ( ie if currentAggPeriod == AggregationPeriod.FIFTEEN_MIN; should it be 15min and lower TFs?)

The code in MoxieFunc predates my efforts on this. That part was posted earlier in this thread before I joined the effort and it was copied/ported from TradingView, if I remember correctly. The code posted before I joined was very close to real Moxie, with just (arguably better) different line coloring and the calculation for the second line on 15m wasn't correct. Fixing that was my main contribution.

My intention was to replicate the real Moxie's behavior exactly. The existing formula seems to do that and so does the choice of using 2 lines only on 15m charts. In some videos you can see Watkins does have 5m and 2m charts that are rarely within the view of the recording and he isn't using two lines on those. He doesn't trade those timeframes and very rarely mentions them in his videos though he did state he has some customers day trading on those with Moxie.

The trampoline indication and vertical lines at crossovers were enhancements I added that the original Moxie doesn't include. I added the inputs to enable/disable them so it's easy to turn them off and have the same experience as the real Moxie indicator if that's what someone wants.
 

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
302 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