SR_Line l = array.get(supportLines, i) 에서 Error on bar 0: In 'array.get()' function.…
- User
SR_Line l = array.get(supportLines, i) 에서 Error on bar 0: In 'array.get()' function. Index 0 is out of bounds, array size is 0. at #main():139 이래. 어떻게 해야 돼?
Assistant
이 오류는 스크립트가 처음 실행될 때
supportLines배열이 비어있는 상태에서 배열의 요소에 접근하려고 해서 발생합니다. 배열이 비어있을 때 접근하면 "인덱스가 범위를 벗어났다(out of bounds)"는 오류가 발생합니다.이 문제를 해결하기 위해 배열에 접근하기 전에 배열의 크기를 확인하는 조건문을 추가해야 합니다. 다음과 같이 코드를 수정해보세요:
pinescript
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.