AddCloud

AddCloud ( CustomColor color2 );

Default values:

color2: Color.RED

Description

Plots a translucent cloud bounded above and below by values data1 and data2. Areas where data1 is greater than data2 are assigned color1, others are filled with color2. By default, the cloud border is invisble: to make it visible, set the showBorder parameter value to yes. Note that AddCloud accepts both defined variables and plots as input parameters.

Input parameters

Parameter Default value Description
data1 - Defines the first value for comparison.
data2 - Defines the second value for comparison.
color1 Color.YELLOW Defines color of sections where data1 is greater than data2.
color1 Color.RED Defines color of sections where data1 is less than or equal to data2.

showBorder

no

Controls visibility of the cloud border.

Example 1

def OpenPrice = open;

def ClosePrice = close;
AddCloud(OpenPrice, ClosePrice, color.RED, color.GREEN, yes);

In this example, the AddCloud function draws a translucent cloud that highlights the difference between the values of OpenPrice and ClosePrice. Green cloud areas correspond to bull candles, while red areas correspond to bear candles. Even though the script contains no plots, the values of OpenPrice and ClosePrice are displayed as the cloud border.

Example 2

plot CurrentPrice = close;
plot PastPrice = close[10];
AddCloud(CurrentPrice, PastPrice, Color.VIOLET, Color.PINK);

In this example, the AddCloud draws the translucent "cloud" and paints it according to the following rule:

  • if CurrentPrice > PastPrice then the cloud is violet;
  • if CurrentPrice < PastPrice then the cloud is pink.

Note that the order in which the arguments appear in the AddCloud function affects the logics. For example, if you swap over the PastPrice and the CurrentPrice:

plot CurrentPrice = close;
plot PastPrice = close[10];
AddCloud(PastPrice, CurrentPrice, Color.VIOLET, Color.PINK);

the rule will be:

  • if PastPrice > CurrentPrice, then the cloud is violet;
  • if PastPrice < CurrentPrice, then the cloud is pink.

Example 3

Although AddCloud requires that both upper and lower boundaries be specified as plots or variables, it is possible to set those as infinity bounds so that certain chart areas are highlighted. Consider the following example:

def hiLevel = if close >= Average(close) then Double.POSITIVE_INFINITY else Double.NEGATIVE_INFINITY;

AddCloud(hiLevel, -hiLevel, Color.LIGHT_GREEN, Color.LIGHT_RED);

This script will display infinite vertical stripes on chart: green stripes where the close price is greater than or equal to its average, and red ones where it is less.