This is an old revision of the document!
Useful Position and Order 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 check=pos side=[side] ifopen=abort
# check for open position on opposite side. if open position found → skip rest of the alert check=pos side=[!side] ifopen=abort
# check for open positions, if long found → goto “isLong:”, if short found → goto “isShort:”, if NO position found → skip rest of the alert check=pos iflong=isLong ifshort=isShort ifnone=abort
# 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 check=pos if[side]=sameSide if[!side]=oppositeSide ifnone=abort
# check for open position on any side with profit over 5%, if NONE open or matches → skip rest of the alert check=pos minpnl=5% ifnone=abort
# check for open position on any side with a size of over 25% of the balance, if found → skip rest of the alert check=pos minsize=25% ifopen=abort
# check for order id STARTING with ANY of the listed ids. if found → skip rest of the alert check=order id=SOME_ID,ANOTHER_ID ifopen=abort
# check for order id CONTAINING ANY of the listed ids. if found → skip rest of the alert check=order id=*IDPART1,*IDPART2 ifopen=abort
# check for order id STARTING with ANY of the listed ids. if NOT found → skip rest of the alert check=order id=SOME_ID,ANOTHER_ID ifnone=abort
# 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 check=order id=SOME_ID iffound=retry jumpdelay=-3 maxtime=30 onerror=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 Check
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 do=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!