Hi,
I am finding some weird behavior with my following code. The MA calculation seems to be wrong sometimes for Period_D1. The behavior is not consistent. I find it working fine most times. Am I doing something wrong here. I have given the function definition of isTrendMaSatisified which calculates the iMA. This function is called for different periods like Period_H1, Period_H4 and Period_D1. I have given one sample output where the iMA is wrong for Period_D1. I have highlighted it. Has anyone seen such behavior? Would it be possible that the local variables of the function ma5 & ma12 are not cleared correctly? I am not able to diagnose this issue. Any help is highly appreciated.
2009.05.25 15:32:33 find_currs_ma_hmp AUDCADFXF,H1: Debug: str = CADJPYFXF look for signal = 0 period = 60 (ma5,ma12) = (84.3216,84.3154) period = 240 (ma5,ma12) = (84.2966,84.0927) period = 1440 (ma5,ma12) = (84.4478,84.5274)
2009.05.25 15:35:42 find_currs_ma_hmp AUDCADFXF,H1: Debug: str = CADJPYFXF look for signal = 0 period = 60 (ma5,ma12) = (84.3316,84.32) period = 240 (ma5,ma12) = (84.3066,84.0974) period = 1440 (ma5,ma12)= (83.872,83.3324)
bool
isTrendMaSatisified(string str, int type, int period)
{
double ma5 = iMA(str,period,5,0,MODE_EMA,PRICE_CLOSE,0);
double ma12 = iMA(str,period,12,0,MODE_EMA,PRICE_CLOSE,0);
debugStr = StringConcatenate(debugStr,"period = ",period,"mas = (",ma5,",",ma12,") ");
if (type == OP_BUY) {
return (NormalizeDouble(ma5,5) > NormalizeDouble(ma12,5));
}
else if (type == OP_SELL) {
return (NormalizeDouble(ma5,5) < NormalizeDouble(ma12,5));
}
return (0);
}
Thanks,
Suresh.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
I am finding some weird behavior with my following code. The MA calculation seems to be wrong sometimes for Period_D1. The behavior is not consistent. I find it working fine most times. Am I doing something wrong here. I have given the function definition of isTrendMaSatisified which calculates the iMA. This function is called for different periods like Period_H1, Period_H4 and Period_D1. I have given one sample output where the iMA is wrong for Period_D1. I have highlighted it. Has anyone seen such behavior? Would it be possible that the local variables of the function ma5 & ma12 are not cleared correctly? I am not able to diagnose this issue. Any help is highly appreciated.
2009.05.25 15:32:33 find_currs_ma_hmp AUDCADFXF,H1: Debug: str = CADJPYFXF look for signal = 0 period = 60 (ma5,ma12) = (84.3216,84.3154) period = 240 (ma5,ma12) = (84.2966,84.0927) period = 1440 (ma5,ma12) = (84.4478,84.5274)
2009.05.25 15:35:42 find_currs_ma_hmp AUDCADFXF,H1: Debug: str = CADJPYFXF look for signal = 0 period = 60 (ma5,ma12) = (84.3316,84.32) period = 240 (ma5,ma12) = (84.3066,84.0974) period = 1440 (ma5,ma12)= (83.872,83.3324)
bool
isTrendMaSatisified(string str, int type, int period)
{
double ma5 = iMA(str,period,5,0,MODE_EMA,PRICE_CLOSE,0);
double ma12 = iMA(str,period,12,0,MODE_EMA,PRICE_CLOSE,0);
debugStr = StringConcatenate(debugStr,"period = ",period,"mas = (",ma5,",",ma12,") ");
if (type == OP_BUY) {
return (NormalizeDouble(ma5,5) > NormalizeDouble(ma12,5));
}
else if (type == OP_SELL) {
return (NormalizeDouble(ma5,5) < NormalizeDouble(ma12,5));
}
return (0);
}
Thanks,
Suresh.