Function

Run custom logic

Configuration

typescript
// Your code here...

Tools

function_execute

Execute TypeScript code. fetch() is available. Code runs in async IIFE wrapper automatically after TypeScript transpiles to JavaScript. CRITICAL: Write plain statements with await/return, NOT wrapped in functions. For available indicators, use indicator.<ID>(marketSeries) or indicator["<ID>"](marketSeries) with full Historical Data output and an optional object of input-title overrides. Do not define indicator(...) or import pinets/PineTS in this block.

Input

ParameterTypeRequiredDescription
codestringYesRaw TypeScript statements (NOT a function). Code is transpiled to JavaScript and auto-wrapped in async context. MUST use fetch() for HTTP (NOT xhr/axios/request libs). Write like: await fetch(url) then return result. Imports require E2B runtime support. For available indicators, pass the full Historical Data MarketSeries object, not a scalar series like <historical_data.close>. The optional second argument must be an object, for example indicator.RSI(<historical_data>, { Length: 7 }) or indicator["custom-indicator-id"](<historical_data>, { inputs: { Length: 7 } }). Use indicator.list() if the available ID is unknown. Do not import pinets or define indicator(...) directly.

Output

ParameterTypeDescription
resultjsonThe returned value of the code execution.
stdoutstringThe standard output of the code execution

Input

ParameterTypeRequiredDescription
codestringNoTypeScript code to execute
timeoutnumberNoExecution timeout

Output

ParameterTypeDescription
resultjsonReturn value from the executed TypeScript function
stdoutstringConsole log output and debug messages from function execution

Usage Instructions

Write TypeScript or JavaScript statements directly, using await and return without a function wrapper. Python is not supported. Code transpiles to JavaScript and runs in a local VM or an E2B sandbox, according to the deployment's E2B system-service configuration; there is no per-block runtime toggle. The default code timeout is 180 seconds, and workflow limits may end a run sooner. fetch() is available subject to URL restrictions; external imports require E2B runtime support. console.log() is captured in stdout. There is no automatically populated input object: use exact upstream tags such as <api.data>, workflow variables such as <variable.riskLimit>, and environment references such as {{API_KEY}}. For indicators, call await indicator.RSI(<historical_data>, { Length: 7 }) with the full Historical Data output and saved input titles; use indicator.list() to discover available IDs. Do not import PineTS or define an indicator in Function code. Execution errors fail the block and can be handled with an error-path connection.

Notes

  • Category: blocks
  • Type: function