Requirement for Use:

Data series must be an IPV that is set to "Auto-Index".

This function will also color Indicators created using Trading Blox built-in Indicator Creation Dialog.

Each element of an IPV Indicator series can be colored.

IPV series indicator can only be plotted on the instrument chart display.

Indicator chart displays using this function override the indicator's dialog plot type selection

Syntax:

SetSeriesColorStyle(series, plotColor, [plotStyle], [offset] )

 

Parameter:

Description:

series

The name of series.

plotColor

Element Color to use with named "series"  

Preference Color Setup:

Color Constant Name:

Click to enlarge, Click to reduce

User Preference Color Table

ColorGrid

ColorBackground

ColorCrossHair

 

ColorLongTrade

ColorShortTrade

 

ColorTradeEntry

ColorTradeStop

ColorTradeExit

 

ColorUpBar

ColorDownBar

ColorUpCandle

ColorDownCandle

 

ColorCustom1

ColorCustom2

ColorCustom3

ColorCustom4

Note:

If you use one of the custom colors from Preferences' Trade Chart Colors section, the user will be able to modify the colors as desired by change the color associated with a color name.

 

The Color picker displays the number for each custom color.  This number can be used to set a fixed color, or you can create of use a color number like 8388736 which is violet.

 

More information about colors is available here: Colors.

[plotStyle]

Style Value:

Style Type:

1

Thin Line

2

Thick Line

3

Trace

4

Small Dot

5

Large Dot

6

Up Arrow

7

Down Arrow

8

Histogram

9

Area

10

Staircase

 

Note: Plot Style number used overrides indicator's dialog plot selection.

[offset]

Zero will change the color of the bar information at the current location.  An offset value of 1 will change the color of the previous bar.  Offset values with this function operate in the same way as a price or auto-index series.

 

Example - 1:

In the following, barPlotColor is a Bar Plot Color type indicator that is checked for plotting and unchecked for display.

barMessage is an auto indexed string series.

plotTrades is an auto indexed numerical series.

'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  Setting the location, color, and style of a plotting IPV series.
If instrument.unitBarsSinceEntry = 1 AND instrument.position = LONG THEN
  plotTrades[1] = instrument.low[1] - instrument.minimumTick * 10
  SetSeriesColorStyle( plotTrades, ColorLongTrade, 6, 1 )
ENDIF
 
If instrument.unitBarsSinceEntry = 1 AND instrument.position = SHORT THEN
  plotTrades[1] = instrument.high[1] + instrument.minimumTick * 10
  SetSeriesColorStyle( plotTrades, ColorShortTrade, 7, 1 )
ENDIF
 
'  Bar Plot Color type indicator example to color the trade
'  chart bars dynamically.
If instrument.close > instrument.open THEN
  SetSeriesColorStyle( barPlotColor, ColorUpBar )
  barMessage = "Up Day!"
ELSE
  SetSeriesColorStyle( barPlotColor, ColorDownBar )
  barMessage = "Down Day!"
ENDIF
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

Or use a number like 8388736 which is violet. The Color picker in Preferences displays the number for each custom color, so you can copy paste from there to set a fixed color.

 

If you use one of the custom colors from preferences, the user will be able to modify the colors as desired.

Example - 2:

'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  This will set the color to a random color for each bar
'  and the style to a random style – nice look!
SetSeriesColorStyle( averageTrueRange, ColorRGB( Random(255), _
                    Random(255), Random(255) ), Random(10))
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Example - 3:

'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  Color of the up bar AND a thin line:
SetSeriesColorStyle( averageTrueRange, ColorUpBar, 1 )
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Example - 4:

'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
'  Label Volume using the direction of bar close change value
If instrument.close[0] > instrument.close[1] THEN
  '  Display Volume Series
  SeriesVolume = instrument.volume[0]
  '  Use ColorUpBar Color on this Volume bar
  SetSeriesColorStyle(SeriesVolume, ColorUpBar, 8, 0 )
ELSE
  If instrument.close[0] < instrument.close[1] THEN
    '  Display Volume Series
     SeriesVolume = instrument.volume[0]
    '  Use ColorDownBar Color on this Volume bar
    SetSeriesColorStyle(SeriesVolume, ColorDownBar, 8, 0 )
  ELSE
    If instrument.close[0] = instrument.close[1] THEN
        '  Use Default Color for Volume bar item
        SeriesVolume = instrument.volume[0]
    ENDIF '  i.close[0] = i.close[1]
  ENDIF '  i.close[0] < i.close[1]
ENDIF '  i.close[0] > i.close[1]
'  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 

Script code output in this example creates this next chart of volume changes:

Display Result:

SetSeriesColorStyle_UpDn-Volume Chart

 

Links:

Colors, ColorRGB

See Also:

Prefernces, Series Functions

 


Edit Time: 9/25/2017 09:09:54 AM


Topic ID#: 555

 

 

Created with Help & Manual 7 and styled with Premium Pack Version 2.80 © by EC Software