Hello, what I am trying to do is very similar to: http://www.forexfactory.com/showthread.php?t=217362
7bit explains how to do it here: http://www.forexfactory.com/showpost.php?p=3424034&postcount=19
The method he posted is what I've been trying to do, but for some reason it doesn't work. The arrow buffers (bullishDivergence and bearishDivergence) ALWAYS return the default value if I attempt to read them with iCustom with an EA. The custom indicator has arrows if applied to a chart, writes the expected values to a log, etc. but every test I attempt through an EA with iCustom returns the default value that it has if there is no arrow.
Show your code.
Ridiculously Simple Expert:
Does the indicator put an arrow on bar 0?
Do you think this could be the problem then? It should place arrows at the current bar, but does go back 2 places in the buffer history.
Well, your EA is looking for arrows at bar 0.
I can't run your indicator code right now, and it is not so easy to read, so...
Write the Alert to look back, find the latest signal, tell how many bars back it was, and remember not to alert on that one again.
Shouldn't MACD current and previous be (..., 2,0) and (..., 2,1) ?
(...,2,x) is the MACD buffer, (...,2,0) is current and (...,2,1) would be previous.
In your code you are reading buffer 2, current value and buffer 3, current value instead. Even if it is intended to be this way (I didn't study all of the code) then your variable naming is a bit confusing.
MacdCurr=iCustom(NULL,PERIOD_M15,"MACD_Divergence_V1.1","*** MACD/OSMA Settings ***",6,60,12,
"*** Indicator Settings ***",0.0005,0.0005,0,true,true,true,2,0);
MacdPrev=iCustom(NULL,PERIOD_M15,"MACD_Divergence_V1.1","*** MACD/OSMA Settings ***",6,60,12,
"*** Indicator Settings ***",0.0005,0.0005,0,true,true,true,3,0);