This should do. Not tested though.
bool bullish, bearish; int BarsCount; int start() { bullish = false; bearish = false; if (Bars > BarsCount) { //bullish bar if ( (Low[1] < Low[2]) && (Close[1] > (High[1] + Low[1])/2) ) bullish = true; //bearish bar if ( (High[1] > High[2]) && (Close[1] < (High[1] + Low[1])/2) ) bearish = true; //alerts if (bullish) Alert("Bullish divergent bar on ", Symbol(), " ", Period()); if (bearish) Alert("Bearish divergent bar on ", Symbol(), " ", Period()); BarsCount = Bars; } return(0); }
Files:
divergentabar_2.mq4
2 kb
janklimo:
This should do. Not tested though.
This should do. Not tested though.
bool bullish, bearish; int BarsCount; int start() { bullish = false; bearish = false; if (Bars > BarsCount) { //bullish bar if ( (Low[1] < Low[2]) && (Close[1] > (High[1] + Low[1])/2) ) bullish = true; //bearish bar if ( (High[1] > High[2]) && (Close[1] < (High[1] + Low[1])/2) ) bearish = true; //alerts if (bullish) Alert("Bullish divergent bar on ", Symbol(), " ", Period()); if (bearish) Alert("Bearish divergent bar on ", Symbol(), " ", Period()); BarsCount = Bars; } return(0); }
janklimo wrote:
This should do. Not tested though.
bool bullish, bearish; int BarsCount; int start() { bullish = false; bearish = false; if (Bars > BarsCount) { //bullish bar if ( (Low[1] < Low[2]) && (Close[1] > (High[1] + Low[1])/2) ) bullish = true; //bearish bar if ( (High[1] > High[2]) && (Close[1] < (High[1] + Low[1])/2) ) bearish = true; //alerts if (bullish) Alert("Bullish divergent bar on ", Symbol(), " ", Period()); if (bearish) Alert("Bearish divergent bar on ", Symbol(), " ", Period()); BarsCount = Bars; } return(0); }
janklimo:
This should do. Not tested though.
This should do. Not tested though.
bool bullish, bearish; int BarsCount; int start() { bullish = false; bearish = false; if (Bars > BarsCount) { //bullish bar if ( (Low[1] < Low[2]) && (Close[1] > (High[1] + Low[1])/2) ) bullish = true; //bearish bar if ( (High[1] > High[2]) && (Close[1] < (High[1] + Low[1])/2) ) bearish = true; //alerts if (bullish) Alert("Bullish divergent bar on ", Symbol(), " ", Period()); if (bearish) Alert("Bearish divergent bar on ", Symbol(), " ", Period()); BarsCount = Bars; } return(0); }
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 all,
Does anybody know how to program a divergent bar (Bill Williams)? Basically I need to program 2 types of bars (candles) based on different time frames. The first is the bullish divergent bar where the low price is lower than the previous bar and the close price is within the top half between High/Low. Reverse for the bearish divergent bar where the high of the bar is higher than the one prior and the close price is within the bottom half bewteen High/Low. What I would like is a warning that there is a divergent bar on a particular currency at a particular time frame. I would then check the bar and its angle to the Alligator and decide if I want to make the trade.
Thanks for the help.