TRADINGVIEW WEBHOOK

Manage your positions and bot from TradingView

Before starting to send signals, ensure you have generated a Mizar API Key. Learn how to do this by reading the instructions here.

Set your TradingView Webhook endpoint to: https://api.mizar.com/api/v1/dca-bots/trading-view/execute-command​

Refer to the following tutorial to learn how to configure your TradingView Webhook.

Each DCA bot has its own unique ID. You can find the IDs in your DCA bot management dashboard here.

Open a new position

Simple Open Signal

This command will initiate the opening of a new BTC/USDT position.

{
   "bot_id": "1",
   "action": "open-position",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "api_key": "<API KEY>"
}

Open a new position and override take-profit settings

This command will trigger the opening of a new position where its take-profit deviation is set at +5% compared to the average entry price.

{
   "bot_id": "1",
   "action": "open-position",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "take_profit_pct": "0.05",
   "api_key": "<API KEY>"
}

Open a new position and override stop-loss settings

This command will trigger the opening of a new position where its stop-loss deviation is set at +5% compared to the average entry price.

{
   "bot_id": "1",
   "action": "open-position",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "stop_loss_pct": "0.05",
   "api_key": "<API KEY>"
}

Open a LONG position (for LONG/SHORT bots)

This command will open a LONG position, BTC/USDT.

{
   "bot_id": "1",
   "action": "open-position",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "api_key": "<API KEY>",
   "side": "long"
}

Open a SHORT position (for LONG/SHORT bots)

This command will open a SHORT position, BTC/USDT.

{
   "bot_id": "1",
   "action": "open-position",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "api_key": "<API KEY>",
   "side": "short"
}

Open a position with target price

This command will open a BTC/USDT position, with base order price set at $42,000. If the order is not completely filled within the expiration time, it will be canceled. If the expiration time is not set, then the default value of 300 seconds will be used.

{
   "bot_id": "1",
   "action": "open-position",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "api_key": "<API KEY>",
   "open_order_price": "42000",
   "open_position_expiration": "10" 
}

Open a position with a reduced size

This command initiates a BTC/USDT position with a base order size that is half of the default size.

  • position_size specifies the relative size of the position compared to the default settings. It accepts values ranging from 0 to 1, where 1 represents 100% of the default size.

{
   "bot_id": "1",
   "action": "open-position",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "api_key": "<API KEY>",
   "position_size": "0.5"
}

Open a position with market at expiration option

This command will open a BTC/USDT position, with base order price set at $42,000. A market order will be executed if the order is not filled within the expiration time.

{
   "bot_id": "1",
   "action": "open-position",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "api_key": "<API KEY>",
   "position_size": "0.5",
   "open_order_price": "42000",
   "open_position_expiration": "10",
   "market_at_expiration: "true"
}

Open a position with aggressive limit order control

When opening a position, you have the option to fine-tune how your limit entry order is placed within the market spread. This is particularly useful for executing trades with a level of aggressiveness that matches your trading strategy, while also incorporating safeguards against excessive market spread.

  • Spread Aggressiveness (spread_aggressiveness): This setting allows you to define the aggressiveness of your limit order placement within the current market spread. A value of 0 aims for the least aggressive placement, targeting the best bid price for buys, which can help in minimizing the cost of entry. A value of 1 targets the most aggressive placement, aiming for the best ask price, which can be beneficial in fast-moving markets where getting the position filled is a priority over the entry cost.

  • Maximum Deviation from Best Price (max_deviation_from_best_price): To protect against the risk of entering a position at an unfavorable price in markets with a wide spread, this setting limits how far from the best available price your order can be placed. It's defined as a percentage of the best price, ensuring that your order remains within a reasonable range of current market prices.

{
   "bot_id": "1",
   "action": "open-position",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "api_key": "<API KEY>",
   "position_size": "0.5",
   "market_at_expiration: "true"
   "spread_aggressiveness: "1",
   "max_deviation_from_best_price: "0.01",
}

Close Positions

This commands will allow you to close your DCA bot positions.

Close Position

This commands will close the BTC/USDT position. In this case, it'll execute a sell order.

{
   "bot_id": "1",
   "action": "close-position",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "api_key": "<API KEY>"
   "side": "long"
}

Close LONG Position (for LONG/SHORT bots)

This commands will close the BTC/USDT LONG position.

{
   "bot_id": "1",
   "action": "close-position",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "api_key": "<API KEY>"
   "side": "long"
}

Close SHORT Position (for LONG/SHORT bots)

This commands will close the BTC/USDT SHORT position.

{
   "bot_id": "1",
   "action": "close-position",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "api_key": "<API KEY>"
   "side": "short"
}

Close All Positions

This command will close all the bot open positions.

{
   "bot_id": "1",
   "action": "close-all-positions",
   "api_key": "<API KEY>"
}

Stop Bot and Close All Positions

This command will close all the bot open positions and stop the bot.

{
   "bot_id": "1",
   "action":  "stop-bot-and-close-all-positions",
   "api_key": "<API KEY>"
}

Add funds

With the add funds function, you can add more orders to your currently open position. The size is a percentage of the base order size and can be larger than 1 (e.g. if size is 1 and the filled base order of the is 0.001 BTC then the add funds will be of 0.001 BTC).

Add funds to a LONG position

If the base order filled amount is 0.001 BTC, this will open an additional order of 0.002 BTC to the current open BTC/USDT position.

{
   "bot_id": "1",
   "action": "add-funds",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "size": "2",
   "api_key": "<API KEY>",
   "side": "long"
}

Alternatively, in the case of trading with extremely volatile assets or if your position size is variable, you might prefer to use the argument bo_settings_size that is the relative quote asset value of the BO subscription settings So if the BO size of the subscription is 10 USDT and bo_settings_size is 2, then the add funds order will be 20 USDT.

{  
   "bot_id": "1",
   "action": "add-funds",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "bo_settings_size": "2",
   "api_key": "<API KEY>",
   "side": "long"
}

Add Funds with limit order

If the base order is set a 0.001 BTC, this will open an additional limit order (at $42,000 price) of 0.002 BTC to the current open BTC/USDT position.

{
   "bot_id": "1",
   "action": "add-funds",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "size": "2",
   "price": "42000",
   "api_key": "<API KEY>",
   "side": "long"
}

Add Funds with client id

If you want to add an order identifier, you can add client_id to the request. The client_idis a string of max length 36 that can be used in case you want to cancel specific add funds orders.

{
   "bot_id": "1",
   "action": "add-funds",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "size": "2",
   "price": "42000",
   "api_key": "<API KEY>",
   "side": "long",
   "client_id": "my order identifier"
}

Cancel add funds orders

You can cancel all the open add funds orders associated with an open position.

{
   "bot_id": "1",
   "action": "cancel-all-api-add-funds-orders",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "api_key": "<API KEY>",
   "side": "long"
}

Cancel add funds orders with client order ids

You can select up to 10 specific add funds orders to cancel with the argument client_ids

{
   "bot_id": "1",
   "action": "cancel-all-api-add-funds-orders",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "api_key": "<API KEY>",
   "side": "long",
   "client_ids": ["my client order id 1", "my client order id 2"]
}

Cancel add funds orders with client order ids with failure if any client id is not found

In case you want to raise an error when client_ids are not found among the add funds orders, then you can set the argument fail_if_ids_not_found to true.

{
   "bot_id": "1",
   "action": "cancel-all-api-add-funds-orders",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "api_key": "<API KEY>",
   "side": "long",
   "client_ids": ["my client order id 1", "my client order id 2"],
   "fail_if_ids_not_found": "true"
}

Remove funds

With the remove funds function, you can remove funds to your currently open position, by partially closing the position. The size can be expressed as a percentage of the base order size, or as a percentage of the total position size.

Remove funds based on base order size

This command will open a sell order of 100% the base order size.

{
   "bot_id": "1",
   "action": "remove-funds",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "size": "1",
   "api_key": "<API KEY>",
   "side": "long"
}

Remove funds based on the position size

This command will open a sell order of 20% of the position size.

{
   "bot_id": "1",
   "action": "remove-funds",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "position_size": "0.2",
   "api_key": "<API KEY>",
   "side": "long"
}

Remove funds based on the position size with limit order

This command will open a sell order (at $42,000 price) of 20% of the position size.

{
   "bot_id": "1",
   "action": "remove-funds",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "position_size": "0.2",
   "price": "42000",
   "api_key": "<API KEY>",
   "side": "long"
}

Remove Funds with client id

If you want to add an order identifier, you can add client_id to the request. The client_idis a string of max length 36 that can be used in case you want to cancel specific add funds orders.

{
   "bot_id": "1",
   "action": "remove-funds",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "size": "2",
   "price": "42000",
   "api_key": "<API KEY>",
   "side": "long",
   "client_id": "my order identifier"
}

Cancel remove funds orders

You can cancel all the open add funds orders associated with an open position.

{
   "bot_id": "1",
   "action": "cancel-all-api-remove-funds-orders",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "api_key": "<API KEY>",
   "side": "long"
}

Cancel remove funds orders with client order ids

You can select up to 10 specific remove funds orders to cancel with the argument client_ids

{
   "bot_id": "1",
   "action": "cancel-all-api-remove-funds-orders",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "api_key": "<API KEY>",
   "side": "long",
   "client_ids": ["my client order id 1", "my client order id 2"]
}

Cancel remove funds orders with client order ids with failure if any client id is not found

In case you want to raise an error when client_ids are not found among the remove funds orders, then you can set the argument fail_if_ids_not_found to true.

{
   "bot_id": "1",
   "action": "cancel-all-api-remove-funds-orders",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "api_key": "<API KEY>",
   "side": "long",
   "client_ids": ["my client order id 1", "my client order id 2"],
   "fail_if_ids_not_found": "true"
}

Edit Take Profit

This allows you to edit the take profit settings of open positions.

Override deviation

This command will set the take profit of the BTC/USDT position to 5%.

{
   "bot_id": "1",
   "action": "edit-take-profit-pct",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "take_profit_pct": "0.05",
   "api_key": "<API KEY>"
}

Override deviation for LONG position (LONG/SHORT bots)

This command will set the take profit of the BTC/USDT LONG position to 5%.

{
   "bot_id": "1",
   "action": "edit-take-profit-pct",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "take_profit_pct": "0.05",
   "api_key": "<API KEY>",
   "side": "long"
}

Override deviation for SHORT position (LONG/SHORT bots)

This command will set the take profit of the BTC/USDT SHORT position to 5%.

{
   "bot_id": "1",
   "action": "edit-take-profit-pct",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "take_profit_pct": "0.05",
   "api_key": "<API KEY>",
   "side": "short"
}

Edit Take Profit with absolute target price

With this command, you'll set the take profit target price to a defined price ($42,000). If a safety order is hit after the take profit is edited, the take profit will be updated based on the position settings (taking the initial take profit deviation).

{
   "bot_id": "1",
   "action": "edit-take-profit",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "take_profit_price": "42000",
   "api_key": "<API KEY>",
}

Edit Stop Loss

This allows you to edit the stop loss settings of open positions.

Override deviation

This command will set the stop loss of the BTC/USDT position to -5%.

{
   "bot_id": "1",
   "action": "edit-stop-loss-pct",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "stop_loss_pct": "0.05",
   "api_key": "<API KEY>"
}

Set stop loss in absolute price

This command will set the stop loss to 42000.

{
   "bot_id": "1",
   "action": "edit-stop-loss",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "stop_loss_price": "42000",
   "api_key": "<API KEY>"
}

Override deviation for LONG position (LONG/SHORT bots)

This command will set the stop loss of the BTC/USDT LONG position to -5%.

{
   "bot_id": "1",
   "action": "edit-stop-loss-pct",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "stop_loss_pct": "0.05",
   "api_key": "<API KEY>",
   "side": "long"
}

Override deviation for SHORT position (LONG/SHORT bots)

This command will set the stop loss of the BTC/USDT SHORT position to -5%.

{
   "bot_id": "1",
   "action": "edit-stop-loss-pct",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "stop_loss_pct": "0.05",
   "api_key": "<API KEY>",
   "side": "short"
}

Edit Safety Orders

This allows you to edit the safety order settings of open positions.

Shift Safety Order Price

This command will set the next safety order price of the BTC/USDT position to $42,000.

{
   "bot_id": "1",
   "action": "shift-safety-orders",
   "safety_orders_start_price": "42000",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "api_key": "<API KEY>"
}

Shift Safety Order Price for LONG Position (LONG/SHORT bot)

This command will set the next safety order price of the BTC/USDT LONG position to $42,000.

{   
   "bot_id": "1",
   "action": "shift-safety-orders",
   "safety_orders_start_price": "42000",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "api_key": "<API KEY>",
   "side": "long"
}

Shift Safety Order Price for SHORT Position (LONG/SHORT bot)

This command will set the next safety order price of the BTC/USDT SHORT position to $42,000.

{   
   "bot_id": "1",
   "action": "shift-safety-orders",
   "safety_orders_start_price": "42000",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "api_key": "<API KEY>",
   "side": "long"
}

Execute the First Available Safety Order as a Market Order

This command will override the safety order deviation settings and execute the first safety order available as a market order.

{
   "bot_id": "1",
   "action": "shift-safety-orders",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "api_key": "<API KEY>"
}

Open position or activate safety order

This command will either open a position if a position for that symbol side is not yet active; otherwise will execute the first available safety order at the mark price. All the arguments to open position can be used with this command

{
   "bot_id": "1",
   "action": "open-position-or-activate-safety-order",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "api_key": "<API KEY>"
}

Delay

You can add a delay to every command by simply adding the argument delay. The is is expressed in seconds and the max allowed is 10 sec.

{
   "bot_id": "1",
   "action": "open-position",
   "base_asset": "BTC",
   "quote_asset": "USDT",
   "api_key": "<API KEY>",
   "open_order_price": "10000",
   "delay": "10" 
}

Multiple commands

Our webhook allows you to efficiently execute multiple commands in a single operation. This is particularly useful for scenarios where you need to perform several actions in a sequence without initiating multiple requests.

Endpoint

To utilize this feature, send your requests to the following endpoint:

  • URL: https://api.mizar.com/api/v1/dca-bots/trading-view/execute-commands

Features

  • Batch Operations: Execute up to 10 commands in a single webhook request.

  • Sequential Execution: Commands are processed in the order they are listed, ensuring a smooth and predictable execution flow.

  • Break on Failure: If enabled, the execution process will halt upon encountering any failure, preventing subsequent commands from being executed.

Example

Below is an example payload that demonstrates chaining two commands: open-position and remove-funds.

{"commands": [
    {
        "action": "open-position",
        "base_asset": "BTC",
        "quote_asset": "USDT",
        "open_order_price": "10000"
    },
    {
        
        "action": "remove-funds",
        "base_asset": "BTC",
        "quote_asset": "USDT",
        "position_size": "0.2",
        "price": "42000"
    }
], 
 "break_on_failure": true,
 "api_key": "<API KEY>",
 "bot_id": "1"
}

Break on failure

If there is any failure in executing

Last updated