TradeOnReplayDOCSSearch the whole guidetradeonreplay.com

Guide / Scripts

When something looks wrong

Errors show the line number and what went wrong. If there is no error and the picture is not what you expected, check this list.

What you seeWhy, and what to do
A line starts part-way along the chartA lookback such as ta.sma(close, 200) has no value until 200 bars exist. The early bars are na.
Two equal prices are not equalPrices are decimals computed from integer points. Compare with a tolerance: math.abs(a - b) < syminfo.mintick / 2.
Hundreds of labels or lines, then old ones vanishline.new inside a plain statement makes a new one every bar, and the oldest is deleted at the limit. Declare it with var, or delete the old one first.
An array element read gives the wrong thinga[i] is the history operator, not element access. Use a.get(i).
“index out of range” or an empty array errorThe index is outside the array, or you called pop, shift, first or last on an empty one. Check size() first.
“Cannot read 'x': the value is na”The object was never created (var p = na). Create it with Name.new(...) before you read a field.
“There is no method ... for that value”The method is defined for another type, or the value is not what you think. Check the first parameter's type.
“There is no library called ...”The library is not saved, or its library("Name") title differs from the name in the import. Save the library and check the spelling.
“In library 'X', line N: ...”The error is inside the library, not in the script that imports it. Open the library, fix that line, and save.
Add to chart says the script is a libraryLibraries are imported, not added. Save it and write import in an indicator.
A higher-timeframe line is steppedThat is correct. It changes only when a higher-timeframe bar closes. See Other timeframes.
A request.security error about a variableThe expression uses a variable changed with := or declared with var, which cannot be recomputed on the higher timeframe. Put the calculation inside the expression.
A ta.* inside if reads too little historyIts argument changes from bar to bar, so skipped bars cannot be replayed. Call it outside the if and use the result inside.
A drawing is not visibleLabels, lines and boxes do not affect the price scale. One far outside the visible prices is off screen.
Stopped after 500,000 iterationsA loop on one bar never ended or is too large. Check its exit condition.
A value differs from TradingViewSee Where it differs from TradingView: ta.ema seeding, pivots reported late, and ta.kc using an EMA of the true range.