Skip to main content
ATK Pine Script®

Library Examples

Examples demonstrating PyneScript V6 library publishing, versioned exports, enum types, and selective import binding.

Library Authoring Examples#

FileWhat it demonstratesBest useDownload
pynescript_library_enum_utils.pyVersioned library publishing with enum exports.Library authoring pattern.Download
pynescript_library_enum_import_indicator.pySelective import binding through import_library(...).Library consumption pattern.Download

Library Declaration#

from source import library, import_library

library("Pyne Enum Utils", version=1, overlay=False,
        description="Shared enum types and helper functions")

class TrendMode:
    BULLISH = "BULLISH"
    BEARISH = "BEARISH"
    NEUTRAL = "NEUTRAL"

def resolve_length(value, minimum=1):
    return max(int(value), int(minimum))

Importing a Library#

from source import indicator, import_library

indicator("Library Consumer", overlay=False)

# Selective import — only pull what you need
utils = import_library("Pyne Enum Utils@1",
                        exports=["TrendMode", "resolve_length"])

mode = utils.TrendMode.BULLISH
safe_len = utils.resolve_length(0, 2)  # returns 2