-
Why did you post your MT4 question in the MT5 General section instead of the MQL4 section, (bottom of the Root page)?
General rules and best pratices of the Forum. - General - MQL5 programming forum?
Next time, post in the correct place. The moderators will likely move this thread there soon. -
You should stop using the old event handlers and IndicatorCounted() and start using new event handlers.
Event Handling Functions - MQL4 Reference
How to do your lookbacks correctly - MQL4 programming forum #9-14 & #19 2016.05.11
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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
Hello everyone,
I'm trying it to add the custom "ary-aind-indicator" to filter the positions that my expert will open.
This indicator is very simple : it display green bars for bullish momentum, and red bars for bearish momentum. And obviously, the returned value is the bar value which is positive for a green bar, and negative for a red one. And also, this bar value is the value that is displayed in the Data window of MT4, so i'm pretty sure that this indicator returns the bar value.
So I used the iCustom function to get the returned bar value (the indicator receive as input a period which is "27" in this case, and 3 buffers indexed as 0,1 and 2):
Here the issue, no matter what buffer I use, the iCustom function doesn't seem to return the bar value. Even when I isolate this indicator and use it alone to know what is the problem as the following (T1 and T2 are used to open one single trade they are both initially set at zero and receive incrementation++ when the order is opened) :
The issue still persist, cause my approach is very simple : if red bar (Val < 0) then open short position
if green bar (Val > 0) then open long position
But when I back test, sometimes even when there is a red bar (Val < 0) the expert doesn't open a short position, and this no matter what buffer I use, so i'm really confused about it.
Here the code of the indicator if someone need to check it, and below you will find attached the indicator file, and a screen shot of the indicator to see what it looks like, and also how in the data window it's the bar value that is returned :
Sorry for being to long. And thanks for any help.