PINE LIBRARY
volSRCore

Library volSRCore
Library to compute volume-based support and resistance zones using fractal logic.
tfStringToFormat(tfInput)
Converts a timeframe string into Pine Script format.
Parameters:
tfInput (string): Timeframe string ("Chart", "1m", "5m", "1h", "D", etc.)
Returns:
string — Pine Script–formatted timeframe
resInMinutes()
Converts the current chart timeframe into minutes.
Returns:
float — number of minutes of the current timeframe
fractalUp(tfHigh, tfVol, tfVolMA)
Detects a bullish fractal (potential resistance).
Parameters:
tfHigh (float): High series of the timeframe
tfVol (float): Volume series of the timeframe
tfVolMA (float): Volume moving average series
Returns:
bool — true if a bullish fractal is detected
fractalDown(tfLow, tfVol, tfVolMA)
Detects a bearish fractal (potential support).
Parameters:
tfLow (float): Low series of the timeframe
tfVol (float): Volume series of the timeframe
tfVolMA (float): Volume moving average series
Returns:
bool — true if a bearish fractal is detected
calcFractalUpLevel(tfHigh, tfVol, tfVolMA)
Computes the resistance level from a bullish fractal.
Parameters:
tfHigh (float): High series
tfVol (float): Volume series
tfVolMA (float): Volume MA series
Returns:
float — resistance level
calcFractalDownLevel(tfLow, tfVol, tfVolMA)
Computes the support level from a bearish fractal.
Parameters:
tfLow (float): Low series
tfVol (float): Volume series
tfVolMA (float): Volume MA series
Returns:
float — support level
calcResistanceZone(tfHigh, tfOpen, tfClose, tfVol, tfVolMA)
Computes the resistance zone (between High and Open/Close).
Parameters:
tfHigh (float): High series
tfOpen (float): Open series
tfClose (float): Close series
tfVol (float): Volume series
tfVolMA (float): Volume MA series
Returns:
float — lower boundary of the resistance zone
calcSupportZone(tfLow, tfOpen, tfClose, tfVol, tfVolMA)
Computes the support zone (between Low and Open/Close).
Parameters:
tfLow (float): Low series
tfOpen (float): Open series
tfClose (float): Close series
tfVol (float): Volume series
tfVolMA (float): Volume MA series
Returns:
float — upper boundary of the support zone
tfNewBar(tfRes)
Detects a new bar on a given timeframe.
Parameters:
tfRes (simple string): Timeframe string
Returns:
bool — true if a new bar is detected
tfBarIndexBack(tfRes, barsBack)
Computes the bar_index N bars back on a target timeframe.
Parameters:
tfRes (simple string): Timeframe string
barsBack (simple int): Number of bars back (1, 3, 5, etc.)
Returns:
int — bar_index at that point in time
tfBarsRange(tfRes, startBar, endBar)
Computes the number of chart bars between two bars of a target timeframe.
Parameters:
tfRes (simple string): Timeframe string
startBar (simple int): Start bar (e.g., 1)
endBar (simple int): End bar (e.g., 5)
Returns:
int — number of chart bars in that range
calcPivotHighBarIndex(startBarsBack, rangeSize, maxBarsBack)
Finds the exact bar_index of the highest high within a given range.
Parameters:
startBarsBack (simple int): Start of the scan (bars back)
rangeSize (simple int): Size of the scan range
maxBarsBack (simple int): max_bars_back limit (e.g., 4999)
Returns:
int — bar_index of the highest high, or maxBarsBack if out of bounds
calcPivotLowBarIndex(startBarsBack, rangeSize, maxBarsBack)
Finds the exact bar_index of the lowest low within a given range.
Parameters:
startBarsBack (simple int): Start of the scan (bars back)
rangeSize (simple int): Size of the scan range
maxBarsBack (simple int): max_bars_back limit (e.g., 4999)
Returns:
int — bar_index of the lowest low, or maxBarsBack if out of bounds
detectPriceInteraction(resLevel, resZone, supLevel, supZone)
Detects price interactions with support/resistance zones.
Parameters:
resLevel (float): Resistance level
resZone (float): Resistance zone
supLevel (float): Support level
supZone (float): Support zone
Returns:
[bool, bool, bool, bool, bool, bool]
EntersResZone
TestsResAsSupport
EntersSupZone
TestsSupAsResistance
BreaksResistance
BreaksSupport
calcSRLevelsFromData(tfOpen, tfHigh, tfLow, tfClose, tfVol, volMaLength)
Computes all support/resistance levels from already-fetched MTF data.
Parameters:
tfOpen (float): TF open
tfHigh (float): TF high
tfLow (float): TF low
tfClose (float): TF close
tfVol (float): TF volume
volMaLength (simple int): Volume MA length
Returns:
[float, float, float, float, bool, bool]
ResistanceLevel
ResistanceZone
SupportLevel
SupportZone
IsFractalUp
IsFractalDown
detectNewSR(resLevel, supLevel)
Detects a new fractal event (new support or resistance found).
Parameters:
resLevel (float): Current resistance level
supLevel (float): Current support level
Returns:
[bool, bool]
NewResistance
NewSupport
Library to compute volume-based support and resistance zones using fractal logic.
tfStringToFormat(tfInput)
Converts a timeframe string into Pine Script format.
Parameters:
tfInput (string): Timeframe string ("Chart", "1m", "5m", "1h", "D", etc.)
Returns:
string — Pine Script–formatted timeframe
resInMinutes()
Converts the current chart timeframe into minutes.
Returns:
float — number of minutes of the current timeframe
fractalUp(tfHigh, tfVol, tfVolMA)
Detects a bullish fractal (potential resistance).
Parameters:
tfHigh (float): High series of the timeframe
tfVol (float): Volume series of the timeframe
tfVolMA (float): Volume moving average series
Returns:
bool — true if a bullish fractal is detected
fractalDown(tfLow, tfVol, tfVolMA)
Detects a bearish fractal (potential support).
Parameters:
tfLow (float): Low series of the timeframe
tfVol (float): Volume series of the timeframe
tfVolMA (float): Volume moving average series
Returns:
bool — true if a bearish fractal is detected
calcFractalUpLevel(tfHigh, tfVol, tfVolMA)
Computes the resistance level from a bullish fractal.
Parameters:
tfHigh (float): High series
tfVol (float): Volume series
tfVolMA (float): Volume MA series
Returns:
float — resistance level
calcFractalDownLevel(tfLow, tfVol, tfVolMA)
Computes the support level from a bearish fractal.
Parameters:
tfLow (float): Low series
tfVol (float): Volume series
tfVolMA (float): Volume MA series
Returns:
float — support level
calcResistanceZone(tfHigh, tfOpen, tfClose, tfVol, tfVolMA)
Computes the resistance zone (between High and Open/Close).
Parameters:
tfHigh (float): High series
tfOpen (float): Open series
tfClose (float): Close series
tfVol (float): Volume series
tfVolMA (float): Volume MA series
Returns:
float — lower boundary of the resistance zone
calcSupportZone(tfLow, tfOpen, tfClose, tfVol, tfVolMA)
Computes the support zone (between Low and Open/Close).
Parameters:
tfLow (float): Low series
tfOpen (float): Open series
tfClose (float): Close series
tfVol (float): Volume series
tfVolMA (float): Volume MA series
Returns:
float — upper boundary of the support zone
tfNewBar(tfRes)
Detects a new bar on a given timeframe.
Parameters:
tfRes (simple string): Timeframe string
Returns:
bool — true if a new bar is detected
tfBarIndexBack(tfRes, barsBack)
Computes the bar_index N bars back on a target timeframe.
Parameters:
tfRes (simple string): Timeframe string
barsBack (simple int): Number of bars back (1, 3, 5, etc.)
Returns:
int — bar_index at that point in time
tfBarsRange(tfRes, startBar, endBar)
Computes the number of chart bars between two bars of a target timeframe.
Parameters:
tfRes (simple string): Timeframe string
startBar (simple int): Start bar (e.g., 1)
endBar (simple int): End bar (e.g., 5)
Returns:
int — number of chart bars in that range
calcPivotHighBarIndex(startBarsBack, rangeSize, maxBarsBack)
Finds the exact bar_index of the highest high within a given range.
Parameters:
startBarsBack (simple int): Start of the scan (bars back)
rangeSize (simple int): Size of the scan range
maxBarsBack (simple int): max_bars_back limit (e.g., 4999)
Returns:
int — bar_index of the highest high, or maxBarsBack if out of bounds
calcPivotLowBarIndex(startBarsBack, rangeSize, maxBarsBack)
Finds the exact bar_index of the lowest low within a given range.
Parameters:
startBarsBack (simple int): Start of the scan (bars back)
rangeSize (simple int): Size of the scan range
maxBarsBack (simple int): max_bars_back limit (e.g., 4999)
Returns:
int — bar_index of the lowest low, or maxBarsBack if out of bounds
detectPriceInteraction(resLevel, resZone, supLevel, supZone)
Detects price interactions with support/resistance zones.
Parameters:
resLevel (float): Resistance level
resZone (float): Resistance zone
supLevel (float): Support level
supZone (float): Support zone
Returns:
[bool, bool, bool, bool, bool, bool]
EntersResZone
TestsResAsSupport
EntersSupZone
TestsSupAsResistance
BreaksResistance
BreaksSupport
calcSRLevelsFromData(tfOpen, tfHigh, tfLow, tfClose, tfVol, volMaLength)
Computes all support/resistance levels from already-fetched MTF data.
Parameters:
tfOpen (float): TF open
tfHigh (float): TF high
tfLow (float): TF low
tfClose (float): TF close
tfVol (float): TF volume
volMaLength (simple int): Volume MA length
Returns:
[float, float, float, float, bool, bool]
ResistanceLevel
ResistanceZone
SupportLevel
SupportZone
IsFractalUp
IsFractalDown
detectNewSR(resLevel, supLevel)
Detects a new fractal event (new support or resistance found).
Parameters:
resLevel (float): Current resistance level
supLevel (float): Current support level
Returns:
[bool, bool]
NewResistance
NewSupport
Pine脚本库
秉承TradingView的精神,作者已将此Pine代码作为开源库发布,以便我们社区的其他Pine程序员可以重用它。向作者致敬!您可以私下或在其他开源出版物中使用此库,但在出版物中重用此代码须遵守网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
Pine脚本库
秉承TradingView的精神,作者已将此Pine代码作为开源库发布,以便我们社区的其他Pine程序员可以重用它。向作者致敬!您可以私下或在其他开源出版物中使用此库,但在出版物中重用此代码须遵守网站规则。
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。