Inspiration
Browsing for new or interesting indicators and specifically moving averages I came across this one:https://user42.tuxfamily.org/chart/manual/Endpoint-Moving-Average.html
which looked interesting.
It turns out to be quite fast, and interesting. I built a strategy with a two ma crossover. Take out the AddOrder() functions at the end if you just want the indicator.
Install
http://tos.mx/6xT3DgLIndicator Code
Code:
#########################################################
#
# Endpoint Moving Average
#
# for the usethinkscript.com community
# by mashume 2023.01
#
# after code from:
# https://user42.tuxfamily.org/chart/manual/Endpoint-Moving-Average.html
#
##########################################################
declare upper;
input fast_length = 30;
input slow_length = 50;
script epma{
input length = 15;
input p = CLOSE;
def numerator = fold n = 0 to length with s do s + (2 * length -((n * 3) + 1)) * getValue(p, n);
def denominator = fold a = 0 to length with b do b + (2 * length -((a * 3) + 1));
plot epma = numerator / denominator;}
plot fast = epma(fast_length, close);
plot slow = epma(slow_length, close);
AddOrder(type = OrderType.BUY_AUTO, fast crosses above slow, tradeSize = 1, tickColor = Color.BLUE, arrowColor = Color.BLUE);
AddOrder(type = OrderType.SELL_AUTO, fast crosses below slow, tradeSize = 1, tickColor = Color.BLUE, arrowColor = Color.BLUE);
Eye Candy
This indicator likes to be adjusted. None of the default settings work for every situation. I've included the Floating Profit Loss indicator using a simple two line crossover strategy.SPY 1Y 1D
TESLA 1Y 1D
/ES 10d 5m
Happy Trading
-mashume