int size=20; double macdarray[]; ArrayResize(macdarray,size);
int MacdMax = ArrayMaximum(macdarray,size,1);
This is finding the maximum of element 1 to 20 in the array. I don't know what the result would be as element 20 does not exist.
As a non-coding comment:
The current MACD value being higher than previous MACD values is an indication that an uptrend is continuing. It doesn't make sense to use this as an indication to exit a buy trade.
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi guys, I started experimenting with a new piece of code that closes orders if the macd reaches the max of its values since 20bars(for example-if the order is buy) and reaches the min for a sell order. It is a function I wrote it looks like:
When i insert this function at the end of OnTick() when is start the expert in the tester the balance drops to zero with the speed of light(it usually doesn`t do that, the expert wins).It usually does that even if i switch the size to 100 bars.Can u help me?
PS. I have an error showing in metaeditor in the array`s size if i write "size" there instead of "20". Can u figure this out too?
Thanks