CS2603
error A method needs the type of the object it works on: example.
#What it means
In the earlier syntax a method named the object it works on as its first parameter, and that parameter needed a type. Only scripts in the earlier syntax (saved before ChartScript moved to its current, brace-based syntax) can show it; the editor converts such a script to the current syntax when you open it, after which this cannot happen. In the current syntax the type is part of the declaration, method float.twice(), and the object is this.
#Typical cause
- A method declared without parameters.
- A first parameter without a type, as in
method twice(x).
#How to fix it
Write the method as method float.twice() => this * 2. See User types, enums and methods.
#Example
In the earlier syntax
//@chartscript 1
indicator("Double")
method twice(x) => x * 2
plot(twice(close))Fixed (the current syntax)
//@chartscript 1
indicator("Double")
method float.twice() => this * 2
plot(close.twice())#Related
- CS1037 — Expected => or a block { … } after the parameter list.