#START OF Mooxie for ThinkOrSwim
#Fair disclosure, lots of others on the web contributed to much of the original code.
#Adjustments were made to simplify it. And changes can be made to customize this.
declare lower;
input aggPeriod = AggregationPeriod.DAY;
script Mooxie {
input priceC = close;
def vc1 = ExpAverage(priceC , 12) - ExpAverage(priceC , 26);
def va1 = ExpAverage(vc1, 9);
plot sData = (vc1 - va1) * 3;}
def priceMooxie = close(period = aggPeriod);
def s2 = Mooxie(priceMooxie);
rec mooxieFT = CompoundValue(1, 0.5 * (Log((1 + s2) / (1 - s2)) + mooxieFT[1]), 0);
Plot zero = 0;
zero.setDefaultColor(Color.RED);
###FIRST TIME FRAME###
plot MooxiePlot = s2; # Plot InverseFT Moxie
MooxiePlot.SetPaintingStrategy(PaintingStrategy.LINE);
MooxiePlot.SetLineWeight(1);
MooxiePlot.DefineColor("Positive and Up", Color.GREEN);
MooxiePlot.DefineColor("Positive and Down", Color.GREEN);
MooxiePlot.DefineColor("Negative and Down", Color.GREEN);
MooxiePlot.DefineColor("Negative and Up", Color.GREEN);
MooxiePlot.AssignValueColor(if s2 >= 0 then if s2 > s2[1] then MooxiePlot.color("Positive and Up") else MooxiePlot.color("Positive and Down") else if s2 < s2[1] then MooxiePlot.color("Negative and Down") else MooxiePlot.color("Negative and Up"));
### SECOND TIME FRAME###
input aggPeriod2 = AggregationPeriod.THREE_DAYS;
script Moxie2 {
input priceC2 = close;
def vc1B = ExpAverage(priceC2 , 12) - ExpAverage(priceC2 , 26);
def va1B = ExpAverage(vc1B, 9);
plot sData2 = (vc1B - va1B) * 3;}
def priceMooxie2 = close(period = aggPeriod2);
def s2B = Mooxie(priceMooxie2);
rec mooxieFTB = CompoundValue(1, 0.5 * (Log((1 + s2B) / (1 - s2B)) + mooxieFTB[1]), 0);
plot MooxiePlot2 = s2B; # Plot InverseFT Mooxie
MooxiePlot2.SetPaintingStrategy(PaintingStrategy.LINE);
MooxiePlot2.SetLineWeight(1);
MooxiePlot2.DefineColor("Positive and Up", Color.DARK_ORANGE);
MooxiePlot2.DefineColor("Positive and Down", Color.DARK_ORANGE);
MooxiePlot2.DefineColor("Negative and Down", Color.DARK_ORANGE);
MooxiePlot2.DefineColor("Negative and Up", Color.DARK_ORANGE);
MooxiePlot2.AssignValueColor(if s2B>= 0 then if s2B > s2B[1] then MooxiePlot2.color("Positive and Up") else MooxiePlot2.color("Positive and Down") else if s2B < s2B[1] then MooxiePlot2.color("Negative and Down") else MooxiePlot2.color("Negative and Up"));
### THIRD TIME FRAME###
input aggPeriod3 = AggregationPeriod.WEEK;
script Mooxie3 {
input priceC3 = close;
def vc1C = ExpAverage(priceC3 , 12) - ExpAverage(priceC3 , 26);
def va1C = ExpAverage(vc1C, 9);
plot sData3 = (vc1C - va1C) * 3;}
def priceMooxie3 = close(period = aggPeriod3);
def s2C = Mooxie(priceMooxie3);
rec mooxieFTC = CompoundValue(1, 0.5 * (Log((1 + s2C) / (1 - s2c)) + mooxieFTC[1]), 0);
plot MooxiePlot3 = s2C; # Plot InverseFT Mooxie
MooxiePlot3.SetPaintingStrategy(PaintingStrategy.LINE);
MooxiePlot3.SetLineWeight(1);
MooxiePlot3.DefineColor("Positive and Up", Color.MAGENTA);
MooxiePlot3.DefineColor("Positive and Down", Color.MAGENTA);
MooxiePlot3.DefineColor("Negative and Down", Color.MAGENTA);
MooxiePlot3.DefineColor("Negative and Up", Color.MAGENTA);
MooxiePlot3.AssignValueColor(if s2c>= 0 then if s2c > s2c[1] then MooxiePlot3.color("Positive and Up") else MooxiePlot3.color("Positive and Down") else if s2c < s2c[1] then MooxiePlot3.color("Negative and Down") else MooxiePlot3.color("Negative and Up"));