Here is a simple code that plots 2 Simple MA and colors the gap between them. I would like to use the Alpha parameter from Color.FromArgb() method to make some transparency effect. But whatever the Alpha value is, the color remain the same, like if it is useless.
Is it a bug ? (Note that it is purely an aesthetic concern)
Code: Select all
using System;
using System.Drawing;
using System.Linq;
using PowerLanguage.Function;
namespace PowerLanguage.Indicator
{
public class TwoSMA : IndicatorObject
{
public TwoSMA(object _ctx):base(_ctx){}
private IPlotObject SMA_plt_1, SMA_plt_2;
private Function.AverageFC SMA_fnc_1, SMA_fnc_2;
private int r_Length_1 = 16;
[Input]
public int Length_1 { get { return r_Length_1; } set { r_Length_1 = value; } }
private int r_Length_2 = 32;
[Input]
public int Length_2 { get { return r_Length_2; } set { r_Length_2 = value; } }
private Color r_UP_color = Color.DodgerBlue;
[Input]
public Color UP_color { get { return r_UP_color; } set { r_UP_color = value; } }
private Color r_DW_color = Color.Gold;
[Input]
public Color DW_color { get { return r_DW_color; } set { r_DW_color = value; } }
private int r_Alpha = 32;
[Input]
public int Alpha { get { return r_Alpha; } set { r_Alpha = value; } }
protected override void Create()
{
SMA_fnc_1 = new Function.AverageFC(this);
SMA_plt_1 = AddPlot(new PlotAttributes("aSMA_1", EPlotShapes.BarHigh, Color.Black, Color.Black, 6, 0, true));
SMA_fnc_2 = new Function.AverageFC(this);
SMA_plt_2 = AddPlot(new PlotAttributes("aSMA_2", EPlotShapes.BarLow, Color.Black, Color.Black, 6, 0, true));
}
protected override void StartCalc()
{
SMA_fnc_1.price = Bars.Close;
SMA_fnc_1.length = this.Length_1;
SMA_fnc_2.price = Bars.Close;
SMA_fnc_2.length = this.Length_2;
}
protected override void CalcBar()
{
SMA_plt_1.Values[0] = SMA_fnc_1[0];
SMA_plt_2.Values[0] = SMA_fnc_2[0];
if (SMA_fnc_1[0] > SMA_fnc_2[0]) { SMA_plt_1.Colors[0] =Color.FromArgb(Alpha, UP_color); SMA_plt_2.Colors[0] = Color.FromArgb(Alpha, UP_color); }
else if (SMA_fnc_1[0] < SMA_fnc_2[0]) { SMA_plt_1.Colors[0] =Color.FromArgb(Alpha, DW_color); SMA_plt_2.Colors[0] = Color.FromArgb(Alpha, DW_color);}
else { SMA_plt_1.Colors[0] = Color.FromArgb(Alpha, Color.Green); SMA_plt_2.Colors[0] = Color.FromArgb(Alpha, Color.Green); }
}
}
}