Created
September 17, 2018 00:56
-
-
Save sophie-eihpos/e63ed275fd4edd8c36ded7f329788dce to your computer and use it in GitHub Desktop.
1HAlerts
This file contains 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=2 | |
study(title='Alert 1H', shorttitle='Alert 1H', overlay=false) | |
duration=input('540') | |
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