Useful Position Checks
It is always recommended to use testnet/sandbox first!
# 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%
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=3 maxtime=30 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.)
Balance Checks
Spot market (in this example Binance / NEOBTC)
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…
Attention
Always double check that you are using the right syntax/alert!