TRADINGVIEW WEBHOOK
Manage your positions and bot from TradingView
Last updated
Manage your positions and bot from TradingView
Last updated
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.
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>"
}
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>"
}
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>"
}
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"
}
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"
}
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"
}
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"
}
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"
}
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",
}
This commands will allow you to close your DCA bot positions.
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"
}
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"
}
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"
}
This command will close all the bot open positions.
{
"bot_id": "1",
"action": "close-all-positions",
"api_key": "<API KEY>"
}
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>"
}
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).
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"
}
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"
}
If you want to add an order identifier, you can add client_id
to the request. The client_id
is 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"
}
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"
}
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"]
}
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"
}
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.
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"
}
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"
}
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"
}
If you want to add an order identifier, you can add client_id
to the request. The client_id
is 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"
}
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"
}
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"]
}
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"
}
This allows you to edit the take profit settings of open positions.
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>"
}
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"
}
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"
}
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>",
}
This allows you to edit the stop loss settings of open positions.
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>"
}
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>"
}
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"
}
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"
}
This allows you to edit the safety order settings of open positions.
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>"
}
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"
}
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"
}
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>"
}
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>"
}
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"
}
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.
To utilize this feature, send your requests to the following endpoint:
URL: https://api.mizar.com/api/v1/dca-bots/trading-view/execute-commands
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"
}
If there is any failure in executing