Text To PDF PDF To Text 402 634
Text To PDF PDF To Text 402 634
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)