Skip to content

Instantly share code, notes, and snippets.

@TraderX0
Created August 24, 2019 17:05
Show Gist options
  • Save TraderX0/c515fed8f4f27a01fb934784a06f3c9f to your computer and use it in GitHub Desktop.
Save TraderX0/c515fed8f4f27a01fb934784a06f3c9f to your computer and use it in GitHub Desktop.
Open levels
//author @X0_Trading_levels
//script to plot various trading levels
//version 1.3
//last edited 24/08/2019
//title
study(title="X0_Trading_levels", shorttitle="X0_Trading_levels", overlay=true)
// holds the daily price levels
dailyOpen = security(tickerid, 'D', open)
dailyHigh = security(tickerid, 'D', high)
dailyLow = security(tickerid, 'D', low)
weeklyOpen = security(tickerid, 'W', open)
monthlyOpen = security(tickerid, 'M', open)
// function which is called by plot to establish day of the week is monday return true or false
isMonday() => dayofweek(time('D')) == monday ? 1 : 0
// plot works by combining the isMonday function combined with the price to plot the line for that given condition
plot(isMonday() and dailyOpen ? dailyOpen: na, title="Monday Open", style=cross, linewidth=2, color=blue)
plot(isMonday() and dailyHigh ? dailyHigh: na, title="Monday High", style=cross, linewidth=2, color=green)
plot(isMonday() and dailyLow ? dailyLow : na, title="Monday Low", style=cross, linewidth=2, color=red)
// plot daily level
plot(dailyOpen, title="Daily Open", style=cross, linewidth=2, color=blue)
plot(dailyHigh, title="Daily High", style=cross, linewidth=2, color=green)
plot(dailyLow, title="Daily Low", style=cross, linewidth=2, color=red)
// plot weekly level
plot(weeklyOpen, title="Weekly Open", style=cross, linewidth=2, color=green)
// plot monthly level
plot(monthlyOpen, title="Monthly Open", style=cross, linewidth=2, color=purple)
// end of script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment