Hi,
I was wondering if AFL supports a concept similar to function pointer is c. This is what I'm trying to achieve
Current Implementation
ma_type = paramlist("MA Type", "SMA|EMA|WMA", 0); <- Select the type of moving average you want to plot
ma_01_p = param("MA-01 Period", 5, 5, 200, 1); <- Moving average period
ma_01_c = paramcolor("MA-01 Color", colordarkgrey); <- color to plot moving average
ma_01_s = paramstyle("MA-01 Style", styleline); <- Style used to plot moving average
switch (ma_type) {
case "SMA":
ma_title = "MA";
ma_01_a = ma(field, ma_01_p);
break;
case "EMA":
ma_title = "EMA";
ma_01_a = ema(field, ma_01_p);
break;
case "WMA":
ma_title = "WMA";
ma_01_a = wma(field, ma_01_p);
break;
}
plot(ma_01_a, ma_title + "(" + ma_01_p + ")", ma_01_c, ma_01_s, null, null, 0, 0, 1);
Is the below implementation where the pointer to the ma function is stored in ma_ptr possible ??
ma_type = paramlist("MA Type", "SMA|EMA|WMA", 0); <- Select the type of moving average you want to plot
ma_01_p = param("MA-01 Period", 5, 5, 200, 1); <- Moving average period
ma_01_c = paramcolor("MA-01 Color", colordarkgrey); <- color to plot moving average
ma_01_s = paramstyle("MA-01 Style", styleline); <- Style used to plot moving average
switch (ma_type) {
case "SMA":
ma_title = "MA";
ma_ptr = ma;
break;
case "EMA":
ma_title = "EMA";
ma_ptr = ema;
break;
case "WMA":
ma_title = "WMA";
ma_ptr = wma;
break;
}
ma_01_a = ma_ptr(c, ma_01_p);
plot(ma_01_a, ma_title + "(" + ma_01_p + ")", ma_01_c, ma_01_s, null, null, 0, 0, 1);
Thanks.