Depending on the indicator you’re using in ThinkorSwim, you can customize the look and feel of it.
Using SetPaintingStrategy in thinkScript, the plot can be changed from a line to an arrow seamlessly.
In this post, we will be going over the usage of SetPaintingStrategy, how to apply it in thinkScript, and how to combine it with the PaintingStrategy constant.
Example of SetPaintingStrategy in thinkScript
Here’s an example
plot Data = open;
Data.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
The example above plot an arrow up at the opening price of each candle.
What if we want to change the up arrow to a down arrow?
We can do so by replacing the ARROW_UP
constant with ARROW_DOWN
.
List of PaintingStrategy Styles
Another important part is the PaintingStrategy
constant. It dictates the style and shape that your indicator is generating.
In thinkScript, there are 20 different constants to define the painting strategy styles.
In other words, you have many options when customizing the shapes and plots of your indicator.
ARROW_DOWN
Data.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
ARROW_UP
Data.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
BOOLEAN_ARROW_DOWN
Boolean plots contain two values: true and false. If a property or condition is true, use this to mark with down arrows.
Data.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
BOOLEAN_ARROW_UP
This one is also similar to the previous constant. Except for this time, it plots up arrows below the low prices of the corresponding candles.
Data.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
BOOLEAN_POINTS
Data.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
BOOLEAN_WEDGE_DOWN
Data.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
BOOLEAN_WEDGE_UP
Data.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
DASHES
Data.SetPaintingStrategy(PaintingStrategy.DASHES);
HISTOGRAM
input length = 50;
plot Vol = volume;
plot VolAvg = Average(volume, length);
Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
HORIZONTAL
Data.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
LINE
Data.SetPaintingStrategy(PaintingStrategy.LINE);
LINE_VS_POINTS
Data.SetPaintingStrategy(PaintingStrategy.LINE_VS_POINTS);
LINE_VS_SQUARES
Data.SetPaintingStrategy(PaintingStrategy.LINE_VS_SQUARES);
LINE_VS_TRIANGLES
Data.SetPaintingStrategy(PaintingStrategy.LINE_VS_TRIANGLES);
POINTS
Data.SetPaintingStrategy(PaintingStrategy.POINTS);
SQUARED_HISTOGRAM
Data.SetPaintingStrategy(PaintingStrategy.SQUARED_HISTOGRAM);
SQUARES
Data.SetPaintingStrategy(PaintingStrategy.SQUARES);
TRIANGLES
Data.SetPaintingStrategy(PaintingStrategy.TRIANGLES);
VALUES_ABOVE
Data.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
VALUES_BELOW
Data.SetPaintingStrategy(PaintingStrategy.VALUES_BELOW);
You can’t get bored changing the style of your ThinkorSwim indicator. Each painting style has its purpose.
It depends on where the signal or line is being plotted on your chart.
The histogram constant is suitable for lower studies while the arrows are favorable on the upper chart.
PaintingStrategy Examples
The following code examples illustrate the use of a few different PaintingStrategy styles.
Simple Moving Average
# Plot arrows for every breakout
input price = close;
input length = 9;
plot SMA = Average(price, length);
plot UpSignal = price crosses above SMA;
plot DownSignal = price crosses below SMA;
SMA.SetDefaultColor(GetColor(1));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
MACD Histogram with Breakout Signals
declare lower;
input fastLength = 12;
input slowLength = 26;
input MACDLength = 9;
input averageType = AverageType.EXPONENTIAL;
plot Diff = MACD(fastLength, slowLength, MACDLength, averageType).Diff;
plot UpSignal = if Diff crosses above 0 then 0 else Double.NaN;
plot DownSignal = if Diff crosses below 0 then 0 else Double.NaN;
Diff.SetDefaultColor(GetColor(5));
Diff.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Diff.SetLineWeight(3);
Diff.DefineColor("Positive and Up", Color.GREEN);
Diff.DefineColor("Positive and Down", Color.DARK_GREEN);
Diff.DefineColor("Negative and Down", Color.RED);
Diff.DefineColor("Negative and Up", Color.DARK_RED);
Diff.AssignValueColor(if Diff >= 0 then if Diff > Diff[1] then Diff.color("Positive and Up") else Diff.color("Positive and Down") else if Diff < Diff[1] then Diff.color("Negative and Down") else Diff.color("Negative and Up"));
UpSignal.SetDefaultColor(Color.UPTICK);
UpSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
DownSignal.SetDefaultColor(Color.DOWNTICK);
DownSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
Happy coding!