Example Syntax for BitMEX

Long/Short Signal (unified)

### BitMEX Long/Short ###
 
# Uncomment this to set exchange & symbol (if different from your chart/alert!)
#exchange=bitmex-testnet symbol=xbtusd
 
# Uncomment this for multi accounts (and fill in your accounts)
#parallel=acc1,acc2,acc3
 
# Uncomment this to skip entry if ANY position is already open
#ifpos=abort
 
# Close open positions on the opposite side at market
# ..if no matching position is found, skip the delay and jump to main order
close=[!side] type=market ifnone=main
# Give closing order time to execute
delay=2s
 
# Place main position order at market
# error abort : Abort/skip rest on error (after retries)
# retries 3   : Give up after 3 retries in case of overload
:main
cancel # cancel any open order/stop first
[side]=YOUR_BUY_IN% leverage=YOUR_LEVERAGE type=market error=abort retries=3 #notify=discord:1 
# Give main order time to execute
delay=2s
 
# Add market stop loss order
# expect 1        : Expect to place an order (needed in case main order takes longer to fill)
# error closeside : If we cannot place SL, cancel orders, close position & abort
close=[side] stoploss=[-]YOUR_STOP_LOSS% type=market expect=1 error=closeside retries=10 id=SL #notify=discord:"`SL at   \z` {stop}" 
# Add limit take profit (reduce/close only) order
close=[side] takeprofit=[+]0.5% price=[+]YOUR_TAKE_PROFIT% expect=1 error=closeside retries=10 id=TP #notify=discord:"`TP at   \z` {price}" 

Quantity, leverage, stoploss and takeprofit have to be adjusted to your strategy / personal needs!

Note: For take profit a TP limit closing-order stop is used in the syntax above which is placed without a quantity. This has the advantage of being exempt from “load shedding” on BitMEX as well as always closing the whole position, even if something was added to the position after the first entry. But for a limit closing-order to not fill immediately it has to be placed as a stop order with a trigger price — thus the takeprofit=[+]0.5% which is the offset from your calculated TP price where the stop will trigger. (adjust if necessary; be aware that if the trigger price is set to 0 or omitted to use the current price, the stop will sometimes not trigger at all!)

Attention

Always double check that you are using the right syntax/alert!