0% found this document useful (0 votes)
5 views2 pages

Text To PDF PDF To Text 402 634

The document outlines a script for creating a table that displays various financial metrics based on user-defined inputs and conditions. It includes calculations for trend strength, annualized return, and compound annual growth rate (CAGR) based on detected periods and slopes. The script also allows for customization of text size and color for better visualization of the data presented.

Uploaded by

kghdth0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Text To PDF PDF To Text 402 634

The document outlines a script for creating a table that displays various financial metrics based on user-defined inputs and conditions. It includes calculations for trend strength, annualized return, and compound annual growth rate (CAGR) based on detected periods and slopes. The script also allows for customization of text size and color for better visualization of the data presented.

Uploaded by

kghdth0
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

var table t = na

if periodMode
t := table.new(position.bottom_center, 2, 3)
t
else
t := table.new(getTablePosition(tablePositionInput), 2, 3)
t
string text1 = periodMode ? 'Auto-Selected Period (Long Term): ' +
str.tostring(detectedPeriod)
: 'Auto-Selected Period: ' + str.tostring(detectedPeriod)
var colorInputLight = color.new(colorInput, 0)
// Display or hide the "Auto-Selected Period" cell
if showAutoSelectedPeriod
table.cell(t, 0, 0, text1, text_color = colorInputLight, text_size =
textSizeInput == 'Large' ?
size.large : textSizeInput == 'Small' ? size.small : size.normal)
// Display or hide the "Trend Strength" or "Pearson's R" cell
if showTrendStrength
if showPearsonInput
table.cell(t, 0, 1, 'Pearson\'s R: ' + str.tostring(detectedSlope > 0.0
? -highestPearsonR :
highestPearsonR, '#.###'), text_color = colorInput, text_size = textSizeInput ==
'Large' ? size.large
: textSizeInput == 'Small' ? size.small : size.normal)
else
table.cell(t, 0, 1, 'Trend Strength: ' + confidence(highestPearsonR),
text_color = colorInput,
text_size = textSizeInput == 'Large' ? size.large : textSizeInput == 'Small' ?
size.small :
size.normal)
// Calculate CAGR
float cagr = na
if not na(detectedPeriod) and bar_index >= detectedPeriod and
is_valid_timeframe()
float num_of_periods = detectedPeriod
float multiplier = get_tf_multiplier()
float startClosePrice = close[detectedPeriod - 1]
cagr := math.pow(close / startClosePrice, multiplier / num_of_periods) - 1
cagr
// Display or hide the "Trend Annualized Return" cell
if showTrendAnnualizedReturn and is_valid_timeframe()
table.cell(t, 0, 2, 'Trend Annualized Return: ' + (not na(cagr) ?
str.tostring(cagr * 100, '#.#') +
'%' : 'N/A'), text_color = colorInput, text_size = textSizeInput == 'Large' ?
size.large : textSizeInput
detectedIntrcpt := intercept15
detectedStdDev := stdDev15
detectedStdDev
pearsonR16 =>
detectedPeriod := Periods.get(16)
detectedSlope := slope16
detectedIntrcpt := intercept16
detectedStdDev := stdDev16
detectedStdDev
pearsonR17 =>
detectedPeriod := Periods.get(17)
detectedSlope := slope17
detectedIntrcpt := intercept17
detectedStdDev := stdDev17
detectedStdDev
pearsonR18 =>
detectedPeriod := Periods.get(18)
detectedSlope := slope18
detectedIntrcpt := intercept18
detectedStdDev := stdDev18
detectedStdDev
=> // pearsonR19
detectedPeriod := Periods.get(19)
detectedSlope := slope19
detectedIntrcpt := intercept19
detectedStdDev := stdDev19
detectedStdDev
var line upperLine = na
var linefill upperFill = na
var line baseLine = na
var line lowerLine = na
var linefill lowerFill = na
// Calculate start and end price based on detected slope and intercept
float startPrice = math.exp(detectedIntrcpt + detectedSlope * (detectedPeriod -
1))
float endPrice = math.exp(detectedIntrcpt)
int startAtBar = bar_index - detectedPeriod + 1
var color ChannelColor = color.new(colorInput, channelTransparency)

You might also like