I really think this is going to be a good strategy. I need to still add Labels so it will work with Macro Recorder. That isn't necessary though. I would like every ones feedback and criticism. Try it out. I will attempt to add labels. I also may add a couple of filters. Not sure if I will need them because with my testing so far, as long as you lengthen the Fast HMA, you can cut out most of the pullbacks and chop.
Latest Code:
HMA_V2 https://tos.mx/s900BxW
Latest Code:
HMA_V2 https://tos.mx/s900BxW
Code:
#Metal's-HMA-Strat-V1
#Credit @dap711 for providing the base code here https://usethinkscript.com/threads/moving-average-master-strategy-for-thinkorswim.13975/post-118000
input price = close;
input fastLength = 20;
input fastDisplace = 0;
input slowLength = 50;
input slowDisplace = 0;
plot Fast_HMA = MovingAverage(AverageType.HULL, price, fastLength)[-fastDisplace];
plot Slow_HMA = MovingAverage(AverageType.HULL, price, slowLength)[-slowDisplace];
Fast_HMA.DefineColor("Up", GetColor(1));
Fast_HMA.DefineColor("Down", GetColor(0));
Fast_HMA.AssignValueColor(if Fast_HMA > Fast_HMA[1] then Fast_HMA.Color("Up") else Fast_HMA.Color("Down"));
Slow_HMA.DefineColor("Up", GetColor(1));
Slow_HMA.DefineColor("Down", GetColor(0));
Slow_HMA.AssignValueColor(if Slow_HMA > Slow_HMA[1] then Slow_HMA.Color("Up") else Slow_HMA.Color("Down"));
plot BuySignal = if (Slow_HMA[1] <= Slow_HMA[2] and Slow_HMA > Slow_HMA[1]) then Slow_HMA else Double.NaN;
BuySignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
BuySignal.AssignValueColor(Color.GREEN);
BuySignal.SetLineWeight(3);
plot SellSignal = if (Slow_HMA[1] >= Slow_HMA[2] and Slow_HMA < Slow_HMA[1]) then Slow_HMA else Double.NaN;
SellSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
SellSignal.AssignValueColor(Color.RED);
SellSignal.SetLineWeight(3);
plot BuyExit = if (Fast_HMA[1] >= Fast_HMA[2] and Fast_HMA < Fast_HMA[1]) then Fast_HMA else Double.NaN;
BuyExit.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
BuyExit.AssignValueColor(Color.YELLOW);
BuyExit.SetLineWeight(3);
plot SellExit = if (Fast_HMA[1] <= Fast_HMA[2] and Fast_HMA > Fast_HMA[1]) then Fast_HMA else Double.NaN;
SellExit.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
SellExit.AssignValueColor(Color.YELLOW);
SellExit.SetLineWeight(3);
AddOrder(OrderType.BUY_TO_OPEN, BuySignal, open[-1], 100, Color.GREEN, Color.GREEN);
AddOrder(OrderType.SELL_TO_CLOSE, SellSignal, open[-1], 100, Color.RED, Color.RED);
AddOrder(OrderType.SELL_TO_OPEN, BuyExit, open[-1], 100, Color.YELLOW, Color.YELLOW);
AddOrder(OrderType.BUY_TO_CLOSE, SellExit, open[-1], 100, Color.YELLOW, Color.YELLOW);
Last edited: