Created
May 2, 2022 11:01
-
-
Save sebv/8a27d84ee55b141538a86d849f12fe87 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//@version=5 | |
indicator(title="Momentum Papa Bear", timeframe="D", timeframe_gaps=true) | |
periods = array.new_int(0) | |
// array.push(periods, input.int(7, minval=1, title="Length")) | |
array.push(periods, input.int(21, minval=1, title="Length")) | |
array.push(periods, input.int(63, minval=1, title="Length")) | |
array.push(periods, input.int(126, minval=1, title="Length")) | |
mom(stock) => | |
pos = str.pos(stock, ":") | |
prefix= str.substring(stock, 0, pos) | |
tkr= str.substring(stock, pos+1) | |
adj_src = ticker.new(prefix, tkr, adjustment=adjustment.dividends) | |
src = request.security(adj_src, "", close) | |
sum = 0.0 | |
for i = 0 to array.size(periods) - 1 | |
p = array.get(periods, i) | |
sum := sum + 100.0 * (src - src[p])/src[p] | |
sum / array.size(periods) | |
plot(mom("BATS:SPY"), color=color.red, title="MOM SPY") | |
plot(mom("BATS:TLT"), color=color.red, title="MOM TLT") | |
plot(mom("BATS:PDBC"), color=color.aqua, title="MOM PDBC") | |
plot(mom("BATS:VNQ"), color=color.blue, title="MOM VNQ") | |
plot(mom("BATS:IAU"), color=color.fuchsia, title="MOM IAU") | |
plot(mom("BATS:VTV"), color=color.green, title="MOM VTV") | |
plot(mom("BATS:VIOV"), color=color.lime, title="MOM VIOV") | |
plot(mom("BATS:VUG"), color=color.maroon, title="MOM VUG") | |
plot(mom("BATS:VEA"), color=color.navy, title="MOM VEA") | |
plot(mom("BATS:BNDX"), color=color.orange, title="MOM BNDX") | |
plot(mom("BATS:VIOG"), color=color.purple, title="MOM VIOG") | |
plot(mom("BATS:VWO"), color=color.olive, title="MOM VWO") | |
plot(mom("BATS:EDV"), color=color.silver, title="MOM EDV") | |
plot(mom("BATS:VGIT"), color=color.teal, title="MOM VGIT") | |
plot(mom("BATS:VCLT"), color=color.yellow, title="MOM VCLT") | |
// plot(mom("BATS:VXUS"), color=color.yellow, title="MOM VXUS") | |
// alt vtv | |
plot(mom("BATS:SPYV"), color=color.green, title="MOM SPYV (alt VTV)") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment