Our plans and pricing are changing on 1st November. Learn more...

Automated Trading Cancel Orders

cancel()

which, tag

Attempts to cancel some or all of your open orders. This will only affect orders on the symbol of the command block the cancel() command is in.

Arguments
which required string, one of buy, sell, all, session, tagged. defaults to session

Determine which order to try and cancel. One of the following :-

Which Which orders are cancelled?
which=buy Try and cancel all open Buy orders
which=sell Try and cancel all open Sell orders
which=session Try and cancel all orders opened so far during the current session (orders opened inside the current command block)
which=tagged Find all the orders opened with the given tag (see tag), and cancel them.
which=all Find all open orders on the exchange for the current symbol/ticker and cancel them.
tag optional string,

When which=tagged, this argument indicates the name of the tag to use. Any orders created with the named tag will be cancelled.

Example: Cancel all open orders before starting a new position

myApiKeys(XBTUSD) {
    # cancel everything and close existing positions
    cancel(which=all);
    market(position=0);

    # open a long and place a stop 1% below it
    market(position=50%);
    stopOrder(position=0, offset=e1%, trigger=last);
}

Cancels all outstanding open orders (eg, from earlier trades), then closes the position if there was one. Finally, it opens a long using 50% of your balance and adds a stop loss order 1% below.

Example: Place an order in 10 minutes

myApiKeys(XBTUSD) {
    limit(side=buy, amount=99%, offset=10, tag=allIn)
    wait(duration=30m);
    cancel(which=tagged, tag=allIn)
}

Places a limit order, waits 30 minutes, then tries to cancel only the limit order from the first step. If it's not been filled, or only partially filled, it will be cancelled.

Some images from Unsplash

About Alertatron.com

Your TradingView alerts, with charts, PM'd to you.

Get all your alerts from TradingView, sent to Telegram, Discord, Slack, Email or webhooks, with a chart snapshot attached.

Capture Charts

See a high quality chart with every alert, captured at the moment the alert was triggered. See exactly what the market was doing and make informed decisions.

Automate Trading

Trigger orders on popular cryptocurrency exchanges and trade 24/7. Access powerful algorithmic orders to maximise your profits.

Integrations

Connect your alerts to Telegram (channels, groups and private chats), Discord, Slack, email or send push notifications to other services with webhooks.

Easy To Setup

Nothing to install and no browser extensions. Captures alerts 24/7, even with your computer switched off. Be up and running in seconds.