PINE LIBRARY
Güncellendi Helper Lib by tristanlee85

Library "helpers"
This library offers various functions and types based on the algorithmic
concepts as authored by ICT.
kv(key, value)
Returns a string of the key/value set, suitable for debug logging
Parameters:
key (string)
value (string)
Returns: A string formatted as "{key}: {value}"
kv(key, value)
Parameters:
key (string)
value (int)
kv(key, value)
Parameters:
key (string)
value (float)
kv(key, value)
Parameters:
key (string)
value (bool)
method enable(this, enable)
Enable/Disable debug logging
Namespace types: Debugger
Parameters:
this (Debugger)
enable (bool): Set to `true` by default.
method group(this, label)
Creates a group label for nested debug() invocations
Namespace types: Debugger
Parameters:
this (Debugger)
label (string)
method groupEnd(this, label)
Ends the specified debug group
Namespace types: Debugger
Parameters:
this (Debugger)
label (string)
method log(this, s, arg1, arg2, arg3, arg4, arg5)
Logs the param values if debug mode is enabled
Namespace types: Debugger
Parameters:
this (Debugger)
s (string): Title of the log message
arg1 (string)
arg2 (string)
arg3 (string)
arg4 (string)
arg5 (string)
method logIf(this, expr, s, arg1, arg2, arg3, arg4, arg5)
Same behavior as debug() except will only log if the passed expression is true
Namespace types: Debugger
Parameters:
this (Debugger)
expr (bool): Boolean expression to determine if debug logs should be logged
s (string): Title of the log message
arg1 (string)
arg2 (string)
arg3 (string)
arg4 (string)
arg5 (string)
style_getLineStyleFromType(opt)
Returns the corresponding line style constant for the given LineStyleType
Parameters:
opt (series LineStyleType): The selected line style type
Returns: The Pine Script line style constant
style_getTextSizeFromType(opt)
Returns the corresponding text size constant for the given TextSizeType
Parameters:
opt (series TextSizeType): The selected text size type
Returns: The Pine Script text size constant
style_getTextHAlignFromType(t)
Returns the corresponding horizontal text align constant for the given HAlignType
Parameters:
t (series HAlignType): The selected text align type
Returns: The Pine Script text align constant
style_getTextVAlignFromType(t)
Returns the corresponding vertical text align constant for the given VAlignType
Parameters:
t (series VAlignType): The selected text align type
Returns: The Pine Script text align constant
format_sentimentType(sentiment, pd)
Used to produce a string with the sentiment and PD array type (e.g., "+FVG")
Parameters:
sentiment (series SentimentType): The sentiment value (e.g., SentimentType.BULLISH)
pd (series PDArrayType): The price data array (e.g., PDArrayType.FVG)
Returns: A formatted string with the sentiment and PD array (e.g., "+FVG")
format_timeToString(timestamp)
Formats a UNIX timestamp into a date and time string based on predefined formats
Parameters:
timestamp (int): The UNIX timestamp to format
Returns: A formatted string as "MM-dd (E) - HH:mm"
method init(this)
Initializes the session and validates the configuration. This MUST be called immediately after creating a new instance.
Namespace types: Session
Parameters:
this (Session): The Session object reference
Returns: The Session object (chainable) or throws a runtime error if invalid
method isActive(this, _time)
Determines if the session is active based on the current bar time
Namespace types: Session
Parameters:
this (Session): The Session object reference
_time (int)
Returns: `true` if the session is currently active; `false` otherwise
method draw(this)
Draws the line and optional label
Namespace types: LineLabel
Parameters:
this (LineLabel): The LineLabel object reference
Returns: The LineLabel object (chainable)
method extend(this, x)
Extends the line and label right to the specified bar index
Namespace types: LineLabel
Parameters:
this (LineLabel): The LineLabel object reference
x (int): The bar index to extend to
Returns: The LineLabel object (chainable)
method destroy(this)
Removes the line and label from the chart
Namespace types: LineLabel
Parameters:
this (LineLabel): The LineLabel object reference
isFVG(includeVI, barIdx)
Checks if the previous bars form a Fair Value Gap (FVG)
Parameters:
includeVI (bool): If true, includes Volume Imbalance in the FVG calculation
barIdx (int): The index of the bar to check from (default is 0 for the current bar)
Returns: A Gap object if a FVG is detected; otherwise, `na`
isVolumeImbalance(barIdx)
Checks if the previous bars form a Volume Imbalance (VI)
Parameters:
barIdx (int): The index of the bar to check from (default is 0 for the current bar)
Returns: A Gap object if a VI is detected; otherwise, `na`
isLiquidityVoid(barIdx)
Checks if the previous bars form a Liquidity Void (LV)
Parameters:
barIdx (int): The index of the bar to check from (default is 0 for the current bar)
Returns: A Gap object if an LV is detected; otherwise, `na`
isSwingPoint(barIdx)
Checks if the previous bars form a swing point
Parameters:
barIdx (int): The index of the bar to check from (default is 0 for the current bar)
Returns: A SwingPoint object if a swing point is detected; otherwise, `na`
Debugger
A debug logging utility with group support
Fields:
enabled (series bool)
_debugGroupStack (array<string>)
Session
Defines a trading session with a name and time range. When creating a new instance of this type, you MUST call init() immediately.
Fields:
name (series string): A display-friendly name (e.g., "NY AM")
session (series string): A string defining the session time range (e.g., "1300-1400")
enabled (series bool): Optional flag for custom logic; defaults to false
start (series int): UNIX time representing the session start (set via isActive())
end (series int): UNIX time representing the session end (set via isActive())
_t (series int)
_start_HH (series float)
_start_mm (series float)
_end_HH (series float)
_end_mm (series float)
Gap
Represents a price inefficiency (gap) with details on sentiment and price levels
Fields:
type (series SentimentType): The sentiment of the gap (e.g., SentimentType.BULLISH)
name (series string): A display-friendly name (e.g., "+FVG")
startTime (series int): UNIX time value for the gap's start
endTime (series int): UNIX time value for the gap's end
startIndex (series int): Bar index where the gap starts
endIndex (series int): Bar index where the gap ends
gapLow (series float): The lowest price level of the gap
gapHigh (series float): The highest price level of the gap
ce (series float): The consequent encroachment level of the gap
SwingPoint
Represents a swing point with details on type and price level
Fields:
type (series SwingPointType): The type of swing point (e.g., SwingPointType.HIGH)
time (series int): UNIX time value for the swing point
barIdx (series int): Bar index where the swing point occurs
price (series float): The price level of the swing point which is either the high or low of the middle bar
LineLabel
Combines a line and box type to produce a line with a label that is properly aligned
Fields:
x (series int): The X-axis starting point as a bar index
y (series float): The Y-axis starting point as the price level
color (series color): Both the line and text color
width (series int): Thickness of the line
label (series string): Text to display
showLabel (series bool): Boolean to conditionally show/hide the label (default is false)
lineStyle (series LineStyleType): The style of the line
textSize (series TextSizeType)
_b (series box)
_l (series line)
This library offers various functions and types based on the algorithmic
concepts as authored by ICT.
kv(key, value)
Returns a string of the key/value set, suitable for debug logging
Parameters:
key (string)
value (string)
Returns: A string formatted as "{key}: {value}"
kv(key, value)
Parameters:
key (string)
value (int)
kv(key, value)
Parameters:
key (string)
value (float)
kv(key, value)
Parameters:
key (string)
value (bool)
method enable(this, enable)
Enable/Disable debug logging
Namespace types: Debugger
Parameters:
this (Debugger)
enable (bool): Set to `true` by default.
method group(this, label)
Creates a group label for nested debug() invocations
Namespace types: Debugger
Parameters:
this (Debugger)
label (string)
method groupEnd(this, label)
Ends the specified debug group
Namespace types: Debugger
Parameters:
this (Debugger)
label (string)
method log(this, s, arg1, arg2, arg3, arg4, arg5)
Logs the param values if debug mode is enabled
Namespace types: Debugger
Parameters:
this (Debugger)
s (string): Title of the log message
arg1 (string)
arg2 (string)
arg3 (string)
arg4 (string)
arg5 (string)
method logIf(this, expr, s, arg1, arg2, arg3, arg4, arg5)
Same behavior as debug() except will only log if the passed expression is true
Namespace types: Debugger
Parameters:
this (Debugger)
expr (bool): Boolean expression to determine if debug logs should be logged
s (string): Title of the log message
arg1 (string)
arg2 (string)
arg3 (string)
arg4 (string)
arg5 (string)
style_getLineStyleFromType(opt)
Returns the corresponding line style constant for the given LineStyleType
Parameters:
opt (series LineStyleType): The selected line style type
Returns: The Pine Script line style constant
style_getTextSizeFromType(opt)
Returns the corresponding text size constant for the given TextSizeType
Parameters:
opt (series TextSizeType): The selected text size type
Returns: The Pine Script text size constant
style_getTextHAlignFromType(t)
Returns the corresponding horizontal text align constant for the given HAlignType
Parameters:
t (series HAlignType): The selected text align type
Returns: The Pine Script text align constant
style_getTextVAlignFromType(t)
Returns the corresponding vertical text align constant for the given VAlignType
Parameters:
t (series VAlignType): The selected text align type
Returns: The Pine Script text align constant
format_sentimentType(sentiment, pd)
Used to produce a string with the sentiment and PD array type (e.g., "+FVG")
Parameters:
sentiment (series SentimentType): The sentiment value (e.g., SentimentType.BULLISH)
pd (series PDArrayType): The price data array (e.g., PDArrayType.FVG)
Returns: A formatted string with the sentiment and PD array (e.g., "+FVG")
format_timeToString(timestamp)
Formats a UNIX timestamp into a date and time string based on predefined formats
Parameters:
timestamp (int): The UNIX timestamp to format
Returns: A formatted string as "MM-dd (E) - HH:mm"
method init(this)
Initializes the session and validates the configuration. This MUST be called immediately after creating a new instance.
Namespace types: Session
Parameters:
this (Session): The Session object reference
Returns: The Session object (chainable) or throws a runtime error if invalid
method isActive(this, _time)
Determines if the session is active based on the current bar time
Namespace types: Session
Parameters:
this (Session): The Session object reference
_time (int)
Returns: `true` if the session is currently active; `false` otherwise
method draw(this)
Draws the line and optional label
Namespace types: LineLabel
Parameters:
this (LineLabel): The LineLabel object reference
Returns: The LineLabel object (chainable)
method extend(this, x)
Extends the line and label right to the specified bar index
Namespace types: LineLabel
Parameters:
this (LineLabel): The LineLabel object reference
x (int): The bar index to extend to
Returns: The LineLabel object (chainable)
method destroy(this)
Removes the line and label from the chart
Namespace types: LineLabel
Parameters:
this (LineLabel): The LineLabel object reference
isFVG(includeVI, barIdx)
Checks if the previous bars form a Fair Value Gap (FVG)
Parameters:
includeVI (bool): If true, includes Volume Imbalance in the FVG calculation
barIdx (int): The index of the bar to check from (default is 0 for the current bar)
Returns: A Gap object if a FVG is detected; otherwise, `na`
isVolumeImbalance(barIdx)
Checks if the previous bars form a Volume Imbalance (VI)
Parameters:
barIdx (int): The index of the bar to check from (default is 0 for the current bar)
Returns: A Gap object if a VI is detected; otherwise, `na`
isLiquidityVoid(barIdx)
Checks if the previous bars form a Liquidity Void (LV)
Parameters:
barIdx (int): The index of the bar to check from (default is 0 for the current bar)
Returns: A Gap object if an LV is detected; otherwise, `na`
isSwingPoint(barIdx)
Checks if the previous bars form a swing point
Parameters:
barIdx (int): The index of the bar to check from (default is 0 for the current bar)
Returns: A SwingPoint object if a swing point is detected; otherwise, `na`
Debugger
A debug logging utility with group support
Fields:
enabled (series bool)
_debugGroupStack (array<string>)
Session
Defines a trading session with a name and time range. When creating a new instance of this type, you MUST call init() immediately.
Fields:
name (series string): A display-friendly name (e.g., "NY AM")
session (series string): A string defining the session time range (e.g., "1300-1400")
enabled (series bool): Optional flag for custom logic; defaults to false
start (series int): UNIX time representing the session start (set via isActive())
end (series int): UNIX time representing the session end (set via isActive())
_t (series int)
_start_HH (series float)
_start_mm (series float)
_end_HH (series float)
_end_mm (series float)
Gap
Represents a price inefficiency (gap) with details on sentiment and price levels
Fields:
type (series SentimentType): The sentiment of the gap (e.g., SentimentType.BULLISH)
name (series string): A display-friendly name (e.g., "+FVG")
startTime (series int): UNIX time value for the gap's start
endTime (series int): UNIX time value for the gap's end
startIndex (series int): Bar index where the gap starts
endIndex (series int): Bar index where the gap ends
gapLow (series float): The lowest price level of the gap
gapHigh (series float): The highest price level of the gap
ce (series float): The consequent encroachment level of the gap
SwingPoint
Represents a swing point with details on type and price level
Fields:
type (series SwingPointType): The type of swing point (e.g., SwingPointType.HIGH)
time (series int): UNIX time value for the swing point
barIdx (series int): Bar index where the swing point occurs
price (series float): The price level of the swing point which is either the high or low of the middle bar
LineLabel
Combines a line and box type to produce a line with a label that is properly aligned
Fields:
x (series int): The X-axis starting point as a bar index
y (series float): The Y-axis starting point as the price level
color (series color): Both the line and text color
width (series int): Thickness of the line
label (series string): Text to display
showLabel (series bool): Boolean to conditionally show/hide the label (default is false)
lineStyle (series LineStyleType): The style of the line
textSize (series TextSizeType)
_b (series box)
_l (series line)
Sürüm Notları
v2Added:
parseSessionString(session)
Parses a session string (e.g., "1300-1400") to start/end hour and minute numbers
Parameters:
session (string): The session string (e.g., "1300-1400")
Returns: A tuple `[start_HH, start_mm, end_HH, end_mm]` of float values
Pine kitaplığı
Gerçek TradingView ruhuyla, yazar bu Pine kodunu açık kaynaklı bir kütüphane olarak yayınladı, böylece topluluğumuzdaki diğer Pine programcıları onu yeniden kullanabilir. Yazara saygı! Bu kütüphaneyi özel olarak veya diğer açık kaynaklı yayınlarda kullanabilirsiniz, ancak bu kodun bir yayında yeniden kullanımı Site Kuralları tarafından yönetilmektedir.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.
Pine kitaplığı
Gerçek TradingView ruhuyla, yazar bu Pine kodunu açık kaynaklı bir kütüphane olarak yayınladı, böylece topluluğumuzdaki diğer Pine programcıları onu yeniden kullanabilir. Yazara saygı! Bu kütüphaneyi özel olarak veya diğer açık kaynaklı yayınlarda kullanabilirsiniz, ancak bu kodun bir yayında yeniden kullanımı Site Kuralları tarafından yönetilmektedir.
Feragatname
Bilgiler ve yayınlar, TradingView tarafından sağlanan veya onaylanan finansal, yatırım, işlem veya diğer türden tavsiye veya tavsiyeler anlamına gelmez ve teşkil etmez. Kullanım Şartları'nda daha fazlasını okuyun.