'TradingView's ‘undeclared identifier’ error in pine

I try to edit script ver.2 and i dont now how to rewrite to ver.4 for public

Bellow errors:

line 11: Undeclared identifier 'jump';
line 12: Undeclared identifier 'jump';
line 13: Undeclared identifier 'jump';
line 14: Undeclared identifier 'jump';
line 15: Undeclared identifier 'upperlinemark';
line 15: Undeclared identifier 'lineset';
line 16: Undeclared identifier 'bellowlinemark';
line 16: Undeclared identifier 'lineset';
line 17: Undeclared identifier 'upperlinemark';
line 17: Undeclared identifier 'bellowlinemark';
line 17: Undeclared identifier 'lineset';
line 18: Undeclared identifier 'upperlinemark';
line 18: Undeclared identifier 'bellowlinemark';
line 18: Undeclared identifier 'lineset';
line 19: Undeclared identifier 'firstplot';
line 19: Undeclared identifier 'thirdplot';
line 19: Undeclared identifier 'lineset';
line 20: Undeclared identifier 'secondplot';
line 20: Undeclared identifier 'fourthplot';
line 20: Undeclared identifier 'lineset'

Help me please, i will be so thankful



Solution 1:[1]

You cannot use a variable in its declaration. You need to declare it first.

Here is how you can fix that issue. You have

graphgo = 0.0
graphback = 0.0
graphgo := close[1]>graphgo[1]? max(go,graphgo[1]) : go
graphback := close[1]<graphback[1]? min(back,graphback[1]) : back

Also, you need to use the color namespace for the colors.

So, change lines like this:

lineset = jump == 1 ? lime : red

To this:

lineset = jump == 1 ? color.lime : color.red

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 vitruvius