Library "Antares" this library contains some utility functions that I use in my open source scripts including moving average helpers, candlstick helpers, money management, formatters, convertors, webhook integration, analysis, filters and drawing helpers
ma(type, length, source) Wraps all ma functions Parameters: type: Either SMA or EMA or RMA or WMA or VWMA length: Number of bars (length). source: Series of values to process. Returns: Moving average of `source` for `length` bars back by the of MA.
bb(ma, length, mult, source) Overwrites `ta.bb` duo to limitations of simple int.float mult. Bollinger Bands. A Bollinger Band is a technical analysis tool defined by a set of lines plotted two standard deviations (positively and negatively) away from a simple moving average (SMA) of the security's price, but can be adjusted to user preferences. Parameters: ma: Either SMA or EMA or RMA or WMA or VWMA length: Number of bars (length). mult: Standard deviation factor. source: Series of values to process. Returns: Bollinger Bands.
atr(length, h, l, c) Overwrites `ta.atr` duo to limitations of simple int length. Function atr (average true range) returns the RMA of true range. True range is max(high - low, abs(high - close[1]), abs(low - close[1])). Parameters: length: Number of bars (length). h: High price high price. l: low price. c: Close price close price. Returns: Average true range.
rsi(length, source) Overwrites `ta.rsi` duo to limitations of simple int length. Relative strength index. It is calculated using the `ta.rma()` of upward and downward changes of `source` over the last `length` bars. Parameters: length: Number of bars (length). source: Series of values to process. Returns: Relative strength index.
lowest(length, source, start) Lowest value for a given number of bars back. Parameters: length: Number of bars (length). source: Series of values to process. start: Series number of bars that should be skipped before process. Returns: Lowest value in the series.
highest(length, source, start) Highest value for a given number of bars back. Parameters: length: Number of bars (length). source: Series of values to process. start: Series number of bars that should be skipped before process. Returns: Highest value in the series.
atr_multiplier(rsi, atr_max_multiplier) Dynamic atr multiplier calculated by RSI. Parameters: rsi: Relative strength index. atr_max_multiplier: The maximum multiplier of atr Returns: Dynamic multiplier of ATR
offset(atr, atr_multiplier) Safe dynamic offset you need to use in your stoploss, stop buy/sell, etc. Parameters: atr: Average true range. atr_multiplier: ATR multiplier got from `atr_multiplier(rsi, atr_max_multiplier)` Returns: Dynamic offset
rsi_emotional(rsi, bottom, top) Tells you if RSI is in emotional zone. Parameters: rsi: Relative Strength Index bottom: The zone that below it market reacts emotionally top: The zone that above it market reacts emotionally Returns: false if RSI was between `bottom` and `top` otherwise true
rsi_signal(rsi, bottom, top) Tells you if RSI is in good point to check your other strategy conditions. Parameters: rsi: Relative Strength Index bottom: The zone that below it market reacts emotionally top: The zone that above it market reacts emotionally Returns: 1 if RSI crossed out 30, 50 or 70. -1 if RSI crossed under 70, 50, 30. otherwise is 0
릴리즈 노트
⋅
v2
Added: body_high(o, c) Parameters: o: Open price c: Close price
body_low(o, c) Parameters: o: Open price c: Close price
is_green(o, c) Parameters: o: Open price c: Close price
is_red(o, c) Parameters: o: Open price c: Close price
body_size(o, c, mintick) Parameters: o: Open price c: Close price mintick: Min tick value for the symbol.
body_percent(o, h, l, c) Parameters: o: Open price h: High price l: Low price c: Close price
top_wick_size(o, h, c, mintick) Parameters: o: Open price h: High price c: Close price mintick: Min tick value for the symbol.
top_wick_percent(o, h, l, c) Parameters: o: Open price h: High price l: Low price c: Close price
bottom_wick_size(o, l, c, mintick) Parameters: o: Open price l: Low price c: Close price mintick: Min tick value for the symbol.
bottom_wick_percent(o, h, l, c) Parameters: o: Open price h: High price l: Low price c: Close price
wick_percent(o, h, l, c) Parameters: o: Open price h: High price l: Low price c: Close price
is_hammer(o, h, l, c, fib, color_match) Parameters: o: Open price h: High price l: Low price c: Close price fib: Fibonachi level color_match: If true then the color of the candle will be checked
is_shooting_star(o, h, l, c, fib, color_match) Parameters: o: Open price h: High price l: Low price c: Close price fib: Fibonachi level color_match: If true then the color of the candle will be checked
is_doji(o, h, l, c, max_body_percent, wick_size) Parameters: o: Open price h: High price l: Low price c: Close price max_body_percent: Max percentage of candle body wick_size: Size of wick
is_whalish(offset, o, c) Parameters: offset: Safe dynamic offset you need to use in your stoploss, stop buy/sell, etc. o: Open price c: Close price
is_bullish_engulfing(o, h, l, c, allowed_gap, allowed_rejection_wick, engulf_wick) Parameters: o: Open price h: High price l: Low price c: Close price allowed_gap: How much gap is allowed allowed_rejection_wick: Max ratio of top wick size on body size engulf_wick: Should it engulf wick of previous candle?
is_bearish_engulfing(o, h, l, c, allowed_gap, allowed_rejection_wick, engulf_wick) Parameters: o: Open price h: High price l: Low price c: Close price allowed_gap: How much gap is allowed allowed_rejection_wick: Max ratio of bottom wick size on body size engulf_wick: Should it engulf wick of previous candle?
bullish_bars(length, o, c, start) Parameters: length: Number of bars (length). o: Open price c: Close price start: Series number of bars that should be skipped before process.
bearish_bars(length, o, c, start) Parameters: length: Number of bars (length). o: Open price c: Close price start: Series number of bars that should be skipped before process.
릴리즈 노트
⋅
v3
Added: trend(light_source, heavy_source, reverse) Parameters: light_source: MA with shorter length heavy_source: MA with longer length reverse: If true then downtrend chart means the price is bullish Returns: 1 if light_source crossed over heavy_source, -1 if crossed under heavy_source, otherwise 0
donchian(length, l, h) Parameters: length: Number of bars (length). l: Low price h: High price
tenkansen(l, h, length) Parameters: l: Low price h: High price length: Number of bars (length).
kijunsen(l, h, length) Parameters: l: Low price h: High price length: Number of bars (length).
senkou_a(tenkansen, kijunsen) Parameters: tenkansen: Conversion Line, is the mid-point of the highest and lowest prices of an asset over the last nine periods. kijunsen: Base line, is an indicator and important component of the Ichimoku Kinko Hyo method of technical analysis
senkou_b(l, h, length) Parameters: l: Low price h: High price length: Number of bars (length).
crossover(heavy_source, light_source, full_enter, full_cross) Parameters: heavy_source: MA with longer length light_source: MA with shorter length full_enter: False means that previous source can be equal or lower than current one, otherwise should be lower full_cross: False means that current source can be equal or greater than previous one, otherwise should be greater
crossunder(heavy_source, light_source, full_enter, full_cross) Parameters: heavy_source: MA with longer length light_source: MA with shorter length full_enter: False means that previous source can be equal or lower than current one, otherwise should be lower full_cross: False means that current source can be equal or greater than previous one, otherwise should be greater
cross(heavy_source, light_source, full_enter, full_cross) Parameters: heavy_source: MA with longer length light_source: MA with shorter length full_enter: False means that previous source can be equal or lower than current one, otherwise should be lower full_cross: False means that current source can be equal or greater than previous one, otherwise should be greater
above_line(line, length, source, start) Parameters: line: Horizontal line that source will be checked with length: Number of bars (length). source: Series of values to process start: Series number of bars that should be skipped before process.
below_line(line, length, source, start) Parameters: line: Horizontal line that source will be checked with length: Number of bars (length). source: Series of values to process start: Series number of bars that should be skipped before process.
crossover_line(line, length, source, start) Parameters: line: Horizontal line that source will be checked with length: Number of bars (length). source: Series of values to process start: Series number of bars that should be skipped before process.
crossunder_line(line, length, source, start) Parameters: line: Horizontal line that source will be checked with length: Number of bars (length). source: Series of values to process start: Series number of bars that should be skipped before process.
cross_line(line, length, source, start) Parameters: line: Horizontal line that source will be checked with length: Number of bars (length). source: Series of values to process start: Series number of bars that should be skipped before process.
bars_crossover_line(line, length, o, c, start) Parameters: line: Horizontal line that source will be checked with length: Number of bars (length). o: Open price c: Close price start: Series number of bars that should be skipped before process.
bars_crossunder_line(line, length, o, c, start) Parameters: line: Horizontal line that source will be checked with length: Number of bars (length). o: Open price c: Close price start: Series number of bars that should be skipped before process.
bars_cross_line(line, length, o, c, start) Parameters: line: Horizontal line that source will be checked with length: Number of bars (length). o: Open price c: Close price start: Series number of bars that should be skipped before process.
릴리즈 노트
⋅
v4
Added: percent(number, precision) the value of `number` percentified to with precision 2 by default Parameters: number: The value to be percentified. precision: Optional argument. Decimal places to which `number` will be rounded. When no argument is supplied, rounding is to the nearest integer. Returns: The value of `number` percentified according to precision.
sl(sl_offset, o, c) Parameters: sl_offset: Comes dynamically from offset(atr, atr_multiplier). But you can use any offset algorithm you want. o: Open price c: Close price
qty(risked_capital, sl_offset) Parameters: risked_capital: What you stand to lose if given stoploss is reached. sl_offset: Comes dynamically from offset(atr, atr_multiplier). But you can use any offset algorithm you want.
amount(qty, entry) Parameters: qty: The size, or quantity, of the asset/coin (not in quote currency) for a position. entry: The price at which you enter the trade.
max_risk(sl_offset, capital, leverage, max_margin, entry) Parameters: sl_offset: Comes dynamically from offset(atr, atr_multiplier). But you can use any offset algorithm you want. capital leverage: The proportion of your trade that will be paid for with borrowed funds. If you are using 2x leverage, you will be funding half of the trade. If you are using 25x leverage you will be funding 1/25 of the trade. max_margin: Max margin entry: The price at which you enter the trade.
risked_capital(risk, max_risk, capital, dynamic) Parameters: risk: The percentage of your total capital you are willing to risk in this trade. max_risk: The maximum risk that your margin allows you to do. capital dynamic: If true, reduces risked capital based on max risk
risked(risked_capital, capital) Parameters: risked_capital: What you stand to lose if given stoploss is reached. capital
tp(sl, ror, entry) Parameters: sl: A price level you can set on a position which will, once reached, close the position and prevent any further loss. ror: The ratio of potential profit of the trade to its potential loss. entry: The price at which you enter the trade.
tp_qty(qty, ror, percent) Parameters: qty: The size, or quantity, of the asset/coin (not currency) for this position. ror: The ratio of potential profit of the trade to its potential loss. percent: The percentage of quantity you're going to take as profit, when the target ROR was reached.
margin(amount, leverage) Parameters: amount: The size of the asset/coin (not in base currency) for a position. leverage: The proportion of your trade that will be paid for with borrowed funds. If you are using 2x leverage, you will be funding half of the trade. If you are using 25x leverage you will be funding 1/25 of the trade.
pnl(exit, qty, short, entry) Parameters: exit: The price at which you exit your trade. Can be referred to as your take profit or "TP". qty: The size, or quantity, of the asset/coin (not currency) for this position. short: A selling position that enables a trader to profit if the price of an asset decreases. entry: The price at which you enter the trade.
risk_reward(risked_capital, pnl) Parameters: risked_capital: What you stand to lose if given stoploss is reached. pnl: Profit and Loss. Shows what you stand to gain or lose with the inputs provided.
roe(pnl, margin) Parameters: pnl: Profit and Loss. Shows what you stand to gain or lose with the inputs provided. margin: Margin is the portion of your own funds that you put into a trade. Keep in mind that depending on what margin mode you are using, your losses may not be limited to this margin.
format_percent(number, fallback) Parameters: number: Number fallback: Fallback, if the value was na
format_pairs(main_value, second_value, title, one_line_value, one_line_pair) Parameters: main_value: The first value second_value: The second value title: The title one_line_value: If true wraps second value with parenthesis and concats it with the main value, otherwise moves it to another line one_line_pair: If true divides the pairs with `:`, otherwise moves the values to another line
_format_quote(source, fallback) Parameters: source: Series of values to process fallback: Fallback, if the value was na
_format_base(source, fallback) Parameters: source: Series of values to process fallback: Fallback, if the value was na
릴리즈 노트
⋅
v5 - Fix atr_multiplier
릴리즈 노트
⋅
v6
Updated: atr_multiplier(rsi, atr_min_multiplier, atr_max_multiplier) Dynamic atr multiplier calculated by RSI. Parameters: rsi: Relative strength index. atr_min_multiplier: The minimum multiplier of atr atr_max_multiplier: The maximum multiplier of atr Returns: Dynamic multiplier of ATR
릴리즈 노트
⋅
v7
Added: sl_size_percent(sl, entry) Parameters: sl: A price level you can set on a position which will, once reached, close the position and prevent any further loss. entry: The price at which you enter the trade.
str_contains(source, substring, case_sensitive) Parameters: source: Source string substring: The substring to search fo case_sensitive: Is it case sensitive? default is false Returns: true if source contains substring
Updated: json(fields, api_key, chart_id, trade_type, tickerid, exchange, base, currency, timeframe) Parameters: fields: Other properties api_key: ApiKey chart_id: Chart ID. You can find it in URL: tradingview.com/chart/{{chartId}} trade_type: Type of the current symbol. Possible values are stock, futures, index, forex, crypto, fund, dr. tickerid exchange: Prefix of current symbol name (i.e. for 'CME_EOD:TICKER' prefix is 'CME_EOD'). base: Base currency for the symbol. For the symbol 'BTCUSD' returns 'BTC'. currency: Currency for the current symbol. Returns currency code: 'USD', 'EUR', etc. timeframe: A string representation of the chart's timeframe. The returned string's format is "[<quantity>][<units>]", where <quantity> and <units> are in some cases absent. <quantity> is the number of units, but it is absent if that number is 1. <unit> is "S" for seconds, "D" for days, "W" for weeks, "M" for months, but it is absent for minutes. No <unit> exists for hours. The variable will return: "10S" for 10 seconds, "60" for 60 minutes, "D" for one day, "2W" for two weeks, "3M" for one quarter. Can be used as an argument with any function containing a `timeframe` parameter.
릴리즈 노트
⋅
v8
Added: get_binance_perp_symbol(group, item, group_items) pagination for binance perpetual symbols. Parameters: group: Group item: Item in each group group_items: Length of group Returns: symbol
릴리즈 노트
⋅
v9
Added: slope_signal(rsi, min_offset, max_offset, offset_check) Tells you if slope of RSI is either ascending or descending Parameters: rsi: Relative Strength Index min_offset: When RSI is either 0 or 100, offset is min_offset max_offset: When RSI is 50, offset is max_offset offset_check: Number of last candles that their offsets should be checked. It should be between 1 and 3
릴리즈 노트
⋅
v11
Added: get_alt_coin_symbol(group, item, group_items) pagination for binance perpetual symbols. Parameters: group (simple int): Group item (simple int): Item in each group group_items (simple int): Length of group Returns: symbol
Removed: get_binance_perp_symbol(group, item, group_items) pagination for binance perpetual symbols.
릴리즈 노트
⋅
v12
Added: percentify(source, length) Turns source to a value between 0 and 100. Parameters: source (float): Series of values to process. length (int): Number of bars (length). Returns: A value between 0 and 100
릴리즈 노트
⋅
v13
Added: signals(signals, status, name, side) Checks all required signals and calculates cumulative score and max score. Parameters: signals (signal[]): Array of signals to be checked. status (string): Either "REQUIRED" or "OPTIONAL" or "IGNORE". name (string): Name of the signal side (int): Either 1 or -1. 1 means "Long", -1 means "Short". If it was na, then side is in the same direct of first signal Returns: A single signal calculated by all the signals passed to
multi_trend_signal(symbol, usd, total2btc, btcusd, altusd, altbtc) Checks usd dominance, total2btc, btcusdt, altusdt and altbtc to see if all of them are verifying the trend. Parameters: symbol (string): Ticker ID. usd (signal): Signal of USD dominance in crypto total2btc (signal): Signal of TOTAL2/BTC in crypto btcusd (signal): Signal of BTC/USD in crypto altusd (signal): Signal of XXX/USD in crypto altbtc (signal): Signal of XXX/BTC in crypto Returns: Single trend signal
rsi_score(rsi, bottom, top) Tells you if RSI is in good point to check your other strategy conditions. Parameters: rsi (float): Relative Strength Index bottom (float): The zone that below it market reacts emotionally top (float): The zone that above it market reacts emotionally Returns: 1 if RSI crossed out 30, 50 or 70. -1 if RSI crossed under 70, 50, 30. otherwise is 0
slope_score(rsi, min_offset, max_offset, offset_check) Tells you if slope of RSI is either ascending or descending Parameters: rsi (float): Relative Strength Index min_offset (float): When RSI is either 0 or 100, offset is min_offset max_offset (float): When RSI is 50, offset is max_offset offset_check (int): Number of last candles that their offsets should be checked. It should be between 1 and 3
size_percent(source_start, source_end) Parameters: source_start (float): The value of the source in the beginning of the change source_end (float): The value of the source in the end of the change Returns: pecent of change
tp_by_limit(mm, limit, percent, enabled) Parameters: mm (mm): Money Management onject limit (float): The price that position should be closed at. percent (float): The percentage of quantity you're going to take as profit, when the target ROR was reached. enabled (bool): True when you dont want set tp Returns: tp object
tp_by_ror(mm, ror, percent, enabled) Parameters: mm (mm): Money Management onject ror (float): The ratio of potential profit of the trade to its potential loss. percent (float): The percentage of quantity you're going to take as profit, when the target ROR was reached. enabled (bool): True when you dont want set tp Returns: tp object
get_btc_pair_symbol(basecurrency) returns btc pair of the current chart Parameters: basecurrency (simple string) Returns: symbol
signal Fields: score (series__integer) max_score (series__integer) status (series__string) name (series__string) subsignals (array__|signal|#OBJ)
Updated: max_risk_percent(sl_size, capital, leverage, max_risk_percent, entry) Parameters: sl_size (float): Comes dynamically from offset(atr, atr_multiplier). But you can use any offset algorithm you want. capital (float): The total amount of capital in your trading account. leverage (int): The proportion of your trade that will be paid for with borrowed funds. If you are using 2x leverage, you will be funding half of the trade. If you are using 25x leverage you will be funding 1/25 of the trade. max_risk_percent (float): Max margin entry (float): The price at which you enter the trade.
risked_capital(risk, max_risk_percent, capital, dynamic) Parameters: risk (float): The percentage of your total capital you are willing to risk in this trade. max_risk_percent (float): The maximum risk that your margin allows you to do. capital (float): The total amount of capital in your trading account. dynamic (bool): If true, reduces risked capital based on max risk
Removed: rsi_signal(rsi, bottom, top) Tells you if RSI is in good point to check your other strategy conditions.
slope_signal(rsi, min_offset, max_offset, offset_check) Tells you if slope of RSI is either ascending or descending
sl_size_percent(sl, entry)
tp_limit(sl, ror, entry)
tp_base_qty(base_qty, ror, percent)
tp(sl, base_qty, ror, percent, enabled, entry)
릴리즈 노트
⋅
v14
릴리즈 노트
⋅
v16
Updated: multi_trend_signal(symbol, usd, total2btc, btcusd, altusd, altbtc, multiplier) Checks usd dominance, total2btc, btcusdt, altusdt and altbtc to see if all of them are verifying the trend. Parameters: symbol (string): Ticker ID. usd (signal): Signal of USD dominance in crypto total2btc (signal): Signal of TOTAL2/BTC in crypto btcusd (signal): Signal of BTC/USD in crypto altusd (signal): Signal of XXX/USD in crypto altbtc (signal): Signal of XXX/BTC in crypto multiplier (float) Returns: Single trend signal
릴리즈 노트
⋅
v17
Added: risk(signal, full_risk_percent, full_risk_min_ratio, half_risk_min_ratio, quarter_risk_min_ratio, one_eight_risk_min_ratio) Handles risk management for your strategies Parameters: signal (signal): Signal object full_risk_percent (float): What should be risk percent at it's maximum value? full_risk_min_ratio (float): What should be minimum of signal score ratio to use full_risk_percent half_risk_min_ratio (float): What should be minimum of signal score ratio to use half_risk_percent quarter_risk_min_ratio (float): What should be minimum of signal score ratio to use quarter_risk_percent one_eight_risk_min_ratio (float): What should be minimum of signal score ratio to use one_eight_risk_percent Returns: risk_percent arg of money_mangament function
format_signal(signal, with_name, with_sign) Parameters: signal (signal): Signal with_name (bool): If true prints name of the signal as well with_sign (bool): If true prints negative sign for short signals
Updated: risked_capital(risk_percent, max_risk_percent, capital, dynamic) Parameters: risk_percent (float) max_risk_percent (float): The maximum risk that your margin allows you to do. capital (float): The total amount of capital in your trading account. dynamic (bool): If true, reduces risked capital based on max risk
money_management(sl, capital, risk_percent, entry, leverage, max_margin) Calculates everything related to money management Parameters: sl (float): A price level you can set on a position which will, once reached, close the position and prevent any further loss. capital (float): The total amount of capital in your trading account. risk_percent (float): The percentage of your total capital you are willing to risk in this trade. entry (float): The price at which you enter the trade. leverage (int): The proportion of your trade that will be paid for with borrowed funds. If you are using 2x leverage, you will be funding half of the trade. If you are using 25x leverage you will be funding 1/25 of the trade. max_margin (float): Max margin percentage Returns: mm object