Direction Finder
Direction Finder
// @ Julien_Eche
//@version=6
indicator("Adaptive Trend Finder", overlay=true, max_bars_back=1200)
sourceInput = close
// CHANNEL SETTINGS
bool shortChannel = input.bool(true, "Show Strongest Short-Term Channel", group="Channels",
inline="Chan1")
color shortColor = input.color(color.gray, "", group="Channels", inline="Chan1")
bool longChannel = input.bool(false, "Show Strongest Long-Term Channel", group="Channels",
inline="Chan2")
color longColor = input.color(color.gray, "", group="Channels", inline="Chan2", tooltip="If the channel is not
visible, scroll back on the chart for additional historical data.")
// MIDLINE SETTINGS
bool showMidline = input.bool(false, "Display Midline", group="Midline Settings", inline="Mid")
color midlineColor = input.color(color.gray, "", group="Midline Settings", inline="Mid")
string midLineStyle = input.string("Dashed", "", options=["Dotted", "Solid", "Dashed"], group="Midline
Settings", inline="Mid")
int midTransp = input.int(50, "Transp", minval=0, maxval=100, step=10, group="Midline Settings",
inline="Mid")
// CHANNEL CONFIGURATION
bool isLog = input.bool(false, "Log Adjustment (for linear charts only)", tooltip="Enable if the chart is in linear
scale.", group="Channel Configuration")
devMultiplier = input.float(2.0, "Deviation Multiplier", step=0.1, group="Channel Configuration",
inline="Chan1")
string lineStyle1 = input.string("Solid", "", options=["Solid", "Dotted", "Dashed"], group="Channel
Configuration", inline="Chan1")
string extendStyle = input.string("Extend Right", "", options=["Extend Right", "Extend Both", "Extend None",
"Extend Left"], group="Channel Configuration", inline="Chan1")
int channelTransparency = input.int(40, "Line Transp", minval=0, maxval=100, step=1, group="Channel
Configuration", inline="Chan2")
int fillTransparency = input.int(93, "Fill Transp", minval=0, maxval=100, step=1, group="Channel
Configuration", inline="Chan2")
// TABLE DATA
string tablePositionInput = input.string("Bottom Right", "Table Position", options=["Bottom Right","Bottom
Left","Middle Right","Middle Left","Top Right","Top Left","Top Center","Bottom Center"], group="Table Data",
inline="Disp")
string textSizeInput = input.string("Normal", "Text Size", options=["Normal", "Large", "Small"], group="Table
Data", inline="Disp")
bool showAutoPeriod = input.bool(true, "Show Trend Period", tooltip="Automatically shows the period with
the strongest trend correlation.", group="Table Data")
bool showTrendStrength = input.bool(true, "Show Trend Strength", group="Table Data", inline="Strength")
bool showPearson = input.bool(false, "Use Pearson's R", tooltip="Pearson's R measures linear price/trend
correlation (1 strong positive, -1 strong negative).", group="Table Data", inline="Strength")
bool showAnnualReturn = input.bool(true, "Show Annualized Return", group="Table Data")
f_getTablePos(_pos) =>
switch _pos
"Bottom Right" => position.bottom_right
"Bottom Left" => position.bottom_left
"Bottom Center" => position.bottom_center
"Top Right" => position.top_right
"Top Left" => position.top_left
"Top Center" => position.top_center
"Middle Right" => position.middle_right
=> position.middle_left
confidence(r) =>
switch