PINE LIBRARY
מעודכן threengine_global_automation_library

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
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
הערות שחרור
v2Added:
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()
הערות שחרור
v3הערות שחרור
v4הערות שחרור
v5Added:
getPriceOfFirstClosedTradeSince()
This gets all closed trades since a provided bar number
@retunrs three arrays: closed trade IDs, closing bar number, and closing price
הערות שחרור
v6Added:
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
הערות שחרור
v7Updated:
getClosedTradeSince()
This gets all closed trades since a provided bar number
@retunrs three arrays: closed trade IDs, closing bar number, and closing price
הערות שחרור
v8Added:
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
הערות שחרור
v9Added:
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.
הערות שחרור
v10Added:
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
הערות שחרור
v11Added:
taGetVwap()
Calculates VWAP based on provided src, anchor, and multiplier
Returns: VWAP, lower band, and upper band
הערות שחרור
v12הערות שחרור
v13הערות שחרור
v14Updated:
taGetVwap()
Calculates VWAP based on provided src, anchor, and multiplier
Returns: VWAP, lower band, and upper band
הערות שחרור
v15Added:
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
הערות שחרור
v16Updated:
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
הערות שחרור
v17Added:
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
הערות שחרור
v18Updated:
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
הערות שחרור
v19Added a forward slash (/) between the symbol and the base currency to match Alertatron formatting.
הערות שחרור
v20הערות שחרור
v21Added:
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.
הערות שחרור
v22Changed ladder lot size to be a standard size for each rung instead of splitting a total amount across the number of rungs.
הערות שחרור
v23Added:
getRateOfChange()
Calulates the rate of change of a series based on a look back length
Returns: the rate of change as a float
הערות שחרור
v24Updated:
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
הערות שחרור
v25Added:
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
הערות שחרור
v26Updated function description.
הערות שחרור
v27Split exchange settings out into two functions to fix a bug.
הערות שחרור
v28Updated getAlertatronExitMessage() to include 'reduceOnly=true' so that the exchange doesn't open a short/long when TV is trying to exit a position.
הערות שחרור
v29update getAlertatronEntryMessage() to include reduceOnly=true on the stop loss.
הערות שחרור
v30Made avgPrice := na when not in a position
הערות שחרור
v31Added:
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
הערות שחרור
v32Added:
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
הערות שחרור
v33Added:
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
הערות שחרור
v34Added:
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
הערות שחרור
v35Added:
formatEntryPrices()
Formats array of entry prices to supported format
Returns: CSV string of properly formated entry prices
הערות שחרור
v36Add getEntryNames() function
הערות שחרור
v37Added:
getEntryNames()
Gets an array of entry names for number of desired entries
Returns: array of entry name strings
הערות שחרור
v38הערות שחרור
v39Updated:
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
הערות שחרור
v40Updated:
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
הערות שחרור
v41הערות שחרור
v42Added "%p" to profitTargetAmounts
הערות שחרור
v43Added \n to end of each alert message part to see if I can force some line breaks in the code.
הערות שחרור
v44הערות שחרור
v45הערות שחרור
v46הערות שחרור
v47Updated:
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
הערות שחרור
v48הערות שחרור
v49הערות שחרור
v50Updated:
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
הערות שחרור
v51הערות שחרור
v52Updated:
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
הערות שחרור
v53הערות שחרור
v54הערות שחרור
v55הערות שחרור
v56הערות שחרור
v57הערות שחרור
v58הערות שחרור
v59Merged all of the Alertatron alert message functions into a single one.
הערות שחרור
v60Removed old functions not being used anymore
הערות שחרור
v61trying to fix a bug.
הערות שחרור
v62Added:
taGetDirectionalIndex()
Calculates the Directional Index based on a DI Length
Returns: directional index (float)
הערות שחרור
v64Added:
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
הערות שחרור
v65Fixed the offset and limit offset.
הערות שחרור
v66Added:
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
הערות שחרור
v67Updating library to fix issue where using "Percent of Account" and leverage don't use correct quantity on bybit.
הערות שחרור
v68Hotfix for leverage percent calulation.
Removed:
getLeveragedPercentAmount()
Calulates the amount for an etnry based on leverage and percent of account you want to use
הערות שחרור
v69Hot fix to fix issue where Stop limit and stop limit offset were reversed on the exchange.
הערות שחרור
v70removing adjustment of lot size so we can use the standard lot size input in a strategy.
הערות שחרור
v71Update 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.
הערות שחרור
v74Added:
convertTimeframeToString()
הערות שחרור
v75Added Support/Resistance functions to the lib.
הערות שחרור
v76small update to the S/R function names.
הערות שחרור
v77Added:
taGetPercentDif()
Calculate the percent difference between two numbers
@retunrs the percentage difference between the two numbers
הערות שחרור
v78Updated:
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
הערות שחרור
v79Updated convertTimeframeToString() to support current chart timeframe
הערות שחרור
v80Added:
getAlertatronAlertMessageMarketClosePercentOfPosition()
הערות שחרור
v81Includes a function to get the entry amount and contract count for TradingView Strategies and alert messages to Alertatron.
Added:
getLotSize()
הערות שחרור
v82Added function to get Alertatron pair override provided in strategy settings.
Added:
getPairOverrides()
הערות שחרור
Fixed the overloaded function issue that was introduced with the latest version of Pine.הערות שחרור
v84Fixed a bug that was introduced when TV added the "P" to the end of "USDT.P" recently.
הערות שחרור
v85Fixed the getChartSymbol() function by adding support for "USDT.P"
הערות שחרור
v86Base Currency Bug fix
הערות שחרור
v87Adding support for USD.P currency.
הערות שחרור
v88Fixing issue where traditional stocks don't work because they don't have a base currency listed as part of the pair.
הערות שחרור
v89Added:
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
הערות שחרור
v90Fixed stop stopLimitOffset in getStop when using "price" as the type.
הערות שחרור
v91Added:
taGetSmoothedVwap()
הערות שחרור
v92Updated:
- 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.
הערות שחרור
v95Added:
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]
ספריית Pine
ברוח TradingView אמיתית, המחבר פרסם את קוד Pine זה כספריית קוד פתוח כך שמתכנתי Pine אחרים מהקהילה שלנו יוכלו לעשות בו שימוש חוזר. כל הכבוד למחבר! אתה יכול להשתמש בספרייה זו באופן פרטי או בפרסומי קוד פתוח אחרים, אך השימוש החוזר בקוד זה בפרסומים כפוף לכללי הבית.
כתב ויתור
המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.
ספריית Pine
ברוח TradingView אמיתית, המחבר פרסם את קוד Pine זה כספריית קוד פתוח כך שמתכנתי Pine אחרים מהקהילה שלנו יוכלו לעשות בו שימוש חוזר. כל הכבוד למחבר! אתה יכול להשתמש בספרייה זו באופן פרטי או בפרסומי קוד פתוח אחרים, אך השימוש החוזר בקוד זה בפרסומים כפוף לכללי הבית.
כתב ויתור
המידע והפרסומים אינם אמורים להיות, ואינם מהווים, עצות פיננסיות, השקעות, מסחר או סוגים אחרים של עצות או המלצות שסופקו או מאושרים על ידי TradingView. קרא עוד בתנאים וההגבלות.