Skip to content

Instantly share code, notes, and snippets.

@rwilkes
Created March 22, 2020 06:23
Show Gist options
  • Save rwilkes/5dfd4fc768881f7fb76f2732a2458b0a to your computer and use it in GitHub Desktop.
Save rwilkes/5dfd4fc768881f7fb76f2732a2458b0a to your computer and use it in GitHub Desktop.
ThinkScript: Moving AVG Crossover
# Moving Average Crossover With Arrows, Alerts, Crossing Count and Bubble at Cross
# Mobius
# Chat Room Request 01.25.2017
# Modified a bit by BenTen
input price = close;
input fastLength = 34;
input slowLength = 50;
input averageType = AverageType.EXPONENTIAL;
plot FastMA = MovingAverage(averageType, price, fastLength);
plot SlowMA = MovingAverage(averageType, price, slowLength);
FastMA.SetDefaultColor(GetColor(1));
SlowMA.SetDefaultColor(GetColor(2));
plot ArrowUp = if FastMA crosses above SlowMA
then low
else double.nan;
ArrowUP.SetPaintingStrategy(PaintingStrategy.Arrow_UP);
ArrowUP.SetLineWeight(3);
ArrowUP.SetDefaultColor(Color.Green);
plot ArrowDN = if FastMA crosses below SlowMA
then high
else double.nan;
ArrowDN.SetPaintingStrategy(PaintingStrategy.Arrow_DOWN);
ArrowDN.SetLineWeight(3);
ArrowDN.SetDefaultColor(Color.Red);
Alert(ArrowUp, " ", Alert.Bar, Sound.Chimes);
Alert(ArrowDN, " ", Alert.Bar, Sound.Bell);
AddCloud(FastMA, SlowMA, Color.GREEN, Color.RED);
# End Code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment