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
مكتبة باين
كمثال للقيم التي تتبناها TradingView، نشر المؤلف شيفرة باين كمكتبة مفتوحة المصدر بحيث يمكن لمبرمجي باين الآخرين من مجتمعنا استخدامه بحرية. تحياتنا للمؤلف! يمكنك استخدام هذه المكتبة بشكل خاص أو في منشورات أخرى مفتوحة المصدر، ولكن إعادة استخدام هذا الرمز في المنشورات تخضع لقواعد الموقع.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.
مكتبة باين
كمثال للقيم التي تتبناها TradingView، نشر المؤلف شيفرة باين كمكتبة مفتوحة المصدر بحيث يمكن لمبرمجي باين الآخرين من مجتمعنا استخدامه بحرية. تحياتنا للمؤلف! يمكنك استخدام هذه المكتبة بشكل خاص أو في منشورات أخرى مفتوحة المصدر، ولكن إعادة استخدام هذا الرمز في المنشورات تخضع لقواعد الموقع.
إخلاء المسؤولية
لا يُقصد بالمعلومات والمنشورات أن تكون، أو تشكل، أي نصيحة مالية أو استثمارية أو تجارية أو أنواع أخرى من النصائح أو التوصيات المقدمة أو المعتمدة من TradingView. اقرأ المزيد في شروط الاستخدام.