How to send a webhook when your condition fires
Your script cannot address an endpoint. Lipi has no webhook function. What a script does is raise an alert; where that alert goes is configured on the platform, outside the script.
So the work in the script is: fire an alert on the right bar, with the message you want delivered.
alert(series string message) → voidalertcondition(series bool condition, const string title, const string message) → voidindicator("Crossover alert", "xalert", true)
fast = talib.sma(close, 10)
slow = talib.sma(close, 30)
bool fired = talib.crossover(fast, slow)
alertcondition(fired, "Fast crossed above slow", "cross-up")
if fired {
alert("Fast crossed above slow")
}
plot(fast, title = "Fast", color = color.blue)
plot(slow, title = "Slow", color = color.orange)Which of the two you want
alert | alertcondition | |
|---|---|---|
| Where you may call it | anywhere, including inside a branch | top level only |
| Message | series string, may change from bar to bar | const string, fixed when the script is compiled |
| What it does | raises an alert as the script runs | declares a condition the platform can offer the reader |
If the message has to carry a number your script worked out on this bar, you
need alert, because only its message is series-form. If you want to hand the
reader a named condition and let them set it up, use alertcondition.
If nothing arrives while you are testing
alert fires at most once per bar, only on realtime bars, and only when the
script is running as an alert. On historical bars it does nothing, so nothing
is raised as the script works through history. That is behaviour, not a fault.
What you cannot do from the script
Address an endpoint, shape a payload, set a retry, authenticate, or place an order. Lipi has no order-placement surface and no strategy construct: what leaves the script is an alert, not an instruction.
See Alerts and Webhooks for algo trading.