Skip to main content
  1. About
  2. For Teams
Asked
Modified 15 days ago
Viewed 45 times
0

This code causes an erroLir Line Cintinuation error. Some reason it does not recognize the colon at the end of the case statements

//@version=6
indicator("Smooth1 with Series Input", overlay=false)

// Define the function properly
smooth1(P, _n, Smooth1_x) =>
    _n == 0 ? Smooth1_x :
    _n == 1 ? (Smooth1_x + P[1] * 2 + P[2]) * 0.25 :
    _n == 2 ? (Smooth1_x + P[1] * 3 + P[2] * 3 + P[3]) * 0.125 :
    _n == 3 ? (Smooth1_x + P[1] * 4 + P[2] * 6 + P[3] * 4 + P[4]) * 0.0625 :
    
    Smooth1_x

// Example usage
sourceSeries = close
level = input.int(3, minval=0, maxval=3)
seed = nz(sourceSeries[1])

result = smooth1(sourceSeries, level, seed)
plot(result, title="Smoothed Series", color=color.orange)

removed the colon. was given an error. to add the colon. with the colon, Line continuation error

1
  • Solved. Using ChatGPT .
    Pat
    –  Pat
    2025-09-29 14:22:53 +00:00
    Commented Sep 29 at 14:22

1 Answer 1

1

When you have a statement on more than one line, the continuation of the statement must begin with one or several (different from multiple of 4).

smooth1(P, _n, Smooth1_x) =>
    _n == 0 ? Smooth1_x :
     _n == 1 ? (Smooth1_x + P[1] * 2 + P[2]) * 0.25 :
     _n == 2 ? (Smooth1_x + P[1] * 3 + P[2] * 3 + P[3]) * 0.125 :
     _n == 3 ? (Smooth1_x + P[1] * 4 + P[2] * 6 + P[3] * 4 + P[4]) * 0.0625 :    
     Smooth1_x
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Post as a guest

Required, but never shown

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.

Morty Proxy This is a proxified and sanitized view of the page, visit original site.