~~Title: TP & SL Check~~
{{tag>guides}}
==== Send Notification on TP or SL ====
You can use the following syntax in a separate alert that is set to run in intervals!
\\
See below for a screenshot on how to set up the alert in **ProfitView** – adjust interval frequency to taste, be aware of API throttling/ban if running too frequently!
\\
\\
e=BITMEX s=XBTUSD ~~codedoc:clean:### remove this line if you are using separate alerts and the run= command (see end of this page)~~
ifpos=abort iferror=abort ifnone=continue retries=0
#~~codedoc:clean:## change expect=2 into expect=1 if you are only using one SL stop instead of 2 (OCC default: limit + market fallback)~~
check id=*SL retries=0 save expect=2 noorder=done iffound=hadBing
check id=*TP retries=0 save iferror=abort
:hadBong
updatebalance notify=discord:~~codedoc:clean:"~~:red_circle: __**{lastid.1} BONG!**__ :red_circle:\n`Balance: \z` **{balance}**\n~~codedoc:clean:"~~,log:~~codedoc:clean:"~~*** {lastid.1} BONG! ***~~codedoc:clean:"~~:-error
#lock=-1440 ~~codedoc:clean:### uncomment this to lock symbol for 24hrs after bong~~
goto=done
:hadBing
updatebalance notify=discord:~~codedoc:clean:"~~:green_circle: __**{lastid.1} BING!**__ :green_circle:\n`Balance: \z` **{balance}**\n~~codedoc:clean:"~~,log:~~codedoc:clean:"~~*** {lastid.1} BING! ***~~codedoc:clean:"~~:-success
goto=done
:done
cancel
disable=[caller]
\\
{{:syntax:notify:notify-tpsl-alert.png?nolink|}}
\\
\\
**Note:** Don't forget to switch the log option to "Errors Only" after testing to not flood your log unnecessarily!
\\
\\
==== Using the new "run" command ====
\\
Alternatively the checking logic from above can be saved to a separate PV alert that is then referenced only from the interval alerts (for each symbol/account) as pictured below.
\\
This also makes use of the new format to specify all three – exchange, symbol and account – in the account parameter (separated by colon).
\\
\\
{{:syntax:notify:notify-tpsl-alert2.png?nolink|}}
\\
\\
The checking alert (set to run in intervals) is then set to **disabled** and in the alert that does the main entry you use the following syntax at the end to **enable** the ''btcperp-check'' interval alert pictured above:
\\
enable=btcperp-check