Pine Script

Pine Script – Undeclared identifier ‘green’ / ‘color.green’ – how to fix it?

Month: January 2023

Pine Script – Undeclared identifier ‘green’ / ‘color.green’ – how to fix it?

You might see the following error in Pine Script quite often, especially if you’re trying to merge a few scripts or copy certain elements from another script. You might see this error with basically all supported colors: Undeclared identifier `color.red` Undeclared identifier `color.black` Undeclared identifier `color.white` Undeclared identifier ‘red’ Undeclared identifier ‘black’ Undeclared identifier ‘white’ Pine Script – Undeclared identifier ‘green’ / ‘color.green’ – how to fix it? Read More →

Displaying Pine Script indicator overlaying the price or in a separate chart.

Depending on the type of your indicator, you might want to plot it on top of your price or in a separate pane. If your indicator has the same scale as your data, you might want it to display on top, for example, BB, SMA, or Ichimoku cloud. If the scale is completely different, you Displaying Pine Script indicator overlaying the price or in a separate chart. Read More →

How to concatenate strings in Pine Script

String concatenation is the main string feature in any programming language. It allows multiple strings to be joined together to form one larger string. This is used in many programming languages to create more complicated strings. String concatenation can be used to combine strings of different lengths, as well as to concatenate strings of text and numerical data.

How to loop/iterate through an array in Pine Script with a “for/in” statement

Arrays are pretty crucial for Pine Script. From the time of their release, it immediately became Pine’s essential feature. Some time ago, I published an article about how to loop through an array in Pine Script. But language evolves quite quickly, and there is already a much more convenient way to iterate through an array. How to loop/iterate through an array in Pine Script with a “for/in” statement Read More →

Pine Script Strategy trading at specific days of the week.

In this article, I’m showing how to work with days of the week in Pine Script and an example of a simple strategy built with only days of the week signals. To know the current day of the week, I’m using “dayofweek()” function. It outputs numbers from 1 to 7 depending on the day of the week. Be careful with the values, 1 is Sunday, and 7 is Saturday here.