Indicadores e estratégias
MusaCandlePatternsLibrary "MusaCandlePatterns"
Patterns is a Japanese candlestick pattern recognition Library for developers. Functions here within detect viable setups in a variety of popular patterns. Please note some patterns are without filters such as comparisons to average candle sizing, or trend detection to allow the author more freedom.
doji(dojiSize, dojiWickSize)
Detects "Doji" candle patterns
Parameters:
dojiSize (float) : (float) The relationship of body to candle size (ie. body is 5% of total candle size). Default is 5.0 (5%)
dojiWickSize (float) : (float) Maximum wick size comparative to the opposite wick. (eg. 2 = bottom wick must be less than or equal to 2x the top wick). Default is 2
Returns: (series bool) True when pattern detected
dLab(showLabel, labelColor, textColor)
Produces "Doji" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
bullEngulf(maxRejectWick, mustEngulfWick)
Detects "Bullish Engulfing" candle patterns
Parameters:
maxRejectWick (float) : (float) Maximum rejection wick size.
The maximum wick size as a percentge of body size allowable for a top wick on the resolution candle of the pattern. 0.0 disables the filter.
eg. 50 allows a top wick half the size of the body. Default is 0% (Disables wick detection).
mustEngulfWick (bool) : (bool) input to only detect setups that close above the high prior effectively engulfing the candle in its entirety. Default is false
Returns: (series bool) True when pattern detected
bewLab(showLabel, labelColor, textColor)
Produces "Bullish Engulfing" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
bearEngulf(maxRejectWick, mustEngulfWick)
Detects "Bearish Engulfing" candle patterns
Parameters:
maxRejectWick (float) : (float) Maximum rejection wick size.
The maximum wick size as a percentge of body size allowable for a bottom wick on the resolution candle of the pattern. 0.0 disables the filter.
eg. 50 allows a botom wick half the size of the body. Default is 0% (Disables wick detection).
mustEngulfWick (bool) : (bool) Input to only detect setups that close below the low prior effectively engulfing the candle in its entirety. Default is false
Returns: (series bool) True when pattern detected
bebLab(showLabel, labelColor, textColor)
Produces "Bearish Engulfing" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
hammer(ratio, shadowPercent)
Detects "Hammer" candle patterns
Parameters:
ratio (float) : (float) The relationship of body to candle size (ie. body is 33% of total candle size). Default is 33%.
shadowPercent (float) : (float) The maximum allowable top wick size as a percentage of body size. Default is 5%.
Returns: (series bool) True when pattern detected
hLab(showLabel, labelColor, textColor)
Produces "Hammer" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
star(ratio, shadowPercent)
Detects "Star" candle patterns
Parameters:
ratio (float) : (float) The relationship of body to candle size (ie. body is 33% of total candle size). Default is 33%.
shadowPercent (float) : (float) The maximum allowable bottom wick size as a percentage of body size. Default is 5%.
Returns: (series bool) True when pattern detected
ssLab(showLabel, labelColor, textColor)
Produces "Star" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
dragonflyDoji()
Detects "Dragonfly Doji" candle patterns
Returns: (series bool) True when pattern detected
ddLab(showLabel, labelColor, textColor)
Produces "Dragonfly Doji" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color)
Returns: (label) A label visible at the chart level intended for the title pattern
gravestoneDoji()
Detects "Gravestone Doji" candle patterns
Returns: (series bool) True when pattern detected
gdLab(showLabel, labelColor, textColor)
Produces "Gravestone Doji" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
tweezerBottom(closeUpperHalf)
Detects "Tweezer Bottom" candle patterns
Parameters:
closeUpperHalf (bool) : (bool) input to only detect setups that close above the mid-point of the candle prior increasing its bullish tendancy. Default is false
Returns: (series bool) True when pattern detected
tbLab(showLabel, labelColor, textColor)
Produces "Tweezer Bottom" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
tweezerTop(closeLowerHalf)
Detects "TweezerTop" candle patterns
Parameters:
closeLowerHalf (bool) : (bool) input to only detect setups that close below the mid-point of the candle prior increasing its bearish tendancy. Default is false
Returns: (series bool) True when pattern detected
ttLab(showLabel, labelColor, textColor)
Produces "TweezerTop" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
spinningTopBull(wickSize)
Detects "Bullish Spinning Top" candle patterns
Parameters:
wickSize (float) : (float) input to adjust detection of the size of the top wick/ bottom wick as a percent of total candle size. Default is 34%, which ensures the wicks are both larger than the body.
Returns: (series bool) True when pattern detected
stwLab(showLabel, labelColor, textColor)
Produces "Bullish Spinning Top" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
spinningTopBear(wickSize)
Detects "Bearish Spinning Top" candle patterns
Parameters:
wickSize (float) : (float) input to adjust detection of the size of the top wick/ bottom wick as a percent of total candle size. Default is 34%, which ensures the wicks are both larger than the body.
Returns: (series bool) True when pattern detected
stbLab(showLabel, labelColor, textColor)
Produces "Bearish Spinning Top" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
spinningTop(wickSize)
Detects "Spinning Top" candle patterns
Parameters:
wickSize (float) : (float) input to adjust detection of the size of the top wick/ bottom wick as a percent of total candle size. Default is 34%, which ensures the wicks are both larger than the body.
Returns: (series bool) True when pattern detected
stLab(showLabel, labelColor, textColor)
Produces "Spinning Top" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
morningStar()
Detects "Bullish Morning Star" candle patterns
Returns: (series bool) True when pattern detected
msLab(showLabel, labelColor, textColor)
Produces "Bullish Morning Star" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
eveningStar()
Detects "Bearish Evening Star" candle patterns
Returns: (series bool) True when pattern detected
esLab(showLabel, labelColor, textColor)
Produces "Bearish Evening Star" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
haramiBull()
Detects "Bullish Harami" candle patterns
Returns: (series bool) True when pattern detected
hwLab(showLabel, labelColor, textColor)
Produces "Bullish Harami" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
haramiBear()
Detects "Bearish Harami" candle patterns
Returns: (series bool) True when pattern detected
hbLab(showLabel, labelColor, textColor)
Produces "Bearish Harami" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
haramiBullCross()
Detects "Bullish Harami Cross" candle patterns
Returns: (series bool) True when pattern detected
hcwLab(showLabel, labelColor, textColor)
Produces "Bullish Harami Cross" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
haramiBearCross()
Detects "Bearish Harami Cross" candle patterns
Returns: (series bool) True when pattern detected
hcbLab(showLabel, labelColor, textColor)
Produces "Bearish Harami Cross" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color)
Returns: (label) A label visible at the chart level intended for the title pattern
marubullzu()
Detects "Bullish Marubozu" candle patterns
Returns: (series bool) True when pattern detected
mwLab(showLabel, labelColor, textColor)
Produces "Bullish Marubozu" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
marubearzu()
Detects "Bearish Marubozu" candle patterns
Returns: (series bool) True when pattern detected
mbLab(showLabel, labelColor, textColor)
Produces "Bearish Marubozu" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
abandonedBull()
Detects "Bullish Abandoned Baby" candle patterns
Returns: (series bool) True when pattern detected
abwLab(showLabel, labelColor, textColor)
Produces "Bullish Abandoned Baby" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
abandonedBear()
Detects "Bearish Abandoned Baby" candle patterns
Returns: (series bool) True when pattern detected
abbLab(showLabel, labelColor, textColor)
Produces "Bearish Abandoned Baby" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
piercing()
Detects "Piercing" candle patterns
Returns: (series bool) True when pattern detected
pLab(showLabel, labelColor, textColor)
Produces "Piercing" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
darkCloudCover()
Detects "Dark Cloud Cover" candle patterns
Returns: (series bool) True when pattern detected
dccLab(showLabel, labelColor, textColor)
Produces "Dark Cloud Cover" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
tasukiBull()
Detects "Upside Tasuki Gap" candle patterns
Returns: (series bool) True when pattern detected
utgLab(showLabel, labelColor, textColor)
Produces "Upside Tasuki Gap" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
tasukiBear()
Detects "Downside Tasuki Gap" candle patterns
Returns: (series bool) True when pattern detected
dtgLab(showLabel, labelColor, textColor)
Produces "Downside Tasuki Gap" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
risingThree()
Detects "Rising Three Methods" candle patterns
Returns: (series bool) True when pattern detected
rtmLab(showLabel, labelColor, textColor)
Produces "Rising Three Methods" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
fallingThree()
Detects "Falling Three Methods" candle patterns
Returns: (series bool) True when pattern detected
ftmLab(showLabel, labelColor, textColor)
Produces "Falling Three Methods" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
risingWindow()
Detects "Rising Window" candle patterns
Returns: (series bool) True when pattern detected
rwLab(showLabel, labelColor, textColor)
Produces "Rising Window" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
fallingWindow()
Detects "Falling Window" candle patterns
Returns: (series bool) True when pattern detected
fwLab(showLabel, labelColor, textColor)
Produces "Falling Window" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
kickingBull()
Detects "Bullish Kicking" candle patterns
Returns: (series bool) True when pattern detected
kwLab(showLabel, labelColor, textColor)
Produces "Bullish Kicking" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
kickingBear()
Detects "Bearish Kicking" candle patterns
Returns: (series bool) True when pattern detected
kbLab(showLabel, labelColor, textColor)
Produces "Bearish Kicking" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
lls(ratio)
Detects "Long Lower Shadow" candle patterns
Parameters:
ratio (float) : (float) A relationship of the lower wick to the overall candle size expressed as a percent. Default is 75%
Returns: (series bool) True when pattern detected
llsLab(showLabel, labelColor, textColor)
Produces "Long Lower Shadow" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
lus(ratio)
Detects "Long Upper Shadow" candle patterns
Parameters:
ratio (float) : (float) A relationship of the upper wick to the overall candle size expressed as a percent. Default is 75%
Returns: (series bool) True when pattern detected
lusLab(showLabel, labelColor, textColor)
Produces "Long Upper Shadow" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
bullNeck()
Detects "Bullish On Neck" candle patterns
Returns: (series bool) True when pattern detected
nwLab(showLabel, labelColor, textColor)
Produces "Bullish On Neck" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
bearNeck()
Detects "Bearish On Neck" candle patterns
Returns: (series bool) True when pattern detected
nbLab(showLabel, labelColor, textColor)
Produces "Bearish On Neck" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
soldiers(wickSize)
Detects "Three White Soldiers" candle patterns
Parameters:
wickSize (float) : (float) Maximum allowable top wick size throughout pattern expressed as a percent of total candle height. Default is 5%
Returns: (series bool) True when pattern detected
wsLab(showLabel, labelColor, textColor)
Produces "Three White Soldiers" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
crows(wickSize)
Detects "Three Black Crows" candle patterns
Parameters:
wickSize (float) : (float) Maximum allowable bottom wick size throughout pattern expressed as a percent of total candle height. Default is 5%
Returns: (series bool) True when pattern detected
bcLab(showLabel, labelColor, textColor)
Produces "Three Black Crows" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
triStarBull()
Detects "Bullish Tri-Star" candle patterns
Returns: (series bool) True when pattern detected
tswLab(showLabel, labelColor, textColor)
Produces "Bullish Tri-Star" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
triStarBear()
Detects "Bearish Tri-Star" candle patterns
Returns: (series bool) True when pattern detected
tsbLab(showLabel, labelColor, textColor)
Produces "Bearish Tri-Star" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
insideBar()
Detects "Inside Bar" candle patterns
Returns: (series bool) True when pattern detected
insLab(showLabel, labelColor, textColor)
Produces "Inside Bar" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
doubleInside()
Detects "Double Inside Bar" candle patterns
Returns: (series bool) True when pattern detected
dinLab(showLabel, labelColor, textColor)
Produces "Double Inside Bar" identifier label
Parameters:
showLabel (bool) : (series bool) Shows label when input is true. Default is false
labelColor (color) : (series color) Color of the label border and arrow
textColor (color) : (series color) Text color
Returns: (label) A label visible at the chart level intended for the title pattern
wrap(cond, barsBack, borderColor, bgColor)
Produces a box wrapping the highs and lows over the look back.
Parameters:
cond (bool) : (series bool) Condition under which to draw the box.
barsBack (int) : (series int) the number of bars back to begin drawing the box.
borderColor (color) : (series color) Color of the four borders. Optional. The default is `color.gray` with a 45% transparency.
bgColor (color)
Returns: (box) A box whom's top and bottom are above and below the highest and lowest points over the lookback
topWick()
Returns the top wick size of the current candle
Returns: (series float) A value equivelent to the distance from the top of the candle body to its high
bottomWick()
Returns the bottom wick size of the current candle
Returns: (series float) A value equivelent to the distance from the bottom of the candle body to its low
body()
Returns the body size of the current candle
Returns: (series float) A value equivelent to the distance between the top and the bottom of the candle body
highestBody()
Returns the highest body of the current candle
Returns: (series float) A value equivelent to the highest body, whether it is the open or the close
lowestBody()
Returns the lowest body of the current candle
Returns: (series float) A value equivelent to the highest body, whether it is the open or the close
barRange()
Returns the height of the current candle
Returns: (series float) A value equivelent to the distance between the high and the low of the candle
bodyPct()
Returns the body size as a percent
Returns: (series float) A value equivelent to the percentage of body size to the overall candle size
midBody()
Returns the price of the mid-point of the candle body
Returns: (series float) A value equivelent to the center point of the distance bewteen the body low and the body high
bodyupGap()
Returns true if there is a gap up between the real body of the current candle in relation to the candle prior
Returns: (series bool) True if there is a gap up and no overlap in the real bodies of the current candle and the preceding candle
bodydwnGap()
Returns true if there is a gap down between the real body of the current candle in relation to the candle prior
Returns: (series bool) True if there is a gap down and no overlap in the real bodies of the current candle and the preceding candle
gapUp()
Returns true if there is a gap down between the real body of the current candle in relation to the candle prior
Returns: (series bool) True if there is a gap down and no overlap in the real bodies of the current candle and the preceding candle
gapDwn()
Returns true if there is a gap down between the real body of the current candle in relation to the candle prior
Returns: (series bool) True if there is a gap down and no overlap in the real bodies of the current candle and the preceding candle
dojiBody()
Returns true if the candle body is a doji
Returns: (series bool) True if the candle body is a doji. Defined by a body that is 5% of total candle size
ColorGradientLibrary "ColorGradient"
Library for creating color gradients and palettes with hex colors
hexToColor(hexStr)
hexToColor
Parameters:
hexStr (string) : Hex color string (e.g., "#FF0000" or "FF0000")
Returns: color value
gradientStep(color1, color2, steps, step)
gradientStep
Parameters:
color1 (string) : Starting color (hex string)
color2 (string) : Ending color (hex string)
steps (int) : Number of steps including start and end
step (int) : Current step (0 to steps-1)
Returns: Interpolated color
multiGradientStep(colors, totalSteps, step)
multiGradientStep
Parameters:
colors (array) : Array of hex color strings
totalSteps (int) : Total number of steps across all colors
step (int) : Current step (0 to totalSteps-1)
Returns: Interpolated color
applyPaletteStyle(hexStr, style)
applyPaletteStyle
Parameters:
hexStr (string) : Hex color string
style (string) : "normal", "pale", "pastel", "bright", "matte"
Returns: Adjusted color
getStyledGradient(colors, totalSteps, step, style)
getStyledGradient
Parameters:
colors (array) : Array of hex color strings
totalSteps (int) : Total number of steps
step (int) : Current step
style (string) : Palette style ("normal", "pale", "pastel", "bright", "matte")
Returns: Styled color
ma_PLibrary "ma_P"
This library is made to expand traders moving average arsenal.
sma(src, length)
Parameters:
src (float)
length (simple int)
sma(src, length)
Parameters:
src (float)
length (int)
eit(src)
Parameters:
src (float)
ema(src, length)
Parameters:
src (float)
length (simple int)
ema(src, length)
Parameters:
src (float)
length (int)
ahma(src, length)
Parameters:
src (float)
length (simple int)
ahma(src, length)
Parameters:
src (float)
length (int)
bmf(src, length)
Parameters:
src (float)
length (simple int)
bmf(src, length)
Parameters:
src (float)
length (int)
cma(src, length)
Parameters:
src (float)
length (simple int)
cma(src, length)
Parameters:
src (float)
length (int)
dema(src, length)
Parameters:
src (float)
length (simple int)
dema(src, length)
Parameters:
src (float)
length (int)
dswf(src, length)
Parameters:
src (float)
length (simple int)
dswf(src, length)
Parameters:
src (float)
length (int)
evwma(src, length, volume)
Parameters:
src (float)
length (simple int)
volume (float)
evwma(src, length, volume)
Parameters:
src (float)
length (int)
volume (float)
esd(src, length)
Parameters:
src (float)
length (simple int)
esd(src, length)
Parameters:
src (float)
length (int)
frama(src, length)
Parameters:
src (float)
length (simple int)
frama(src, length)
Parameters:
src (float)
length (int)
flsma(src, len)
Parameters:
src (float)
len (simple int)
flsma(src, len)
Parameters:
src (float)
len (int)
gmma(src, length)
Parameters:
src (float)
length (simple int)
gmma(src, length)
Parameters:
src (float)
length (int)
hcf(src, length)
Parameters:
src (float)
length (simple int)
hcf(src, length)
Parameters:
src (float)
length (int)
hma(src, length)
Parameters:
src (float)
length (simple int)
hma(src, length)
Parameters:
src (float)
length (int)
jma(src, length)
Parameters:
src (float)
length (simple int)
jma(src, length)
Parameters:
src (float)
length (int)
kama(source, length, min_length, max_length)
Parameters:
source (float)
length (int)
min_length (int)
max_length (int)
kijun(src, length)
Parameters:
src (float)
length (simple int)
kijun(src, length)
Parameters:
src (float)
length (int)
lsma(src, length)
Parameters:
src (float)
length (simple int)
lsma(src, length)
Parameters:
src (float)
length (int)
lma(src, length)
Parameters:
src (float)
length (simple int)
lma(src, length)
Parameters:
src (float)
length (int)
mf(src, length)
Parameters:
src (float)
length (simple int)
mf(src, length)
Parameters:
src (float)
length (int)
mm(src, length)
Parameters:
src (float)
length (simple int)
mm(src, length)
Parameters:
src (float)
length (int)
smma(src, length)
Parameters:
src (float)
length (simple int)
smma(src, length)
Parameters:
src (float)
length (int)
ssma(src, length)
Parameters:
src (float)
length (simple int)
ssma(src, length)
Parameters:
src (float)
length (int)
swma(src, length)
Parameters:
src (float)
length (simple int)
swma(src, length)
Parameters:
src (float)
length (int)
tma(src, length)
Parameters:
src (float)
length (simple int)
tma(src, length)
Parameters:
src (float)
length (int)
tema(src, length)
Parameters:
src (float)
length (simple int)
tema(src, length)
Parameters:
src (float)
length (int)
tsf(src, length)
Parameters:
src (float)
length (simple int)
tsf(src, length)
Parameters:
src (float)
length (int)
varma(src, length)
Parameters:
src (float)
length (simple int)
varma(src, length)
Parameters:
src (float)
length (int)
vama(src, length)
Parameters:
src (float)
length (simple int)
vama(src, length)
Parameters:
src (float)
length (int)
vma(src, length)
Parameters:
src (float)
length (simple int)
vma(src, length)
Parameters:
src (float)
length (int)
vbma(src, length)
Parameters:
src (float)
length (simple int)
vbma(src, length)
Parameters:
src (float)
length (int)
vida(src, length)
Parameters:
src (float)
length (simple int)
vida(src, length)
Parameters:
src (float)
length (int)
qma(src, length)
Parameters:
src (float)
length (simple int)
qma(src, length)
Parameters:
src (float)
length (int)
rpma(src, len)
Parameters:
src (float)
len (simple int)
rpma(src, len)
Parameters:
src (float)
len (int)
rma(src, length)
Parameters:
src (float)
length (simple int)
rma(src, length)
Parameters:
src (float)
length (int)
rsrma(src, length)
Parameters:
src (float)
length (simple int)
rsrma(src, length)
Parameters:
src (float)
length (int)
zlema(src, length)
Parameters:
src (float)
length (simple int)
zlema(src, length)
Parameters:
src (float)
length (int)
selector(src, length, selectMA, min_length, max_length)
This function gives trader an instrument to test different kinds of moving averages on their strategy.
Parameters:
src (float)
length (simple int)
selectMA (string)
min_length (int)
max_length (int)
Returns: user selected moving average
selector(src, length, selectMA, min_length, max_length)
Parameters:
src (float)
length (int)
selectMA (string)
min_length (int)
max_length (int)
iQFFTLibrary "iQFFT"
TODO: add library description here
fft(x, y, dir)
Parameters:
x (array)
y (array)
dir (string)
fftPower(x, y)
Parameters:
x (array)
y (array)
fftFreq(N)
Parameters:
N (int)
CoreMACDHTF [CHE]Library "CoreMACDHTF"
calc_macd_htf(src, preset_str, smooth_len)
Parameters:
src (float)
preset_str (simple string)
smooth_len (int)
is_hist_rising(src, preset_str, smooth_len)
Parameters:
src (float)
preset_str (simple string)
smooth_len (int)
hist_rising_01(src, preset_str, smooth_len)
Parameters:
src (float)
preset_str (simple string)
smooth_len (int)
CoreMACDHTF — Hardcoded HTF MACD Presets with Smoothed Histogram Regime Flags
Summary
CoreMACDHTF provides a reusable MACD engine that approximates higher-timeframe behavior by selecting hardcoded EMA lengths based on the current chart timeframe, then optionally smoothing the resulting histogram with a stateful filter. It is published as a Pine v6 library but intentionally includes a minimal demo plot so you can validate behavior directly on a chart. The primary exported outputs are MACD, signal, a smoothed histogram, and the resolved lengths plus a timeframe tag. In addition, it exposes a histogram rising condition so importing scripts can reuse the same regime logic instead of re-implementing it.
Motivation: Why this design?
Classic MACD settings are often tuned to one timeframe. When you apply the same parameters to very different chart intervals, the histogram can become either too noisy or too sluggish. This script addresses that by using a fixed mapping from the chart timeframe into a precomputed set of EMA lengths, aiming for more consistent “tempo” across intervals. A second problem is histogram micro-chop around turning points; the included smoother reduces short-run flips so regime-style conditions can be more stable for alerts and filters.
What’s different vs. standard approaches?
Reference baseline: a standard MACD using fixed fast, slow, and signal lengths on the current chart timeframe.
Architecture differences:
Automatic timeframe bucketing that selects a hardcoded length set for the chosen preset.
Two preset families: one labeled A with lengths three, ten, sixteen; one labeled B with lengths twelve, twenty-six, nine.
A custom, stateful histogram smoother intended to damp noisy transitions.
Library exports that return both signals and metadata, plus a dedicated “histogram rising” boolean.
Practical effect:
The MACD lengths change when the chart timeframe changes, so the oscillator’s responsiveness is not constant across intervals by design.
The rising-flag logic is based on the smoothed histogram, which typically reduces single-bar flip noise compared to using the raw histogram directly.
How it works (technical)
1. The script reads the chart timeframe and converts it into milliseconds using built-in timeframe helpers.
2. It assigns the timeframe into a bucket label, such as an intraday bucket or a daily-and-above bucket, using fixed thresholds.
3. It resolves a hardcoded fast, slow, and signal length triplet based on:
The selected preset family.
The bucket label.
In some cases, the current minute multiplier for finer mapping.
4. It computes fast and slow EMAs on the selected source and subtracts them to obtain MACD, then computes an EMA of MACD for the signal line.
5. The histogram is derived from the difference between MACD and signal, then passed through a custom smoother.
6. The smoother uses persistent internal state to carry forward its intermediate values from bar to bar. This is intentional and means the smoothing output depends on contiguous bar history.
7. The histogram rising flag compares the current smoothed histogram to its prior value. On the first comparable bar it defaults to “rising” to avoid a missing prior reference.
8. Exports:
A function that returns MACD, signal, smoothed histogram, the resolved lengths, and a text tag.
A function that returns the boolean rising state.
A function that returns a numeric one-or-zero series for direct plotting or downstream numeric logic.
HTF note: this is not a true higher-timeframe request. It does not fetch higher-timeframe candles. It approximates HTF feel by selecting different lengths on the current timeframe.
Parameter Guide
Source — Input price series used for EMA calculations — Default close — Trade-offs/Tips
Preset — Selects the hardcoded mapping family — Default preset A — Preset A is more reactive than preset B in typical use
Table Position — Anchor for an information table — Default top right — Present but not wired in the provided code (Unknown/Optional)
Table Size — Text size for the information table — Default normal — Present but not wired in the provided code (Unknown/Optional)
Dark Mode — Theme toggle for the table — Default enabled — Present but not wired in the provided code (Unknown/Optional)
Show Table — Visibility toggle for the table — Default enabled — Present but not wired in the provided code (Unknown/Optional)
Zero dead-band (epsilon) — Intended neutral band around zero for regime classification — Default zero — Present but not used in the provided code (Unknown/Optional)
Acceptance bars (n) — Intended debounce count for regime confirmation — Default three — Present but not used in the provided code (Unknown/Optional)
Smoothing length — Length controlling the histogram smoother’s responsiveness — Default nine — Smaller values react faster but can reintroduce flip noise
Reading & Interpretation
Smoothed histogram: use it as the momentum core. A positive value implies MACD is above signal, a negative value implies the opposite.
Histogram rising flag:
True means the smoothed histogram increased compared to the prior bar.
False means it did not increase compared to the prior bar.
Demo plot:
The included plot outputs one when rising is true and zero otherwise. It is a diagnostic-style signal line, not a scaled oscillator display.
Practical Workflows & Combinations
Trend following:
Use rising as a momentum confirmation filter after structural direction is established by higher highs and higher lows, or lower highs and lower lows.
Combine with a simple trend filter such as a higher-timeframe moving average from your main script (Unknown/Optional).
Exits and risk management:
If you use rising to stay in trends, consider exiting or reducing exposure when rising turns false for multiple consecutive bars rather than reacting to a single flip.
If you build alerts, evaluate on closed bars to avoid intra-bar flicker in live candles.
Multi-asset and multi-timeframe:
Because the mapping is hardcoded, validate on each asset class you trade. Volatility regimes differ and the perceived “equivalence” across timeframes is not guaranteed.
For consistent behavior, keep the smoothing length aligned across assets and adjust only when flip frequency becomes problematic.
Behavior, Constraints & Performance
Repaint and confirmation:
There is no forward-looking indexing. The logic uses current and prior values only.
Live-bar values can change until the bar closes, so rising can flicker intra-bar if you evaluate it in real time.
security and HTF:
No higher-timeframe candle requests are used. Length mapping is internal and deterministic per chart timeframe.
Resources:
No loops and no arrays in the core calculation path.
The smoother maintains persistent state, which is lightweight but means results depend on uninterrupted history.
Known limits:
Length mappings are fixed. If your chart timeframe is unusual, the bucket choice may not represent what you expect.
Several table and regime-related inputs are declared but not used in the provided code (Unknown/Optional).
The smoother is stateful; resetting chart history or changing symbol can alter early bars until state settles.
Sensible Defaults & Quick Tuning
S tarting point:
Preset A
Smoothing length nine
Source close
Tuning recipes:
Too many flips: increase smoothing length and evaluate rising only on closed bars.
Too sluggish: reduce smoothing length, but expect more short-run reversals.
Different timeframe feel after switching intervals: keep preset fixed and adjust smoothing length first before changing preset.
Want a clean plot signal: use the exported numeric rising series and apply your own display rules in the importing script.
What this indicator is—and isn’t
This is a momentum and regime utility layer built around a MACD-style backbone with hardcoded timeframe-dependent parameters and an optional smoother. It is not a complete trading system, not a risk model, and not predictive. Use it in context with market structure, execution rules, and risk controls.
Disclaimer
The content provided, including all code and materials, is strictly for educational and informational purposes only. It is not intended as, and should not be interpreted as, financial advice, a recommendation to buy or sell any financial instrument, or an offer of any financial product or service. All strategies, tools, and examples discussed are provided for illustrative purposes to demonstrate coding techniques and the functionality of Pine Script within a trading context.
Any results from strategies or tools provided are hypothetical, and past performance is not indicative of future results. Trading and investing involve high risk, including the potential loss of principal, and may not be suitable for all individuals. Before making any trading decisions, please consult with a qualified financial professional to understand the risks involved.
By using this script, you acknowledge and agree that any trading decisions are made solely at your discretion and risk.
Do not use this indicator on Heikin-Ashi, Renko, Kagi, Point-and-Figure, or Range charts, as these chart types can produce unrealistic results for signal markers and alerts.
Best regards and happy trading
Chervolino
CoreTFRSIMD CoreTFRSIMD library — Reusable TFRSI core for consistent momentum inputs across scripts
The library provides a reusable exported function such as calcTfrsi(src, len, signalLen) so you can compute TFRSI in your own indicators or strategies, e.g. tfrsi = CoreTFRSIMD.calcTfrsi(close, 6, 2)
Summary
CoreTFRSIMD is a Pine Script v6 library that implements a TFRSI-style oscillator core and exposes it as a reusable exported function. It is designed for authors who want the same TFRSI calculation across multiple indicators or strategies without duplicating logic. The library includes a simple demo plot and band styling so you can visually sanity-check the output. No higher-timeframe sampling is used, and there are no loops or arrays, so runtime cost is minimal for typical chart usage.
Motivation: Why this design?
When you reuse an oscillator across different tools, small implementation differences create inconsistent signals and hard-to-debug results. This library isolates the signal path into one exported function so that every dependent script consumes the exact same oscillator output. The design combines filtering, normalization, and a final smoothing pass to produce a stable, RSI-like readout intended for momentum and regime context.
What’s different vs. standard approaches?
Baseline: Traditional RSI computed directly from gains and losses with standard smoothing.
Architecture differences:
A high-pass stage to attenuate slower components before the main smoothing.
A multi-pole smoothing stage implemented with persistent state to reduce noise.
A running peak-tracker style normalization that adapts to changing signal amplitude.
A final signal smoothing layer using a simple moving average.
Practical effect:
The oscillator output tends to be less dominated by raw volatility spikes and more consistent across changing conditions.
The normalization step helps keep the output in an RSI-like reading space without relying on fixed scaling.
How it works (technical)
1. Input source: The exported function accepts a source series and two integer parameters controlling responsiveness and final smoothing.
2. High-pass stage: A recursive filter is applied to the source to emphasize shorter-term movement. This stage uses persistent storage so it can reference prior internal states across bars.
3. Smoothing stage: The filtered stream is passed through a SuperSmoother-like recursive smoother derived from the chosen length. This again uses persistent state and prior values for continuity.
4. Adaptive normalization: The absolute magnitude of the smoothed stream is compared to a slowly decaying reference level. If the current magnitude exceeds the reference, the reference is updated. This acts like a “peak hold with decay” so the oscillator scales relative to recent conditions.
5. Oscillator mapping: The normalized value is mapped into an RSI-like reading range.
6. Signal smoothing: A simple moving average is applied over the requested signal length to reduce bar-to-bar chatter.
7. Demo rendering: The library script plots the oscillator, draws horizontal guide levels, and applies background plus gradient fills for overbought and oversold regions.
Parameter Guide
Parameter — Effect — Default — Trade-offs/Tips
src — Input series used by the oscillator — close in demo — Use close for general momentum, or a derived series if you want to emphasize a specific behavior.
len — Controls the responsiveness of internal filtering and smoothing — six in demo — Smaller values react faster but can increase short-term noise; larger values smooth more but can lag turns.
signalLen — Controls the final smoothing of the mapped oscillator — two in demo — Smaller values preserve detail but can flicker; larger values reduce flicker but can delay transitions.
Reading & Interpretation
The plot is an oscillator intended to be read similarly to an RSI-style momentum gauge.
The demo includes three reference levels: upper at one hundred, mid at fifty, and lower at zero.
The fills visually emphasize zones above the midline and below the midline. Treat these as context, not as standalone entries.
If the oscillator appears unusually compressed or unusually jumpy, the normalization reference may be adapting to an abrupt change in amplitude. That is expected behavior for adaptive normalization.
Practical Workflows & Combinations
Trend following:
Use structure first, then confirm with oscillator behavior around the midline.
Prefer signals aligned with higher-high higher-low or lower-low lower-high context from price.
Exits/Stops:
Use oscillator loss of momentum as a caution flag rather than an automatic exit trigger.
In strong trends, consider keeping risk rules price-based and use the oscillator mainly to avoid adding into exhaustion.
Multi-asset/Multi-timeframe:
Start with the demo defaults when you want a responsive oscillator.
If an asset is noisier, increase the main length or the signal smoothing length to reduce false flips.
Behavior, Constraints & Performance
Repaint/confirmation: No higher-timeframe sampling is used. Output updates on the live bar like any normal series. There is no explicit closed-bar gating in the library.
security or HTF: Not used, so there is no HTF synchronization risk.
Resources: No loops, no arrays, no large history buffers. Persistent variables are used for filter state.
Known limits: Like any filtered oscillator, sharp gaps and extreme one-bar events can produce transient distortions. The adaptive normalization can also make early bars unstable until enough history has accumulated.
Sensible Defaults & Quick Tuning
Starting values: length six, signal smoothing two.
Too many flips: Increase signal smoothing length, or increase the main length.
Too sluggish: Reduce the main length, or reduce signal smoothing length.
Choppy around midline: Increase signal smoothing length slightly and rely more on price structure filters.
What this indicator is—and isn’t
This library is a reusable signal component and visualization aid. It is not a complete trading system, not predictive, and not a substitute for market structure, execution rules, and risk controls. Use it as a momentum and regime context layer, and validate behavior per asset and timeframe before relying on it.
Disclaimer
The content provided, including all code and materials, is strictly for educational and informational purposes only. It is not intended as, and should not be interpreted as, financial advice, a recommendation to buy or sell any financial instrument, or an offer of any financial product or service. All strategies, tools, and examples discussed are provided for illustrative purposes to demonstrate coding techniques and the functionality of Pine Script within a trading context.
Any results from strategies or tools provided are hypothetical, and past performance is not indicative of future results. Trading and investing involve high risk, including the potential loss of principal, and may not be suitable for all individuals. Before making any trading decisions, please consult with a qualified financial professional to understand the risks involved.
By using this script, you acknowledge and agree that any trading decisions are made solely at your discretion and risk.
Do not use this indicator on Heikin-Ashi, Renko, Kagi, Point-and-Figure, or Range charts, as these chart types can produce unrealistic results for signal markers and alerts.
Best regards and happy trading
Chervolino
BybitMinOrderSizeBybit Order Quantity Compliance Library
This library provides all utility functions required for TradingView strategies
that execute orders on Bybit via webhooks.
Problem:
Bybit enforces two strict rules on every order submitted:
Minimum Order Size – each symbol has its own minimum quantity.
Quantity Precision – each symbol requires rounding to the correct number of decimals.
TradingView does not expose this metadata, so strategies can easily submit
quantities that Bybit rejects as invalid.
Solution (This Library):
This library embeds full Bybit contract metadata, including:
A complete mapping of Bybit symbols → minimum order size
A complete mapping of Bybit symbols → allowed precision (decimal places)
A helper to normalize tickers (removing `.P` suffix for Bybit perpetuals)
It also exposes utility functions to automatically make your quantities valid:
`normalizeTicker()` — removes `.P` for consistent lookup
`getMinOrderSize()` — returns the correct minimum order size
`getPrecisionForTicker()` — returns required quantity precision
`floorQty()` — floors quantities to valid minimum increments
`roundQty()` — rounds quantities to valid decimal precision
Use Cases:
Ensuring webhook strategies never send too-small orders
Rounding limit/market orders correctly before execution
Making Pine strategies execution-accurate for Bybit
Avoiding "order rejected: qty too small / invalid precision" errors
This library is recommended for:
Live trading via TradingView → Bybit webhooks
Backtesting strategies that simulate real Bybit constraints
Source: www.bybit.com
Updated: 2025-11-25 — Bybit contract metadata
normalizeTicker(symbol)
Normalizes Bybit perpetual tickers by removing the ".P" suffix.
precisionFromMinOrder(minOrder)
Derives precision (decimal places) from minimum order size.
getMinOrderSize(symbol)
Retrieves the minimum order size for the current or given symbol.
getPrecisionForTicker(symbol)
Retrieves the required quantity precision (decimal places) for a given Bybit symbol.
floorQty(qty, symbol)
Rounds a quantity down to the nearest valid minimum order size for a given symbol.
roundQty(qty, symbol)
Rounds a quantity to the valid precision for the specified symbol.
Mirpapa_Lib_4waveLibrary "Mirpapa_Lib_4wave"
Library for MACD 4Wave Trading System - Type definitions and calculation functions
_macd_calc(_src, _fast, _slow, _signal)
Parameters:
_src (float)
_fast (simple int)
_slow (simple int)
_signal (simple int)
_normalize(_value, _current_max, _current_norm)
Parameters:
_value (float)
_current_max (float)
_current_norm (float)
calc_visual(_current, _prev_val, _color_up, _color_down, _transparency_up, _transparency_down)
Parameters:
_current (float)
_prev_val (float)
_color_up (color)
_color_down (color)
_transparency_up (int)
_transparency_down (int)
_detect_line_position(_line1, _line2)
Parameters:
_line1 (float)
_line2 (float)
_get_divergence_score(_div)
Parameters:
_div (_DivergenceCounter)
calculate_score_1_HighTrend(_htfHigh_macd_norm, _htfHigh_macd_norm_prev, _max_score)
Parameters:
_htfHigh_macd_norm (float)
_htfHigh_macd_norm_prev (float)
_max_score (int)
calculate_score_1_TRIX_Align(_trix_norm, _trix_norm_prev, _max_score)
Parameters:
_trix_norm (float)
_trix_norm_prev (float)
_max_score (int)
calculate_score_2_MidAlign(_htfMid_macd_norm, _htfMid_macd_norm_prev, _htfHigh_macd_norm, _htfHigh_macd_norm_prev, _max_score)
Parameters:
_htfMid_macd_norm (float)
_htfMid_macd_norm_prev (float)
_htfHigh_macd_norm (float)
_htfHigh_macd_norm_prev (float)
_max_score (int)
calculate_score_3_LowAlign(_htfLow_macd_norm, _htfLow_macd_norm_prev, _htfMid_macd_norm, _htfMid_macd_norm_prev, _htfHigh_macd_norm, _htfHigh_macd_norm_prev, _max_score)
Parameters:
_htfLow_macd_norm (float)
_htfLow_macd_norm_prev (float)
_htfMid_macd_norm (float)
_htfMid_macd_norm_prev (float)
_htfHigh_macd_norm (float)
_htfHigh_macd_norm_prev (float)
_max_score (int)
calculate_score_4_CurrentAlign(_current_macd_norm, _htfMid_macd_norm, _htfHigh_macd_norm, _max_score)
Parameters:
_current_macd_norm (float)
_htfMid_macd_norm (float)
_htfHigh_macd_norm (float)
_max_score (int)
calculate_score_4_CurrentHistogram(_hist, _hist_prev, _max_score)
Parameters:
_hist (float)
_hist_prev (float)
_max_score (int)
calculate_score_4_MACD_Cross(_current_norm, _htfLow_norm, _htfMid_norm, _htfHigh_norm, _max_score)
Parameters:
_current_norm (float)
_htfLow_norm (float)
_htfMid_norm (float)
_htfHigh_norm (float)
_max_score (int)
calculate_score_4_MACD_Extreme(_htfMid_norm, _htfMid_norm_prev, _htfLow_norm, _htfLow_norm_prev, _htfHigh_norm, _oversold_line, _overbought_line, _max_score)
Parameters:
_htfMid_norm (float)
_htfMid_norm_prev (float)
_htfLow_norm (float)
_htfLow_norm_prev (float)
_htfHigh_norm (float)
_oversold_line (float)
_overbought_line (float)
_max_score (int)
calculate_score_4_MACD_Convergence(_htfLow_norm, _htfMid_norm, _htfHigh_norm, _max_score)
Parameters:
_htfLow_norm (float)
_htfMid_norm (float)
_htfHigh_norm (float)
_max_score (int)
calculate_score_5_RSI_Divergence(_rsiDivBull, _rsiDivBear, _max_score)
Parameters:
_rsiDivBull (_DivergenceCounter)
_rsiDivBear (_DivergenceCounter)
_max_score (int)
calculate_score_5_MACD_Divergence(_macdDivBull, _macdDivBear, _max_score)
Parameters:
_macdDivBull (_DivergenceCounter)
_macdDivBear (_DivergenceCounter)
_max_score (int)
calculate_score_5_Bonus_Divergence(_rsiDivBull, _rsiDivBear, _macdDivBull, _macdDivBear, _trixDivBull, _trixDivBear, _max_score)
Parameters:
_rsiDivBull (_DivergenceCounter)
_rsiDivBear (_DivergenceCounter)
_macdDivBull (_DivergenceCounter)
_macdDivBear (_DivergenceCounter)
_trixDivBull (_DivergenceCounter)
_trixDivBear (_DivergenceCounter)
_max_score (int)
_calculate_total_score(_score_data)
Parameters:
_score_data (_Score)
_FilterSettings
Fields:
_need_macd (series bool)
_need_rsi (series bool)
_need_trix (series bool)
_show_indicator_visual (series bool)
_show_trade_visual (series bool)
_Macd
Fields:
_macd (series float)
_signal (series float)
_hist (series float)
_hist_prev (series float)
_max (series float)
_norm (series float)
_normPrev (series float)
_Rsi
Fields:
_value (series float)
_norm (series float)
_normPrev (series float)
_Trix
Fields:
_value (series float)
_max (series float)
_norm (series float)
_normPrev (series float)
_Divergence
Fields:
_bull (series bool)
_bear (series bool)
_DivergenceCounter
Fields:
_div1 (series int)
_div2 (series int)
_div3 (series int)
_Score
Fields:
_1_MACD_HighTrend (series float)
_1_TRIX_Align (series float)
_2_MACD_MidAlign (series float)
_3_MACD_LowAlign (series float)
_4_MACD_CurrentAlign (series float)
_4_MACD_CurrentHistogram (series float)
_4_MACD_Cross (series float)
_4_MACD_Extreme (series float)
_4_MACD_Convergence (series float)
_5_RSI_Divergence (series float)
_5_MACD_Divergence (series float)
_5_Bonus_Divergence (series float)
_total (series float)
_canContinue (series bool)
_directionAligned (series bool)
_IsNewBar
Fields:
_high (series bool)
_mid (series bool)
_low (series bool)
_Visual
Fields:
_prev (series float)
_increasing (series bool)
_color (series color)
_ScoreThresholds
Fields:
_1_MACD_HighTrend_MAX (series int)
_1_TRIX_Align_MAX (series int)
_2_MACD_MidAlign_MAX (series int)
_3_MACD_LowAlign_MAX (series int)
_4_MACD_CurrentAlign_MAX (series int)
_4_MACD_CurrentHistogram_MAX (series int)
_4_MACD_Cross_MAX (series int)
_4_MACD_Extreme_MAX (series int)
_4_MACD_Convergence_MAX (series int)
_5_RSI_Divergence_MAX (series int)
_5_MACD_Divergence_MAX (series int)
_5_Bonus_Divergence_MAX (series int)
_EntryThresholds
Fields:
_LONG (series int)
_SHORT (series int)
_StopLossThresholds
Fields:
_PCT (series float)
_SCORE_DROP (series int)
_MDDThresholds
Fields:
_DAILY_LIMIT (series float)
_PositionSizeMultipliers
Fields:
_SIZE_120_PLUS (series float)
_SIZE_100_119 (series float)
_SIZE_90_99 (series float)
_SIZE_75_89 (series float)
_SIZE_60_74 (series float)
_MDDMultipliers
Fields:
_MULT_0_1 (series float)
_MULT_1_2 (series float)
_MULT_2_25 (series float)
_MULT_25_3 (series float)
_MULT_3_PLUS (series float)
_TrixThresholds
Fields:
_STRONG_BULL (series float)
_WEAK_BULL (series float)
_STRONG_BEAR (series float)
_WEAK_BEAR (series float)
_RsiThresholds
Fields:
_OVERSOLD_STRONG (series int)
_OVERSOLD_WEAK (series int)
_OVERBOUGHT_WEAK (series int)
_OVERBOUGHT_STRONG (series int)
_MacdThresholds
Fields:
_OVERSOLD_STRONG (series int)
_OVERSOLD_WEAK (series int)
_OVERBOUGHT_WEAK (series int)
_OVERBOUGHT_STRONG (series int)
_LineThresholds
Fields:
_TOP (series int)
_MIDDLE (series int)
_BOTTOM (series int)
_HIST_BASE (series int)
_Transparency
Fields:
_MAX (series int)
_STRONG (series int)
_MEDIUM (series int)
_WEAK (series int)
_MIN (series int)
_FILL (series int)
_TimeframeNames
Fields:
_CURRENT (series string)
_HTF1 (series string)
_HTF2 (series string)
_HTF3 (series string)
_IndicatorColors
Fields:
_RSI (series color)
_TRIX (series color)
_MACD_CURRENT (series color)
_MACD_HTF1 (series color)
_MACD_HTF2 (series color)
_MACD_HTF3 (series color)
_EntryState
Fields:
_WAITING (series string)
_ENTERED (series string)
_CLOSED (series string)
_TradeState
Fields:
_state (series string)
_is_long (series bool)
_signal_bar (series int)
_signal_score (series float)
_signal_high (series float)
_signal_low (series float)
_entry_bar (series int)
_entry_price (series float)
_entry_score (series float)
_entry_reason (series string)
_exit_bar (series int)
_exit_price (series float)
_exit_reason (series string)
_h_line (series line)
_v_line (series line)
_signal_label (series label)
_entry_label (series label)
_exit_label (series label)
RLSR logreg_support_libLibrary "logreg_support_lib"
sigmoid(z)
Parameters:
z (float)
prng01(seed1, seed2)
Parameters:
seed1 (float)
seed2 (float)
normalize(value, minval, maxval)
Parameters:
value (float)
minval (float)
maxval (float)
calcpercentilefast(arr, percentile)
Parameters:
arr (array)
percentile (float)
calcpercentile_series_sampled(s, length, percentile, stride)
Parameters:
s (float)
length (int)
percentile (float)
stride (int)
calcRangeWithLog(value, minval, maxval, uselog)
Parameters:
value (float)
minval (float)
maxval (float)
uselog (bool)
calcMomentumAdvanced(src, length, momType)
Parameters:
src (float)
length (simple int)
momType (string)
normalizeMomentumByType(rawMom, momType, momMin, momMax, momNorm)
Parameters:
rawMom (float)
momType (string)
momMin (float)
momMax (float)
momNorm (float)
normalizeMomentumByTypeExt(rawMom, momType, momMin, momMax, momNorm, bouncingdecay)
Parameters:
rawMom (float)
momType (string)
momMin (float)
momMax (float)
momNorm (float)
bouncingdecay (float)
calcrollingstddev(src, length)
Parameters:
src (float)
length (int)
addlog(buffer, level, msg)
Parameters:
buffer (string)
level (string)
msg (string)
calcfeaturecorrelation(x1, x2)
Parameters:
x1 (array)
x2 (array)
calcnoiseratio(src, lookback)
Parameters:
src (float)
lookback (int)
calccompatibilityscore(x1, x2)
Parameters:
x1 (array)
x2 (array)
getfuturereturn(offset, returnlookback)
Parameters:
offset (int)
returnlookback (int)
calculatema(source, length, matype)
Parameters:
source (float)
length (simple int)
matype (string)
adaptive_trigger_for_source(src, enabled, freeze, lookback, threshold, volahistory)
Parameters:
src (float)
enabled (bool)
freeze (bool)
lookback (int)
threshold (float)
volahistory (array)
checkadaptivetrigger5(s1, enabled1, freeze1, hist1, s2, enabled2, freeze2, hist2, s3, enabled3, freeze3, hist3, s4, enabled4, freeze4, hist4, s5, enabled5, freeze5, hist5, lookback, threshold)
Parameters:
s1 (float)
enabled1 (bool)
freeze1 (bool)
hist1 (array)
s2 (float)
enabled2 (bool)
freeze2 (bool)
hist2 (array)
s3 (float)
enabled3 (bool)
freeze3 (bool)
hist3 (array)
s4 (float)
enabled4 (bool)
freeze4 (bool)
hist4 (array)
s5 (float)
enabled5 (bool)
freeze5 (bool)
hist5 (array)
lookback (int)
threshold (float)
ring_start_index(rb_write_idx, rb_count, rb_cap)
Parameters:
rb_write_idx (int)
rb_count (int)
rb_cap (int)
reversalLibrary "reversals"
psar(af_start, af_increment, af_max)
Calculates Parabolic Stop And Reverse (SAR)
Parameters:
af_start (simple float) : Initial acceleration factor (Wilder's original: 0.02)
af_increment (simple float) : Acceleration factor increment per new extreme (Wilder's original: 0.02)
af_max (simple float) : Maximum acceleration factor (Wilder's original: 0.20)
Returns: SAR value (stop level for current trend)
fractals()
Detects Williams Fractal patterns (5-bar pattern)
Returns: Tuple with fractal values (na if no fractal)
swings(lookback, source_high, source_low)
Detects swing highs and swing lows using lookback period
Parameters:
lookback (simple int) : Number of bars on each side to confirm swing point
source_high (float) : Price series for swing high detection (typically high)
source_low (float) : Price series for swing low detection (typically low)
Returns: Tuple with swing point values (na if no swing)
pivot(tf)
Calculates classic/standard/floor pivot points
Parameters:
tf (simple string) : Timeframe for pivot calculation ("D", "W", "M")
Returns: Tuple with pivot levels
pivotcam(tf)
Calculates Camarilla pivot points with 8 levels for short-term trading
Parameters:
tf (simple string) : Timeframe for pivot calculation ("D", "W", "M")
Returns: Tuple with pivot levels
pivotdem(tf)
Calculates d-mark pivot points with conditional open/close logic
Parameters:
tf (simple string) : Timeframe for pivot calculation ("D", "W", "M")
Returns: Tuple with pivot levels (only 3 levels)
pivotext(tf)
Calculates extended traditional pivot points with R4-R5 and S4-S5 levels
Parameters:
tf (simple string) : Timeframe for pivot calculation ("D", "W", "M")
Returns: Tuple with pivot levels
pivotfib(tf)
Calculates Fibonacci pivot points using Fibonacci ratios
Parameters:
tf (simple string) : Timeframe for pivot calculation ("D", "W", "M")
Returns: Tuple with pivot levels
pivotwood(tf)
Calculates Woodie's pivot points with weighted closing price
Parameters:
tf (simple string) : Timeframe for pivot calculation ("D", "W", "M")
Returns: Tuple with pivot levels
libpublicLibrary "libpublic"
sma(src, len)
Simple Moving Average
Parameters:
src (float) : Series to use
len (int) : Filtering length
Returns: Filtered series
ema(src, len)
Exponential Moving Average
Parameters:
src (float) : Series to use
len (int) : Filtering length
Returns: Filtered series
rma(src, len)
Wilder's Smoothing (Running Moving Average)
Parameters:
src (float) : Series to use
len (int) : Filtering length
Returns: Filtered series
hma(src, len)
Hull Moving Average
Parameters:
src (float) : Series to use
len (int) : Filtering length
Returns: Filtered series
vwma(src, len)
Volume Weighted Moving Average
Parameters:
src (float) : Series to use
len (int) : Filtering length
Returns: Filtered series
jma(src, len, phase)
Jurik MA
Parameters:
src (float) : Series to use
len (int) : Filtering length
phase (int) : JMA Phase
Returns: Filtered series
c_Ema(_src, _length)
Parameters:
_src (float)
_length (int)
c_zlema(_src, _length)
Parameters:
_src (float)
_length (int)
to_pips(_v)
Convert price to pips.
Parameters:
_v (float) : Price
Returns: Pips
toPips(_v)
Parameters:
_v (float)
get_day(_n)
Get the day of the week
Parameters:
_n (int) : Number of day of week
clear_lines(_arr, _min)
Deletes the lines included in the array.
Parameters:
_arr (array) : Array of lines
_min (int) : Deletes the lines included in the array.
clear_labels(_arr, _min)
Deletes the labels included in the array.
Parameters:
_arr (array) : Array of labels
_min (int) : Deletes the labels included in the array.
clear_boxes(_arr, _min)
Deletes the boxes included in the array.
Parameters:
_arr (array) : Array of boxes
_min (int) : Deletes the boxes included in the array.
tfToInt(_timeframe)
Parameters:
_timeframe (string)
tfCurrentView(_tf)
Parameters:
_tf (float)
f_round(_val, _decimals)
Parameters:
_val (float)
_decimals (int)
getTablePos(_switch)
Parameters:
_switch (string)
getTxtSize(_switch)
Parameters:
_switch (string)
getTendChar(_trendChar)
Parameters:
_trendChar (string)
blueWaves(src, chlLen, avgLen)
Parameters:
src (float)
chlLen (int)
avgLen (int)
candleType(_candle)
Parameters:
_candle (int)
normalizeVolume(_vol, _precision)
Parameters:
_vol (float)
_precision (string)
InSession(sessionTime, sessionTimeZone)
Parameters:
sessionTime (string)
sessionTimeZone (string)
IsSessionStart(sessionTime, sessionTimeZone)
Parameters:
sessionTime (string)
sessionTimeZone (string)
createSessionTime(_timeOffsetStart, _timeOffsetEnd, _offsetTypeStart, _offsetTypeEnd, sessionTimeZone)
Parameters:
_timeOffsetStart (int)
_timeOffsetEnd (int)
_offsetTypeStart (string)
_offsetTypeEnd (string)
sessionTimeZone (string)
clrsLibrary "clrs"
Helpers for color manipulations
opacify(oldColor, opacity)
Applies opacity to color
Parameters:
oldColor (color) : color
opacity (float) : opacity
Returns: color with opacity
getColorsRange(topColor, bottomColor, numColors)
Gets two colors as parameters and number of colors you need. Returns range of colors between them
Parameters:
topColor (color) : color color
bottomColor (color) : color
numColors (int) : number of colors in range
Mirpapa_Lib_SumBoxLibrary "Mirpapa_Lib_SumBox"
CreateSumCandleStates()
CreateSumCandleStates
@desc Creates a set of sum candle state strings.
Returns (SumCandleStates): State string set (pending, confirmed, completed)
Returns: SumCandleStates state string set
CreateSumCandleData(sumOpen, sumHigh, sumLow, sumClose, sumStartTime, sumEndTime, sumHighTime, sumLowTime, state)
CreateSumCandleData
@desc Creates sum candle data (factory function).
sumOpen (float): Sum open price
sumHigh (float): Sum high price
sumLow (float): Sum low price
sumClose (float): Sum close price
sumStartTime (int): Sum start time (milliseconds)
sumEndTime (int): Sum end time (milliseconds)
sumHighTime (int): High point occurrence time (milliseconds)
sumLowTime (int): Low point occurrence time (milliseconds)
state (string): State (pending/confirmed/completed)
Returns (SumCandleData): Created sum candle data
Parameters:
sumOpen (float): (float) Sum open price
sumHigh (float): (float) Sum high price
sumLow (float): (float) Sum low price
sumClose (float): (float) Sum close price
sumStartTime (int): (int) Sum start time
sumEndTime (int): (int) Sum end time
sumHighTime (int): (int) High point occurrence time
sumLowTime (int): (int) Low point occurrence time
state (string): (string) State
Returns: SumCandleData Created sum candle data
ValidateSumCandleData(sumData, confirmedState)
ValidateSumCandleData
@desc Validates sum candle data.
sumData (SumCandleData): Sum candle data to validate
confirmedState (string): CONFIRMED state string
Returns ( ):
Parameters:
sumData (SumCandleData): (SumCandleData) Sum candle data to validate
confirmedState (string): (string) CONFIRMED state string
Returns:
CanConfirmSumCandle(sumData, pendingState, confirmedState, completedState)
CanConfirmSumCandle
@desc Validates whether a sum candle can be confirmed.
sumData (SumCandleData): Sum candle data to confirm
pendingState (string): PENDING state string
confirmedState (string): CONFIRMED state string
completedState (string): COMPLETED state string
Returns ( ):
Parameters:
sumData (SumCandleData): (SumCandleData) Sum candle data to confirm
pendingState (string): (string) PENDING state string
confirmedState (string): (string) CONFIRMED state string
completedState (string): (string) COMPLETED state string
Returns:
UpdateSumCandleState(sumData, newState, pendingState, confirmedState, completedState)
UpdateSumCandleState
@desc Updates the state of a sum candle (includes validation).
sumData (SumCandleData): Sum candle data to update
newState (string): New state
pendingState (string): PENDING state string
confirmedState (string): CONFIRMED state string
completedState (string): COMPLETED state string
Returns ( ):
Parameters:
sumData (SumCandleData): (SumCandleData) Sum candle data to update
newState (string): (string) New state
pendingState (string): (string) PENDING state string
confirmedState (string): (string) CONFIRMED state string
completedState (string): (string) COMPLETED state string
Returns:
CreateSumCandleBox(sumOpen, sumClose, sumStartTime, endTime, bullColor, bearColor, borderColor, borderWidth)
CreateSumCandleBox
@desc Creates a sum candle body box.
sumOpen (float): Sum open price
sumClose (float): Sum close price
sumStartTime (int): Sum start time (milliseconds)
endTime (int): Sum end time (milliseconds)
bullColor (color): Bullish candle color
bearColor (color): Bearish candle color
borderColor (color): Border color
borderWidth (int): Border width (1-5)
Returns (box): Created body box
Parameters:
sumOpen (float): (float) Sum open price
sumClose (float): (float) Sum close price
sumStartTime (int): (int) Sum start time
endTime (int): (int) Sum end time
bullColor (color): (color) Bullish candle color
bearColor (color): (color) Bearish candle color
borderColor (color): (color) Border color
borderWidth (int): (int) Border width
Returns: box Body box
CreateSumCandleLine(x, y1, y2, lineColor, lineWidth)
CreateSumCandleLine
@desc Creates a sum candle wick line.
x (int): Line x coordinate (time, milliseconds)
y1 (float): Line start y coordinate (price)
y2 (float): Line end y coordinate (price)
lineColor (color): Line color
lineWidth (int): Line width (1-5)
Returns (line): Created wick line
Parameters:
x (int): (int) Line x coordinate (time)
y1 (float): (float) Line start y coordinate
y2 (float): (float) Line end y coordinate
lineColor (color): (color) Line color
lineWidth (int): (int) Line width
Returns: line Wick line
DeleteSumCandleVisuals(sumData)
DeleteSumCandleVisuals
@desc Deletes visualization objects (boxes, lines) of a sum candle.
sumData (SumCandleData): Sum candle data to delete
Returns (void): No return value
Parameters:
sumData (SumCandleData): (SumCandleData) Sum candle data to delete
Returns: void
GetBodyBounds(sumOpen, sumClose)
GetBodyBounds
@desc Calculates the top and bottom boundaries of the body.
sumOpen (float): Sum open price
sumClose (float): Sum close price
Returns ( ):
Parameters:
sumOpen (float): (float) Sum open price
sumClose (float): (float) Sum close price
Returns:
ManageMemory(sumArray, maxSize)
ManageMemory
@desc Manages array size and deletes old data.
sumArray (array): Sum candle array to manage
maxSize (int): Maximum size
Returns (void): No return value
Parameters:
sumArray (array): (array) Sum candle array to manage
maxSize (int): (int) Maximum size
Returns: void
IsSingleCandle(sumData)
IsSingleCandle
@desc Checks if it's a sum consisting of only one candle.
sumData (SumCandleData): Sum candle data to check
Returns (bool): true if single candle, false otherwise
Parameters:
sumData (SumCandleData): (SumCandleData) Sum candle data to check
Returns: bool Single candle status
CalculateWickCenterTime(startTime, endTime)
CalculateWickCenterTime
@desc Calculates the center time where the wick will be displayed.
startTime (int): Sum start time (milliseconds)
endTime (int): Sum end time (milliseconds)
Returns (int): Center time (milliseconds)
Parameters:
startTime (int): (int) Sum start time
endTime (int): (int) Sum end time
Returns: int Center time
SumCandleStates
Fields:
pending (series string)
confirmed (series string)
completed (series string)
SumCandleData
Fields:
_open (series float)
_high (series float)
_low (series float)
_close (series float)
_startTime (series int)
_endTime (series int)
_highTime (series int)
_lowTime (series int)
_isBull (series bool)
_state (series string)
_boxBody (series box)
_wickHigh (series line)
_wickLow (series line)
oct25libLibrary of technical indicators for use in scripts.
1) salmav3(src, length, smooth, mult, sd_len)
Parameters:
src (float)
length (int)
smooth (simple int)
mult(float)
sd_len(int)
2) boltzman(src, length, T, alpha, smoothLen)
Parameters:
src (float)
length (int)
T(float)
Alpha(float)
smoothLen (simple int)
3) shannon(src, vol, len, bc, vc, smooth)
Parameters:
src (float)
vol (float)
len (int)
bc (bool)
vc (bool)
smooth (simple int)
4) vama(src, baseLen, volLen, beta)
Parameters:
src (float)
baseLen (int)
volLen (int)
beta (float)
5) fwma(src, period, lambda, smooth)
Parameters:
src (float)
period (int)
lambda (float)
smooth (simple int)
6) savitzky(srcc, srch, srcl, length)
Parameters:
srcc (float)
srch (float)
srcl (float)
length (int)
7) butterworth(src, length, poles, smooth)
Parameters:
src (float)
length (int)
poles (int)
smooth (simple int)
8) rti(src, trend_data_count, trend_sensitivity_percentage, midline, smooth)
Parameters:
src (float)
trend_data_count (int)
trend_sensitivity_percentage (int)
midline (int)
smooth (simple int)
9) chandemo(src, length, smooth)
Parameters:
src (float)
length (int)
smooth (simple int)
10) hsma(assetClose, length, emalen, midline)
Parameters:
assetClose (float)
length (int)
emalen (simple int)
midline (float)
11) rsi(src, rsiLengthInput, rsiemalen, midline)
Parameters:
src (float)
rsiLengthInput (simple int)
rsiemalen (simple int)
midline (float)
12) lacoca(src, lookback, malen, matype)
Parameters:
src (float)
lookback (int)
malen (simple int)
matype (string)
AdjCloseLibLibrary "AdjCloseLib"
Library for producing gap-adjusted price series that removes intraday gaps at market open
get_adj_close(_gapThresholdPct)
Calculates gap-adjusted close price by detecting and removing gaps at market open (09:15)
Parameters:
_gapThresholdPct (float) : Minimum gap size (in percentage) required to trigger adjustment. Example: 0.5 for 0.5%
Returns: Adjusted close price for the current bar (always returns a numeric value, never na)
@details Detects gaps by comparing 09:15 open with previous day's close. If gap exceeds threshold,
subtracts the gap value from all bars between 09:15-15:29 inclusive. State resets after session close.
get_adj_ohlc(_gapThresholdPct)
Calculates gap-adjusted OHLC values by subtracting detected gap from all price components
Parameters:
_gapThresholdPct (float) : Minimum gap size (in percentage) required to trigger adjustment. Example: 0.5 for 0.5%
Returns: Tuple of
@details Useful for calculating indicators (ATR, Heikin-Ashi, etc.) on gap-adjusted data.
Applies the same gap adjustment logic to all OHLC components simultaneously.
smaemarvwapClaireLibrary "smaemarvwapClaire"
repeat_character(count)
Parameters:
count (int)
f_1_k_line_width()
is_price_in_merge_range(p1, p2, label_merge_range)
Parameters:
p1 (float)
p2 (float)
label_merge_range (float)
get_pre_label_string(kc, t, is_every)
Parameters:
kc (VWAP_key_levels_draw_settings)
t (int)
is_every (bool)
f_is_new_period_from_str(str)
Parameters:
str (string)
total_for_time_when(source, days, ma_set)
Parameters:
source (float)
days (int)
ma_set (ma_setting)
f_calculate_sma_ema_rolling_vwap(src, length, ma_settings)
Parameters:
src (float)
length (simple int)
ma_settings (ma_setting)
f_calculate_sma_ema_rvwap(ma_settings)
Parameters:
ma_settings (ma_setting)
f_get_ma_pre_label(ma_settings, sma, ema, rolling_vwap)
Parameters:
ma_settings (ma_setting)
sma (float)
ema (float)
rolling_vwap (float)
f_smart_ma_calculation(ma_settings2)
Parameters:
ma_settings2 (ma_setting)
f_calculate_endpoint(start_time, kc, is_every, endp, extend1, extend2, line_label_extend_length)
Parameters:
start_time (int)
kc (VWAP_key_levels_draw_settings)
is_every (bool)
endp (int)
extend1 (bool)
extend2 (bool)
line_label_extend_length (int)
f_single_line_label_fatory(left_point, right_point, line_col, line_width, lines_style_select, labeltext_col, label_text_size, label_array, line_array, label_col, label_text, l1, label1)
根据两个点创建线段和/或标签,并将其添加到对应的数组中
Parameters:
left_point (chart.point) : 左侧起点坐标
right_point (chart.point) : 右侧终点坐标
line_col (color) : 线段颜色
line_width (int) : 线段宽度
lines_style_select (string) : 线段样式(实线、虚线等)
labeltext_col (color) : 标签文字颜色
label_text_size (string) : 标签文字大小
label_array (array) : 存储标签对象的数组
line_array (array) : 存储线段对象的数组
label_col (color) : 标签背景颜色(默认:半透明色)
label_text (string) : 标签文字内容(默认:空字符串)
l1 (bool) : 是否创建线段(默认:false)
label1 (bool) : 是否创建标签(默认:false)
Returns: void
f_line_and_label_merge_func(t, data, l_text, kc, is_every, endp, merge_str_map, label_array, line_array, extend1, extend2, line_label_extend_length, label_merge_control, line_width, lines_style_select, label_text_size)
Parameters:
t (int)
data (float)
l_text (string)
kc (VWAP_key_levels_draw_settings)
is_every (bool)
endp (int)
merge_str_map (map)
label_array (array)
line_array (array)
extend1 (bool)
extend2 (bool)
line_label_extend_length (int)
label_merge_control (bool)
line_width (int)
lines_style_select (string)
label_text_size (string)
plot_ohlc(kc, ohlc_data, extend1, extend2, merge_str_map, label_array, line_array, is_every, line_label_extend_length, label_merge_control, line_width, lines_style_select, label_text_size)
Parameters:
kc (VWAP_key_levels_draw_settings)
ohlc_data (bardata)
extend1 (bool)
extend2 (bool)
merge_str_map (map)
label_array (array)
line_array (array)
is_every (bool)
line_label_extend_length (int)
label_merge_control (bool)
line_width (int)
lines_style_select (string)
label_text_size (string)
plot_vwap_keylevels(kc, vwap_data, extend1, extend2, merge_str_map, label_array, line_array, is_every, line_label_extend_length, label_merge_control, line_width, lines_style_select, label_text_size)
Parameters:
kc (VWAP_key_levels_draw_settings)
vwap_data (vwap_snapshot)
extend1 (bool)
extend2 (bool)
merge_str_map (map)
label_array (array)
line_array (array)
is_every (bool)
line_label_extend_length (int)
label_merge_control (bool)
line_width (int)
lines_style_select (string)
label_text_size (string)
plot_vwap_bardata(kc, ohlc_data, vwap_data, extend1, extend2, merge_str_map, label_array, line_array, is_every, line_label_extend_length, label_merge_control, line_width, lines_style_select, label_text_size)
Parameters:
kc (VWAP_key_levels_draw_settings)
ohlc_data (bardata)
vwap_data (vwap_snapshot)
extend1 (bool)
extend2 (bool)
merge_str_map (map)
label_array (array)
line_array (array)
is_every (bool)
line_label_extend_length (int)
label_merge_control (bool)
line_width (int)
lines_style_select (string)
label_text_size (string)
f_start_end_total_min(session)
Parameters:
session (string)
f_get_vwap_array(anchor1, data_manager, is_historical)
Parameters:
anchor1 (string)
data_manager (data_manager)
is_historical (bool)
f_get_bardata_array(anchorh, data_manager, is_historical)
Parameters:
anchorh (string)
data_manager (data_manager)
is_historical (bool)
vwap_snapshot
Fields:
t (series int)
vwap (series float)
upper1 (series float)
lower1 (series float)
upper2 (series float)
lower2 (series float)
upper3 (series float)
lower3 (series float)
VWAP_key_levels_draw_settings
Fields:
enable (series bool)
index (series int)
anchor (series string)
session (series string)
vwap_col (series color)
bands_col (series color)
bg_color (series color)
text_color (series color)
val (series bool)
poc (series bool)
vah (series bool)
enable2x (series bool)
enable3x (series bool)
o_control (series bool)
h_control (series bool)
l_control (series bool)
c_control (series bool)
extend_control (series bool)
only_show_the_lastone_control (series bool)
bg_control (series bool)
line_col_labeltext_col (series color)
bardata
Fields:
o (series float)
h (series float)
l (series float)
c (series float)
v (series float)
start_time (series int)
end_time (series int)
ma_setting
Fields:
day_control (series bool)
kline_numbers (series int)
ma_color (series color)
ema_color (series color)
rvwap_color (series color)
ma_control (series bool)
ema_control (series bool)
rvwap_control (series bool)
session (series string)
merge_label_template
Fields:
left_point (chart.point)
right_point (chart.point)
label_text (series string)
p (series float)
label_color (series color)
merge_init_false (series bool)
anchor_snapshots
Fields:
vwap_current (array)
vwap_historical (array)
bardata_current (array)
bardata_historical (array)
data_manager
Fields:
snapshots_map (map)
draw_settings_map (map)
Count█ OVERVIEW
A library of functions for counting the number of times (frequency) that elements occur in an array or matrix.
█ USAGE
Import the Count library.
import joebaus/count/1 as c
Create an array or matrix that is a `float`, `int`, `string`, or `bool` type to count elements from, then call the count function on the array or matrix.
id = array.from(1.00, 1.50, 1.25, 1.00, 0.75, 1.25, 1.75, 1.25)
countMap = id.count() // Alternatively: countMap = c.count(id)
The "count map" will return a map with keys for each unique element in the array or matrix, and with respective values representing the number of times the unique element was counted. The keys will be the same type as the array or matrix counted. The values will always be an `int` type.
array mapKeys = countMap.keys() // Returns unique keys
array mapValues = countMap.values() // Returns counts
If an array is in ascending or descending order, then the keys of the map will also generate in the same order.
intArray = array.from(2, 2, 2, 3, 4, 4, 4, 4, 4, 6, 6) // Ascending order
map countMap = intArray.count() // Creates a "count map" of all unique elements
array mapKeys = countMap.keys() // Returns // Ascending order
array mapValues = countMap.values() // Returns count
Include a value to get the count of only that value in an array or matrix.
floatMatrix = matrix.new(3, 3, 0.0)
floatMatrix.set(0, 0, 1.0), floatMatrix.set(1, 0, 1.0), floatMatrix.set(2, 0, 1.0)
floatMatrix.set(0, 1, 1.5), floatMatrix.set(1, 1, 2.0), floatMatrix.set(2, 1, 2.5)
floatMatrix.set(0, 2, 1.0), floatMatrix.set(1, 2, 2.5), floatMatrix.set(2, 2, 1.5)
int countFloatMatrix = floatMatrix.count(1.0) // Counts all 1.0 elements, returns 5
// Alternatively: int countFloatMatrix = c.count(floatMatrix, 1.0)
The string method of count() can use strings or regular expressions like "bull*" to count all matching occurrences in a string array.
stringArray = array.from('bullish', 'bull', 'bullish', 'bear', 'bull', 'bearish', 'bearish')
int countString = stringArray.count('bullish') // Returns 2
int countStringRegex = stringArray.count('bull*') // Returns 4
To count multiple values, use an array of values instead of a single value. Returning a count map only of elements in the array.
countArray = array.from(1.0, 2.5)
map countMap = floatMatrix.count(countArray)
array mapKeys = countMap.keys() // Returns keys
array mapValues = countMap.values() // Returns counts
Multiple regex patterns or strings can be counted as well.
stringMatrix = matrix.new(3, 3, '')
stringMatrix.set(0, 0, 'a'), stringMatrix.set(1, 0, 'a'), stringMatrix.set(2, 0, 'a')
stringMatrix.set(0, 1, 'b'), stringMatrix.set(1, 1, 'c'), stringMatrix.set(2, 1, 'd')
stringMatrix.set(0, 2, 'a'), stringMatrix.set(1, 2, 'd'), stringMatrix.set(2, 2, 'b')
// Count the number of times the regex patterns `'^(a|c)$'` and `'^(b|d)$'` occur
array regexes = array.from('^(a|c)$', '^(b|d)$')
map countMap = stringMatrix.count(regexes)
array mapKeys = countMap.keys() // Returns
array mapValues = countMap.values() // Returns
An optional comparison operator can be specified to count the number of times an equality was satisfied for `float`, `int`, and `bool` methods of `count()`.
intArray = array.from(2, 2, 2, 3, 4, 4, 4, 4, 4, 6, 6)
// Count the number of times an element is greater than 4
countInt = intArray.count(4, '>') // Returns 2
When passing an array of values to count and a comparison operator, the operator will apply to each value.
intArray = array.from(2, 2, 2, 3, 4, 4, 4, 4, 4, 6, 6)
values = array.from(3, 4)
// Count the number of times and element is greater than 3 and 4
map countMap = intArray.count(values, '>')
array mapKeys = countMap.keys() // Returns
array mapValues = countMap.values() // Returns
Multiple comparison operators can be applied when counting multiple values.
intMatrix = matrix.new(3, 3, 0)
intMatrix.set(0, 0, 2), intMatrix.set(1, 0, 3), intMatrix.set(2, 0, 5)
intMatrix.set(0, 1, 2), intMatrix.set(1, 1, 4), intMatrix.set(2, 1, 2)
intMatrix.set(0, 2, 5), intMatrix.set(1, 2, 2), intMatrix.set(2, 2, 3)
values = array.from(3, 4)
comparisons = array.from('<', '>')
// Count the number of times an element is less than 3 and greater than 4
map countMap = intMatrix.count(values, comparisons)
array mapKeys = countMap.keys() // Returns
array mapValues = countMap.values() // Returns
LapseBacktestingTableLibrary "LapseBacktestingMetrics"
This library provides a robust set of quantitative backtesting and performance evaluation functions for Pine Script strategies. It’s designed to help traders, quants, and developers assess risk, return, and robustness through detailed statistical metrics — including Sharpe, Sortino, Omega, drawdowns, and trade efficiency.
Built to enhance any trading strategy’s evaluation framework, this library allows you to visualize performance with the quantlapseTable() function, producing an interactive on-chart performance table.
Credit to EliCobra and BikeLife76 for original concept inspiration.
curve(disp_ind)
Retrieves a selected performance curve of your strategy.
Parameters:
disp_ind (simple string): Type of curve to plot. Options include "Equity", "Open Profit", "Net Profit", "Gross Profit".
Returns: (float) Corresponding performance curve value.
cleaner(disp_ind, plot)
Filters and displays selected strategy plots for clean visualization.
Parameters:
disp_ind (simple string): Type of display.
plot (simple float): Strategy plot variable.
Returns: (float) Filtered plot value.
maxEquityDrawDown()
Calculates the maximum equity drawdown during the strategy’s lifecycle.
Returns: (float) Maximum equity drawdown percentage.
maxTradeDrawDown()
Computes the worst intra-trade drawdown among all closed trades.
Returns: (float) Maximum intra-trade drawdown percentage.
consecutive_wins()
Finds the highest number of consecutive winning trades.
Returns: (int) Maximum consecutive wins.
consecutive_losses()
Finds the highest number of consecutive losing trades.
Returns: (int) Maximum consecutive losses.
no_position()
Counts the maximum consecutive bars where no position was held.
Returns: (int) Maximum flat days count.
long_profit()
Calculates total profit generated by long positions as a percentage of initial capital.
Returns: (float) Total long profit %.
short_profit()
Calculates total profit generated by short positions as a percentage of initial capital.
Returns: (float) Total short profit %.
prev_month()
Measures the previous month’s profit or loss based on equity change.
Returns: (float) Monthly equity delta.
w_months()
Counts the number of profitable months in the backtest.
Returns: (int) Total winning months.
l_months()
Counts the number of losing months in the backtest.
Returns: (int) Total losing months.
checktf()
Returns the time-adjusted scaling factor used in Sharpe and Sortino ratio calculations based on chart timeframe.
Returns: (float) Annualization multiplier.
stat_calc()
Performs complete statistical computation including drawdowns, Sharpe, Sortino, Omega, trade stats, and profit ratios.
Returns: (array)
.
f_colors(x, nv)
Generates a color gradient for performance values, supporting dynamic table visualization.
Parameters:
x (simple string): Metric label name.
nv (simple float): Metric numerical value.
Returns: (color) Gradient color value for table background.
quantlapseTable(option, position)
Displays an interactive Performance Table summarizing all major backtesting metrics.
Includes Sharpe, Sortino, Omega, Profit Factor, drawdowns, profitability %, and trade statistics.
Parameters:
option (simple string): Table type — "Full", "Simple", or "None".
position (simple string): Table position — "Top Left", "Middle Right", "Bottom Left", etc.
Returns: (table) On-chart performance visualization table.
This library empowers advanced quantitative evaluation directly within Pine Script®, ideal for strategy developers seeking deeper performance diagnostics and intuitive on-chart metrics.
LibVeloLibrary "LibVelo"
This library provides a sophisticated framework for **Velocity
Profile (Flow Rate)** analysis. It measures the physical
speed of trading at specific price levels by relating volume
to the time spent at those levels.
## Core Concept: Market Velocity
Unlike Volume Profiles, which only answer "how much" traded,
Velocity Profiles answer "how fast" it traded.
It is calculated as:
`Velocity = Volume / Duration`
This metric (contracts per second) reveals hidden market
dynamics invisible to pure Volume or TPO profiles:
1. **High Velocity (Fast Flow):**
* **Aggression:** Initiative buyers/sellers hitting market
orders rapidly.
* **Liquidity Vacuum:** Price slips through a level because
order book depth is thin (low resistance).
2. **Low Velocity (Slow Flow):**
* **Absorption:** High volume but very slow price movement.
Indicates massive passive limit orders ("Icebergs").
* **Apathy:** Little volume over a long time. Lack of
interest from major participants.
## Architecture: Triple-Engine Composition
To ensure maximum performance while offering full statistical
depth for all metrics, this library utilises **object
composition** with a lazy evaluation strategy:
#### Engine A: The Master (`vpVol`)
* **Role:** Standard Volume Profile.
* **Purpose:** Maintains the "ground truth" of volume distribution,
price buckets, and ranges.
#### Engine B: The Time Container (`vpTime`)
* **Role:** specialized container for time duration (in ms).
* **Hack:** It repurposes standard volume arrays (specifically
`aBuy`) to accumulate time duration for each bucket.
#### Engine C: The Calculator (`vpVelo`)
* **Role:** Temporary scratchpad for derived metrics.
* **Purpose:** When complex statistics (like Value Area or Skewness)
are requested for **Velocity**, this engine is assembled
on-demand to leverage the full statistical power of `LibVPrf`
without rewriting complex algorithms.
---
**DISCLAIMER**
This library is provided "AS IS" and for informational and
educational purposes only. It does not constitute financial,
investment, or trading advice.
The author assumes no liability for any errors, inaccuracies,
or omissions in the code. Using this library to build
trading indicators or strategies is entirely at your own risk.
As a developer using this library, you are solely responsible
for the rigorous testing, validation, and performance of any
scripts you create based on these functions. The author shall
not be held liable for any financial losses incurred directly
or indirectly from the use of this library or any scripts
derived from it.
create(buckets, rangeUp, rangeLo, dynamic, valueArea, allot, estimator, cdfSteps, split, trendLen)
Construct a new `Velo` controller, initializing its engines.
Parameters:
buckets (int) : series int Number of price buckets ≥ 1.
rangeUp (float) : series float Upper price bound (absolute).
rangeLo (float) : series float Lower price bound (absolute).
dynamic (bool) : series bool Flag for dynamic adaption of profile ranges.
valueArea (int) : series int Percentage for Value Area (1..100).
allot (series AllotMode) : series AllotMode Allocation mode `Classic` or `PDF` (default `PDF`).
estimator (series PriceEst enum from AustrianTradingMachine/LibBrSt/1) : series PriceEst PDF model for distribution attribution (default `Uniform`).
cdfSteps (int) : series int Resolution for PDF integration (default 20).
split (series SplitMode) : series SplitMode Buy/Sell split for the master volume engine (default `Classic`).
trendLen (int) : series int Look‑back for trend factor in dynamic split (default 3).
Returns: Velo Freshly initialised velocity profile.
method clone(self)
Create a deep copy of the composite profile.
Namespace types: Velo
Parameters:
self (Velo) : Velo Profile object to copy.
Returns: Velo A completely independent clone.
method clear(self)
Reset all engines and accumulators.
Namespace types: Velo
Parameters:
self (Velo) : Velo Profile object to clear.
Returns: Velo Cleared profile (chaining).
method merge(self, srcVolBuy, srcVolSell, srcTime, srcRangeUp, srcRangeLo, srcVolCvd, srcVolCvdHi, srcVolCvdLo)
Merges external data (Volume and Time) into the current profile.
Automatically handles resizing and re-bucketing if ranges differ.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
srcVolBuy (array) : array Source Buy Volume bucket array.
srcVolSell (array) : array Source Sell Volume bucket array.
srcTime (array) : array Source Time bucket array (ms).
srcRangeUp (float) : series float Upper price bound of the source data.
srcRangeLo (float) : series float Lower price bound of the source data.
srcVolCvd (float) : series float Source Volume CVD final value.
srcVolCvdHi (float) : series float Source Volume CVD High watermark.
srcVolCvdLo (float) : series float Source Volume CVD Low watermark.
Returns: Velo `self` (chaining).
method addBar(self, offset)
Main data ingestion. Distributes Volume and Time to buckets.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
offset (int) : series int Offset of the bar to add (default 0).
Returns: Velo `self` (chaining).
method setBuckets(self, buckets)
Sets the number of buckets for the profile.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
buckets (int) : series int New number of buckets.
Returns: Velo `self` (chaining).
method setRanges(self, rangeUp, rangeLo)
Sets the price range for the profile.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
rangeUp (float) : series float New upper price bound.
rangeLo (float) : series float New lower price bound.
Returns: Velo `self` (chaining).
method setValueArea(self, va)
Set the percentage of volume/time for the Value Area.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
va (int) : series int New Value Area percentage (0..100).
Returns: Velo `self` (chaining).
method getBuckets(self)
Returns the current number of buckets in the profile.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
Returns: series int The number of buckets.
method getRanges(self)
Returns the current price range of the profile.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
Returns:
rangeUp series float The upper price bound of the profile.
rangeLo series float The lower price bound of the profile.
method getArrayBuyVol(self)
Returns the internal raw data array for **Buy Volume** directly.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
Returns: array The internal array for buy volume.
method getArraySellVol(self)
Returns the internal raw data array for **Sell Volume** directly.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
Returns: array The internal array for sell volume.
method getArrayTime(self)
Returns the internal raw data array for **Time** (in ms) directly.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
Returns: array The internal array for time duration.
method getArrayBuyVelo(self)
Returns the internal raw data array for **Buy Velocity** directly.
Automatically executes _assemble() if data is dirty.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
Returns: array The internal array for buy velocity.
method getArraySellVelo(self)
Returns the internal raw data array for **Sell Velocity** directly.
Automatically executes _assemble() if data is dirty.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
Returns: array The internal array for sell velocity.
method getBucketBuyVol(self, idx)
Returns the **Buy Volume** of a specific bucket.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
idx (int) : series int The index of the bucket.
Returns: series float The buy volume.
method getBucketSellVol(self, idx)
Returns the **Sell Volume** of a specific bucket.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
idx (int) : series int The index of the bucket.
Returns: series float The sell volume.
method getBucketTime(self, idx)
Returns the raw accumulated time (in ms) spent in a specific bucket.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
idx (int) : series int The index of the bucket.
Returns: series float The time in milliseconds.
method getBucketBuyVelo(self, idx)
Returns the **Buy Velocity** (Aggressive Buy Flow) of a bucket.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
idx (int) : series int The index of the bucket.
Returns: series float The buy velocity in .
method getBucketSellVelo(self, idx)
Returns the **Sell Velocity** (Aggressive Sell Flow) of a bucket.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
idx (int) : series int The index of the bucket.
Returns: series float The sell velocity in .
method getBktBnds(self, idx)
Returns the price boundaries of a specific bucket.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
idx (int) : series int The index of the bucket.
Returns:
up series float The upper price bound of the bucket.
lo series float The lower price bound of the bucket.
method getPoc(self, target)
Returns Point of Control (POC) information for the specified target metric.
Calculates on-demand if the target is 'Velocity' and data changed.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
target (series Metric) : Metric The data aspect to analyse (Volume, Time, Velocity).
Returns:
pocIdx series int The index of the POC bucket.
pocPrice series float The mid-price of the POC bucket.
method getVA(self, target)
Returns Value Area (VA) information for the specified target metric.
Calculates on-demand if the target is 'Velocity' and data changed.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
target (series Metric) : Metric The data aspect to analyse (Volume, Time, Velocity).
Returns:
vaUpIdx series int The index of the upper VA bucket.
vaUpPrice series float The upper price bound of the VA.
vaLoIdx series int The index of the lower VA bucket.
vaLoPrice series float The lower price bound of the VA.
method getMedian(self, target)
Returns the Median price for the specified target metric distribution.
Calculates on-demand if the target is 'Velocity' and data changed.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
target (series Metric) : Metric The data aspect to analyse (Volume, Time, Velocity).
Returns:
medianIdx series int The index of the bucket containing the median.
medianPrice series float The median price.
method getAverage(self, target)
Returns the weighted average price (VWAP/TWAP) for the specified target.
Calculates on-demand if the target is 'Velocity' and data changed.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
target (series Metric) : Metric The data aspect to analyse (Volume, Time, Velocity).
Returns:
avgIdx series int The index of the bucket containing the average.
avgPrice series float The weighted average price.
method getStdDev(self, target)
Returns the standard deviation for the specified target distribution.
Calculates on-demand if the target is 'Velocity' and data changed.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
target (series Metric) : Metric The data aspect to analyse (Volume, Time, Velocity).
Returns: series float The standard deviation.
method getSkewness(self, target)
Returns the skewness for the specified target distribution.
Calculates on-demand if the target is 'Velocity' and data changed.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
target (series Metric) : Metric The data aspect to analyse (Volume, Time, Velocity).
Returns: series float The skewness.
method getKurtosis(self, target)
Returns the excess kurtosis for the specified target distribution.
Calculates on-demand if the target is 'Velocity' and data changed.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
target (series Metric) : Metric The data aspect to analyse (Volume, Time, Velocity).
Returns: series float The excess kurtosis.
method getSegments(self, target)
Returns the fundamental unimodal segments for the specified target metric.
Calculates on-demand if the target is 'Velocity' and data changed.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
target (series Metric) : Metric The data aspect to analyse (Volume, Time, Velocity).
Returns: matrix A 2-column matrix where each row is an pair.
method getCvd(self, target)
Returns Cumulative Volume/Velo Delta (CVD) information for the target metric.
Namespace types: Velo
Parameters:
self (Velo) : Velo The profile object.
target (series Metric) : Metric The data aspect to analyse (Volume, Time, Velocity).
Returns:
cvd series float The final delta value.
cvdHi series float The historical high-water mark of the delta.
cvdLo series float The historical low-water mark of the delta.
Velo
Velo Composite Velocity Profile Controller.
Fields:
_vpVol (VPrf type from AustrianTradingMachine/LibVPrf/2) : LibVPrf.VPrf Engine A: Master Volume source.
_vpTime (VPrf type from AustrianTradingMachine/LibVPrf/2) : LibVPrf.VPrf Engine B: Time duration container (ms).
_vpVelo (VPrf type from AustrianTradingMachine/LibVPrf/2) : LibVPrf.VPrf Engine C: Scratchpad for velocity stats.
_aTime (array) : array Pointer alias to `vpTime.aBuy` (Time storage).
_valueArea (series float) : int Percentage of total volume to include in the Value Area (1..100)
_estimator (series PriceEst enum from AustrianTradingMachine/LibBrSt/1) : LibBrSt.PriceEst PDF model for distribution attribution.
_allot (series AllotMode) : AllotMode Attribution model (Classic or PDF).
_cdfSteps (series int) : int Integration resolution for PDF.
_isDirty (series bool) : bool Lazy evaluation flag for vpVelo.
TrendDetectorLibLibrary "TrendDetector_Lib"
method formatTF(timeframe)
Namespace types: series string, simple string, input string, const string
Parameters:
timeframe (string) : (string) The timeframe to convert (e.g., "15", "60", "240").
Returns: (string) The formatted timeframe (e.g., "15M", "1H", "4H").
f_ma(type, src, len)
Computes a Moving Average value based on type and length.
Parameters:
type (simple string) : (string) One of: "SMA", "EMA", "RMA", "WMA", "VWMA".
src (float) : (series float) Source series for MA (e.g., close).
len (simple int) : (simple int) Length of the MA.
Returns: (float) The computed MA series.
render(tbl, trendDetectorSwitch, frameColor, frameWidth, borderColor, borderWidth, textColor, ma1ShowTrendData, ma1Timeframe, ma1Value, ma2ShowTrendData, ma2Timeframe, ma2Value, ma3ShowTrendData, ma3Timeframe, ma3Value)
Fills the provided table with Trend Detector contents.
@desc This renderer does NOT plot and does NOT create tables; call from indicator after your table exists.
Parameters:
tbl (table) : (table) Existing table to render into.
trendDetectorSwitch (bool) : (bool) Master toggle to draw the table content.
frameColor (color) : (color) Table frame color.
frameWidth (int) : (int) Table frame width (0–5).
borderColor (color) : (color) Table border color.
borderWidth (int) : (int) Table border width (0–5).
textColor (color) : (color) Table text color.
ma1ShowTrendData (bool) : (bool) Show MA #1 in table.
ma1Timeframe (simple string) : (string) MA #1 timeframe.
ma1Value (float)
ma2ShowTrendData (bool) : (bool) Show MA #2 in table.
ma2Timeframe (simple string) : (string) MA #2 timeframe.
ma2Value (float)
ma3ShowTrendData (bool) : (bool) Show MA #3 in table.
ma3Timeframe (simple string) : (string) MA #3 timeframe.
ma3Value (float)
QuickInputsLevelParserLibrary "QuickInputsLevelParser"
Provides a parsing library that indicator authors can use in order to parse Quick Inputs Levels.
parseLevels(s)
Parses the string content and returns the `QILevels` found within.
Parameters:
s (string) : The string to parse.
Returns: The parsed WTD levels.
zoneRange
Fields:
high (series float)
low (series float)
QILevels
Fields:
supplyLines (array)
supplyZones (array)
majorLines (array)
onZones (array)
onLines (array)
highLines (array)
lowLines (array)
htfZones (array)
mansupLines (array)
mansupmajLines (array)
mansupZones (array)
mansupmajZones (array)
manresLines (array)
manresmajLines (array)
manresZones (array)
manresmajZones (array)
fibonacci2Library "fibonacci2"
Useful methods to calculate and display fibonacci retracement
modelParamsNew(point_0, point_1)
Parameters:
point_0 (chart.point)
point_1 (chart.point)
modelParamsNew(this, point_0, point_1)
Parameters:
this (viewParams)
point_0 (chart.point)
point_1 (chart.point)
method toModelParams(this, point_0, point_1)
Namespace types: viewParams
Parameters:
this (viewParams)
point_0 (chart.point)
point_1 (chart.point)
method createModel(params)
Namespace types: modelParams
Parameters:
params (modelParams)
method createView(this, params)
Namespace types: model
Parameters:
this (model)
params (viewParams)
method delete(view)
Namespace types: view
Parameters:
view (view)
levelModelParams
Fields:
level (series float)
levelViewParams
Fields:
level (series float)
color (series color)
line_width (series int)
line_style (series lineStyleEnum enum from Hamster-Coder/drawing/1)
levelModel
Represents a Fibonacci retracement level
Fields:
level (series float) : The Fibonacci level ratio (e.g., 0.382, 0.5, 0.618)
value (series float) : The Y-coordinate on the chart corresponding to this level
modelParams
Represents the full parameter set for the Fibonacci retracement model
Fields:
point_1 (chart.point) : Coordinates of the anchor Point (1) of the model
point_0 (chart.point) : Coordinates of the anchor Point (0) of the model
levels (array) : List of levels to display for this model
model
Fields:
point_1 (chart.point)
point_0 (chart.point)
levels (array)
viewParams
Fields:
levels (array)
x1 (series int)
x2 (series int)
xloc (series string)
show_level_value (series bool)
value_format (series string)
force_overlay (series bool)
view
Fields:
model (model)
lines (array)
labels (array)






















