CS4113
error Values cannot be shared inside a request expression.
#What it means
The expression of a request runs on the requested bars. Shared values belong to the script's own bars on the chart, so share.* cannot run inside a request, also not through a function called from one.
#Typical cause
- A
share.*call inside a function that arequest.tforrequest.marketexpression calls.
#How to fix it
Bring the value back from the request and share it at the top level. See Linking scripts.
#Example
//@chartscript 1
indicator("Daily close")
function dayClose() {
share.event("day_close", { price: close })
return close
}
plot(request.tf("1D", dayClose()), "Daily close")Fixed
//@chartscript 1
indicator("Daily close")
const d = request.tf("1D", close)
share.series("day_close", d, { title: "Last daily close" })
plot(d, "Daily close")