When I send this POST using POSTMAN the text 'Hello World' is added to a Google Sheet.
https://script.google.com/macros/s/AKfycbwXdAoAnggrOL2NXhyIi7L2uQKKv4bmZjg_Z67VYi6jUuNp5HmiTw78ARGVZWSHYaM7/exec?gid=2061&Message=Hello World
I have tried to use this as webhook URL in TradingView:
https://script.google.com/macros/s/AKfycbwXdAoAnggrOL2NXhyIi7L2uQKKv4bmZjg_Z67VYi6jUuNp5HmiTw78ARGVZWSHYaM7/exec?
and add the gid and Message as message in the Pine script alert function but without success. I have tried a lot of different ways but nothing gets written to the Google sheet.
if DiffCloseMA > 0
alert ("gid=2061&Message=Buy", alert.freq_once_per_bar)
else if DiffCloseMA < 0
alert ("gid=2061&Message=Sell", alert.freq_once_per_bar)
Have someone solved something similar? Thanks!
EDIT: Got it to work using this script
//@version=5
indicator("My script", overlay = true)
DiffCloseMA = close-ta.sma(close,10)
datanew = '{"Message": "Hello World"}'
if DiffCloseMA > 0
alert (datanew, alert.freq_once_per_bar)
else if DiffCloseMA < 0
alert (datanew, alert.freq_once_per_bar)
plot(ta.sma(close,5))
and this as web hook URL
https://script.google.com/macros/s/AKfycbzqdmXRkOQ5HiBegwKnQMg_kO7o5OFGmdM_aW8IRapSD-5k-wVGLeMG7mAwJ6A/exec
The TradingView server, from which the POST is done, as no authorization to post to your google sheet.
For posting from pinescript, I format my message like this (be carefull it is not a message for a google sheet) :
datanew = '{
"client": client_id,
"apiKey": client_API_Key,
"secretKey": client_Secret_Key,
"command": "batch_cancel_active_order",
"symbol": symbol,
"side": side,
"orderCategory" : orderCategory
}'
alert(datanew, alert.freq_once_per_bar)