CryptonianFibTypes

AYEHAN · library · 134 行 · 点赞 0 · TradingView 原页

本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。

Pine Script

// This Pine Script® code is subject to the terms of the Mozilla Public License 2.0 at https://mozilla.org/MPL/2.0/
// © AYEHAN
 
//@version=6
//@description [Cryptonian] Fibonacci shared types and lifecycle contracts. Part 0 / v0.1.0.
// PUBLICATION NOTE: Pine libraries must be published to import them. Do not store secrets here.
library("CryptonianFibTypes", overlay = false)
 
// ENUM CONTRACTS ------------------------------------------------------------
//@enum Direction of a confirmed structure; neutral means no directional thesis.
export enum Direction
    bullish = "Bullish"
    bearish = "Bearish"
    neutral = "Neutral"
 
//@enum Lifecycle of a structural interpretation. Never resurrect a retired identity.
export enum StructureState
    candidate = "Candidate"
    confirmed = "Confirmed"
    invalidated = "Invalidated"
    retired = "Retired"
 
//@enum Lifecycle of a forecast scenario; an original event record must not be rewritten.
export enum ScenarioState
    candidate = "Candidate"
    armed = "Armed"
    testing = "Testing"
    confirmed = "Confirmed"
    invalidated = "Invalidated"
    completed = "Completed"
    retired = "Retired"
 
//@enum Lifecycle of a trade. Confirmed entries and original levels are immutable by contract.
export enum TradeState
    waiting = "Waiting"
    active = "Active"
    tp1 = "TP1"
    breakeven = "Break-even"
    tp2 = "TP2"
    stopped = "Stopped"
    exited = "Exited"
    cancelled = "Cancelled"
 
//@enum Persistent semantic event classification (for later FibForecast/FibTrade modules).
export enum EventKind
    structureConfirmed = "Structure confirmed"
    scenarioPublished = "Scenario published"
    scenarioInvalidated = "Scenario invalidated"
    entryConfirmed = "Entry confirmed"
    targetOne = "Target 1"
    targetTwo = "Target 2"
    stopHit = "Stop hit"
    tradeExited = "Trade exited"
 
// SHARED DATA CONTRACTS -----------------------------------------------------
// UDT instances are mutable Pine objects; event immutability is an engine rule,
// not an automatic restriction enforced by Pine's type system.
//@type An immutable-by-contract *confirmed* price swing. All timestamps are chart exchange milliseconds.
//@field id Sequential in-chart identity; never reuse within a calculation run.
//@field fromBar Actual bar index of the older confirmed pivot, NOT the discovery bar.
//@field toBar Actual bar index of the newer confirmed pivot, NOT the discovery bar.
//@field confirmationBar Bar index where the newer pivot became known.
//@field fromTime Actual timestamp of the older pivot.
//@field toTime Actual timestamp of the newer pivot.
//@field confirmationTime Timestamp when the structure first became confirmed.
//@field fromPrice Price of the older pivot.
//@field toPrice Price of the newer pivot.
//@field direction Bullish low->high or bearish high->low.
//@field status State of this interpretation.
//@field symbol Chart symbol used for its construction.
//@field timeframe Chart timeframe used for its construction.
export type Swing
    int id
    int fromBar
    int toBar
    int confirmationBar
    int fromTime
    int toTime
    int confirmationTime
    float fromPrice
    float toPrice
    Direction direction
    StructureState status
    string symbol
    string timeframe
 
//@type Persistent candidate Fibonacci region, to be populated by later modules.
export type Zone
    int id
    int swingId
    float lowerPrice
    float upperPrice
    float leadRatio
    int publishedBar
    int publishedTime
    Direction direction
    StructureState status
 
//@type Immutable-by-contract scenario plan; modifications require a NEW scenario identity.
export type Scenario
    int id
    int swingId
    int zoneId
    int publishedBar
    int publishedTime
    float invalidation
    float target1
    float target2
    Direction direction
    ScenarioState status
 
//@type Trade plan. Original levels never change; managed stop is a separate field.
export type Trade
    int id
    int scenarioId
    int signalBar
    int signalTime
    float originalEntry
    float originalStop
    float originalTarget1
    float originalTarget2
    float managedStop
    Direction direction
    TradeState status
 
//@type Historical event record; append new events, never edit the fact of an old one.
export type Event
    int id
    int parentId
    int occurredBar
    int occurredTime
    float recordedPrice
    EventKind kind
    string note

← 返回列表