CS1056
error this can only be used inside a method.
#What it means
this is the object a method works on. It exists only inside a method (method Zone.width() { return this.top - this.bottom }); in a function or at the top level there is no such object.
#Typical cause
thisin a function declared withfunctionor=>.- A method body copied out of a method.
#How to fix it
Turn the function into a method of the type it works on (method float.twice() => this * 2), or pass the value as a parameter. See User types, enums and methods.
#Example
//@chartscript 1
indicator("Double")
function twice() {
return this * 2
}
plot(twice())Fixed
//@chartscript 1
indicator("Double")
method float.twice() => this * 2
plot(close.twice())