iMA calculation weird behaviorBack to topics list |
|
g123sk
2009.05.26 01:09
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 else if (type == OP_SELL) { Thanks, |
|
bayesiantrader
2009.08.10 06:58
g123sk :
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 else if (type == OP_SELL) { Thanks, |
|
bayesiantrader
2009.08.10 07:02
You may be able to solve your "weird" behavior problem using the iMA function by specifying a shift of 1 instead of 0. My experience with this function is that when you use 0 shift, your MA calculation is being reshaped at every tick, since Close(0) is constantly moving with the tick trades until the next period bar is reached. By using 1 shift, your MA calculation should track better and not be giving false indications of when to trade.
|
