I want to be able, to use, the User selected Enum DIRECTLY in a Function.
The Following will Not work.
#region _Variables
private MovAvg_MA_TF1 mA_TF1 = MovAvg_MA_TF1.SMA;
#endregion
public enum MovAvg_MA_TF1
{
EMA,
HMA,
SMA,
WMA
}
switch (mA_TF1)
{
//If the MovAvgType is defined as EMA then...
case MovAvg_MA_TF1.EMA:
{
var movAvgType = EMA;
break;
}
//If the MovAvgType is defined as HMA then...
case MovAvg_MA_TF1.HMA:
{
var movAvgType = HMA;
break;
}
//If the MovAvgType is defined as SMA then...
case MovAvg_MA_TF1.SMA:
{
var movAvgType = SMA;
break;
}
//If the MovAvgType is defined as WMA then...
case MovAvg_MA_TF1.WMA:
{
var movAvgType = WMA;
break;
}
}
Plot0.Set(movAvgType(Close[0], Period)[0]);
# region Properties
[Description("Choose a Moving Average type.")]
[GridCategory("MA_TF1 Settings")]
public MovAvg_MA_TF1 MA_TF1
{
get { return mA_TF1; }
set { mA_TF1 = value; }
}
#endregion
Could someone PLEASE tell How I can modify the:
var movAvgType =
AND
Plot0.Set(movAvgType(Close[0], Period)[0]);
So that this method would work ???
THANK YOU IN ADVANCE !!!
P.S.
(I know the other way that works is to put the:
Plot0.Set(EMA(Close[0], Period)[0]);
Plot0.Set(HMA(Close[0], Period)[0]);
Plot0.Set(SMA(Close[0], Period)[0]);
Plot0.Set(WMA(Close[0], Period)[0]);
Inside each Case, But for other Reasons I Do Not want to do this.)

Comment