LRI Momentum Cycles [AlgoAlpha]Discover the LRI Momentum Cycles indicator by AlgoAlpha, a cutting-edge tool designed to identify market momentum shifts using trend normalization and linear regression analysis. This advanced indicator helps traders detect bullish and bearish cycles with enhanced accuracy, making it ideal for swing traders and intraday enthusiasts alike.
Key Features :
🎨 Customizable Appearance : Set personalized colors for bullish and bearish trends to match your charting style.
🔧 Dynamic Trend Analysis : Tracks market momentum using a unique trend normalization algorithm.
📊 Linear Regression Insight : Calculates real-time trend direction using linear regression for better precision.
🔔 Alert Notifications : Receive alerts when the market switches from bearish to bullish or vice versa.
How to Use :
🛠 Add the Indicator : Favorite and apply the indicator to your TradingView chart. Adjust the lookback period, linear regression source, and regression length to fit your strategy.
📊 Market Analysis : Watch for color changes on the trend line. Green signals bullish momentum, while red indicates bearish cycles. Use these shifts to time entries and exits.
🔔 Set Alerts : Enable notifications for momentum shifts, ensuring you never miss critical market moves.
How It Works :
The LRI Momentum Cycles indicator calculates trend direction by applying linear regression on a user-defined price source over a specified period. It compares historical trend values, detecting bullish or bearish momentum through a dynamic scoring system. This score is normalized to ensure consistent readings, regardless of market conditions. The indicator visually represents trends using gradient-colored plots and fills to highlight changes in momentum. Alerts trigger when the momentum state changes, providing actionable trading signals.
دورات
Log Regression OscillatorThe Log Regression Oscillator transforms the logarithmic regression curves into an easy-to-interpret oscillator that displays potential cycle tops/bottoms.
🔶 USAGE
Calculating the logarithmic regression of long-term swings can help show future tops/bottoms. The relationship between previous swing points is calculated and projected further. The calculated levels are directly associated with swing points, which means every swing point will change the calculation. Importantly, all levels will be updated through all bars when a new swing is detected.
The "Log Regression Oscillator" transforms the calculated levels, where the top level is regarded as 100 and the bottom level as 0. The price values are displayed in between and calculated as a ratio between the top and bottom, resulting in a clear view of where the price is situated.
The main picture contains the Logarithmic Regression Alternative on the chart to compare with this published script.
Included are the levels 30 and 70. In the example of Bitcoin, previous cycles showed a similar pattern: the bullish parabolic was halfway when the oscillator passed the 30-level, and the top was very near when passing the 70-level.
🔹 Proactive
A "Proactive" option is included, which ensures immediate calculations of tentative unconfirmed swings.
Instead of waiting 300 bars for confirmation, the "Proactive" mode will display a gray-white dot (not confirmed swing) and add the unconfirmed Swing value to the calculation.
The above example shows that the "Calculated Values" of the potential future top and bottom are adjusted, including the provisional swing.
When the swing is confirmed, the calculations are again adjusted, showing a red dot (confirmed top swing) or a green dot (confirmed bottom swing).
🔹 Dashboard
When less than two swings are available (top/bottom), this will be shown in the dashboard.
The user can lower the "Threshold" value or switch to a lower timeframe.
🔹 Notes
Logarithmic regression is typically used to model situations where growth or decay accelerates rapidly at first and then slows over time, meaning some symbols/tickers will fit better than others.
Since the logarithmic regression depends on swing values, each new value will change the calculation. A well-fitted model could not fit anymore in the future.
Users have to check the validity of swings; for example, if the direction of swings is downwards, then the dataset is not fitted for logarithmic regression.
In the example above, the "Threshold" is lowered. However, the calculated levels are unreliable due to the swings, which do not fit the model well.
Here, the combination of downward bottom swings and price accelerates slower at first and faster recently, resulting in a non-fit for the logarithmic regression model.
Note the price value (white line) is bound to a limit of 150 (upwards) and -150 (down)
In short, logarithmic regression is best used when there are enough tops/bottoms, and all tops are around 100, and all bottoms around 0.
Also, note that this indicator has been developed for a daily (or higher) timeframe chart.
🔶 DETAILS
In mathematics, the dot product or scalar product is an algebraic operation that takes two equal-length sequences of numbers (arrays) and returns a single number, the sum of the products of the corresponding entries of the two sequences of numbers.
The usual way is to loop through both arrays and sum the products.
In this case, the two arrays are transformed into a matrix, wherein in one matrix, a single column is filled with the first array values, and in the second matrix, a single row is filled with the second array values.
After this, the function matrix.mult() returns a new matrix resulting from the product between the matrices m1 and m2.
Then, the matrix.eigenvalues() function transforms this matrix into an array, where the array.sum() function finally returns the sum of the array's elements, which is the dot product.
dot(x, y)=>
if x.size() > 1 and y.size() > 1
m1 = matrix.new()
m2 = matrix.new()
m1.add_col(m1.columns(), y)
m2.add_row(m2.rows (), x)
m1.mult (m2)
.eigenvalues()
.sum()
🔶 SETTINGS
Threshold: Period used for the swing detection, with higher values returning longer-term Swing Levels.
Proactive: Tentative Swings are included with this setting enabled.
Style: Color Settings
Dashboard: Toggle, "Location" and "Text Size"
Improved Scalping Signals Indicator (1-Minute)Improved Scalping Signals Indicator (1-Minute)
includes predictions and buy sell signals based on different indicators for scalping./
Fibonacci Extention / Retracment / Pivot Points by DGT//@version=5
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //
//# * ══════════════════════════════════════════════════════════════════════════════════════════════
//# *
//# * Study : Fibonacci Extention / Retracment / Pivot Points
//# * - Volume and Volatility AddOns
//# * Author : © dgtrd
//# *
//# * Revision History
//# * Release : Apr 19, 2021
//# * Update : May 11, 2021 : added ability to draw simultaneously Extensions or Retracements + Pivot Points
//# * added ability to filter Pivot Points Support or Resistance Levels based on Price Action
//# * Update : May 22, 2021 : added ability to draw Historical Pivot Points
//# * Update : Jan 29, 2022 : made labels much more customizable, slight improvments and converted to pine v5
//# *
//# * ══════════════════════════════════════════════════════════════════════════════════════════════
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //
indicator('Fibonacci Extention / Retracment / Pivot Points by DGT', 'FIBs ʙʏ DGT ☼☾', true, max_lines_count = 500, max_labels_count = 500)
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //
//
// Fibonacci Retracement / Extention / Pivot Points and Zig Zag
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //
// ---------------------------------------------------------------------------------------------- //
// -Inputs -------------------------------------------------------------------------------------- //
tooltip_threshold = 'Deviation is a multiplier that affects how much the price should deviate from the previous pivot in order for the bar to become a new pivot' +
' Depth affects the minimum number of bars that will be taken into account when building'
tooltip_pivot_point = 'A pivot point is a technical analysis indicator used to determine the overall trend of the market over different time frames'
tooltip_zigzag = 'The Zig Zag indicator is used to identify price trends then connected by straight lines that help the trader visual the price action' +
'This indicator works to eliminate confusion over small price changes or fluctuations and aims to project trend changes overtime'
// ---------------------------------------------------------------------------------------------- //
group_pick = 'Pick a Fibonacci Tool'
i_isFib = input.bool (true, 'Pick a Fibonacci Tool', inline='FIB', group=group_pick)
i_fibTool = input.string('Pivot Points', ' ',
options= , inline='FIB', group=group_pick)
i_fibTime = input.bool (true, 'Fib Time Zones', inline='TZ', group=group_pick)
i_tzColor = input.color(#2196f3, '' , inline='TZ', group=group_pick)
// ---------------------------------------------------------------------------------------------- //
group_pivot = 'Fibonacci Pivot Points Settings'
i_htf_mode = input.string('Auto', 'Pivot Points TimeFrame', options= , inline='HTF', group=group_pivot, tooltip=tooltip_pivot_point)
i_htf_user_ = input.string('Weekly', ' or User Defined',
options= , inline='HTF1', group=group_pivot)
i_htf_user = i_htf_user_ == '15 Min' ? '15' :
i_htf_user_ == '1 Hour' ? '60' :
i_htf_user_ == '4 Hour' ? '240' :
i_htf_user_ == 'Daily' ? 'D' :
i_htf_user_ == 'Weekly' ? 'W' :
i_htf_user_ == 'Monthly' ? 'M' :
i_htf_user_ == 'Quarterly' ? '3M' : '12M'
i_levelsPvt = input.string('Levels', 'Level Labels', options= , inline='pvt', group=group_pivot)
i_levelsPvtP = input.string('Pivot End', '', options= , inline='pvt', group=group_pivot)
i_levelsPvtS = input.string('Small', '', options= , inline='pvt', group=group_pivot)
i_relevant = input.bool(false, 'Only Relevant Pivot Point Levels', group=group_pivot)
i_histPP = input.bool(false, 'Historical Pivot Points', group=group_pivot)
i_extend = input.bool(false, 'Extend Pivot Point Lines', inline='fLines', group=group_pivot)
i_extendL = input.string('Dashed', '', options= , inline='fLines', group=group_pivot)
// ---------------------------------------------------------------------------------------------- //
group_fib_tool = 'Fibonacci Extention / Retracement / TimeZone Settings'
i_dev_thresh = ta.atr(10) / close * 100 * input.float(3, 'Deviation', minval=0, inline='Pivots', group=group_fib_tool, tooltip=tooltip_threshold)
i_depth = input.int(11, ' Depth', minval=1, inline='Pivots', group=group_fib_tool)
i_levels = input.string('Levels', 'Level Labels', options= , inline='fLines', group=group_fib_tool)
i_levelsP = input.string('Pivot Start', '', options= , inline='fLines', group=group_fib_tool)
i_levelsS = input.string('Small', '', options= , inline='fLines', group=group_fib_tool)
i_reverse = input.bool(false, 'Reverse Extention / Retracement Levels', group=group_fib_tool)
i_extendER = input.bool(false, 'Extend Extention / Retracement Lines', inline='fLine', group=group_fib_tool)
i_histPivot = input.int (0, 'Historical Extention / Retracement Levels', minval=0, group=group_fib_tool)
i_histPivot2 = input.int(0, 'Historical Time Zones', minval=0, group=group_fib_tool)
i_fib_tzl = input.bool(true, 'Time Zone Lables', inline='tz poz', group=group_fib_tool)
i_fib_tzlp = input.string('Left', '', options= , inline='tz poz', group=group_fib_tool)
fib_tzlp = i_fib_tzlp == 'Left' ? label.style_label_left : label.style_label_right
i_fib_tzlp2 = input.string('Bottom', '', options= , inline='tz poz', group=group_fib_tool)
// ---------------------------------------------------------------------------------------------- //
group_zigzag = 'ZigZag Settings'
i_zigZag = input.bool(false, 'Zig Zag ', inline='ZZ', group=group_zigzag, tooltip=tooltip_zigzag)
i_zzColor = input.color(#c77a08, '', inline='ZZ', group=group_zigzag)
i_zzStyle = input.string('Solid', '', options= , inline='ZZ', group=group_zigzag)
i_zzWidth = input.int(1, '', minval=1, inline='ZZ', group=group_zigzag)
// ---------------------------------------------------------------------------------------------- //
// -Calculations -------------------------------------------------------------------------------- //
var line lineLast = na
var int iLast = 0
var int iPrev = 0
var float pLast = 0
var isHighLast = false // otherwise the last pivot is a low pivot
var iPrevPivot = 0
var pPrevPivot = 0.
var iLastPivot = 0
var pLastPivot = 0.
pivots(src, length, isHigh) =>
l2 = length * 2
c = nz(src )
ok = true
for i = 0 to l2 by 1
if isHigh and src > c
ok := false
ok
if not isHigh and src < c
ok := false
ok
if ok
[bar_index , c]
else
= pivots(high, i_depth / 2, true)
= pivots(low, i_depth / 2, false)
calc_dev(base_price, price) =>
100 * (price - base_price) / price
pivotFound(dev, isHigh, index, price) =>
if isHighLast == isHigh and not na(lineLast)
// same direction
if isHighLast ? price > pLast : price < pLast
line.set_xy2(lineLast, index, price)
else
else
// reverse the direction (or create the very first line)
if math.abs(dev) > i_dev_thresh
// price move is significant
// ---------------------------------------------------------------------------------------- //
= if not i_zigZag
else
// ---------------------------------------------------------------------------------------- //
id = line.new(iLast, pLast, index, price, color=zzCol, width=zzWid, style=zzSty)
else
if not na(iH)
dev = calc_dev(pLast, pH)
= pivotFound(dev, true, iH, pH)
if not na(id)
if id != lineLast
// ---------------------------------------------------------------------------------------- //
iPrevPivot := line.get_x1(lineLast)
pPrevPivot := line.get_y1(lineLast)
iLastPivot := line.get_x2(lineLast)
pLastPivot := line.get_y2(lineLast)
if not i_zigZag
// ---------------------------------------------------------------------------------------- //
line.delete(lineLast)
lineLast := id
isHighLast := isHigh
iPrev := iLast
iLast := iH
pLast := pH
pLast
else
if not na(iL)
dev = calc_dev(pLast, pL)
= pivotFound(dev, false, iL, pL)
if not na(id)
if id != lineLast
// ---------------------------------------------------------------------------------------- //
iPrevPivot := line.get_x1(lineLast)
pPrevPivot := line.get_y1(lineLast)
iLastPivot := line.get_x2(lineLast)
pLastPivot := line.get_y2(lineLast)
if not i_zigZag
// ---------------------------------------------------------------------------------------- //
line.delete(lineLast)
lineLast := id
isHighLast := isHigh
iPrev := iLast
iLast := iL
pLast := pL
pLast
iStartBase = i_histPivot > 0 ? ta.valuewhen(ta.change(iPrevPivot), iPrevPivot, i_histPivot) : ta.valuewhen(ta.change(iPrevPivot), iPrevPivot, 0)
pStartBase = i_histPivot > 0 ? ta.valuewhen(ta.change(pPrevPivot), pPrevPivot, i_histPivot) : ta.valuewhen(ta.change(pPrevPivot), pPrevPivot, 0)
iEndBase = i_histPivot > 0 ? ta.valuewhen(ta.change(iLastPivot), iLastPivot, i_histPivot - 1) : line.get_x2(lineLast)
pEndBase = i_histPivot > 0 ? ta.valuewhen(ta.change(pLastPivot), pLastPivot, i_histPivot - 1) : line.get_y2(lineLast)
iMidPivot = i_histPivot > 0 ? ta.valuewhen(ta.change(iPrevPivot), iPrevPivot, i_histPivot - 1) : line.get_x1(lineLast)
pMidPivot = i_histPivot > 0 ? ta.valuewhen(ta.change(pPrevPivot), pPrevPivot, i_histPivot - 1) : line.get_y1(lineLast)
iEndBase2 = i_histPivot2 > 0 ? ta.valuewhen(ta.change(iLastPivot), iLastPivot, i_histPivot2 - 1) : line.get_x2(lineLast)
pEndBase2 = i_histPivot2 > 0 ? ta.valuewhen(ta.change(pLastPivot), pLastPivot, i_histPivot2 - 1) : line.get_y2(lineLast)
iMidPivot2 = i_histPivot2 > 0 ? ta.valuewhen(ta.change(iPrevPivot), iPrevPivot, i_histPivot2 - 1) : line.get_x1(lineLast)
pMidPivot2 = i_histPivot2 > 0 ? ta.valuewhen(ta.change(pPrevPivot), pPrevPivot, i_histPivot2 - 1) : line.get_y1(lineLast)
//------------------------------------------------------------------------------
// auto higher time frame code snippet from pine wizard LonesomeTheBlue
htf_auto = timeframe.period == '1' ? '240' :
timeframe.period == '3' ? '240' :
timeframe.period == '5' ? '240' :
timeframe.period == '15' ? 'D' :
timeframe.period == '30' ? 'D' :
timeframe.period == '45' ? 'D' :
timeframe.period == '60' ? 'W' :
timeframe.period == '120' ? 'W' :
timeframe.period == '180' ? 'W' :
timeframe.period == '240' ? 'W' :
timeframe.period == 'D' ? 'M' :
timeframe.period == 'W' ? '3M' : '12M'
htf = i_htf_mode == 'Auto' ? htf_auto : i_htf_user
//------------------------------------------------------------------------------
// security function free price calculations
f_htf_ohlc(_htf) =>
var htf_o = 0.
var htf_h = 0.
var htf_l = 0.
htf_c = close
var htf_ox = 0.
var htf_hx = 0.
var htf_lx = 0.
var htf_cx = 0.
if ta.change(time(_htf))
htf_ox := htf_o
htf_o := open
htf_hx := htf_h
htf_h := high
htf_lx := htf_l
htf_l := low
htf_cx := htf_c
htf_cx
else
htf_h := math.max(high, htf_h)
htf_l := math.min(low , htf_l)
htf_l
= f_htf_ohlc(htf)
// ---------------------------------------------------------------------------------------------- //
// -Plotting ------------------------------------------------------------------------------------ //
time_x10 = ta.valuewhen(ta.change(time(htf)), time, 1)
time_x11 = ta.valuewhen(ta.change(time(htf)), time, 0)
time_x21 = 2 * time_x11 - time_x10
f_drawLineX(_x1, _y1, _x2, _y2, _xloc, _extend, _color, _style, _width) =>
var id = line.new(_x1, _y1, _x2, _y2, _xloc, _extend, _color, _style, _width)
if _y1 > 0 and _y2 > 0
line.set_xy1(id, _x1, _y1)
line.set_xy2(id, _x2, _y2)
line.set_color(id, _color)
else
line.set_xy1(id, _x1, close)
line.set_xy2(id, _x2, close)
line.set_color(id, #00000000)
f_drawLabelX(_x, _y, _text, _xloc, _yloc, _color, _style, _textcolor, _size, _textalign, _tooltip) =>
var id = label.new(_x, _y, _text, _xloc, _yloc, _color, _style, _textcolor, _size, _textalign, _tooltip)
label.set_text(id, i_extend or i_extendER or i_levelsP == 'Last Bar' ? _text + ' ' : _text)
label.set_tooltip(id, _tooltip)
if _y > 0
label.set_xy(id, _x, _y)
label.set_textcolor(id, _textcolor)
else
label.set_xy(id, _x, close)
label.set_textcolor(id, #00000000)
f_crossingLevel(_curret, _level) =>
_level > _curret and _level < _curret or _level < _curret and _level > _curret
var ln = array.new_line()
var lb = array.new_label()
if ta.change(time) and array.size(ln) > 0
for i = 1 to array.size(ln) by 1
line.delete(array.shift(ln))
if ta.change(time) and array.size(lb) > 0
for i = 1 to array.size(lb) by 1
label.delete(array.shift(lb))
f_drawLineTZ(_x1, _y1, _x2, _y2, _xloc, _extend, _c, _s, _w) =>
if _x1 - bar_index < 500
array.push(ln, line.new(_x1, _y1, _x2, _y2, _xloc, _extend, _c, _s, _w))
f_drawLabelTZ(_x, _y, _text, _xloc, _yloc, _color, _style, _textcolor, _size, _textalign, _tooltip) =>
if _x - bar_index < 500
array.push(lb, label.new(_x, _y, _text, _xloc, _yloc, _color, _style, _textcolor, _size, _textalign, _tooltip))
f_drawLinePVT(_x1, _y1, _x2, _y2, _xloc, _extend, _c, _s, _w) =>
if _y1 > 0
array.push(ln, line.new(_x1, _y1, _x2, _y2, _xloc, _extend, _c, _s, _w))
f_drawLabelPVT(_x, _y, _text, _xloc, _yloc, _color, _style, _textcolor, _size, _textalign, _tooltip) =>
if _y > 0
array.push(lb, label.new(_x, _y, i_extend or i_levelsPvtP == "Last Bar" ? _text + ' ' : _text, _xloc, _yloc, _color, _style, _textcolor, _size, _textalign, _tooltip))
if i_fibTime
referance = math.round(iEndBase2 - iMidPivot2)
f_drawLineTZ(iMidPivot2 - referance , pEndBase2, iMidPivot2 - referance , pMidPivot2, xloc.bar_index, extend.both, i_tzColor , line.style_solid, 1)
f_drawLineTZ(iMidPivot2 , pEndBase2, iMidPivot2 , pMidPivot2, xloc.bar_index, extend.both, color.gray, line.style_solid, 1)
f_drawLineTZ(iMidPivot2 + referance , pEndBase2, iMidPivot2 + referance , pMidPivot2, xloc.bar_index, extend.both, color.gray, line.style_solid, 1)
f_drawLineTZ(iMidPivot2 + referance * 2 , pEndBase2, iMidPivot2 + referance * 2 , pMidPivot2, xloc.bar_index, extend.both, i_tzColor , line.style_solid, 1)
f_drawLineTZ(iMidPivot2 + referance * 3 , pEndBase2, iMidPivot2 + referance * 3 , pMidPivot2, xloc.bar_index, extend.both, i_tzColor , line.style_solid, 1)
f_drawLineTZ(iMidPivot2 + referance * 5 , pEndBase2, iMidPivot2 + referance * 5 , pMidPivot2, xloc.bar_index, extend.both, i_tzColor , line.style_solid, 1)
f_drawLineTZ(iMidPivot2 + referance * 8 , pEndBase2, iMidPivot2 + referance * 8 , pMidPivot2, xloc.bar_index, extend.both, i_tzColor , line.style_solid, 1)
f_drawLineTZ(iMidPivot2 + referance * 13 , pEndBase2, iMidPivot2 + referance * 13, pMidPivot2, xloc.bar_index, extend.both, i_tzColor , line.style_solid, 1)
f_drawLineTZ(iMidPivot2 + referance * 21 , pEndBase2, iMidPivot2 + referance * 21, pMidPivot2, xloc.bar_index, extend.both, i_tzColor , line.style_solid, 1)
f_drawLineTZ(iMidPivot2 + referance * 34 , pEndBase2, iMidPivot2 + referance * 34, pMidPivot2, xloc.bar_index, extend.both, i_tzColor , line.style_solid, 1)
f_drawLineTZ(iMidPivot2 + referance * 55 , pEndBase2, iMidPivot2 + referance * 55, pMidPivot2, xloc.bar_index, extend.both, i_tzColor , line.style_solid, 1)
f_drawLineTZ(iMidPivot2 + referance * 89 , pEndBase2, iMidPivot2 + referance * 89, pMidPivot2, xloc.bar_index, extend.both, i_tzColor , line.style_solid, 1)
if i_fib_tzl
f_drawLabelTZ(iMidPivot2 + referance * -1, i_fib_tzlp2 == 'Bottom' ? math.min(pEndBase2, pMidPivot2) : math.max(pEndBase2, pMidPivot2), '-1', xloc.bar_index, yloc.price, #00000000, fib_tzlp, i_tzColor , size.normal, text.align_center, '')
f_drawLabelTZ(iMidPivot2 + referance * 0 , i_fib_tzlp2 == 'Bottom' ? math.min(pEndBase2, pMidPivot2) : math.max(pEndBase2, pMidPivot2), '0' , xloc.bar_index, yloc.price, #00000000, fib_tzlp, color.gray, size.normal, text.align_center, '')
f_drawLabelTZ(iMidPivot2 + referance * 1 , i_fib_tzlp2 == 'Bottom' ? math.min(pEndBase2, pMidPivot2) : math.max(pEndBase2, pMidPivot2), '1' , xloc.bar_index, yloc.price, #00000000, fib_tzlp, color.gray, size.normal, text.align_center, '')
f_drawLabelTZ(iMidPivot2 + referance * 2 , i_fib_tzlp2 == 'Bottom' ? math.min(pEndBase2, pMidPivot2) : math.max(pEndBase2, pMidPivot2), '2' , xloc.bar_index, yloc.price, #00000000, fib_tzlp, i_tzColor , size.normal, text.align_center, '')
f_drawLabelTZ(iMidPivot2 + referance * 3 , i_fib_tzlp2 == 'Bottom' ? math.min(pEndBase2, pMidPivot2) : math.max(pEndBase2, pMidPivot2), '3' , xloc.bar_index, yloc.price, #00000000, fib_tzlp, i_tzColor , size.normal, text.align_center, '')
f_drawLabelTZ(iMidPivot2 + referance * 5 , i_fib_tzlp2 == 'Bottom' ? math.min(pEndBase2, pMidPivot2) : math.max(pEndBase2, pMidPivot2), '5' , xloc.bar_index, yloc.price, #00000000, fib_tzlp, i_tzColor , size.normal, text.align_center, '')
f_drawLabelTZ(iMidPivot2 + referance * 8 , i_fib_tzlp2 == 'Bottom' ? math.min(pEndBase2, pMidPivot2) : math.max(pEndBase2, pMidPivot2), '8' , xloc.bar_index, yloc.price, #00000000, fib_tzlp, i_tzColor , size.normal, text.align_center, '')
f_drawLabelTZ(iMidPivot2 + referance * 13, i_fib_tzlp2 == 'Bottom' ? math.min(pEndBase2, pMidPivot2) : math.max(pEndBase2, pMidPivot2), '13', xloc.bar_index, yloc.price, #00000000, fib_tzlp, i_tzColor , size.normal, text.align_center, '')
f_drawLabelTZ(iMidPivot2 + referance * 21, i_fib_tzlp2 == 'Bottom' ? math.min(pEndBase2, pMidPivot2) : math.max(pEndBase2, pMidPivot2), '21', xloc.bar_index, yloc.price, #00000000, fib_tzlp, i_tzColor , size.normal, text.align_center, '')
f_drawLabelTZ(iMidPivot2 + referance * 34, i_fib_tzlp2 == 'Bottom' ? math.min(pEndBase2, pMidPivot2) : math.max(pEndBase2, pMidPivot2), '34', xloc.bar_index, yloc.price, #00000000, fib_tzlp, i_tzColor , size.normal, text.align_center, '')
f_drawLabelTZ(iMidPivot2 + referance * 55, i_fib_tzlp2 == 'Bottom' ? math.min(pEndBase2, pMidPivot2) : math.max(pEndBase2, pMidPivot2), '55', xloc.bar_index, yloc.price, #00000000, fib_tzlp, i_tzColor , size.normal, text.align_center, '')
f_drawLabelTZ(iMidPivot2 + referance * 89, i_fib_tzlp2 == 'Bottom' ? math.min(pEndBase2, pMidPivot2) : math.max(pEndBase2, pMidPivot2), '89', xloc.bar_index, yloc.price, #00000000, fib_tzlp, i_tzColor , size.normal, text.align_center, '')
f_processLevelX(_show, _level, _color) =>
if i_isFib
pPivotDiff = math.abs(pMidPivot - pEndBase)
price = 0.
if i_fibTool == 'Extentions' or i_fibTool == 'Extentions + Pivot Points'
f_drawLineX(iStartBase, pStartBase, iMidPivot, pMidPivot, xloc.bar_index, extend.none, color.gray, line.style_dashed, 1)
f_drawLineX(iMidPivot , pMidPivot , iEndBase , pEndBase , xloc.bar_index, extend.none, color.gray, line.style_dashed, 1)
offset = math.abs(pMidPivot - pStartBase)
price := pEndBase < pMidPivot ? pMidPivot - pPivotDiff + (i_reverse ? -1 : 1) * offset * _level : pMidPivot + pPivotDiff - (i_reverse ? -1 : 1) * offset * _level
if _show
f_drawLineX(iMidPivot, price, bar_index, price, xloc.bar_index, i_extendER ? extend.both : extend.right, _color, line.style_solid, 1)
if i_levels != 'None'
bar = i_levelsP == "Last Bar" ? bar_index : iMidPivot
style = i_levelsP == "Last Bar" ? label.style_label_left : label.style_label_right
size = i_levelsS == 'Small' ? size.small : size.normal
f_drawLabelX(bar, price, (i_levels == 'Prices' ? '' : 'EXT ' + str.tostring(_level)) + (i_levels == 'Levels + Prices' or i_levels == 'Prices' ? ' (' + str.tostring(price, format.mintick) + ')' : ''), xloc.bar_index, yloc.price, #00000000, style, _color, size, text.align_left, str.tostring(price, format.mintick))
if f_crossingLevel(close, price)
alert('AutoFib Extention : ' + syminfo.ticker + ' crossing level ' + str.tostring(_level))
if i_fibTool == 'Retracements' or i_fibTool == 'Retracements + Pivot Points'
f_drawLineX(iMidPivot, pMidPivot, iEndBase, pEndBase, xloc.bar_index, extend.none, color.gray, line.style_dashed, 1)
price := pEndBase < pMidPivot ? (i_reverse ? pEndBase : pMidPivot) - (i_reverse ? -1 : 1) * pPivotDiff * _level : (i_reverse ? pEndBase : pMidPivot) + (i_reverse ? -1 : 1) * pPivotDiff * _level
if _show
f_drawLineX(iMidPivot, price, bar_index, price, xloc.bar_index, i_extendER ? extend.both : extend.right, _color, line.style_solid, 1)
if i_levels != 'None'
bar = i_levelsP == "Last Bar" ? bar_index : iMidPivot
style = i_levelsP == "Last Bar" ? label.style_label_left : label.style_label_right
size = i_levelsS == 'Small' ? size.small : size.normal
f_drawLabelX(bar, price, (i_levels == 'Prices' ? '' : 'RET ' + str.tostring(_level)) + (i_levels == 'Levels + Prices' or i_levels == 'Prices' ? ' (' + str.tostring(price, format.mintick) + ')' : ''), xloc.bar_index, yloc.price, #00000000, style, _color, size, text.align_left, str.tostring(price, format.mintick))
if f_crossingLevel(close, price)
alert('AutoFib Retracment : ' + syminfo.ticker + ' crossing level ' + str.tostring(_level))
if i_fibTool == 'Pivot Points' or i_fibTool == 'Extentions + Pivot Points' or i_fibTool == 'Retracements + Pivot Points'
pivot = math.avg(htf_h1, htf_l1, htf_c1)
range_2 = htf_h1 - htf_l1
if not i_histPP
f_drawLinePVT(time_x10, pivot, time_x21, pivot, xloc.bar_time, extend.none, color.gray, line.style_dashed, 1)
if _show and _level >= 0
pvtPoints = _level == 0 or _level == 0.382 or _level == 0.618 or _level == 1
f_drawLinePVT(time_x11, pivot - range_2 * _level, time_x21, pivot - range_2 * _level, xloc.bar_time, extend.none, i_relevant ? close < pivot ? _color : na : _color, pvtPoints ? line.style_solid : line.style_dashed, pvtPoints ? 2 : 1)
f_drawLinePVT(time_x11, pivot + range_2 * _level, time_x21, pivot + range_2 * _level, xloc.bar_time, extend.none, i_relevant ? close > pivot ? _color : na : _color, pvtPoints ? line.style_solid : line.style_dashed, pvtPoints ? 2 : 1)
if i_extend
style = i_extendL == 'Solid' ? line.style_solid : i_extendL == 'Dotted' ? line.style_dotted : line.style_dashed
f_drawLinePVT(time_x11, pivot - range_2 * _level, time_x21, pivot - range_2 * _level, xloc.bar_time, extend.both, i_relevant ? close < pivot ? _color : na : _color, style, 1)
f_drawLinePVT(time_x11, pivot + range_2 * _level, time_x21, pivot + range_2 * _level, xloc.bar_time, extend.both, i_relevant ? close > pivot ? _color : na : _color, style, 1)
if i_levelsPvt != 'None'
time_xx = i_levelsPvtP == "Last Bar" ? timenow : time_x21
size = i_levelsPvtS == 'Small' ? size.small : size.normal
if pvtPoints
if _level == 0
f_drawLabelPVT(time_xx, pivot, (i_levelsPvt == 'Prices' ? '' : 'PP') + (i_levelsPvt == 'Levels + Prices' or i_levelsPvt == 'Prices' ? ' (' + str.tostring(pivot, format.mintick) + ')' : ''), xloc.bar_time, yloc.price, #00000000, label.style_label_left, _color, size, text.align_left, str.tostring(pivot, format.mintick))
else
f_drawLabelPVT(time_xx, pivot - range_2 * _level, (i_levelsPvt == 'Prices' ? '' : (_level == 0.382 ? 'S1 PP ' : _level == 0.618 ? 'S2 PP ' : 'S3 PP ') + str.tostring(_level)) + (i_levelsPvt == 'Levels + Prices' or i_levelsPvt == 'Prices' ? ' (' + str.tostring(pivot - range_2 * _level, format.mintick) + ')' : ''), xloc.bar_time, yloc.price, #00000000, label.style_label_left, i_relevant ? close < pivot ? _color : na : _color, size, text.align_left, str.tostring(pivot - range_2 * _level, format.mintick))
f_drawLabelPVT(time_xx, pivot + range_2 * _level, (i_levelsPvt == 'Prices' ? '' : (_level == 0.382 ? 'R1 PP ' : _level == 0.618 ? 'R2 PP ' : 'R3 PP ') + str.tostring(_level)) + (i_levelsPvt == 'Levels + Prices' or i_levelsPvt == 'Prices' ? ' (' + str.tostring(pivot + range_2 * _level, format.mintick) + ')' : ''), xloc.bar_time, yloc.price, #00000000, label.style_label_left, i_relevant ? close > pivot ? _color : na : _color, size, text.align_left, str.tostring(pivot + range_2 * _level, format.mintick))
else
f_drawLabelPVT(time_xx, pivot - range_2 * _level, (i_levelsPvt == 'Prices' ? '' : ' PP ' + str.tostring(_level)) + (i_levelsPvt == 'Levels + Prices' or i_levelsPvt == 'Prices' ? ' (' + str.tostring(pivot - range_2 * _level, format.mintick) + ')' : ''), xloc.bar_time, yloc.price, #00000000, label.style_label_left, i_relevant ? close < pivot ? _color : na : _color, size, text.align_left, str.tostring(pivot - range_2 * _level, format.mintick))
f_drawLabelPVT(time_xx, pivot + range_2 * _level, (i_levelsPvt == 'Prices' ? '' : ' PP ' + str.tostring(_level)) + (i_levelsPvt == 'Levels + Prices' or i_levelsPvt == 'Prices' ? ' (' + str.tostring(pivot + range_2 * _level, format.mintick) + ')' : ''), xloc.bar_time, yloc.price, #00000000, label.style_label_left, i_relevant ? close > pivot ? _color : na : _color, size, text.align_left, str.tostring(pivot + range_2 * _level, format.mintick))
if f_crossingLevel(close, pivot - range_2 * _level)
alert('AutoFib PivotPoints : ' + syminfo.ticker + ' crossing support level ' + str.tostring(_level))
if f_crossingLevel(close, pivot + range_2 * _level)
alert('AutoFib PivotPoints : ' + syminfo.ticker + ' crossing resistance level ' + str.tostring(_level))
group_fib_levels = 'Fibonacci Levels'
show_0 = input.bool(true, '', inline='Level0', group=group_fib_levels)
value_0 = input.float(0., '', inline='Level0', group=group_fib_levels)
color_0 = input.color(#787b86, '', inline='Level0', group=group_fib_levels)
f_processLevelX(show_0, value_0, color_0)
show_0_236 = input.bool(true, '', inline='Level0', group=group_fib_levels)
value_0_236 = input.float(0.236, '', inline='Level0', group=group_fib_levels)
color_0_236 = input.color(#f44336, '', inline='Level0', group=group_fib_levels)
f_processLevelX(show_0_236, value_0_236, color_0_236)
show_0_382 = input.bool(true, '', inline='Level1', group=group_fib_levels)
value_0_382 = input.float(0.382, '', inline='Level1', group=group_fib_levels)
color_0_382 = input.color(#81c784, '', inline='Level1', group=group_fib_levels)
f_processLevelX(show_0_382, value_0_382, color_0_382)
show_0_5 = input.bool(true, '', inline='Level1', group=group_fib_levels)
value_0_5 = input.float(0.5, '', inline='Level1', group=group_fib_levels)
color_0_5 = input.color(#4caf50, '', inline='Level1', group=group_fib_levels)
f_processLevelX(show_0_5, value_0_5, color_0_5)
show_0_618 = input.bool(true, '', inline='Level2', group=group_fib_levels)
value_0_618 = input.float(0.618, '', inline='Level2', group=group_fib_levels)
color_0_618 = input.color(#009688, '', inline='Level2', group=group_fib_levels)
f_processLevelX(show_0_618, value_0_618, color_0_618)
show_0_65 = input.bool(false, '', inline='Level2', group=group_fib_levels)
value_0_65 = input.float(0.65, '', inline='Level2', group=group_fib_levels)
color_0_65 = input.color(#009688, '', inline='Level2', group=group_fib_levels)
f_processLevelX(show_0_65, value_0_65, color_0_65)
show_0_786 = input.bool(true, '', inline='Level3', group=group_fib_levels)
value_0_786 = input.float(0.786, '', inline='Level3', group=group_fib_levels)
color_0_786 = input.color(#64b5f6, '', inline='Level3', group=group_fib_levels)
f_processLevelX(show_0_786, value_0_786, color_0_786)
show_1 = input.bool(true, '', inline='Level3', group=group_fib_levels)
value_1 = input.float(1., '', inline='Level3', group=group_fib_levels)
color_1 = input.color(#787b86, '', inline='Level3', group=group_fib_levels)
f_processLevelX(show_1, value_1, color_1)
show_1_272 = input.bool(false, '', inline='Level4', group=group_fib_levels)
value_1_272 = input.float(1.272, '', inline='Level4', group=group_fib_levels)
color_1_272 = input.color(#81c784, '', inline='Level4', group=group_fib_levels)
f_processLevelX(show_1_272, value_1_272, color_1_272)
show_1_414 = input.bool(false, '', inline='Level4', group=group_fib_levels)
value_1_414 = input.float(1.414, '', inline='Level4', group=group_fib_levels)
color_1_414 = input.color(#f44336, '', inline='Level4', group=group_fib_levels)
f_processLevelX(show_1_414, value_1_414, color_1_414)
show_1_618 = input.bool(true, '', inline='Level5', group=group_fib_levels)
value_1_618 = input.float(1.618, '', inline='Level5', group=group_fib_levels)
color_1_618 = input.color(#2196f3, '', inline='Level5', group=group_fib_levels)
f_processLevelX(show_1_618, value_1_618, color_1_618)
show_1_65 = input.bool(false, '', inline='Level5', group=group_fib_levels)
value_1_65 = input.float(1.65, '', inline='Level5', group=group_fib_levels)
color_1_65 = input.color(#2196f3, '', inline='Level5', group=group_fib_levels)
f_processLevelX(show_1_65, value_1_65, color_1_65)
show_2_618 = input.bool(false, '', inline='Level6', group=group_fib_levels)
value_2_618 = input.float(2.618, '', inline='Level6', group=group_fib_levels)
color_2_618 = input.color(#f44336, '', inline='Level6', group=group_fib_levels)
f_processLevelX(show_2_618, value_2_618, color_2_618)
show_2_65 = input.bool(false, '', inline='Level6', group=group_fib_levels)
value_2_65 = input.float(2.65, '', inline='Level6', group=group_fib_levels)
color_2_65 = input.color(#f44336, '', inline='Level6', group=group_fib_levels)
f_processLevelX(show_2_65, value_2_65, color_2_65)
show_3_618 = input.bool(false, '', inline='Level7', group=group_fib_levels)
value_3_618 = input.float(3.618, '', inline='Level7', group=group_fib_levels)
color_3_618 = input.color(#9c27b0, '', inline='Level7', group=group_fib_levels)
f_processLevelX(show_3_618, value_3_618, color_3_618)
show_3_65 = input.bool(false, '', inline='Level7', group=group_fib_levels)
value_3_65 = input.float(3.65, '', inline='Level7', group=group_fib_levels)
color_3_65 = input.color(#9c27b0, '', inline='Level7', group=group_fib_levels)
f_processLevelX(show_3_65, value_3_65, color_3_65)
show_4_236 = input.bool(false, '', inline='Level8', group=group_fib_levels)
value_4_236 = input.float(4.236, '', inline='Level8', group=group_fib_levels)
color_4_236 = input.color(#e91e63, '', inline='Level8', group=group_fib_levels)
f_processLevelX(show_4_236, value_4_236, color_4_236)
show_4_618 = input.bool(false, '', inline='Level8', group=group_fib_levels)
value_4_618 = input.float(4.618, '', inline='Level8', group=group_fib_levels)
color_4_618 = input.color(#81c784, '', inline='Level8', group=group_fib_levels)
f_processLevelX(show_4_618, value_4_618, color_4_618)
show_neg_0_236 = input.bool(false, '', inline='Level9', group=group_fib_levels)
value_neg_0_236 = input.float(-0.236, '', inline='Level9', group=group_fib_levels)
color_neg_0_236 = input.color(#f44336, '', inline='Level9', group=group_fib_levels)
f_processLevelX(show_neg_0_236, value_neg_0_236, color_neg_0_236)
show_neg_0_382 = input.bool(false, '', inline='Level9', group=group_fib_levels)
value_neg_0_382 = input.float(-0.382, '', inline='Level9', group=group_fib_levels)
color_neg_0_382 = input.color(#81c784, '', inline='Level9', group=group_fib_levels)
f_processLevelX(show_neg_0_382, value_neg_0_382, color_neg_0_382)
show_neg_0_618 = input.bool(true, '', inline='Level10', group=group_fib_levels)
value_neg_0_618 = input.float(-0.618, '', inline='Level10', group=group_fib_levels)
color_neg_0_618 = input.color(#009688, '', inline='Level10', group=group_fib_levels)
f_processLevelX(show_neg_0_618, value_neg_0_618, color_neg_0_618)
show_neg_0_65 = input.bool(false, '', inline='Level10', group=group_fib_levels)
value_neg_0_65 = input.float(-0.65, '', inline='Level10', group=group_fib_levels)
color_neg_0_65 = input.color(#009688, '', inline='Level10', group=group_fib_levels)
f_processLevelX(show_neg_0_65, value_neg_0_65, color_neg_0_65)
i_histPP := i_histPP and (i_fibTool == 'Pivot Points' or i_fibTool == 'Extentions + Pivot Points' or i_fibTool == 'Retracements + Pivot Points')
plot(i_histPP and show_0 ? math.avg(htf_h1, htf_l1, htf_c1) : na, 'PP' , ta.change(time(htf)) ? na : color_0)
plot(i_histPP and show_0_236 ? math.avg(htf_h1, htf_l1, htf_c1) - (htf_h1 - htf_l1) * value_0_236 : na, 'PP 0_236', ta.change(time(htf)) ? na : color_0_236, 1, plot.style_cross)
plot(i_histPP and show_0_236 ? math.avg(htf_h1, htf_l1, htf_c1) + (htf_h1 - htf_l1) * value_0_236 : na, 'PP 0_236', ta.change(time(htf)) ? na : color_0_236, 1, plot.style_cross)
plot(i_histPP and show_0_382 ? math.avg(htf_h1, htf_l1, htf_c1) - (htf_h1 - htf_l1) * value_0_382 : na, 'PP 0_382', ta.change(time(htf)) ? na : color_0_382)
plot(i_histPP and show_0_382 ? math.avg(htf_h1, htf_l1, htf_c1) + (htf_h1 - htf_l1) * value_0_382 : na, 'PP 0_382', ta.change(time(htf)) ? na : color_0_382)
plot(i_histPP and show_0_5 ? math.avg(htf_h1, htf_l1, htf_c1) - (htf_h1 - htf_l1) * value_0_5 : na, 'PP 0_5 ', ta.change(time(htf)) ? na : color_0_5 , 1, plot.style_cross)
plot(i_histPP and show_0_5 ? math.avg(htf_h1, htf_l1, htf_c1) + (htf_h1 - htf_l1) * value_0_5 : na, 'PP 0_5 ', ta.change(time(htf)) ? na : color_0_5 , 1, plot.style_cross)
plot(i_histPP and show_0_618 ? math.avg(htf_h1, htf_l1, htf_c1) - (htf_h1 - htf_l1) * value_0_618 : na, 'PP 0_618', ta.change(time(htf)) ? na : color_0_618)
plot(i_histPP and show_0_618 ? math.avg(htf_h1, htf_l1, htf_c1) + (htf_h1 - htf_l1) * value_0_618 : na, 'PP 0_618', ta.change(time(htf)) ? na : color_0_618)
plot(i_histPP and show_0_65 ? math.avg(htf_h1, htf_l1, htf_c1) - (htf_h1 - htf_l1) * value_0_65 : na, 'PP 0_65 ', ta.change(time(htf)) ? na : color_0_65 , 1, plot.style_cross)
plot(i_histPP and show_0_65 ? math.avg(htf_h1, htf_l1, htf_c1) + (htf_h1 - htf_l1) * value_0_65 : na, 'PP 0_65 ', ta.change(time(htf)) ? na : color_0_65 , 1, plot.style_cross)
plot(i_histPP and show_0_786 ? math.avg(htf_h1, htf_l1, htf_c1) - (htf_h1 - htf_l1) * value_0_786 : na, 'PP 0_786', ta.change(time(htf)) ? na : color_0_786, 1, plot.style_cross)
plot(i_histPP and show_0_786 ? math.avg(htf_h1, htf_l1, htf_c1) + (htf_h1 - htf_l1) * value_0_786 : na, 'PP 0_786', ta.change(time(htf)) ? na : color_0_786, 1, plot.style_cross)
plot(i_histPP and show_1 ? math.avg(htf_h1, htf_l1, htf_c1) - (htf_h1 - htf_l1) * value_1 : na, 'PP 1 ', ta.change(time(htf)) ? na : color_1)
plot(i_histPP and show_1 ? math.avg(htf_h1, htf_l1, htf_c1) + (htf_h1 - htf_l1) * value_1 : na, 'PP 1 ', ta.change(time(htf)) ? na : color_1)
plot(i_histPP and show_1_272 ? math.avg(htf_h1, htf_l1, htf_c1) - (htf_h1 - htf_l1) * value_1_272 : na, 'PP 1_272', ta.change(time(htf)) ? na : color_1_272, 1, plot.style_cross)
plot(i_histPP and show_1_272 ? math.avg(htf_h1, htf_l1, htf_c1) + (htf_h1 - htf_l1) * value_1_272 : na, 'PP 1_272', ta.change(time(htf)) ? na : color_1_272, 1, plot.style_cross)
plot(i_histPP and show_1_414 ? math.avg(htf_h1, htf_l1, htf_c1) - (htf_h1 - htf_l1) * value_1_414 : na, 'PP 1_414', ta.change(time(htf)) ? na : color_1_414, 1, plot.style_cross)
plot(i_histPP and show_1_414 ? math.avg(htf_h1, htf_l1, htf_c1) + (htf_h1 - htf_l1) * value_1_414 : na, 'PP 1_414', ta.change(time(htf)) ? na : color_1_414, 1, plot.style_cross)
plot(i_histPP and show_1_618 ? math.avg(htf_h1, htf_l1, htf_c1) - (htf_h1 - htf_l1) * value_1_618 : na, 'PP 1_618', ta.change(time(htf)) ? na : color_1_618, 1, plot.style_cross)
plot(i_histPP and show_1_618 ? math.avg(htf_h1, htf_l1, htf_c1) + (htf_h1 - htf_l1) * value_1_618 : na, 'PP 1_618', ta.change(time(htf)) ? na : color_1_618, 1, plot.style_cross)
plot(i_histPP and show_1_65 ? math.avg(htf_h1, htf_l1, htf_c1) - (htf_h1 - htf_l1) * value_1_65 : na, 'PP 1_65 ', ta.change(time(htf)) ? na : color_1_65 , 1, plot.style_cross)
plot(i_histPP and show_1_65 ? math.avg(htf_h1, htf_l1, htf_c1) + (htf_h1 - htf_l1) * value_1_65 : na, 'PP 1_65 ', ta.change(time(htf)) ? na : color_1_65 , 1, plot.style_cross)
plot(i_histPP and show_2_618 ? math.avg(htf_h1, htf_l1, htf_c1) - (htf_h1 - htf_l1) * value_2_618 : na, 'PP 2_618', ta.change(time(htf)) ? na : color_2_618, 1, plot.style_cross)
plot(i_histPP and show_2_618 ? math.avg(htf_h1, htf_l1, htf_c1) + (htf_h1 - htf_l1) * value_2_618 : na, 'PP 2_618', ta.change(time(htf)) ? na : color_2_618, 1, plot.style_cross)
plot(i_histPP and show_2_65 ? math.avg(htf_h1, htf_l1, htf_c1) - (htf_h1 - htf_l1) * value_2_65 : na, 'PP 2_65 ', ta.change(time(htf)) ? na : color_2_65 , 1, plot.style_cross)
plot(i_histPP and show_2_65 ? math.avg(htf_h1, htf_l1, htf_c1) + (htf_h1 - htf_l1) * value_2_65 : na, 'PP 2_65 ', ta.change(time(htf)) ? na : color_2_65 , 1, plot.style_cross)
plot(i_histPP and show_3_618 ? math.avg(htf_h1, htf_l1, htf_c1) - (htf_h1 - htf_l1) * value_3_618 : na, 'PP 3_618', ta.change(time(htf)) ? na : color_3_618, 1, plot.style_cross)
plot(i_histPP and show_3_618 ? math.avg(htf_h1, htf_l1, htf_c1) + (htf_h1 - htf_l1) * value_3_618 : na, 'PP 3_618', ta.change(time(htf)) ? na : color_3_618, 1, plot.style_cross)
// Fibonacci Retracement / Extention / Pivot Points and Zig Zag
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //
//
// Volume / Volatility AddOns
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //
// ---------------------------------------------------------------------------------------------- //
// -Inputs -------------------------------------------------------------------------------------- //
group_vol_vol = 'Volume / Volatility AddOns'
tooltip_volume_spike_sign_of_exhaustion = 'Moments where ' + 'huge volume detected : current volume is grater than the product of the theshold value and volume moving average'
tooltip_high_volatility = 'Moments where ' + 'price range of the current bar is grater than the product of the theshold value and average true range value of defined period'
tooltip_volume_weighted_colored_bars = 'Volume Weighted Colored Bars Colors bars based on the bar\'s volume relative to volume moving average'
// ---------------------------------------------------------------------------------------------- //
// High Volatility ------------------------------------------------------------------------------ //
i_hATRLb = input.bool(true, '⚡', inline='ATR', group=group_vol_vol, tooltip=tooltip_high_volatility)
i_weightedATR = ta.atr(input.int(13, 'ATR : Length', inline='ATR', group=group_vol_vol)) * input.float(2.718, 'Mult', minval=.1, step=.1, inline='ATR', group=group_vol_vol)
// ---------------------------------------------------------------------------------------------- //
// Volume Moving Average : Base ----------------------------------------------------------------- //
i_vSMA = ta.sma(nz(volume), input.int(89, 'Volume Moving Average Length', group=group_vol_vol))
// ---------------------------------------------------------------------------------------------- //
// Volume Spike - Sign of Exhaustion ------------------------------------------------------------ //
i_vSpikeLb = input.bool(true, '🚦', inline='SRS1', group=group_vol_vol, tooltip=tooltip_volume_spike_sign_of_exhaustion)
i_vSpikeThresh = input.float(4.669, 'Volume Spike Theshold ', minval=.1, step=.1, inline='SRS1', group=group_vol_vol)
// ---------------------------------------------------------------------------------------------- //
// Volume Weighted Colored Bars ----------------------------------------------------------------- //
i_vwcb = input.bool(true, '', inline='VWC', group=group_vol_vol, tooltip=tooltip_volume_weighted_colored_bars)
i_vwcbHighThresh = input.float(1.618, 'VWCB : High ', minval=1., step=.1, inline='VWC', group=group_vol_vol)
i_vwcbLowThresh = input.float(0.618, ' Low', minval=.1, step=.1, inline='VWC', group=group_vol_vol)
// ---------------------------------------------------------------------------------------------- //
// -Calculations and Plotting ------------------------------------------------------------------- //
nzVolume = nz(volume)
bullCandle = close > open
bearCandle = close < open
range_1 = math.abs(high - low)
// ---------------------------------------------------------------------------------------------- //
// Volume Spike - Sign of Exhaustion ------------------------------------------------------------ //
exhaustVol = nzVolume > i_vSpikeThresh * i_vSMA
plotchar(i_vSpikeLb and nzVolume ? exhaustVol : na, 'Exhaustion Bar', '🚦', location.abovebar, size=size.tiny)
alertcondition(ta.crossover(nzVolume, i_vSMA * i_vSpikeThresh), 'Volume Spikes', 'sign of exhaustion, huge volume increase detected {{exchange}}:{{ticker}}-> Open = {{open}}, Current = {{close}}, Time = {{time}}')
// ---------------------------------------------------------------------------------------------- //
// High Volatility ------------------------------------------------------------------------------ //
highVolatility = range_1 > i_weightedATR
plotchar(i_hATRLb ? highVolatility : na, 'High Volatile Bar', '⚡', location.belowbar, size=size.tiny)
alertcondition(ta.crossover(range_1, i_weightedATR), 'High Volatility', 'high volatility detected {{exchange}}:{{ticker}}-> Open = {{open}}, Current = {{close}}, Time = {{time}}')
// ---------------------------------------------------------------------------------------------- //
// Volume Weighted Colored Bars by Kıvanç Özbilgiç ---------------------------------------------- //
vwcbCol = nzVolume > i_vSMA * i_vwcbHighThresh ? bullCandle ? #006400 : #910000 : nzVolume < i_vSMA * i_vwcbLowThresh ? bearCandle ? #FF9800 : #7FFFD4 : na
barcolor(i_vwcb and nzVolume ? vwcbCol : na, title='Volume Weighted Colored Bars')
// Voloume / Volatility AddOns
// ══════════════════════════════════════════════════════════════════════════════════════════════════ //
var table logo = table.new(position.bottom_right, 1, 1)
table.cell(logo, 0, 0, '☼☾ ', text_size=size.normal, text_color=color.teal)
Scalping 1//@version=5
indicator("Trend Line Indicator for Scalping", overlay=true)
// تنظیمات
length = input(14, title="Length")
sensitivity = input(1.5, title="Sensitivity")
// محاسبه نقاط قیمتی
highestHigh = ta.highest(high, length)
lowestLow = ta.lowest(low, length)
// محاسبه ترند لاین
trendLine = (highestHigh + lowestLow) / 2
// تعیین سیگنال فروش
sellSignal = close < trendLine and ta.crossover(close, trendLine)
// رسم ترند لاین
plot(trendLine, title="Trend Line", color=color.red, linewidth=2)
// رسم سیگنال فروش با فلش قرمز
plotshape(series=sellSignal, location=location.abovebar, color=color.red, style=shape.triangledown, text="Sell", size=size.small)
// نمایش اطلاعات
bgcolor(sellSignal ? color.new(color.red, 90) : na)
sertces 1 parali sarsertces 1 parali sar sertces 1 parali sar sertces 1 parali sar sertces 1 parali sar
dr.triz: 200th Candle Marker200th Candle Marker
The 200th Candle Indicator is a technical analysis tool that helps you identify the 200th candle before the current one on a chart. This indicator draws a vertical line at the position of the 200th candle, allowing you to observe long-term price changes and patterns.
This indicator is typically used for analyzing long-term trends and helps traders identify entry and exit points based on long-term patterns. By marking the 200th candle, traders can get a sense of how the price has evolved over a longer period and make more informed decisions.
Scalping 1//@version=5
indicator("Trend Line Indicator for Scalping", overlay=true)
// تنظیمات
length = input(14, title="Length")
sensitivity = input(1.5, title="Sensitivity")
// محاسبه نقاط قیمتی
highestHigh = ta.highest(high, length)
lowestLow = ta.lowest(low, length)
// محاسبه ترند لاین
trendLine = (highestHigh + lowestLow) / 2
// تعیین سیگنال فروش
sellSignal = close < trendLine and ta.crossover(close, trendLine)
// رسم ترند لاین
plot(trendLine, title="Trend Line", color=color.red, linewidth=2)
// رسم سیگنال فروش با فلش قرمز
plotshape(series=sellSignal, location=location.abovebar, color=color.red, style=shape.triangledown, text="Sell", size=size.small)
// نمایش اطلاعات
bgcolor(sellSignal ? color.new(color.red, 90) : na)
Dynamic High/Low Cross AlertAutomatically create a high and low alert based on the last 15 period lookback
Drawdown and Max Drawdown with BubbleProvides the drawdown history and highlights the max drawdown in a bubble on the plot
Deshik(MACD)normal MACD indicator, but with different lookout levels. Can be configured for different markets, with changes to MA values and primary levels.
ATT + Key Levels with SessionsKey Features:
ATT Turning Point Numbers:
This input allows the user to define specific numbers (e.g., "3,11,17,29,41,47,53,59") that mark turning points in price action, which are checked using the bar_index modulo 60. If the current bar index matches one of these turning points, it triggers potential buy or sell signals.
RSI (Relative Strength Index):
The RSI is calculated based on a user-defined period (rsi_period), typically 14, and used to indicate overbought or oversold conditions. The script defines overbought (70) and oversold (30) levels, which are used to filter buy or sell signals.
Session Times:
The script includes predefined session times for major trading markets:
New York: From 9:30 AM EST to 4:00 PM EST.
London: From 8:00 AM GMT to 4:30 PM GMT.
Asia: From 12:00 AM GMT to 9:00 AM GMT.
These session times are used to restrict the buy and sell signals to specific market sessions.
Key Levels:
The script calculates and plots key market levels for the current day and week:
Daily High and Low: The highest and lowest prices of the current day.
Weekly High and Low: The highest and lowest prices of the current week.
These levels are plotted with different colors for visual reference.
Signal Logic:
Buy Signal: Triggered when the current bar is a turning point (according to the ATT model), the RSI is below the oversold threshold, and the current time is within the active session times (New York, London, or Asia).
Sell Signal: Triggered when the current bar is a turning point, the RSI is above the overbought threshold, and the current time is within the active session times.
Signal Limitations:
A user-defined limit (max_signals_per_session) controls the maximum number of signals that can be plotted within each session. This prevents excessive signal generation.
Plotting and Background Highlights:
Buy and Sell Signals: The script plots shapes (labels) above or below the bars to indicate buy or sell signals when the conditions are met.
Background Highlight: The background color is highlighted in yellow when the current bar matches one of the defined ATT turning points.
In Summary:
The indicator combines multiple technical factors to generate trading signals:
Turning points in price action (based on custom ATT numbers),
RSI levels (overbought/oversold),
Market session times (New York, London, Asia),
Key price levels (daily and weekly highs and lows).
This combination helps traders identify potential buying and selling opportunities while considering broader market dynamics and limiting the number of signals during each session.
Deshik(PMQ)Used for Indexes. Reduces stochastic noise, and bares the RSI levels, to create green and red dots. They consequently mean buy and sell signals
AuriumFlowAURIUM (GOLD-Weighted Average with Fractal Dynamics)
Aurium is a cutting-edge indicator that blends volume-weighted moving averages (VWMA), fractal geometry, and Fibonacci-inspired calculations to deliver a precise and holistic view of market trends. By dynamically adjusting to price and volume, Aurium uncovers key levels of confluence for trend reversals and continuations, making it a powerful tool for traders.
Key Features:
Dynamic Trendline (GOLD):
The central trendline is a weighted moving average based on price and volume, tuned using Fibonacci-based fast (34) and slow (144) exponential moving average lengths. This ensures the trendline adapts seamlessly to the flow of market dynamics.
Formula:
GOLD = VWMA(34) * Volume Factor + VWMA(144) * (1 - Volume Factor)
Fractal Highs and Lows:
Detects pivotal market points using a fractal lookback period (default 5, odd-numbered). Fractals identify local highs and lows over a defined window, capturing the structure of market cycles.
Trend Background Highlighting:
Bullish Zone: Price above the GOLD line with a green background.
Bearish Zone: Price below the GOLD line with a red background.
Buy and Sell Alerts:
Generates actionable signals when fractals align with GOLD. Bullish fractals confirm continuation or reversal in an uptrend, while bearish fractals validate a downtrend.
The Math Behind Aurium:
Volume-Weighted Adjustments:
By integrating volume into the calculation, Aurium dynamically emphasizes price levels with greater participation, giving traders insight into zones of institutional interest.
Formula:
VWMA = EMA(Close * Volume) / EMA(Volume)
Fractal Calculations:
Fractals are identified as local maxima (highs) or minima (lows) based on the surrounding bars, leveraging the natural symmetry in price behavior.
Fibonacci Relationships:
The 34 and 144 EMA lengths are Fibonacci numbers, offering a natural alignment with price cycles and market rhythms.
Ideal For:
Traders seeking a precise and intuitive indicator for aligning with trends and detecting reversals.
Strategies inspired by Bill Williams, with added volume and fractal-based insights.
Short-term scalpers and long-term trend-followers alike.
Unlock deeper market insights and trade with precision using Aurium!
Jay ORAbility to mark out opening range with customization on what that range & standard deviation from ranges are.
Weighted Fourier Transform: Spectral Gating & Main Frequency🙏🏻 This drop has 2 purposes:
1) to inform every1 who'd ever see it that Weighted Fourier Tranform does exist, while being available nowhere online, not even in papers, yet there's nothing incredibly complicated about it, and it can/should be used in certain cases;
2) to show TradingView users how they can use it now in dem endevours, to show em what spectral filtering is, and what can they do with all of it in diy mode.
... so we gonna have 2 sections in the description
Section 1: Weighted Fourier Transform
It's quite easy to include weights in Fourier analysis: you just premultiply each datapoint by its corresponding weight -> feed to direct Fourier Transform, and then divide by weights after inverse Fourier transform. Alternatevely, in direct transform you just multiply contributions of each data point to the real and imaginary parts of the Fourier transform by corresponding weights (in accumulation phase), and in inverse transform you divide by weights instead during the accumulation phase. Everything else stays the same just like in non-weighted version.
If you're from the first target group let's say, you prolly know a thing or deux about how to code & about Fourier Transform, so you can just check lines of code to see the implementation of Weighted Discrete version of Fourier Transform, and port it to to any technology you desire. Pine Script is a developing technology that is incredibly comfortable in use for quant-related tasks and anything involving time series in general. While also using Python for research and C++ for development, every time I can do what I want in Pine Script, I reach for it and never touch matlab, python, R, or anything else.
Weighted version allows you to explicetly include order/time information into the operation, which is essential with every time series, although not widely used in mainstream just as many other obvious and right things. If you think deeply, you'll understand that you can apply a usual non-weighted Fourier to any 2d+ data you can (even if none of these dimensions represent time), because this is a geometric tool in essence. By applying linearly decaying weights inside Fourier transform, you're explicetly saying, "one of these dimensions is Time, and weights represent the order". And obviously you can combine multiple weightings, eg time and another characteristic of each datum, allows you to include another non-spatial dimension in your model.
By doing that, on properly processed (not only stationary but Also centered around zero data), you can get some interesting results that you won't be able to recreate without weights:
^^ A sine wave, centered around zero, period of 16. Gray line made by: DWFT (direct weighted Fourier transform) -> spectral gating -> IWFT (inverse weighted Fourier transform) -> plotting the last value of gated reconstructed data, all applied to expanding window. Look how precisely it follows the original data (the sine wave) with no lag at all. This can't be done by using non-weighted version of Fourier transform.
^^ spectral filtering applied to the whole dataset, calculated on the latest data update
And you should never forget about Fast Fourier Transform, tho it needs recursion...
Section 2: About use cases for quant trading, about this particular implementaion in Pine Script 6 (currently the latest version as of Friday 13, December 2k24).
Given the current state of things, we have certain limits on matrix size on TradingView (and we need big dope matrixes to calculate polynomial regression -> detrend & center our data before Fourier), and recursion is not yet available in Pine Script, so the script works on short datasets only, and requires some time.
A note on detrending. For quality results, Fourier Transform should be applied to not only stationary but also centered around zero data. The rightest way to do detrending of time series
is to fit Cumulative Weighted Moving Polynomial Regression (known as WLSMA in some narrow circles xD) and calculate the deltas between datapoint at time t and this wonderful fit at time t. That's exactly what you see on the main chart of script description: notice the distances between chart and WLSMA, now look lower and see how it matches the distances between zero and purple line in WFT study. Using residuals of one regression fit of the whole dataset makes less sense in time series context, we break some 'time' and order rules in a way, tho not many understand/cares abouit it in mainstream quant industry.
Two ways of using the script:
Spectral Gating aka Spectral filtering. Frequency domain filtering is quite responsive and for a greater computational cost does not introduce a lag the way it works with time-domain filtering. Works this way: direct Fourier transform your data to get frequency & phase info -> compute power spectrum out of it -> zero out all dem freqs that ain't hit your threshold -> inverse Fourier tranform what's left -> repeat at each datapoint plotting the very first value of reconstructed array*. With this you can watch for zero crossings to make appropriate trading decisions.
^^ plot Freq pass to use the script this way, use Level setting to control the intensity of gating. These 3 only available values: -1, 0 and 1, are the general & natural ones.
* if you turn on labels in script's style settings, you see the gray dots perfectly fitting your data. They get recalculated (for the whole dataset) at each update. You call it repainting, this is for analytical & aesthetic purposes. Included for demonstration only.
Finding main/dominant frequency & period. You can use it to set up Length for your other studies, and for analytical purposes simply to understand the periodicity of your data.
^^ plot main frequency/main period to use the script this way. On the screenshot, you can see the script applied to sine wave of period 16, notice how many datapoints it took the algo to figure out the signal's period quite good in expanding window mode
Now what's the next step? You can try applying signal windowing techniques to make it all less data-driven but your ego-driven, make a weighted periodogram or autocorrelogram (check Wiener-Khinchin Theorem ), and maybe whole shiny spectrogram?
... you decide, choice is yours,
The butterfly reflect the doors ...
∞
Long-term Bean Dip (v.1)This strategy aims to capitalize on significant price dips in a bullish market by incrementally purchasing assets as they decline and selling all holdings once the price recovers near its all-time high (ATH). The approach is designed to systematically build positions during market pullbacks and lock in profits during recoveries.
Liquidity IndicatorThe Liquidity Indicator helps identify key price levels where liquidity may be concentrated by highlighting local highs and local lows on the chart. These levels are calculated using a lookback period to determine the highest and lowest points in the recent price action.
Local Highs: Displayed as red lines, these indicate recent peaks where price has experienced rejection or a possible reversal point.
Local Lows: Displayed as green lines, these represent recent troughs where price may find support or experience a bounce.
This indicator is useful for spotting potential areas of interest for price reversal or continuation, as high liquidity zones may lead to more significant price movements.
Key Features:
Adjustable lookback period to define the scope for identifying local highs and lows.
Continuous plotting without any time restrictions, providing real-time insights into liquidity conditions.
Alerts available for when a local high or local low is detected, enabling timely market analysis.
Use Case:
This indicator can be used in conjunction with other technical analysis tools or strategies to help identify significant price levels where liquidity could impact price action. It is suitable for both intraday and swing traders looking for key price zones where potential reversals or continuations might occur.
Last 2 Days High/Low MarkerThis indicator plots the high and low levels of the last two daily candlesticks, visually highlighting the most recent price action. The lines are color-coded to differentiate between the two days:
Blue lines represent the high and low for yesterday's trading session.
Yellow lines represent the high and low for the day before yesterday's trading session.
Each line extends for a fixed number of bars, providing a clear visual reference to the recent price range. This indicator can be used to track key levels from the previous days for intraday trading or trend analysis.
Enhanced RSIEnhanced RSI with Phases, Divergences & Volume Control:
This advanced RSI indicator expands on the traditional Relative Strength Index by introducing dynamic exhaustion phase detection, automatic divergence identification, and volume-based control evaluation. It provides traders with actionable insights into trend momentum, potential reversals, and market dominance.
Key Features:
Dynamic Exhaustion Phases:
Identifies real phases of the RSI based on slope and momentum:
Acceleration: Momentum increasing rapidly (green phase).
Deceleration: Momentum weakening (red phase).
Plateau: Momentum flattening (yellow phase).
Neutral: No significant momentum shift detected.
Phases are displayed dynamically in a box on the chart.
Automatic Divergence Detection:
Bullish Divergence: Identified when price makes a lower low while RSI makes a higher low.
Bearish Divergence: Identified when price makes a higher high while RSI makes a lower high.
Divergences are marked directly on the RSI chart with labeled circles.
Volume-Based Control Evaluation:
Analyzes price action relative to volume to determine market dominance:
Bulls in Control: Closing price is higher than the opening price.
Bears in Control: Closing price is lower than the opening price.
Neutral: No significant dominance (closing equals opening).
Volume status is displayed alongside the RSI phase in the chart’s top-left box.
Custom RSI Plot:
Includes overbought (70), oversold (30), and neutral (50) levels for easier interpretation of market conditions.
RSI plotted in blue for clarity.
How to Use:
Add to Chart:
Apply this indicator to any chart in TradingView.
Interpret the RSI Phase Box:
Use the RSI phase (Acceleration, Deceleration, Plateau, Neutral) to identify trend momentum.
Combine the phase with the volume status (Bulls or Bears in Control) to confirm market sentiment.
Identify Divergences:
Look for Bullish Divergence (potential upward reversal) or Bearish Divergence (potential downward reversal) marked directly on the RSI chart.
Adjust Settings:
Customize the RSI period, phase sensitivity, and divergence lookback period to fit your trading style.
Disclaimer:
This indicator is a tool to assist with technical analysis. It is not a financial advice or a guarantee of market performance. Always combine this indicator with other methods or strategies for better results.
Little HelperA.I buddy while you trade, green triangle for long, red for short, many green and red equals consolidation, use as overlay with your current strat.
Shooting Star + Elephant Candle - BearishShooting Star + Elephant Candle - Bearish
This indicator identifies a specific bearish reversal pattern in the market, combining the Shooting Star and Elephant Candle patterns. The Shooting Star pattern is a single-day bearish reversal pattern that appears during an uptrend, characterized by a small body and a long upper shadow. The Elephant Candle pattern is a strong confirmation candle that appears after the Shooting Star, indicating a potential reversal in the market.
How it works:
1. The indicator first detects the trend using two methods: SMA50 and SMA200.
2. It then identifies the Shooting Star pattern
3. After the Shooting Star pattern is detected, the indicator looks for a strong confirmation candle (Elephant Candle) within the next three candles.
4. If the Elephant Candle is detected, the indicator triggers an alert and plots a label on the chart.
Features:
Identifies bearish reversal patterns in the market
Combines Shooting Star and Elephant Candle patterns for strong confirmation
Customizable trend detection methods (SMA50 and SMA200)
Adjustable parameters for Shooting Star and Elephant Candle detection
Alerts and labels for easy identification of patterns
Usage:
1. Add the indicator to your chart
2. Adjust the trend detection method and parameters to suit your trading strategy
3. Look for the Shooting Star + Elephant Candle pattern to appear on the chart
4. Use the alert and label features to notify you of potential reversals
Disclaimer:
This indicator is for educational purposes only and should not be used as the sole basis for making trading decisions. Always use proper risk management and combine with other forms of analysis before entering a trade.