Skip to content

Instantly share code, notes, and snippets.

@sophie-eihpos
Created September 21, 2018 18:20
Show Gist options
  • Save sophie-eihpos/16b227db97027bbed4d30aa22aa33d54 to your computer and use it in GitHub Desktop.
Save sophie-eihpos/16b227db97027bbed4d30aa22aa33d54 to your computer and use it in GitHub Desktop.
1WAlerts
//@version=2
study(title='Alert 1W', shorttitle='Alert 1W', overlay=false)
duration=input('90D')
ch1 = security(tickerid, duration, open)
ch2 = security(tickerid, duration, close)
// Signals//
long = crossover(ch2, ch1)
short = crossunder(ch2, ch1)
last_long = long ? time : nz(last_long[1])
last_short = short ? time : nz(last_short[1])
long_signal = crossover(last_long, last_short) ? 1 : -1
short_signal = crossover(last_short, last_long) ? -1 : 1
plot(long_signal, title="Long", color=green)
plot(short_signal, title="Short", color=red)
plot(0, title="Trigger", color=white)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment