Mizar_trading

Mizar_Library

The "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.

Pine脚本库

本着真正的TradingView精神,作者将此Pine代码以开源脚本库发布,以便我们社区的其他Pine程序员可以重用它。向作者致敬!您可以私下或在其他开源出版物中使用此库,但在出版物中重用此代码受网站规则约束。

免责声明

这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。

想使用这个脚本库吗?

复制以下行并将其粘贴到您的脚本中。