I am using iMA function in EA program I developed and testing it currently. What I see is very strange. May be my iMA usage in not correct. Can someone help in finding the reason why it might be happening. Details are as follows:
I have EA running on EURCHF, M20. My EA program uses following iMA function:
double Sma15_1 = iMA(NULL,0,SMATrendPeriod15,0,MODE_SMA,PRICE_CLOSE,1); -- This calculates Simple MA for close price of the previous bar with Average period 15 bars.
double Sma15 = iMA(NULL,0,SMATrendPeriod15,0,MODE_SMA,PRICE_CLOSE,0); - This calculates simple MA for close price of current bar with Average period 15 bars
double Ema2_1 = iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,1); - This calculates Exp. MA of previous bar with Average period 2 bars
double Ema2 = iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,0); - This calculates Exp. MA of current bar with Average period 2 bars
What I see on Chart and Data window match each other and following are the values I see in data window when I am testing.
At 9/30/2008 time 16:00 I have data window with following values of above functions:
Sma15_1 = 1.5766
Sma15 = 1.5765
Ema2_1 = 1.5752
Ema2 = 1.5767
During testing I print out these values and those are follows:
Sma15_1 = 1.5766
Sma15 = 1.5763
Ema2_1 = 1.5752
Ema2 = 1.5753
As you can see clearly Sma15 and Ema2 values do not match with values in Data Window values. This is causing not generating long/Short signals correctly based on my EA program. This could be serious issue with function or I may not be using iMA correctly. So far I looked up every where and I dont see any problem in iMA usage.
Did anyone has seen such issue? can anyone suggest what may be the issue here and point out the correct usage of iMA functionn. Please help me fixing this issue.
This is running on M30 and not on M20 as it is mentioned. M20 is typo and should be read as M30.
same here...
how did you solve this problem???
Could it be timing and how time/data is recorded in testing? What model did you use for testing - every tick, control.., open..?
I used everytick model and used close. Here is what I think is happening. When close is used for the current bar for which close is not stable, therefore when it is printed out it does not print the final close value. This close value gets stable only at the end of the period. All values of previous bar do not have such issue becasue all previous values are stable. Same thing applies to all LOW[0], CLose[0], High[0] except OPEN[0]. OPEN[0] is the only value for the current bar is stable value. For Technical Analysis purpose fuction should use only the stable values after the end of the bar and print out the same and not the during the period otherwise these values can not be used for developting tecnhcal indicators.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I am using iMA function in EA program I developed and testing it currently. What I see is very strange. May be my iMA usage in not correct. Can someone help in finding the reason why it might be happening. Details are as follows:
I have EA running on EURCHF, M20. My EA program uses following iMA function:
double Sma15_1 = iMA(NULL,0,SMATrendPeriod15,0,MODE_SMA,PRICE_CLOSE,1); -- This calculates Simple MA for close price of the previous bar with Average period 15 bars.
double Sma15 = iMA(NULL,0,SMATrendPeriod15,0,MODE_SMA,PRICE_CLOSE,0); - This calculates simple MA for close price of current bar with Average period 15 bars
double Ema2_1 = iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,1); - This calculates Exp. MA of previous bar with Average period 2 bars
double Ema2 = iMA(NULL,0,MATrendPeriod,0,MODE_EMA,PRICE_CLOSE,0); - This calculates Exp. MA of current bar with Average period 2 bars
What I see on Chart and Data window match each other and following are the values I see in data window when I am testing.
At 9/30/2008 time 16:00 I have data window with following values of above functions:
Sma15_1 = 1.5766
Sma15 = 1.5765
Ema2_1 = 1.5752
Ema2 = 1.5767
During testing I print out these values and those are follows:
Sma15_1 = 1.5766
Sma15 = 1.5763
Ema2_1 = 1.5752
Ema2 = 1.5753
As you can see clearly Sma15 and Ema2 values do not match with values in Data Window values. This is causing not generating long/Short signals correctly based on my EA program. This could be serious issue with function or I may not be using iMA correctly. So far I looked up every where and I dont see any problem in iMA usage.
Did anyone has seen such issue? can anyone suggest what may be the issue here and point out the correct usage of iMA functionn. Please help me fixing this issue.