| Welcome Guest, please sign in to participate in a discussion. | Search | Active Topics | |
Registered User Joined: 3/9/2006 Posts: 39
|
Hi,
I have an indicator that plots six discreet value of -15, -10, -5, +5, +10, +15. I can create a painscheme in realcode (please see below) and save it to this indicator.
However, I have 18 of these indicators (multiple time frames). Since the realcode below references a specific indicator, I have to edit each of the 18 indicator to chage the reference W. Once the reference are changed, opening and closing the layout seems to loose these references.
Is there some generic way of specifying the color scheme without a reference to a specific chart?
'# W = chart.CycleforIndexA/D
If W.value() = 15 Then PlotColor = color.Green
If W.value() = 10 Then PlotColor = color.Yellow
If W.value() = 5 Then plotcolor = color.orange
If W.value() = -15 Then plotcolor = color.red
If w.value() = -10 Then plotcolor = color.Magenta
if w.value() = -5 then plotcolor = color.Aqua
thanks in advance.
|
|
Registered User Joined: 12/31/2005 Posts: 2,499
|
Given the nature of W, this coloring scheme code might be faster:
'# W = chart.CycleforIndexA/D
static isAllSet as boolean
static colors(7) as color
if not isAllSet then
isAllset = True
colors(2) = color.Aqua
colors(1) = color.Magenta
colors(0) = color.red
colors(4) = color.orange
colors(5) = color.Yellow
colors(6) = color.Green
end if
plotColor = colors((W.value+15)/5)
This doesn't help with the question but may improve performance.
Having W return vales of (0,1,2,4,5,6) would eliminate any math for the subscript. PlotColor = colors(W.value)
If plotting W around 0 is a concern then values of (-3,-2,-1,1,2,3) would just require addition PlotColor = colors(W.value+3) and avoid any division
|
|
Registered User Joined: 12/31/2005 Posts: 2,499
|
QUOTE (jas0501) Given the nature of W, this coloring scheme code might be faster:
'# W = chart.CycleforIndexA/D
static isAllSet as boolean
static colors(7) as color
if not isAllSet then
isAllset = True
colors(2) = color.Aqua
colors(1) = color.Magenta
colors(0) = color.red
colors(4) = color.orange
colors(5) = color.Yellow
colors ( 6 ) = color.Green
end if
plotColor = colors((W.value+15)/5)
This doesn't help with the question but may improve performance.
Having W return vales of (0,1,2,4,5,6) would eliminate any math for the subscript. PlotColor = colors(W.value)
If plotting W around 0 is a concern then values of (-3,-2,-1,1,2,3) would just require addition PlotColor = colors(W.value+3) and avoid any division
|
|
|
Guest-1 |