libKageBotLibrary "libKageBot"
Library of function to generate command strings for bots FrostyBot and Zignally. This version ONLY WORKS WITH FROSTYBOT.
strSize(_sizePercent, _sizeCurrency)
Converts a float to a formated string suitable to position size in percentage or currency. At leaste one parameter must be given
Parameters:
_sizePercent : (float) Position size in percent value. Optional. Default = na. Mandatory if _sizeCurrency is not given.
_sizeCurrency : (float) Position size in currency value. Optional. Default = na. Mandatory if _sizePercent is not given.
Returns: (string) A formated string containing the position size
entry(_bot, _direction, _sizePercent, _sizeCurrency)
Generates a simple entry command string for a bot
Parameters:
_bot : (TradeBot) Previously instancied bot type variable
_direction : (string) Flag to opena long or a short position. Must be either DIRECTION_LONG or DIRECTION_SHORT constant
_sizePercent : (float) Position size in percent value. Optional. Default = na. Mandatory if _sizeCurrency is not given.
_sizeCurrency : (float) Position size in currency value. Optional. Default = na. Mandatory if _sizePercent is not given.
Returns: (string) A string of a simple open position command
exit(_bot, _sizePercent, _sizeCurrency, _reduce)
Generates a simple exit command string for a bot
Parameters:
_bot : (TradeBot) Previously instancied bot type variable
_sizePercent : (float) Position size in percent value. Optional. Default = na. Mandatory if _sizeCurrency is not given.
_sizeCurrency : (float) Position size in currency value. Optional. Default = na. Mandatory if _sizePercent is not given.
_reduce : (bool) Flag to use Ruce Only option on Binance positions. Optional. Default = true
Returns: (string) A string of a simple close position command
cancelAll(_bot)
Generates a command string for a bot that cancels all open orders
Parameters:
_bot : (TradeBot) Previously instancied bot type variable
Returns: (string) A string of a command to cancel all open orders
leverage(_bot, _leverage, _type)
Generates a command string for a bot to set leverage
Parameters:
_bot : (TradeBot) Previously instancied bot type variable
_leverage : (int) The amount of leverage to be used when opening a position. Optional. If does not given, the bot's default will be used
_type : (string) Type of leverage. Must be either LEVERAGE_CROSS or LEVERAGE_ISOLATED. Optional. Default is LEVERAGE_CROSS.
Returns: (string) A string of a simple leverage command
entryLong(_bot, _leverage, _leverageType, _sizePercent, _sizeCurrency)
Generates a complete long entry command string for a bot
Parameters:
_bot : (TradeBot) Previously instancied bot type variable
_leverage : (int) The amount of leverage to be used when opening a position. Optional. If does not given, the bot's default will be used
_leverageType : (string) Type of leverage. Must be either LEVERAGE_CROSS or LEVERAGE_ISOLATED. Optional. Default is LEVERAGE_CROSS.
_sizePercent : (float) Position size in percent value. Optional. Default = na. Mandatory if _sizeCurrency is not given.
_sizeCurrency : (float) Position size in currency value. Optional. Default = na. Mandatory if _sizePercent is not given.
Returns: (string) A string of a complete open long position command
entryShort(_bot, _leverage, _leverageType, _sizePercent, _sizeCurrency)
Generates a complete short entry command string for a bot
Parameters:
_bot : (TradeBot) Previously instancied bot type variable
_leverage : (int) The amount of leverage to be used when opening a position. Optional. If does not given, the bot's default will be used
_leverageType
_sizePercent : (float) Position size in percent value. Optional. Default = na. Mandatory if _sizeCurrency is not given.
_sizeCurrency : (float) Position size in currency value. Optional. Default = na. Mandatory if _sizePercent is not given.
Returns: (string) A string of a complete open short position command
exitPosition(_bot, _sizePercent, _sizeCurrency, _reduce)
Generates a complete close position command string for a bot
Parameters:
_bot : (TradeBot) Previously instancied bot type variable
_sizePercent : (float) Position size in percent value. Optional. Default = na. Mandatory if _sizeCurrency is not given.
_sizeCurrency : (float) Position size in currency value. Optional. Default = na. Mandatory if _sizePercent is not given.
_reduce : (bool) Flag to use Ruce Only option on Binance positions. Optional. Default = true
Returns: (string) A string of a comlete close position command
printBot(_bot, _command)
Print bot's information for debug purposes
Parameters:
_bot : (TradeBot) Previously instancied bot type variable
_command : (string) A command string to be debugged
Returns: Nothing.
Constants
Constants to be used in both in internal and external code
Fields:
SERVER_FROSTBOT : (string) Identifier to FrostyBot
SERVER_ZIGNALY : (string) Identifier to Zignaly
DIRECTION_LONG : (string) Flag to open a long position
DIRECTION_SHORT
LEVERAGE_CROSS : (string) Flag to set leverage to cross
LEVERAGE_ISOLATED : (string) Flag to set leverage to isolated
TradeBot
Bot type to handle its essential information
Fields:
server : (string) Type o server. Must me one of the SERVER_* constant values
id : (string) Id of the account in the server (Stub for FrostyBot or Key to Zignally)
symbol : (string) Symbol of the pair to be negotiated (example: ETH/USDT)
leverage : (int) Leverage coeficient. Default is 1
Buscar en scripts para "bot"
Mizar_LibraryThe "Mizar_Library" is a powerful tool designed for Pine Script™ programmer’s, providing a collection of general functions that facilitate the usage of Mizar’s DCA (Dollar-Cost-Averaging) bot system.
To begin using the Mizar Library, you first need to import it into your indicator script. Insert the following line below your indicator initiation line: import Mizar_Trading/Mizar_Library/1 as mizar (mizar is the chosen alias).
In the import statement, Mizar_Trading.Mizar_Library_v1 refers to the specific version of the Mizar Library you wish to use. Feel free to modify mizar to your preferred alias name.
Once the library is imported, you can leverage its functions by prefixing them with mizar. . This will prompt auto-completion suggestions displaying all the available user-defined functions provided by the Mizar Library.
Now, let's delve into some of the key functions available in the Mizar Library:
DCA_bot_msg(_cmd)
The DCA_bot_msg function accepts an user-defined type (UDT) _cmd as a parameter and returns a string with the complete JSON command for a Mizar DCA bot.
Parameters:
_cmd (bot_params) : ::: User-defined type (UDT) that holds all the necessary information for the bot command.
Returns: A string with the complete JSON command for a Mizar DCA bot.
rounding_to_ticks(value, ticks, rounding_type)
The rounding_to_ticks function rounds a calculated price to the nearest actual price based on the specified tick size.
Parameters:
value (float) : ::: The calculated price as float type, to be rounded to the nearest real price.
ticks (float) : ::: The smallest possible price obtained through a request in your script.
rounding_type (int) : ::: The rounding type for the price: 0 = closest real price, 1 = closest real price above, 2 = closest real price below.
Returns: A float value representing the rounded price to the next tick.
bot_params
Bot_params is an user-defined type (UDT) that represents the parameters required for a Mizar DCA bot.
Fields:
bot_id (series string) : The ID number of your Mizar DCA bot.
api_key (series string) : Your private API key from your Mizar account (keep it confidential!).
action (series string) : The command to perform: "open" (standard) or "close" optional .
tp_perc (series string) : The take profit percentage in decimal form (1% = "0.01") optional .
base_asset (series string) : The cryptocurrency you want to buy (e.g., "BTC").
quote_asset (series string) : The coin or fiat currency used for payment (e.g., "USDT" is standard if not specified) optional .
direction (series string) : The direction of the position: "long" or "short" (only applicable for two-way hedge bots) optional .
To obtain the JSON command string for the alert_function call, you can use the DCA_bot_msg function provided by the library. Simply pass the cmd_msg UDT as an argument and assign the returned string value to a variable.
Here's an example to illustrate the process:
// Import of the Mizar Library to use the included functions
import/Mizar_Trading/Mizar_Library/1 as mizar
// Example to set a variable called “cmd_msg” and all of its parameters
cmd_msg = mizar.bot_params. new()
cmd_msg.action := "open"
cmd_msg.api_key := "top secret"
cmd_msg.bot_id := "9999"
cmd_msg.base_asset := "BTC"
cmd_msg.quote_asset := "USDT"
cmd_msg.direction := "long"
cmd_msg.tp_perc := "0.015"
// Calling the Mizar conversion function named “DCA_bot_msg()” with the cmd_msg as argument to receive the JSON command and save it in a string variable called “alert_msg”
alert_msg = mizar.DCA_bot_msg(cmd_msg)
Feel free to utilize (series) string variables instead of constant strings. By incorporating the Mizar Library into your Pine Script, you gain access to a powerful set of functions and can leverage them according to your specific requirements.
For additional help or support, you can join the Mizar Discord channel. There, you'll find a dedicated Pine Script channel where you can ask any questions related to Pine Script.
TRADINGLibrary "TRADING"
This library is a client script for making a webhook signal formatted string to PoABOT server.
entry_message(password, percent, leverage, margin_mode, kis_number)
Create a entry message for POABOT
Parameters:
password (string) : (string) The password of your bot.
percent (float) : (float) The percent for entry based on your wallet balance.
leverage (int) : (int) The leverage of entry. If not set, your levereage doesn't change.
margin_mode (string) : (string) The margin mode for trade(only for OKX). "cross" or "isolated"
kis_number (int) : (int) The number of koreainvestment account. Default 1
Returns: (string) A json formatted string for webhook message.
order_message(password, percent, leverage, margin_mode, kis_number)
Create a order message for POABOT
Parameters:
password (string) : (string) The password of your bot.
percent (float) : (float) The percent for entry based on your wallet balance.
leverage (int) : (int) The leverage of entry. If not set, your levereage doesn't change.
margin_mode (string) : (string) The margin mode for trade(only for OKX). "cross" or "isolated"
kis_number (int) : (int) The number of koreainvestment account. Default 1
Returns: (string) A json formatted string for webhook message.
close_message(password, percent, margin_mode, kis_number)
Create a close message for POABOT
Parameters:
password (string) : (string) The password of your bot.
percent (float) : (float) The percent for close based on your wallet balance.
margin_mode (string) : (string) The margin mode for trade(only for OKX). "cross" or "isolated"
kis_number (int) : (int) The number of koreainvestment account. Default 1
Returns: (string) A json formatted string for webhook message.
exit_message(password, percent, margin_mode, kis_number)
Create a exit message for POABOT
Parameters:
password (string) : (string) The password of your bot.
percent (float) : (float) The percent for exit based on your wallet balance.
margin_mode (string) : (string) The margin mode for trade(only for OKX). "cross" or "isolated"
kis_number (int) : (int) The number of koreainvestment account. Default 1
Returns: (string) A json formatted string for webhook message.
manual_message(password, exchange, base, quote, side, qty, price, percent, leverage, margin_mode, kis_number, order_name)
Create a manual message for POABOT
Parameters:
password (string) : (string) The password of your bot.
exchange (string) : (string) The exchange
base (string) : (string) The base
quote (string) : (string) The quote of order message
side (string) : (string) The side of order messsage
qty (float) : (float) The qty of order message
price (float) : (float) The price of order message
percent (float) : (float) The percent for order based on your wallet balance.
leverage (int) : (int) The leverage of entry. If not set, your levereage doesn't change.
margin_mode (string) : (string) The margin mode for trade(only for OKX). "cross" or "isolated"
kis_number (int) : (int) The number of koreainvestment account.
order_name (string) : (string) The name of order message
Returns: (string) A json formatted string for webhook message.
in_trade(start_time, end_time, hide_trade_line)
Create a trade start line
Parameters:
start_time (int) : (int) The start of time.
end_time (int) : (int) The end of time.
hide_trade_line (bool) : (bool) if true, hide trade line. Default false.
Returns: (bool) Get bool for trade based on time range.
real_qty(qty, precision, leverage, contract_size, default_qty_type, default_qty_value)
Get exchange specific real qty
Parameters:
qty (float) : (float) qty
precision (float) : (float) precision
leverage (int) : (int) leverage
contract_size (float) : (float) contract_size
default_qty_type (string)
default_qty_value (float)
Returns: (float) exchange specific qty.
method set(this, password, start_time, end_time, leverage, initial_capital, default_qty_type, default_qty_value, margin_mode, contract_size, kis_number, entry_percent, close_percent, exit_percent, fixed_qty, fixed_cash, real, auto_alert_message, hide_trade_line)
Set bot object.
Namespace types: bot
Parameters:
this (bot)
password (string) : (string) password for poabot.
start_time (int) : (int) start_time timestamp.
end_time (int) : (int) end_time timestamp.
leverage (int) : (int) leverage.
initial_capital (float)
default_qty_type (string)
default_qty_value (float)
margin_mode (string) : (string) The margin mode for trade(only for OKX). "cross" or "isolated"
contract_size (float)
kis_number (int) : (int) kis_number for poabot.
entry_percent (float) : (float) entry_percent for poabot.
close_percent (float) : (float) close_percent for poabot.
exit_percent (float) : (float) exit_percent for poabot.
fixed_qty (float) : (float) fixed qty.
fixed_cash (float) : (float) fixed cash.
real (bool) : (bool) convert qty for exchange specific.
auto_alert_message (bool) : (bool) convert alert_message for exchange specific.
hide_trade_line (bool) : (bool) if true, Hide trade line. Default false.
Returns: (void)
method print(this, message)
Print message using log table.
Namespace types: bot
Parameters:
this (bot)
message (string)
Returns: (void)
method start_trade(this)
start trade using start_time and end_time
Namespace types: bot
Parameters:
this (bot)
Returns: (void)
method entry(this, id, direction, qty, limit, stop, oca_name, oca_type, comment, alert_message, when)
It is a command to enter market position. If an order with the same ID is already pending, it is possible to modify the order. If there is no order with the specified ID, a new order is placed. To deactivate an entry order, the command strategy.cancel or strategy.cancel_all should be used. In comparison to the function strategy.order, the function strategy.entry is affected by pyramiding and it can reverse market position correctly. If both 'limit' and 'stop' parameters are 'NaN', the order type is market order.
Namespace types: bot
Parameters:
this (bot)
id (string) : (string) A required parameter. The order identifier. It is possible to cancel or modify an order by referencing its identifier.
direction (string) : (string) A required parameter. Market position direction: 'strategy.long' is for long, 'strategy.short' is for short.
qty (float) : (float) An optional parameter. Number of contracts/shares/lots/units to trade. The default value is 'NaN'.
limit (float) : (float) An optional parameter. Limit price of the order. If it is specified, the order type is either 'limit', or 'stop-limit'. 'NaN' should be specified for any other order type.
stop (float) : (float) An optional parameter. Stop price of the order. If it is specified, the order type is either 'stop', or 'stop-limit'. 'NaN' should be specified for any other order type.
oca_name (string) : (string) An optional parameter. Name of the OCA group the order belongs to. If the order should not belong to any particular OCA group, there should be an empty string.
oca_type (string) : (string) An optional parameter. Type of the OCA group. The allowed values are: "strategy.oca.none" - the order should not belong to any particular OCA group; "strategy.oca.cancel" - the order should belong to an OCA group, where as soon as an order is filled, all other orders of the same group are cancelled; "strategy.oca.reduce" - the order should belong to an OCA group, where if X number of contracts of an order is filled, number of contracts for each other order of the same OCA group is decreased by X.
comment (string) : (string) An optional parameter. Additional notes on the order.
alert_message (string) : (string) An optional parameter which replaces the {{strategy.order.alert_message}} placeholder when it is used in the "Create Alert" dialog box's "Message" field.
when (bool) : (bool) An optional parmeter. Condition, deprecated.
Returns: (void)
method order(this, id, direction, qty, limit, stop, oca_name, oca_type, comment, alert_message, when)
It is a command to place order. If an order with the same ID is already pending, it is possible to modify the order. If there is no order with the specified ID, a new order is placed. To deactivate order, the command strategy.cancel or strategy.cancel_all should be used. In comparison to the function strategy.entry, the function strategy.order is not affected by pyramiding. If both 'limit' and 'stop' parameters are 'NaN', the order type is market order.
Namespace types: bot
Parameters:
this (bot)
id (string) : (string) A required parameter. The order identifier. It is possible to cancel or modify an order by referencing its identifier.
direction (string) : (string) A required parameter. Market position direction: 'strategy.long' is for long, 'strategy.short' is for short.
qty (float) : (float) An optional parameter. Number of contracts/shares/lots/units to trade. The default value is 'NaN'.
limit (float) : (float) An optional parameter. Limit price of the order. If it is specified, the order type is either 'limit', or 'stop-limit'. 'NaN' should be specified for any other order type.
stop (float) : (float) An optional parameter. Stop price of the order. If it is specified, the order type is either 'stop', or 'stop-limit'. 'NaN' should be specified for any other order type.
oca_name (string) : (string) An optional parameter. Name of the OCA group the order belongs to. If the order should not belong to any particular OCA group, there should be an empty string.
oca_type (string) : (string) An optional parameter. Type of the OCA group. The allowed values are: "strategy.oca.none" - the order should not belong to any particular OCA group; "strategy.oca.cancel" - the order should belong to an OCA group, where as soon as an order is filled, all other orders of the same group are cancelled; "strategy.oca.reduce" - the order should belong to an OCA group, where if X number of contracts of an order is filled, number of contracts for each other order of the same OCA group is decreased by X.
comment (string) : (string) An optional parameter. Additional notes on the order.
alert_message (string) : (string) An optional parameter which replaces the {{strategy.order.alert_message}} placeholder when it is used in the "Create Alert" dialog box's "Message" field.
when (bool) : (bool) An optional parmeter. Condition, deprecated.
Returns: (void)
method close_all(this, comment, alert_message, immediately, when)
Exits the current market position, making it flat.
Namespace types: bot
Parameters:
this (bot)
comment (string) : (string) An optional parameter. Additional notes on the order.
alert_message (string) : (string) An optional parameter which replaces the {{strategy.order.alert_message}} placeholder when it is used in the "Create Alert" dialog box's "Message" field.
immediately (bool) : (bool) An optional parameter. If true, the closing order will be executed on the tick where it has been placed, ignoring the strategy parameters that restrict the order execution to the open of the next bar. The default is false.
when (bool) : (bool) An optional parmeter. Condition, deprecated.
Returns: (void)
method cancel(this, id, when)
It is a command to cancel/deactivate pending orders by referencing their names, which were generated by the functions: strategy.order, strategy.entry and strategy.exit.
Namespace types: bot
Parameters:
this (bot)
id (string) : (string) A required parameter. The order identifier. It is possible to cancel an order by referencing its identifier.
when (bool) : (bool) An optional parmeter. Condition, deprecated.
Returns: (void)
method cancel_all(this, when)
It is a command to cancel/deactivate all pending orders, which were generated by the functions: strategy.order, strategy.entry and strategy.exit.
Namespace types: bot
Parameters:
this (bot)
when (bool) : (bool) An optional parmeter. Condition, deprecated.
Returns: (void)
method close(this, id, comment, qty, qty_percent, alert_message, immediately, when)
It is a command to exit from the entry with the specified ID. If there were multiple entry orders with the same ID, all of them are exited at once. If there are no open entries with the specified ID by the moment the command is triggered, the command will not come into effect. The command uses market order. Every entry is closed by a separate market order.
Namespace types: bot
Parameters:
this (bot)
id (string) : (string) A required parameter. The order identifier. It is possible to close an order by referencing its identifier.
comment (string) : (string) An optional parameter. Additional notes on the order.
qty (float) : (float) An optional parameter. Number of contracts/shares/lots/units to exit a trade with. The default value is 'NaN'.
qty_percent (float) : (float) Defines the percentage (0-100) of the position to close. Its priority is lower than that of the 'qty' parameter. Optional. The default is 100.
alert_message (string) : (string) An optional parameter which replaces the {{strategy.order.alert_message}} placeholder when it is used in the "Create Alert" dialog box's "Message" field.
immediately (bool) : (bool) An optional parameter. If true, the closing order will be executed on the tick where it has been placed, ignoring the strategy parameters that restrict the order execution to the open of the next bar. The default is false.
when (bool) : (bool) An optional parmeter. Condition, deprecated.
Returns: (void)
ticks_to_price(ticks, from)
Converts ticks to a price offset from the supplied price or the average entry price.
Parameters:
ticks (float) : (float) Ticks to convert to a price.
from (float) : (float) A price that can be used to calculate from. Optional. The default value is `strategy.position_avg_price`.
Returns: (float) A price level that has a distance from the entry price equal to the specified number of ticks.
method exit(this, id, from_entry, qty, qty_percent, profit, limit, loss, stop, trail_price, trail_points, trail_offset, oca_name, comment, comment_profit, comment_loss, comment_trailing, alert_message, alert_profit, alert_loss, alert_trailing, when)
It is a command to exit either a specific entry, or whole market position. If an order with the same ID is already pending, it is possible to modify the order. If an entry order was not filled, but an exit order is generated, the exit order will wait till entry order is filled and then the exit order is placed. To deactivate an exit order, the command strategy.cancel or strategy.cancel_all should be used. If the function strategy.exit is called once, it exits a position only once. If you want to exit multiple times, the command strategy.exit should be called multiple times. If you use a stop loss and a trailing stop, their order type is 'stop', so only one of them is placed (the one that is supposed to be filled first). If all the following parameters 'profit', 'limit', 'loss', 'stop', 'trail_points', 'trail_offset' are 'NaN', the command will fail. To use market order to exit, the command strategy.close or strategy.close_all should be used.
Namespace types: bot
Parameters:
this (bot)
id (string) : (string) A required parameter. The order identifier. It is possible to cancel or modify an order by referencing its identifier.
from_entry (string) : (string) An optional parameter. The identifier of a specific entry order to exit from it. To exit all entries an empty string should be used. The default values is empty string.
qty (float) : (float) An optional parameter. Number of contracts/shares/lots/units to exit a trade with. The default value is 'NaN'.
qty_percent (float) : (float) Defines the percentage of (0-100) the position to close. Its priority is lower than that of the 'qty' parameter. Optional. The default is 100.
profit (float) : (float) An optional parameter. Profit target (specified in ticks). If it is specified, a limit order is placed to exit market position when the specified amount of profit (in ticks) is reached. The default value is 'NaN'.
limit (float) : (float) An optional parameter. Profit target (requires a specific price). If it is specified, a limit order is placed to exit market position at the specified price (or better). Priority of the parameter 'limit' is higher than priority of the parameter 'profit' ('limit' is used instead of 'profit', if its value is not 'NaN'). The default value is 'NaN'.
loss (float) : (float) An optional parameter. Stop loss (specified in ticks). If it is specified, a stop order is placed to exit market position when the specified amount of loss (in ticks) is reached. The default value is 'NaN'.
stop (float) : (float) An optional parameter. Stop loss (requires a specific price). If it is specified, a stop order is placed to exit market position at the specified price (or worse). Priority of the parameter 'stop' is higher than priority of the parameter 'loss' ('stop' is used instead of 'loss', if its value is not 'NaN'). The default value is 'NaN'.
trail_price (float) : (float) An optional parameter. Trailing stop activation level (requires a specific price). If it is specified, a trailing stop order will be placed when the specified price level is reached. The offset (in ticks) to determine initial price of the trailing stop order is specified in the 'trail_offset' parameter: X ticks lower than activation level to exit long position; X ticks higher than activation level to exit short position. The default value is 'NaN'.
trail_points (float) : (float) An optional parameter. Trailing stop activation level (profit specified in ticks). If it is specified, a trailing stop order will be placed when the calculated price level (specified amount of profit) is reached. The offset (in ticks) to determine initial price of the trailing stop order is specified in the 'trail_offset' parameter: X ticks lower than activation level to exit long position; X ticks higher than activation level to exit short position. The default value is 'NaN'.
trail_offset (float) : (float) An optional parameter. Trailing stop price (specified in ticks). The offset in ticks to determine initial price of the trailing stop order: X ticks lower than 'trail_price' or 'trail_points' to exit long position; X ticks higher than 'trail_price' or 'trail_points' to exit short position. The default value is 'NaN'.
oca_name (string) : (string) An optional parameter. Name of the OCA group (oca_type = strategy.oca.reduce) the profit target, the stop loss / the trailing stop orders belong to. If the name is not specified, it will be generated automatically.
comment (string) : (string) Additional notes on the order. If specified, displays near the order marker on the chart. Optional. The default is na.
comment_profit (string) : (string) Additional notes on the order if the exit was triggered by crossing `profit` or `limit` specifically. If specified, supercedes the `comment` parameter and displays near the order marker on the chart. Optional. The default is na.
comment_loss (string) : (string) Additional notes on the order if the exit was triggered by crossing `stop` or `loss` specifically. If specified, supercedes the `comment` parameter and displays near the order marker on the chart. Optional. The default is na.
comment_trailing (string) : (string) Additional notes on the order if the exit was triggered by crossing `trail_offset` specifically. If specified, supercedes the `comment` parameter and displays near the order marker on the chart. Optional. The default is na.
alert_message (string) : (string) Text that will replace the '{{strategy.order.alert_message}}' placeholder when one is used in the "Message" field of the "Create Alert" dialog. Optional. The default is na.
alert_profit (string) : (string) Text that will replace the '{{strategy.order.alert_message}}' placeholder when one is used in the "Message" field of the "Create Alert" dialog. Only replaces the text if the exit was triggered by crossing `profit` or `limit` specifically. Optional. The default is na.
alert_loss (string) : (string) Text that will replace the '{{strategy.order.alert_message}}' placeholder when one is used in the "Message" field of the "Create Alert" dialog. Only replaces the text if the exit was triggered by crossing `stop` or `loss` specifically. Optional. The default is na.
alert_trailing (string) : (string) Text that will replace the '{{strategy.order.alert_message}}' placeholder when one is used in the "Message" field of the "Create Alert" dialog. Only replaces the text if the exit was triggered by crossing `trail_offset` specifically. Optional. The default is na.
when (bool) : (bool) An optional parmeter. Condition, deprecated.
Returns: (void)
percent_to_ticks(percent, from)
Converts a percentage of the supplied price or the average entry price to ticks.
Parameters:
percent (float) : (float) The percentage of supplied price to convert to ticks. 50 is 50% of the entry price.
from (float) : (float) A price that can be used to calculate from. Optional. The default value is `strategy.position_avg_price`.
Returns: (float) A value in ticks.
percent_to_price(percent, from)
Converts a percentage of the supplied price or the average entry price to a price.
Parameters:
percent (float) : (float) The percentage of the supplied price to convert to price. 50 is 50% of the supplied price.
from (float) : (float) A price that can be used to calculate from. Optional. The default value is `strategy.position_avg_price`.
Returns: (float) A value in the symbol's quote currency (USD for BTCUSD).
bot
Fields:
password (series__string)
start_time (series__integer)
end_time (series__integer)
leverage (series__integer)
initial_capital (series__float)
default_qty_type (series__string)
default_qty_value (series__float)
margin_mode (series__string)
contract_size (series__float)
kis_number (series__integer)
entry_percent (series__float)
close_percent (series__float)
exit_percent (series__float)
log_table (series__table)
fixed_qty (series__float)
fixed_cash (series__float)
real (series__bool)
auto_alert_message (series__bool)
hide_trade_line (series__bool)
libKageMiscLibrary "libKageMisc"
Kage's Miscelaneous library
print(_value)
Print a numerical value in a label at last historical bar.
Parameters:
_value : (float) The value to be printed.
Returns: Nothing.
barsBackToDate(_year, _month, _day)
Get the number of bars we have to go back to get data from a specific date.
Parameters:
_year : (int) Year of the specific date.
_month : (int) Month of the specific date. Optional. Default = 1.
_day : (int) Day of the specific date. Optional. Default = 1.
Returns: (int) Number of bars to go back until reach the specific date.
bodySize(_index)
Calculates the size of the bar's body.
Parameters:
_index : (simple int) The historical index of the bar. Optional. Default = 0.
Returns: (float) The size of the bar's body in price units.
shadowSize(_direction)
Size of the current bar shadow. Either "top" or "bottom".
Parameters:
_direction : (string) Direction of the desired shadow.
Returns: (float) The size of the chosen bar's shadow in price units.
shadowBodyRatio(_direction)
Proportion of current bar shadow to the bar size
Parameters:
_direction : (string) Direction of the desired shadow.
Returns: (float) Ratio of the shadow size per body size.
bodyCloseRatio(_index)
Proportion of chosen bar body size to the close price
Parameters:
_index : (simple int) The historical index of the bar. Optional. Default = 0.()
Returns: (float) Ratio of the body size per close price.
lastDayOfMonth(_month)
Returns the last day of a month.
Parameters:
_month : (int) Month number.
Returns: (int) The number (28, 30 or 31) of the last day of a given month.
nameOfMonth(_month)
Return the short name of a month.
Parameters:
_month : (int) Month number.
Returns: (string) The short name ("Jan", "Feb"...) of a given month.
pl(_initialValue, _finalValue)
Calculate Profit/Loss between two values.
Parameters:
_initialValue : (float) Initial value.
_finalValue : (float) Final value = Initial value + delta.
Returns: (float) Profit/Loss as a percentual change.
gma(_Type, _Source, _Length)
Generalist Moving Average (GMA).
Parameters:
_Type : (string) Type of average to be used. Either "EMA", "HMA", "RMA", "SMA", "SWMA", "WMA" or "VWMA".
_Source : (series float) Series of values to process.
_Length : (simple int) Number of bars (length).
Returns: (float) The value of the chosen moving average.
xFormat(_percentValue, _minXFactor)
Transform a percentual value in a X Factor value.
Parameters:
_percentValue : (float) Percentual value to be transformed.
_minXFactor : (float) Minimum X Factor to that the conversion occurs. Optional. Default = 10.
Returns: (string) A formated string.
isLong()
Check if the open trade direction is long.
Returns: (bool) True if the open position is long.
isShort()
Check if the open trade direction is short.
Returns: (bool) True if the open position is short.
lastPrice()
Returns the entry price of the last openned trade.
Returns: (float) The last entry price.
barsSinceLastEntry()
Returns the number of bars since last trade was oppened.
Returns: (series int)
getBotNameFrosty()
Return the name of the FrostyBot Bot.
Returns: (string) A string containing the name.
getBotNameZig()
Return the name of the FrostyBot Bot.
Returns: (string) A string containing the name.
getTicksValue(_currencyValue)
Converts currency value to ticks
Parameters:
_currencyValue : (float) Value to be converted.
Returns: (float) Value converted to minticks.
getSymbol(_botName, _botCustomSymbol)
Formats the symbol string to be used with a bot
Parameters:
_botName : (string) Bot name constant. Either BOT_NAME_FROSTY or BOT_NAME_ZIG. Optional. Default is empty string.
_botCustomSymbol : (string) Custom string. Optional. Default is empy string.
Returns: (string) A string containing the symbol for the bot. If all arguments are empty, the current symbol is returned in Binance format.
showProfitLossBoard()
Calculates and shows a board of Profit/Loss through the years.
Returns: Nothing.
PineHelperLibrary "PineHelper"
This library provides various functions to reduce your time.
recent_opentrade_entry_bar_index()
get a recent opentrade entry bar_index
Returns: (int) bar_index
recent_closedtrade_entry_bar_index()
get a recent closedtrade entry bar_index
Returns: (int) bar_index
recent_closedtrade_exit_bar_index()
get a recent closedtrade exit bar_index
Returns: (int) bar_index
all_opnetrades_roi()
get all aopentrades roi
Returns: (float) roi
bars_since_recent_opentrade_entry()
get bars since recent opentrade entry
Returns: (int) number of bars
bars_since_recent_closedtrade_entry()
get bars since recent closedtrade entry
Returns: (int) number of bars
bars_since_recent_closedtrade_exit()
get bars since recent closedtrade exit
Returns: (int) number of bars
recent_opentrade_entry_id()
get recent opentrade entry ID
Returns: (string) entry ID
recent_closedtrade_entry_id()
get recent closedtrade entry ID
Returns: (string) entry ID
recent_closedtrade_exit_id()
get recent closedtrade exit ID
Returns: (string) exit ID
recent_opentrade_entry_price()
get recent opentrade entry price
Returns: (float) price
recent_closedtrade_entry_price()
get recent closedtrade entry price
Returns: (float) price
recent_closedtrade_exit_price()
get recent closedtrade exit price
Returns: (float) price
recent_opentrade_entry_time()
get recent opentrade entry time
Returns: (int) time
recent_closedtrade_entry_time()
get recent closedtrade entry time
Returns: (int) time
recent_closedtrade_exit_time()
get recent closedtrade exit time
Returns: (int) time
time_since_recent_opentrade_entry()
get time since recent opentrade entry
Returns: (int) time
time_since_recent_closedtrade_entry()
get time since recent closedtrade entry
Returns: (int) time
time_since_recent_closedtrade_exit()
get time since recent closedtrade exit
Returns: (int) time
recent_opentrade_size()
get recent opentrade size
Returns: (float) size
recent_closedtrade_size()
get recent closedtrade size
Returns: (float) size
all_opentrades_size()
get all opentrades size
Returns: (float) size
recent_opentrade_profit()
get recent opentrade profit
Returns: (float) profit
all_opentrades_profit()
get all opentrades profit
Returns: (float) profit
recent_closedtrade_profit()
get recent closedtrade profit
Returns: (float) profit
recent_opentrade_max_runup()
get recent opentrade max runup
Returns: (float) runup
recent_closedtrade_max_runup()
get recent closedtrade max runup
Returns: (float) runup
recent_opentrade_max_drawdown()
get recent opentrade maxdrawdown
Returns: (float) mdd
recent_closedtrade_max_drawdown()
get recent closedtrade maxdrawdown
Returns: (float) mdd
max_open_trades_drawdown()
get max open trades drawdown
Returns: (float) mdd
recent_opentrade_commission()
get recent opentrade commission
Returns: (float) commission
recent_closedtrade_commission()
get recent closedtrade commission
Returns: (float) commission
qty_by_percent_of_equity(percent)
get qty by percent of equtiy
Parameters:
percent : (series float) percent that you want to set
Returns: (float) quantity
qty_by_percent_of_position_size(percent)
get size by percent of position size
Parameters:
percent : (series float) percent that you want to set
Returns: (float) size
is_day_change()
get bool change of day
Returns: (bool) day is change or not
is_in_trade()
get bool using number of bars
Returns: (bool) allowedToTrade
discord_message(name, message)
get json format discord message
Parameters:
name : (string) name of bot
message : (string) message that you want to send
Returns: (string) json format string
telegram_message(chat_id, message)
get json format telegram message
Parameters:
chat_id : (string) chatId of bot
message : (string) message that you want to send
Returns: (string) json format string
DiscordWebhookFunctionLibrary "DiscordWebhookFunction"
discordMarkdown(_str, _italic, _bold, _code, _strike, _under) Convert string to markdown formatting User can combine any function at the same time.
Parameters:
_str : String input
_italic : Italic
_bold : Bold
_code : Code markdown
_strike : Strikethrough
_under : Underline
Returns: string Markdown formatted string.
discordWebhookJSON(_username, _avatarImgUrl, _contentText, _bodyTitle, _descText, _bodyUrl, _embedCol, _timestamp, _authorName, _authorUrl, _authorIconUrl, _footerText, _footerIconUrl, _thumbImgUrl, _imageUrl) Convert data to JSON format for Discord Webhook Integration.
Parameters:
_username : Override bot (webhook) username string / name,
_avatarImgUrl : Override bot (webhook) avatar by image URL,
_contentText : Main content page message,
_bodyTitle : Custom Webhook's embed message body title,
_descText : Webhook's embed message body description,
_bodyUrl : Webhook's embed body direct link URL,
_embedCol : Webhook's embed color,
_timestamp : Timestamp,
_authorName : Webhook's embed author name / title,
_authorUrl : Webhook's embed author direct link URL,
_authorIconUrl : Webhook's embed author icon by image URL,
_footerText : Webhook's embed footer text / title,
_footerIconUrl : Webhook's embed footer icon by image URL,
_thumbImgUrl : Webhook's embed thumbnail image URL,
_imageUrl : Webhook's embed body image URL.
Returns: string Single-line JSON format
POALibrary "POA"
This library is a client script for making a webhook signal formatted string to POABOT server.
entry_message(password, percent, leverage, kis_number)
Create a entry message for POABOT
Parameters:
password : (string) The password of your bot.
percent : (float) The percent for entry based on your wallet balance.
leverage : (int) The leverage of entry. If not set, your levereage doesn't change.
kis_number : (int) The number of koreainvestment account.
Returns: (string) A json formatted string for webhook message.
close_message(password, percent, kis_number)
Create a close message for POABOT
Parameters:
password : (string) The password of your bot.
percent : (float) The percent for close based on your wallet balance.
kis_number : (int) The number of koreainvestment account.
Returns: (string) A json formatted string for webhook message.
exit_message(password, percent)
Create a exit message for POABOT
Parameters:
password : (string) The password of your bot.
percent : (float) The percent for exit based on your wallet balance.
Returns: (string) A json formatted string for webhook message.
in_trade(start_time, end_time)
Create a trade start line
Parameters:
start_time : (int) The start of time.
end_time : (int) The end of time.
Returns: (bool) Get bool for trade based on time range.
FrostyBotLibrary "FrostyBot"
JSON Alert Builder for FrostyBot.js Binance Futures and FTX orders
github.com
More Complete Version Soon.
TODO: Comment Functions and annotations from command reference ^^
TODO: Add additional whitelist and symbol mappings.
leverage()
buy()
sell()
cancelall()
closelong()
closeshort()
traillong()
trailshort()
long()
short()
takeprofit()
stoploss()
TradingHookLibrary "TradingHook"
This library is a client script for making a webhook signal formatted string to TradingHook webhook server.
buy_message(password, amount, order_name) Make a buy Message for TradingHook.
Parameters:
password : (string) password that you set in .env file.
amount : (float) amount. If not set, your strategy qty will be sent.
order_name : (string) order_name. The default name is "Order".
Returns: (string) A string containing the formatted webhook message.
sell_message(password, percent, order_name) Make a sell message for TradingHook.
Parameters:
password : (string) password that you set in .env file.
percent : (string) what percentage of your quantity you want to sell.
order_name : (string) order_name. The default name is "Order".
Returns: (string) A string containing the formatted webhook message.
You can use TradingHook WebServer open source code in github(github.com)