Introduction
The Quagensia® Desktop Application’s “Color” data type represents a color with a red, green and blue component that together form a color that can be applied to a line, shape, or text that can be displayed on the chart to which a strategy is attached.
When you create an input parameter or internal variable of type “Color”, you will see a button that you can click on to select a color from a color chooser window. The color chooser window allows you to select a color from a color palette or enter a color using numeric values for its red, green, and blue values. When you select a color and click OK, the button that represents your color variable will show a square with the color you selected, followed by either the name of the color or a hexadecimal value representing the color if the color’s name is not known.
Color variables are just like numeric variables or any other kind of variable. They can be set to different values from the “Set a Variable” action, and the value to set your variable equal to can be selected manually from another color chooser window, can be set to the value of another color variable, or can be the return value of a Quagensia Function that returns a color. You can create time series containing one color for each or your primary instrument’s price bars, lists of colors, single-dimensional and multi-dimensional arrays of colors, and Quagensia Functions that accept colors as input parameters and return colors either as return values or by passing a color variable into the Quagensia Function by reference and setting it from within the function.
To see the many kinds of things you can do with colors and drawing, click on any location in the “When Bar Updates” section where an action is allowed, and browse through the many Quagensia Functions under the “Draw Something” folder of the “Replace Item”, “Add Item Above Me”, or “Add Item Below Me” folders of the context menu that appears.
Creating partially or fully transparent colors and creating colors programmatically in Quagensia N Edition
Creating a partially transparent color in Quagensia N Edition allows you to do things like draw small partially transparent shapes on top of price bars on a NinjaTrader® chart and still be able to see the price bars beneath the partially transparent shapes.
To create a partially or fully transparent color in Quagensia N Edition from a preexisting color manually chosen from a color picker, use the built-in function called “Create a Partially or Fully Transparent Color”. It accepts a color and an “alpha value”, where 0 is 100% transparent and 255 is 100% opaque, and returns a partially or fully transparent color. You can add this function to a Quagensia N Edition Strategy by clicking on a location on the strategy’s workspace where a color is allowed, then navigating to the “More Expressions > Drawing > Colors” context menu subfolder and selecting the “Create a Partially or Fully Transparent Color” function.
To see examples of using partially transparent colors in Quagensia N Edition Strategies, take a look at these three built-in strategies, which use the “Create a Partially or Fully Transparent Color” function to create little green partially transparent diamonds at the profit target prices for each bar, and little red, orange, and yellow partially transparent diamonds at the stop loss, breakeven stop, and trailing stop prices for each bar, respectively:
- Bollinger Bands® Long Entry on Breakout Above Upper Band with Breakeven and ATR-Based Stop Loss, Trailing Stop, & Profit Target (W Exit Order Fxns)
- Bollinger Bands® Short Entry on Breakout Below Lower Band with Breakeven and ATR-Based Stop Loss, Trailing Stop, & Profit Target (W Exit Order Fxns)
- Moving Average Crossover Long-Short Reversal with Breakeven and ATR-Based Stop Loss, Trailing Stop, & Profit Target (W Exit Order Fxns)
The limitation of Quagensia N Edition’s “Create a Partially or Fully Transparent Color” function is that the color input parameter of this function has to be manually selected from a color picker or set to an expression that returns a color with red, green, and blue values already set so it is not possible to calculate values from 0 to 255 for the red, green, and blue components of the color.
If you want to be able to create a color programmatically instead of manually from a color picker you can use the Quagensia N Edition Function called “Create Color From Alpha, Red, Green, and Blue (ARGB) Values” that accepts a Whole Number from 0 to 255 for the red, green, and blue components where 0 means “none of that color”, 255 means “the maximum amount of that color”, and a number in between 0 and 255 means “some of that color”. Like the “Create a Partially or Fully Transparent Color” function described above, this function also has an input parameter for the “alpha value”, where 0 is 100% transparent and 255 is 100% opaque, and returns an opaque color or a partially or fully transparent color. Since the alpha, red, green, and blue (ARGB) input parameters are all Whole Numbers, you can calculate each of the four color components’ values from 0 to 255 and pass the calculated color component values into this function to create a color fully programmatically. You can add this function to a Quagensia N Edition Strategy by clicking on a location on the strategy’s workspace where a color is allowed, then navigating to the “More Expressions > Drawing > Colors” context menu subfolder and selecting the “Create Color From Alpha, Red, Green, and Blue (ARGB) Values” function.
Creating partially or fully transparent colors and creating colors programmatically in Quagensia T Edition
You can create partially or fully transparent colors in your Quagensia T Edition Strategies, and you can create partially or fully transparent colors and opaque colors fully programmatically.
This allows you to do things like draw small partially transparent shapes on top of price bars on a TradeStation® chart and still be able to see the price bars beneath the partially transparent shapes, and optionally even do so using calculated values for the red, green, blue, and “alpha value” (in TradeStation® 10.0) or “transparency value” (in TradeStation® 9.5) of the color.
The following four built-in functions were added to this release to enable you to create partially transparent colors and optionally create opaque colors and partially or fully transparent colors programmatically:
- Create a Partially or Fully Transparent Color (TradeStation® 10.0 Only)
- Create a Partially or Fully Transparent Color (TradeStation® 9.5 Only)
- Create Color From Alpha, Red, Green, and Blue (ARGB) Values (TradeStation® 10.0 Only)
- Create Color From Transparency, Red, Green, and Blue (Transparency and RGB) Values (TradeStation® 9.5 Only)
To use one of these functions, click on a location where a color is allowed and select one of the functions above from the “More Expressions > Drawing > Colors” context menu subfolder.
Note that of the four functions above, two are only for TradeStation® 9.5 and two are only for TradeStation® 10.0. We created separate functions for TradeStation® 9.5 and TradeStation® 10.0 because these functions use the “Reserved Word” built into TradeStation® called ARGB() to create a color with transparency. The meaning of the first parameter of ARGB was changed between TradeStation® 9.5 and TradeStation® 10.0. In TradeStation® 9.5, the first parameter of ARGB represents the “Transparency”, where a higher number means more transparent and less opaque. In TradeStation® 10.0, the first parameter of ARGB represents the “Alpha”, where a higher number means more opaque and less transparent.
If you want to use the TradeStation® 10.0 variants of these functions the value of the drop-down list named “Version of TradeStation® In Which This Code Will Be Used” in the Code Generation Tab directly below the Algo Workspace must be set to either “The Newest Version” or to one of the TradeStation® 10.0 “Updates” (versions). Note that if you set this drop-down list to either “The Newest Version” or set it to one of the TradeStation® 10.0 “Updates” (versions), you will still see the TradeStation® 9.5 function variants as options in the context menus that appear when you click on locations where a color can go, but adding a TradeStation® 9.5 variant to that location will cause a validation error to occur when you attempt to save the algo or generate its code.
If you want to use the TradeStation® 9.5 variants of these functions the value of the drop-down list named “Version of TradeStation® In Which This Code Will Be Used” in the Code Generation Tab directly below the Algo Workspace must be set to one of the TradeStation® 9.5 “Updates” (versions). Note that if you set this drop-down list to one of the TradeStation® 9.5 “Updates” (versions), you will still see the TradeStation® 10.0 function variants as options in the context menus that appear when you click on locations where a color can go, but adding a TradeStation® 10.0 variant to that location will cause a validation error to occur when you attempt to save the algo or generate its code.
The two functions “Create a Partially or Fully Transparent Color (TradeStation® 10.0 Only)” and “Create a Partially or Fully Transparent Color (TradeStation® 9.5 Only)” allow you to create a partially or fully transparent color from a color and a Whole Number that either represents an “alpha value” in the TradeStation® 10.0 function variant or a “transparency value” in the TradeStation® 9.5 function variant.
The limitation of these two functions is that the color input parameter of this function has to be manually selected from a color picker or set to an expression that returns a color with red, green, and blue values already set so it is not possible to calculate values from 0 to 255 for the red, green, and blue components of the color. To get around this limitation, you can use either the “Create Color From Alpha, Red, Green, and Blue (ARGB) Values (TradeStation® 10.0 Only)” function or the “Create Color From Transparency, Red, Green, and Blue (Transparency and RGB) Values (TradeStation® 9.5 Only)” function. These two functions accept a Whole Number from 0 to 255 for the red, green, and blue components where 0 means “none of that color”, 255 means “the maximum amount of that color”, and a number in between 0 and 255 means “some of that color”. Like the functions described in the previous paragraph, these two functions also have an input parameter for the “alpha value” in the TradeStation® 10.0 function variant or the “transparency value” in the TradeStation® 9.5 function variant. Since the alpha (or transparency), red, green, and blue (ARGB) input parameters are all Whole Numbers, you can calculate each of the three red, green, and blue color components’ values from 0 to 255 and calculate either the “alpha value” from 1 to 255 (for the TradeStation® 10.0 function variant where 1 is 100% transparent and 255 is 100% opaque) or the “transparency value” from 0 to 254 (for the TradeStation® 9.5 function variant where 0 is 100% opaque and 254 is 100% transparent) and pass the calculated color component values into this function to create a color fully programmatically.