PINE LIBRARY

threengine_global_automation_library

Cập nhật
Library "threengine_global_automation_library"
A collection of functions used for trade automation

getBaseCurrency()
  Gets the base currency for the chart's ticker. Supported trade pairs are USD, USDT, USDC, BTC, and PERP.
  Returns: Base currency as a string

getChartSymbol()
  Get the current chart's symbol without the base currency appended to it. Supported trade paris are USD, USDT, USDC, BTC, and PERP.
  Returns: Ssymbol and base currency

getDecimals()
  Calculates how many decimals are on the quote price of the current market
  Returns: The current deimal places on the market quote price

checkVar()
  Plot a string as a label on the chart to test variable value. Use str.tostring() for any variable that isn't a string.
  Returns: Label with stringified variable

getStrategyAlertMessage()
  Generates stringified JSON for a limit order that can be passed to the strategy alert_message for a long entry.
  Returns: Stringifed JSON for a long entry

taGetAdx()
  Calculates the Average Directional Index
  Returns: The value of ADX as a float

taGetEma()
  Calculates the EMA based on a type, source, and length. Supported types are EMA, SMA, RMA, and WMA.
  Returns: The value of the selected EMA

isBetweenTwoTimes()
  Checks to see if within a rage based on two times
@retunrs true/false boolean

getAllTradeIDs()
  This gets all closed trades and open trades
@retunrs an array of all open and closed trade ID's

getOpenTradeIDs()
  This gets all open trades
@retunrs an array of all open trade ID's

orderAlreadyExists()
  This checks to see if a provided order id uses the getAllTradeIDs() function to check
@retunrs an array of all open and closed trade ID's

orderCurrentlyExists()
  This checks to see if a provided order id uses the getAllTradeIDs() function to check
  Returns: an array of all open and closed trade ID's

getContractCount()
  calulates the number of contracts you can buy with a set amount of capital and a limit price
  Returns: number of contracts you can buy based on amount of capital you want to use and a price

getLadderSteps()
  Returns: array of ladder entry prices and amounts based on total amount you want to invest across all ladder rungs and either a range between ladderStart and LadderStop based on specificed number of ladderRungs OR ladderStart, ladderRungs, and LadderSpacingPercent
Phát hành các Ghi chú
v2

Added:
getLadderInSteps()
  Constructs arrays used for creating strategy entry orders via a for loop
  Returns: array of ladder entry prices and amounts based on total amount you want to invest across all ladder rungs and either a range between ladderStart and LadderStop based on specificed number of ladderRungs OR ladderStart, ladderRungs, and LadderSpacingPercent

getLadderOutSteps()
  Constructs arrays used for creating strategy exit orders via a for loop
  Returns: array of ladder entry prices and amounts based on total amount you want to invest across all ladder rungs and either a range between ladderStart and LadderStop based on specificed number of ladderRungs OR ladderStart, ladderRungs, and LadderSpacingPercent

Removed:
getLadderSteps()
Phát hành các Ghi chú
v3
Phát hành các Ghi chú
v4
Phát hành các Ghi chú
v5

Added:
getPriceOfFirstClosedTradeSince()
  This gets all closed trades since a provided bar number
@retunrs three arrays: closed trade IDs, closing bar number, and closing price
Phát hành các Ghi chú
v6

Added:
getClosedTradeSince()
  This gets all closed trades since a provided bar number
@retunrs three arrays: closed trade IDs, closing bar number, and closing price

Removed:
getPriceOfFirstClosedTradeSince()
  This gets all closed trades since a provided bar number
@retunrs three arrays: closed trade IDs, closing bar number, and closing price
Phát hành các Ghi chú
v7

Updated:
getClosedTradeSince()
  This gets all closed trades since a provided bar number
@retunrs three arrays: closed trade IDs, closing bar number, and closing price
Phát hành các Ghi chú
v8

Added:
getLadderStart()
  Detect when the ladder has started to fill so that the ladder start can be locked to the initial strategy entry price. After trades close, reset it back to zero.
  Returns: Locked ladder start price and the bar number that the first ladder was filled on

getAveragePriceOfFilledLadders()
  Keeps count of the number of ladder orders that have been filled for an strategy entry
  Returns: maximum number of ladder orders filled
Phát hành các Ghi chú
v9

Added:
getLockedLadderStart()
  Detect when the ladder has started to fill so that the ladder start can be locked to the initial strategy entry price. After trades close, reset it back to zero.
  Returns: Locked ladder start price and the bar number that the first ladder was filled on

Removed:
getLadderStart()
  Detect when the ladder has started to fill so that the ladder start can be locked to the initial strategy entry price. After trades close, reset it back to zero.
Phát hành các Ghi chú
v10

Added:
orderAlreadyClosedSince()
  Checks to see if a trade has already closed since a past bar number
@retunrs boolean of whether provided trade id has already closed since provided bar number
Phát hành các Ghi chú
v11

Added:
taGetVwap()
  Calculates VWAP based on provided src, anchor, and multiplier
  Returns: VWAP, lower band, and upper band
Phát hành các Ghi chú
v12
Phát hành các Ghi chú
v13
Phát hành các Ghi chú
v14

Updated:
taGetVwap()
  Calculates VWAP based on provided src, anchor, and multiplier
  Returns: VWAP, lower band, and upper band
Phát hành các Ghi chú
v15

Added:
getAlertatronAlertMessage()
  Generates stringified JSON for a limit order that can be passed to the strategy alert_message for a long entry.
  Returns: Stringifed JSON for a long entry
Phát hành các Ghi chú
v16

Updated:
getAlertatronAlertMessage()
  Generates stringified JSON for a limit order that can be passed to the strategy alert_message for a long entry.
  Returns: Stringifed JSON for a long entry
Phát hành các Ghi chú
v17

Added:
getAlertatronExitMessage()
  Generates stringified JSON for a limit Exit that can be passed to the strategy alert_message for a long entry.
  Returns: Stringifed JSON for a exit entry
Phát hành các Ghi chú
v18

Updated:
getAlertatronAlertMessage()
  Generates stringified JSON for a limit order that can be passed to the strategy alert_message for an entry.
  Returns: Stringifed JSON for an entry

getAlertatronExitMessage()
  Generates stringified JSON for a limit Exit that can be passed to the strategy alert_message for a long entry.
  Returns: Stringifed JSON for a exit entry
Phát hành các Ghi chú
v19

Added a forward slash (/) between the symbol and the base currency to match Alertatron formatting.
Phát hành các Ghi chú
v20
Phát hành các Ghi chú
v21

Added:
getAlertatronEntryMessage()
  Generates stringified JSON for a limit order that can be passed to the strategy alert_message for an entry.
  Returns: Stringifed JSON for an entry

Removed:
getAlertatronAlertMessage()
  Generates stringified JSON for a limit order that can be passed to the strategy alert_message for an entry.
Phát hành các Ghi chú
v22

Changed ladder lot size to be a standard size for each rung instead of splitting a total amount across the number of rungs.
Phát hành các Ghi chú
v23

Added:
getRateOfChange()
  Calulates the rate of change of a series based on a look back length
  Returns: the rate of change as a float
Phát hành các Ghi chú
v24

Updated:
getAlertatronEntryMessage()
  Generates stringified JSON for a limit order that can be passed to the strategy alert_message for an entry.
  Returns: Stringifed JSON for an entry

getAlertatronExitMessage()
  Generates stringified JSON for a limit Exit that can be passed to the strategy alert_message for a long entry.
  Returns: Stringifed JSON for a exit entry
Phát hành các Ghi chú
v25

Added:
getPairDividerForExchange()
  Generates stringified JSON for a limit order that can be passed to the strategy alert_message for a long entry.
  Returns: Stringifed JSON for a long entry
Phát hành các Ghi chú
v26

Updated function description.
Phát hành các Ghi chú
v27
Split exchange settings out into two functions to fix a bug.
Phát hành các Ghi chú
v28

Updated getAlertatronExitMessage() to include 'reduceOnly=true' so that the exchange doesn't open a short/long when TV is trying to exit a position.
Phát hành các Ghi chú
v29

update getAlertatronEntryMessage() to include reduceOnly=true on the stop loss.
Phát hành các Ghi chú
v30

Made avgPrice := na when not in a position
Phát hành các Ghi chú
v31

Added:
getCountOfClosedTradeSince()
  This gets the count of closed trades since a provided bar index
@retunrs three arrays: closed trade IDs, closing bar number, and closing price
Phát hành các Ghi chú
v32

Added:
closeUnfilledEntriesAfter()
  Constructs arrays used for creating strategy exit orders via a for loop
  Returns: array of ladder entry prices and amounts based on total amount you want to invest across all ladder rungs and either a range between ladderStart and LadderStop based on specificed number of ladderRungs OR ladderStart, ladderRungs, and LadderSpacingPercent
Phát hành các Ghi chú
v33

Added:
getAlertatronEntryMessageV2()
  Generates a string for a limit order that can be passed to the strategy alert_message for an entry.
  Returns: string that represents a block of entries for alertatron
Phát hành các Ghi chú
v34

Added:
getOrderAlertMessage()
  Generates a string for one or more orders to be placed on exchange using Alertatron
  Returns: string to be passed to Alertatron

getCancelUnfilledOrdersAlertMessage()
  Generates a string for the alert message needed to place a stopLimit order when a strategy produces an exit signal after hitting a trailing stop
  Returns: string to be passed to Alertatron

getTrailingStopAlertMessage()
  Generates a string for the alert message needed to cancel all unfilled orders with the matching strategy tag
  Returns: string to be passed to Alertatron
Phát hành các Ghi chú
v35

Added:
formatEntryPrices()
  Formats array of entry prices to supported format
  Returns: CSV string of properly formated entry prices
Phát hành các Ghi chú
v36

Add getEntryNames() function
Phát hành các Ghi chú
v37

Added:
getEntryNames()
  Gets an array of entry names for number of desired entries
  Returns: array of entry name strings
Phát hành các Ghi chú
v38
Phát hành các Ghi chú
v39

Updated:
checkVar()
  Plot a string as a label on the chart to test variable value. Use str.tostring() for any variable that isn't a string.
  Returns: Label with stringified variable
Phát hành các Ghi chú
v40

Updated:
checkVar()
  Plot a string as a label on the chart to test variable value. Use str.tostring() for any variable that isn't a string.
  Returns: Label with stringified variable

getOrderAlertMessage()
  Generates a string for one or more orders to be placed on exchange using Alertatron
  Returns: string to be passed to Alertatron

getTrailingStopAlertMessage()
  Generates a string for the alert message needed to cancel all unfilled orders with the matching strategy tag
  Returns: string to be passed to Alertatron
Phát hành các Ghi chú
v41
Phát hành các Ghi chú
v42

Added "%p" to profitTargetAmounts
Phát hành các Ghi chú
v43

Added \n to end of each alert message part to see if I can force some line breaks in the code.
Phát hành các Ghi chú
v44
Phát hành các Ghi chú
v45
Phát hành các Ghi chú
v46
Phát hành các Ghi chú
v47

Updated:
getOrderAlertMessage()
  Generates a string for one or more orders to be placed on exchange using Alertatron
  Returns: string to be passed to Alertatron

getTrailingStopAlertMessage()
  Generates a string for the alert message needed to trail the best price a certain distance
  Returns: string to be passed to Alertatron
Phát hành các Ghi chú
v48
Phát hành các Ghi chú
v49
Phát hành các Ghi chú
v50

Updated:
getLadderInSteps()
  Constructs arrays used for creating strategy entry orders via a for loop
  Returns: array of ladder entry prices and amounts based on total amount you want to invest across all ladder rungs and either a range between ladderStart and LadderStop based on specificed number of ladderRungs OR ladderStart, ladderRungs, and LadderSpacingPercent
Phát hành các Ghi chú
v51
Phát hành các Ghi chú
v52

Updated:
getLadderOutSteps()
  Constructs arrays used for creating strategy exit orders via a for loop
  Returns: array of ladder entry prices and amounts based on total amount you want to invest across all ladder rungs and either a range between ladderStart and LadderStop based on specificed number of ladderRungs OR ladderStart, ladderRungs, and LadderSpacingPercent
Phát hành các Ghi chú
v53
Phát hành các Ghi chú
v54
Phát hành các Ghi chú
v55
Phát hành các Ghi chú
v56
Phát hành các Ghi chú
v57
Phát hành các Ghi chú
v58
Phát hành các Ghi chú
v59
Merged all of the Alertatron alert message functions into a single one.
Phát hành các Ghi chú
v60

Removed old functions not being used anymore
Phát hành các Ghi chú
v61

trying to fix a bug.
Phát hành các Ghi chú
v62

Added:
taGetDirectionalIndex()
  Calculates the Directional Index based on a DI Length
  Returns: directional index (float)
Phát hành các Ghi chú
v64

Added:
getAlertatronMarketEntryMessage()
  Generates Alertatron alert message for a market entry
  Returns: string of instructions for Alertatron to market enter
side, amount, position, reduceOnly) =>

getAlertatronMarketExitMessage()
  Generates Alertatron alert message for a market exit
  Returns: string of instructions for Alertatron to market close a position
Phát hành các Ghi chú
v65

Fixed the offset and limit offset.
Phát hành các Ghi chú
v66

Added:
taGetExtremes()
  Calculates and average, min, and max for provided series using a lookback period and sample size
  Returns: Min, Max, and Average values

getLeveragedPercentAmount()
  Calulates the amount for an etnry based on leverage and percent of account you want to use
  Returns: float
Phát hành các Ghi chú
v67

Updating library to fix issue where using "Percent of Account" and leverage don't use correct quantity on bybit.
Phát hành các Ghi chú
v68

Hotfix for leverage percent calulation.

Removed:
getLeveragedPercentAmount()
  Calulates the amount for an etnry based on leverage and percent of account you want to use
Phát hành các Ghi chú
v69

Hot fix to fix issue where Stop limit and stop limit offset were reversed on the exchange.
Phát hành các Ghi chú
v70

removing adjustment of lot size so we can use the standard lot size input in a strategy.
Phát hành các Ghi chú
v71

Update Alertatron Market orders to include tags for the pair and cancel any existing orders before placing new ones.

Fixes issue where conditional orders were left on the exchange.
Phát hành các Ghi chú
v74

Added:
convertTimeframeToString()
Phát hành các Ghi chú
v75

Added Support/Resistance functions to the lib.
Phát hành các Ghi chú
v76
small update to the S/R function names.
Phát hành các Ghi chú
v77

Added:
taGetPercentDif()
  Calculate the percent difference between two numbers
@retunrs the percentage difference between the two numbers
Phát hành các Ghi chú
v78

Updated:
taGetDirectionalIndex()
  Calculates the Plust and Minus Directional Index and the distance betwen the two
  Returns: The value of DI Plus, DI Minus, & Distance between them
Phát hành các Ghi chú
v79

Updated convertTimeframeToString() to support current chart timeframe
Phát hành các Ghi chú
v80

Added:
getAlertatronAlertMessageMarketClosePercentOfPosition()
Phát hành các Ghi chú
v81
Includes a function to get the entry amount and contract count for TradingView Strategies and alert messages to Alertatron.
Added:
getLotSize()
Phát hành các Ghi chú
v82
Added function to get Alertatron pair override provided in strategy settings.

Added:
getPairOverrides()
Phát hành các Ghi chú
Fixed the overloaded function issue that was introduced with the latest version of Pine.
Phát hành các Ghi chú
v84

Fixed a bug that was introduced when TV added the "P" to the end of "USDT.P" recently.
Phát hành các Ghi chú
v85

Fixed the getChartSymbol() function by adding support for "USDT.P"
Phát hành các Ghi chú
v86

Base Currency Bug fix
Phát hành các Ghi chú
v87

Adding support for USD.P currency.
Phát hành các Ghi chú
v88

Fixing issue where traditional stocks don't work because they don't have a base currency listed as part of the pair.
Phát hành các Ghi chú
v89

Added:
getAlertatronOcoMessage()
  Generates Alertatron alert message for a market entry with a stop loss and profit target
  Returns: string of instructions for Alertatron to create an OCO order
Phát hành các Ghi chú
v90
Fixed stop stopLimitOffset in getStop when using "price" as the type.
Phát hành các Ghi chú
v91

Added:
taGetSmoothedVwap()
Phát hành các Ghi chú
v92

Updated:
- getAlertatronMarketEntryMessage()
- getAlertatronMarketExitMessage()

Changes:
- Functions now require a "strategyKey" to be passed which is used to add additional clarity to the tagging structure. This allows multiple strategies to share a single account on the same trading pair.
Phát hành các Ghi chú
v95

Added:
wavetrend(source, channelLength, avg, movingAverageLength, oversoldLevel, overboughtLevel)
  Calculates Wavetrend
  Parameters:
    source
    channelLength
    avg
    movingAverageLength
    oversoldLevel
    overboughtLevel
  Returns: Tupple [waveTrend1, waveTrend2, wtOversold, wtOverbought, wtCross, wtCrossUp, wtCrossDown]
automationdebuggingformattinglibrarystrategies

Thư viện Pine

Theo tinh thần TradingView thực sự, tác giả đã xuất bản mã Pine này dưới dạng thư viện nguồn mở để các lập trình viên Pine khác trong cộng đồng của chúng tôi có thể sử dụng lại. Chúc mừng tác giả! Bạn có thể sử dụng thư viện này riêng tư hoặc trong các bài đăng nguồn mở khác. Tuy nhiên, bạn cần sử dụng lại mã này theo Quy tắc nội bộ.


Ngoài ra, trên:

Thông báo miễn trừ trách nhiệm