QuaScript DocumentationLanguage guide, engine API, 601 builtins and the preset library · v3.0.0-phase1 mathGenerated from the engine catalog by tools/gen-docs.mjs; do not edit.ConstantsNameValueMeaningmath.e2.718281828459045Euler's number.math.phi1.618033988749895Golden ratio.math.pi3.141592653589793Pi.math.absscript.qsmath.abs(x) -> numAbsolute value.ArgumentKindDefaultNotesxnumrequiredmath.acosscript.qsmath.acos(x) -> numArc cosine.ArgumentKindDefaultNotesxnumrequiredmath.asinscript.qsmath.asin(x) -> numArc sine.ArgumentKindDefaultNotesxnumrequiredmath.atanscript.qsmath.atan(x) -> numArc tangent.ArgumentKindDefaultNotesxnumrequiredmath.atan2script.qsmath.atan2(y, x) -> numAngle of the point (x, y).ArgumentKindDefaultNotesynumrequiredxnumrequiredmath.avg_ofscript.qsmath.avg_of(a, b) -> numMean of 2 .. 16 values.ArgumentKindDefaultNotesanumrequiredbnumrequiredmath.ceilscript.qsmath.ceil(x) -> numSmallest integer >= x.ArgumentKindDefaultNotesxnumrequiredmath.clampscript.qsmath.clamp(x, lo, hi) -> numx limited to [lo, hi].ArgumentKindDefaultNotesxnumrequiredlonumrequiredhinumrequiredmath.coalescescript.qsmath.coalesce(x, fallback) -> anyx, or fallback when x is na.ArgumentKindDefaultNotesxanyrequiredfallbackanyrequiredmath.cosscript.qsmath.cos(x) -> numCosine (radians).ArgumentKindDefaultNotesxnumrequiredmath.equalscript.qsmath.equal(a, b, eps = 1e-9) -> boola - b<= eps.ArgumentKindDefaultNotesanumrequiredbnumrequiredepsnum1e-9math.expscript.qsmath.exp(x) -> nume to the power x.ArgumentKindDefaultNotesxnumrequiredmath.floorscript.qsmath.floor(x) -> numLargest integer <= x.ArgumentKindDefaultNotesxnumrequiredmath.hypotscript.qsmath.hypot(a, b) -> numsqrt(a^2 + b^2).ArgumentKindDefaultNotesanumrequiredbnumrequiredmath.is_nascript.qsmath.is_na(x) -> boolTrue when x is na.ArgumentKindDefaultNotesxanyrequiredmath.lerpscript.qsmath.lerp(a, b, t) -> numa + t * (b - a).ArgumentKindDefaultNotesanumrequiredbnumrequiredtnumrequiredmath.logscript.qsmath.log(x) -> numNatural logarithm (na for x <= 0).ArgumentKindDefaultNotesxnumrequiredmath.log10script.qsmath.log10(x) -> numBase-10 logarithm.ArgumentKindDefaultNotesxnumrequiredmath.maxscript.qsmath.max(a, b) -> numLarger of a and b (na if either is na).ArgumentKindDefaultNotesanumrequiredbnumrequiredmath.minscript.qsmath.min(a, b) -> numSmaller of a and b (na if either is na).ArgumentKindDefaultNotesanumrequiredbnumrequiredmath.normalizescript.qsmath.normalize(x, lo, hi) -> num(x - lo) / (hi - lo).ArgumentKindDefaultNotesxnumrequiredlonumrequiredhinumrequiredmath.powscript.qsmath.pow(x, p) -> numx to the power p.ArgumentKindDefaultNotesxnumrequiredpnumrequiredmath.randomscript.qsmath.random(seed = 0) -> numDeterministic uniform random number in [0, 1), one stream per call site.ArgumentKindDefaultNotesseedint0math.reluscript.qsmath.relu(x) -> nummax(x, 0).ArgumentKindDefaultNotesxnumrequiredmath.roundscript.qsmath.round(x, digits = 0) -> numRound half away from zero to digits decimals.ArgumentKindDefaultNotesxnumrequireddigitsint0math.round_toscript.qsmath.round_to(x, step = asset.tick_size) -> numRound to the nearest multiple of step (default: the tick size).ArgumentKindDefaultNotesxnumrequiredstepnumasset.tick_sizemath.sigmoidscript.qsmath.sigmoid(x) -> numLogistic function 1 / (1 + e^-x).ArgumentKindDefaultNotesxnumrequiredmath.signscript.qsmath.sign(x) -> num-1, 0 or 1.ArgumentKindDefaultNotesxnumrequiredmath.sinscript.qsmath.sin(x) -> numSine (radians).ArgumentKindDefaultNotesxnumrequiredmath.sqrtscript.qsmath.sqrt(x) -> numSquare root (na for x < 0).ArgumentKindDefaultNotesxnumrequiredmath.sum_ofscript.qsmath.sum_of(a, b) -> numSum of 2 .. 16 values.ArgumentKindDefaultNotesanumrequiredbnumrequiredmath.tanscript.qsmath.tan(x) -> numTangent (radians).ArgumentKindDefaultNotesxnumrequiredmath.tanhscript.qsmath.tanh(x) -> numHyperbolic tangent.ArgumentKindDefaultNotesxnumrequiredmath.to_boolscript.qsmath.to_bool(x) -> boolTrue for a non-zero number; na is false.ArgumentKindDefaultNotesxnumrequiredmath.to_degreesscript.qsmath.to_degrees(x) -> numRadians to degrees.ArgumentKindDefaultNotesxnumrequiredmath.to_radiansscript.qsmath.to_radians(x) -> numDegrees to radians.ArgumentKindDefaultNotesxnumrequiredmath.truncscript.qsmath.trunc(x) -> numInteger part (towards zero).ArgumentKindDefaultNotesxnumrequired← stat: statisticscolor →All 81 chaptersGuideGetting startedScript headersLanguage basicsFunctionsStructs, enums and traitsLibrariesParametersRenderingColorsDrawingsCollectionsTime, sessions and dataStrategiesBotsExecution modelBuilding complex analysesAdvancedChart styles by exampleEngineEngine APIPerformanceDiagnosticsReferenceta: technical analysisstat: statisticsmathcolorrender: outputsdraw: drawing objectsarraylistmapgridtablestr: textparam: settingsbarassetintervaltimesessionfeed: other intervalsalertorderexitpositionportfolioriskbook: order book (host data)orderbook (host data)derivative (host data)financial (host data)option pricinganchorshapestyleraysidepanechartaccounthftPresetsEvery chartGalleryLanguage showcasesbookFundamentals and flowsWebGPU StudioMicrostructureTrendlines and levelsMoving averagesMomentumMultiple intervalsLayoutsMarket structureStatisticsTrendVolatilityVolumeVertical panesBotsChart stylesLibrariesStrategies