스크리너에서 퍼포먼스는 어떻게 셈하나요?

스크리너 퍼포먼스 데이터는 다음 포뮬러로 셈을 합니다:

//@version=5
indicator(title="Screener Performance")

rateOfreturn(ref) =>
	if ref < 0 and close > 0
		na
	else
		(close - ref) * 100 / math.abs(ref)

rr(bb, maxbarsback) =>
	open[maxbarsback] * 0 + bb == 0 ? na : rateOfreturn(open[bb])

perfYTD() =>
	var lastYearOpen = open
	if year > year[1]
		lastYearOpen := open
	rateOfreturn(lastYearOpen)

fastSearchTimeIndex(x, maxbarsback) =>
	mid = 0 * time[maxbarsback]
	right = math.min(bar_index, maxbarsback)
	left = 0
	if time < x
		0
	else
		for i = 0 to 9 by 1
			mid := math.ceil((left + right) / 2)
			if left == right
				break
			else if time[mid] < x
				right := mid
				continue
			else if time[mid] > x
				left := mid
				continue
			else
				break
		mid

week1 = 7
week_ago = timenow - 1000 * 60 * 60 * 24 * week1
week_ago_this_bar = time - 1000 * 60 * 60 * 24 * week1
countOfBarsWeekAgo = fastSearchTimeIndex(week_ago, week1)

month1 = 30
month_ago = timenow - 1000 * 60 * 60 * 24 * month1
countOfBars1MonthAgo = fastSearchTimeIndex(month_ago, month1)

month3 = 90
months3_ago = timenow - 1000 * 60 * 60 * 24 * month3
countOfBars3MonthAgo = fastSearchTimeIndex(months3_ago, month3)

month6 = 180
months6_ago = timenow - 1000 * 60 * 60 * 24 * month6
countOfBars6MonthAgo = fastSearchTimeIndex(months6_ago, month6)

years1 = 365
oneYearAgo = timenow - 1000 * 60 * 60 * 24 * years1
barsCountOneYear = fastSearchTimeIndex(oneYearAgo, years1)

years3 = 365 * 3
years3_ago = timenow - 1000 * 60 * 60 * 24 * years3
countOfBars3YearAgo = fastSearchTimeIndex(years3_ago, years3)

years5 = 365 * 4 + 366
years5_ago = timenow - 1000 * 60 * 60 * 24 * years5
countOfBars5YearAgo = fastSearchTimeIndex(years5_ago, years5)

years10 = (365 * 4 + 366) * 2
years10_ago = timenow - 1000 * 60 * 60 * 24 * years10
countOfBars10YearAgo = fastSearchTimeIndex(years10_ago, years10)

perfYTD = perfYTD()
plot((close - open[4]) / open[4] * 100, title='Perf.5D')
plot(rr(countOfBarsWeekAgo, week1), title='Perf.W')
plot(rr(countOfBars1MonthAgo, month1), title='Perf.1M')
plot(rr(countOfBars3MonthAgo, month3), title='Perf.3M')
plot(rr(countOfBars6MonthAgo, month6), title='Perf.6M')
plot(rr(barsCountOneYear, years1), title='Perf.Y')
plot(rr(countOfBars3YearAgo, years3), title='Perf.3Y')
plot(rr(countOfBars5YearAgo, years5), title='Perf.5Y')
plot(rr(countOfBars10YearAgo, years10), title='Perf.10Y')
plot(perfYTD, title='Perf.YTD')
Java

노트: 이 스크립트 밸류는 히스토리와 리얼타임에서 서로 다릅니다. 이는 timenow 때문이며, https://kr.tradingview.com/pine-script-docs/en/v4/essential/Indicator_repainting.html 를 읽어 보기 바랍니다.

비주얼 디스플레이는 이 스크립트를 파인 에디터로 데일리 차트 프레임에 넣으면 됩니다. 차트에 인디케이터가 나타나고, 그 플롯에서는 각 타입의 퍼포먼스 밸류가 나옵니다.

체인지 % vs 퍼포먼스 %:

오늘이 화요일이라고 가정하겠습니다. 위클리 체인지는 오늘 클로즈 (화요일) 에서 지난 주 클로즈 (지난 금요일 클로즈 프라이스) 를 뻰 값입니다. 위클리 퍼포먼스는 오늘 클로즈 (화요일) 에서 딱 1주 앞 클로즈 (지난 주 화요일) 를 뻰 값입니다.