final kiran code
final kiran code
0 at
https://mozilla.org/MPL/2.0/
// © Algoryze
//@version=5
indicator("Kiran Indicator", overlay=true, max_lines_count=500,
max_boxes_count=500, max_labels_count=500)
// Function to get the highest, lowest, and closing prices of the previous day
_getPreviousDayLevels(utcOffsetInMs) =>
dow = dayofweek(time + utcOffsetInMs)
var prevDayHigh = high
var prevDayLow = low
var prevDayClose = close
var dayHigh = high
var dayLow = low
var dayClose = close
if (dow != dow[1])
prevDayHigh := dayHigh[1]
prevDayLow := dayLow[1]
prevDayClose := close[1]
dayHigh := high
dayLow := low
dayClose := close
else
dayHigh := math.max(dayHigh, high)
dayLow := math.min(dayLow, low)
dayClose := close
const string TZ_TOOLTIP_TEXT = "The session's time zone, specified in either GMT
notation (e.g., 'GMT-5') or as an IANA time zone database name (e.g.,
'America/New_York')."
+ " We recommend the latter since it includes other time-related changes, such as
daylight savings."
type SessionDisplay
box sessionBox
label sessionLabel
line openLine
line avgLine
line closeLine
float sumClose
int numOfBars
type SessionInfo
color color
string name
string session
string timezone
SessionDisplay active = na
sessionLabel.set_y(sessionBox.get_bottom())
sessionLabel.set_text(array.join(boxText, "\n"))
sessionBox.set_top(math.max(sessionBox.get_top(), high))
sessionBox.set_bottom(math.min(sessionBox.get_bottom(), low))
sessionBox.set_right(bar_index)
sessionDisp.setName(this.name)
if showSessionOC
openLine.set_x2(bar_index)
closeLine.set_x2(bar_index)
closeLine.set_y1(close)
closeLine.set_y2(close)
if showSessionAverage
avgLine.set_x2(bar_index)
avg = sessionDisp.sumClose / sessionDisp.numOfBars
avgLine.set_y1(avg)
avgLine.set_y2(avg)
sessionDisp
getSessionInfos()=>
array<SessionInfo> sessionInfos = array.new<SessionInfo>()
if showFirst
sessionInfos.push(SessionInfo.new(firstSessionColor, firstSessionName,
firstSessionTime, firstSessionTZ))
if showSecond
sessionInfos.push(SessionInfo.new(secondSessionColor, secondSessionName,
secondSessionTime, secondSessionTZ))
if showThird
sessionInfos.push(SessionInfo.new(thirdSessionColor, thirdSessionName,
thirdSessionTime, thirdSessionTZ))
sessionInfos