| / | Forum |
|
natsirte
2008.06.08 22:27
hi in my EA, I try to print my two variables but it's not working: ********************************************************** double m_10 = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, Current + 0); } ********************************************************** this is the message error : '[' assignment expected Help please!! Thanks in advance. |
|
The article describes the method of creating a tool for comfortable scalping. However, such an approach to trade opening can be applied in any trading. |
|
ukt
2008.06.08 22:53
search forum for "arrays" and learn how to use them. For example: http://book.mql4.com/variables/arrays you use "[]" on a variable... do you know why you do? these are concepts you should learn completely otherwise problems will continue to appear all the time. yes... people can just key in the code and show you but come on - this is basic programming syntax which you need to master. The mql4 book has so much to offer - why not take advantage of what it can give to you? Will not regret it ! Best... ;) |
|
natsirte
2008.06.08 23:34
Hi I used [] because I don't want to write 500 lines, and I thought it was the good method ( I used it in a indicator but now I'm in a EA) ! I was wrong and I don't know who to do that's why I try to find another method thank in advance |
|
phy
2008.06.09 01:24
double m_10 = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, Current + 0); should be changed to: double m_10[501]; double m_20[501]; |
|
natsirte
2008.06.09 03:05
Hi Phy and thank you When I replace double m_10 by double m_10[501] the message error is : '0' variable expected ( for this line : double m_10 = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, Current + 0);) so I do this : double m_10[500] ; double m_20[500]; m_10 = iMA(NULL, 0, 10, 0, MODE_SMA, PRICE_CLOSE, Current + 0); Alert(m_10[i]+ " " + m_20[i]); } But the result of the Alert is 0 and O |
|
forexfordinner
2008.06.09 06:50
Hi Natsirte, There are 2 mistakes as far as I can see but without testing it I can't tell, give it a try though. First replace i-- for i++, since you want your i value to increase not to decrease. Also keep in mind that an array is used if you want to access an specific position data stored by it, otherwise you can perfectly write it as follows: for(int i=1; i<500 ; i++) }
Also, why do you shift it constantly? why Current + i? Good luck. |
|
natsirte
2008.06.09 16:35
Hi great thanks for your help I'll try it this evening! :-) |
|
natsirte
2008.06.09 22:59
natsirte wrote:
Hi great thanks for your help I'll try it this evening! :-) |
|
natsirte
2008.06.09 23:01
double m_10[500] ; } Thanks to everybody for this help! |
|
phy
2008.06.10 19:40
You changed [501] to [500]. Your loop now writes outside the bounds of the array. |