Skip to content

Build a price-alert list

A price-alert list is a set of price levels you want to know about without watching the chart. This guide shortlists your symbols, checks how they are quoted and when they trade, arms an alert on each level and finishes with a script that rebuilds the whole list in one run.

Tip

Define your credentials in shell variables once. Every interactive command below reuses them, so the steps stay short and the script stays portable.

export CTID=letstrade
export ACC=7654321
export PWD_FILE=$HOME/.ctrader/pwd

1. Shortlist the symbols you want to watch

symbols lists every instrument available on the account. Save the output so you can pick the exact names to use in later steps.

ctrader-cli symbols --ctid=$CTID --pwd-file=$PWD_FILE --account=$ACC > symbols.txt

Use the names exactly as they appear here. A name that does not match returns Unknown symbol name.

2. Read where the shortlist is trading now

prices returns the current bid and ask for several symbols in one call, so you can set levels relative to the live market rather than from memory.

ctrader-cli prices --ctid=$CTID --pwd-file=$PWD_FILE --account=$ACC -q \
    --symbols=EURUSD,GBPUSD,XAUUSD

For a single instrument, price takes --symbol instead.

ctrader-cli price --ctid=$CTID --pwd-file=$PWD_FILE --account=$ACC -q --symbol=EURUSD

3. Confirm how the symbol is quoted

symbol shows one instrument's details, including the number of digits it is quoted to. Match your alert price to those digits so the level you set is the level you meant.

ctrader-cli symbol --ctid=$CTID --pwd-file=$PWD_FILE --account=$ACC -q --symbol=XAUUSD

4. Check when the market is open

sessions lists the trading sessions for a symbol with its open and close times. A level set into a closed session will not be tested until the market reopens, which matters most for metals, indices and anything that pauses over the weekend.

ctrader-cli sessions --ctid=$CTID --pwd-file=$PWD_FILE --account=$ACC -q --symbol=XAUUSD

5. Arm an alert on each level

alert create takes the symbol, the price and the condition that triggers it. Add --message to label the alert so its purpose is obvious when it fires, and --yes to skip the confirmation prompt in a script.

The condition is above or below. Alerts compare the symbol's Bid price with the level you set.

ctrader-cli alert create --ctid=$CTID --pwd-file=$PWD_FILE --account=$ACC -q \
    --symbol=EURUSD --price=1.1050 --condition=above \
    --message="EURUSD breaks range high" --yes

Repeat for each level on each symbol. One alert covers one price on one symbol.

Note

Accepted values: above, below.

6. Review the price-alert list and clear what is stale

alerts prints everything currently armed on the account. Run it after any change to confirm the list matches what you intended.

ctrader-cli alerts --ctid=$CTID --pwd-file=$PWD_FILE --account=$ACC -q

Remove a single alert by its identifier once its level has been hit or the idea behind it has passed.

ctrader-cli alert delete --ctid=$CTID --pwd-file=$PWD_FILE --account=$ACC -q \
    --alert=44556677 --yes

To start from an empty list, all deletes every alert on the account.

ctrader-cli alert delete all yes --ctid=$CTID --pwd-file=$PWD_FILE --account=$ACC -q

Inside the interactive shell, the same command is written as > alert delete all yes.

7. Rebuild the whole price-alert list from a script

Save the sequence as price-alert-list.sh. The script clears the old alerts, arms every level in the PRICE_ALERT_LIST array and prints the result, so one run takes you from any state to the list you defined at the top.

Each entry is a symbol, a price, a condition and a message, separated by |.

#!/usr/bin/env bash
set -euo pipefail

CTID=letstrade
ACC=7654321
PWD_FILE=$HOME/.ctrader/pwd

PRICE_ALERT_LIST=(
    "EURUSD|1.1050|above|EURUSD breaks range high"
    "EURUSD|1.0900|below|EURUSD loses range low"
    "XAUUSD|2400.00|above|Gold at round number"
)

cli() {
    ctrader-cli "$@" --ctid="$CTID" --pwd-file="$PWD_FILE" --account="$ACC" -q
}

# Start from a clean list so the array below is the single source of truth.
cli alert delete all yes

# Arm every level in the price-alert list.
for ENTRY in "${PRICE_ALERT_LIST[@]}"; do
    IFS='|' read -r SYMBOL PRICE CONDITION MESSAGE <<< "$ENTRY"
    echo "Arming $SYMBOL at $PRICE ($CONDITION)"
    cli alert create --symbol="$SYMBOL" --price="$PRICE" \
        --condition="$CONDITION" --message="$MESSAGE" --yes
done

# Confirm what is armed.
cli alerts

Run it with bash price-alert-list.sh whenever your levels change. Because the script deletes every alert before it rebuilds, edit the array rather than adding alerts by hand, or the next run will remove them.

The CLI references lists all available options for the commands used in this workflow.

Warning

cTrader CLI is a tool for trading and automation. It does not provide financial, investment, legal or tax advice. Commands that place or change orders can trigger real trades and result in losses. Verify every command before you run it, test on a demo account first and protect your credentials.