TradingView Strategy Alert Webhook that buys and sells crypto with the Binance API This script work on both one-way mode and Hegde mode.
Open Position can use "$20" or "@0.02" for determined size In my case I can use "@xxx" as VXD auto calculate size
{"side":"OpenShort","amount":"@0.006","symbol":"BTCUSDTPERP","passphrase":"1234","leverage":"125"}
- API_KEY = your api key
- API_SECRET = your api secret key
- LINE_TOKEN = your Line-notify token can be genarated @https://notify-bot.line.me/en/
- BOT_NAME = any name
- FREEBALANCE = Min balance for trade(Bot will Halted if FREEBALANCE < Equity)
- SECRET_KEY = your passphrase form tradingview signal
- ORDER_ENABLE = "TRUE" = Enable Bots "FALSE" = Disable Bots
passphrase = input.string(defval='xxxx', title ='Bot Pass',group='═ Bot Setting ═')
leveragex = input.int(125,title='leverage',group='═ Bot Setting ═',tooltip='"NOTHING" to do with Position size',minval=1)
Alert_OpenLong = '{"side": "OpenLong", "amount": "@{{strategy.order.contracts}}", "symbol": "{{ticker}}", "passphrase": "'+passphrase+'","leverage":"'+str.tostring(leveragex)+'"}'
Alert_OpenShort = '{"side": "OpenShort", "amount": "@{{strategy.order.contracts}}", "symbol": "{{ticker}}", "passphrase": "'+passphrase+'","leverage":"'+str.tostring(leveragex)+'"}'
Alert_LongTP = '{"side": "CloseLong", "amount": "@{{strategy.order.contracts}}", "symbol": "{{ticker}}", "passphrase": "'+passphrase+'","leverage":"'+str.tostring(leveragex)+'"}'
Alert_ShortTP = '{"side": "CloseShort", "amount": "@{{strategy.order.contracts}}", "symbol": "{{ticker}}", "passphrase": "'+passphrase+'","leverage":"'+str.tostring(leveragex)+'"}'
message_closelong = '{"side": "CloseLong", "amount": "%100", "symbol": "{{ticker}}", "passphrase": "'+passphrase+'","leverage":"'+str.tostring(leveragex)+'"}'
message_closeshort = '{"side": "CloseShort", "amount": "%100", "symbol": "{{ticker}}", "passphrase": "'+passphrase+'","leverage":"'+str.tostring(leveragex)+'"}'