Mladen's explanation is exactly how divergences work... They need clearly defined "peaks or troughs"...which requires them to be confirmed on (normally) two bars back.
However...you seem to have some interesting ideas you want to test with divergences...so here is what I have...
You CAN set the divergences to the current bar....BUT...you WILL get a number false positives...as the peaks and troughs continue to change with a new high or new low until they are finally confirmed.
While that being said...there may be some value in using this as a "heads up" of the real divergences to come...and then use that in conjunction with other indicators to get your final signal.
Here is how to set the divergences for the "current bar" on any divergence indicator...
It assumes you have the .mt4 source file to change the code.
Find the divergence drawing routines and find the "i+2" loops and change them to "i+1" (one bar back) or "i+0" (current bar)...and you will get your divergences shown on those bars...
Please see the attached example showing the multiple divergence lines on my Stoch Divergence indicator...set to Current Bar 0...
I am curious as to what your interest/strategy is...for why you want this method to see divergences...?
I hope this helps you,
Mladen why is it that that if i set the alarm to alert on current to true it does not trigger but if i set it to false it works?
That indicator should be rewritten )it uses 1 future bar in calculation, and that is probably the reason for that)
Very well explained . But which part of the source file that I need to change ? Do you mean this one?void CalculateIndicator(int countedBars)
for(int i = Bars - countedBars; i >= 0; i--)
CatchBullishDivergence(i + 2);
CatchBearishDivergence(i + 2);
Attached here are osmadivergence_alerts.ex4osmadivergence_alerts.mq4
Yes exactly... You found it on the first try... Good for you.
You can also change it without re-doing the code each time...by adding a variable name as an "extern"...and using that in the place of the bar number.
At the top in user settings....add...extern int BarNum = 0; // 0 = current bar
Then in the functions below - change the (i+2) to....(i+BarNum)....
That way you can change the user settings real time and immediately see the differences depending on which bar it is set on...
Hope this helps you,
Dear mrtools and Mladen !
Please help I need to remove a notice on the little arrows and leave at large on the green and red. And add the white balls to buy and sell. Thank you!
Having trouble understanding exactly what your looking for.
Can help to convert and attached indicator to use on new metatrader? And is it possible help to add Push Notification also?
Hello MrTools and Mladen, thanks for doing a wonderful job on this forum. Pls i need ur help in making this indicator to alert sound and popup alert messages including the pair names even though it seems to have these functions in built.
Thanks in advance.
Pls, also with option on alert on candle close or on current candle.Thanks in advance.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.