Useful Position Checks
# check for ANY open position on the account (on ANY market). if open position found → skip rest of the alert ifpos=abort sym=*
Note: For more info on supported filter options and combinations see ➤ Position Filtering!
# check for open position on same side. if open position found → skip rest of the alert ifpos=abort side=[side]
# check for open position on opposite side. if open position found → skip rest of the alert ifpos=abort side=[!side]
# check for open positions, if long found → goto “isLong:”, if short found → goto “isShort:”, if NO position found → skip rest of the alert ifnopos=abort iflong=isLong ifshort=isShort
# variant of the above for a “unified” alert using side placeholders… # if open position on same side found → goto “sameSide”, if open position on the opposite side → goto “oppositeSide”, if NO position found → abort ifnopos=abort if[side]=sameSide if[!side]=oppositeSide
# check for open position on any side with profit over 5%, if NONE open or matches → skip rest of the alert ifnopos=abort minpnl=5%
# check for open position on any side with positive profit (“in profit”), if NONE open or matches → skip rest of the alert ifnopos=abort minpnl=0
# check for open position on any side with negative profit (“underwater”), if NONE open or matches → skip rest of the alert ifnopos=abort maxpnl=0
# check for open position on any side with a size of over 25% of the balance, if found → skip rest of the alert ifpos=abort minsize=25%
# this one-liner will check every sec (for up to 5sec) if a position has been closed completely, # then it will continue → if it wasn't closed within 5sec it will jump/goto to “timedOut:” and continue there ifpos=retry retrydelay=1s maxtime=5s iftime=timedOut
Useful Order Checks
# check for order id STARTING with ANY of the listed ids. if found → skip rest of the alert iforder=abort id=SOME_ID,ANOTHER_ID
# check for order id CONTAINING ANY of the listed ids. if found → skip rest of the alert iforder=abort id=*IDPART1,*IDPART2
# check for order id STARTING with ANY of the listed ids. if NOT found → skip rest of the alert ifnoorder=abort id=SOME_ID,ANOTHER_ID
# this one-liner will check every 3sec (for up to 30sec) if the order with id SOME_ID has been filled completely, # then it will continue → if it wasn't filled within 30sec it will jump/goto to “timedOut:” and continue there iforder=retry id=SOME_ID retrydelay=3s maxtime=30s iftime=timedOut
All of the above can be combined with custom jump marks in ifnone / iffound options, further also the lock and lockcheck commands can be used to place/check for custom made-up symbol names to basically have custom variables that can be set and checked (eg. “flip flop” logic etc.)
Preprocessor Checks
# if it's saturday (6) or sunday (0) → skip rest of the alert [if weekday=6 or weekday=0] abort [end] # rest of the alert…
# if it's before 6am or after 6pm → skip rest of the alert [if time <= 600 or time >= 1800] abort [end] # rest of the alert…
Note: Time based “ignoring” of alerts can also be achieved using the Schedule
option for PV alerts!
Balance Checks
Spot market (in this example Binance / NEOBTC) applies to all Spot markets!
exchange=binance symbol=NEOBTC updatebalance side=sell maxbalance=0 iferror=balancePositive # Note: Use side=buy to check the base currency (in this case BTC) :balanceNegativeOrZero # we have 0 or less balance of NEO abort :balancePositive # we have greater 0 balance of NEO
Margin trading (in this example Bybit / BTCUSDT)
exchange=bybit-testnet symbol=btcusdt # if we have less than 200 (in this case usdt) balance, abort updatebalance minbalance=200 iferror=abort # otherwise (more than 200 usdt) continue here…
To check for relative amount of free balance (free margin):
exchange=binanceft-testnet symbol=btcusdt # if we have less than half of the total margin balance available free, cancel all orders and abort updatebalance minbalance=50% iferror=cancelall # otherwise (more than 50% balance free) continue here…
Note: Depending on the exchange/market you might have to specify the correct symbol depending on which asset balance you want to check!
Attention
Always double check that you are using the right syntax/alert!