Hello, I am trying to modify an indicator so that it only goes off if the previous bar size is greater then 20 pips. Here is the code that I thought would do the trick but the indicator still goes off if the previous bar is less then 20 pips.
if (iClose(NULL, p, 2) - iOpen(NULL, p, 2) > .002) continue;
Please let me know!
Thanks
P.S. I am editing Blubb's DOUBLE ALERT indi if that helps any.
Bar Size MT4 programming help!
Moderator: moderators
Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.
Thank you for your support.
Hey blubbb, thanks for replying! I am not extremely savvy in MT4 programming but I know a little bit. I believe I the continue statement was inside of the proper loop. Here is the piece of code I am inserting it into:
-------------------------------------------
if (Close[0] == iHigh(NULL, p, 0)) {
if (iClose(NULL, p, i+1) > iOpen(NULL, p, i+1)) continue;
if (Close[0] <= z) continue;
if (Old > z) continue;
if (iOpen(NULL, p, 2) - iClose(NULL, p, 2) > 20*Point) continue;
DisplayAlert("Look for a "+Symbol()+" SHORT on "+PeriodNice(p)+" (wick)");
t = iTime(NULL, p, 0);
return(0);
}
if (Close[0] == iLow(NULL, p, 0)) {
if (iClose(NULL, p, i+1) < iOpen(NULL, p, i+1)) continue;
if (Close[0] >= z) continue;
if (Old < z) continue;
if (iClose(NULL, p, 2) - iOpen(NULL, p, 2) > 20*Point) continue;
DisplayAlert("Look for a "+Symbol()+" LONG on "+PeriodNice(p)+" (wick)");
t = iTime(NULL, p, 0);
return(0);
}
}
-------------------------------------
-------------------------------------------
if (Close[0] == iHigh(NULL, p, 0)) {
if (iClose(NULL, p, i+1) > iOpen(NULL, p, i+1)) continue;
if (Close[0] <= z) continue;
if (Old > z) continue;
if (iOpen(NULL, p, 2) - iClose(NULL, p, 2) > 20*Point) continue;
DisplayAlert("Look for a "+Symbol()+" SHORT on "+PeriodNice(p)+" (wick)");
t = iTime(NULL, p, 0);
return(0);
}
if (Close[0] == iLow(NULL, p, 0)) {
if (iClose(NULL, p, i+1) < iOpen(NULL, p, i+1)) continue;
if (Close[0] >= z) continue;
if (Old < z) continue;
if (iClose(NULL, p, 2) - iOpen(NULL, p, 2) > 20*Point) continue;
DisplayAlert("Look for a "+Symbol()+" LONG on "+PeriodNice(p)+" (wick)");
t = iTime(NULL, p, 0);
return(0);
}
}
-------------------------------------
- blubbb
- rank: 150+ posts
- Posts: 219
- Joined: Mon Sep 29, 2008 8:07 pm
- Reputation: 0
- Location: Europe
- Gender:
continue makes the loop continue i.e. beginning the next cycle omitting the rest of the lines. So in fact you make your alert pop up only when bar 2 is NOT > 20 pips.
My suggestion (some lines further up rewritten, based on the current version in my thread):
My suggestion (some lines further up rewritten, based on the current version in my thread):
Code: Select all
if (MinFactorWicking > 0) for(int i = 0; i < MaxBars; i++) {
double b2 = MathAbs(iClose(NULL, p, i+2) - iOpen(NULL, p, i+2));
if (b2 < 20 * Point) continue;
double b1 = MathAbs(iClose(NULL, p, i+1) - iOpen(NULL, p, i+1));
if (b1 < b2 * MinFactorWicking) continue;
double z = (iClose(NULL, p, i+1) + iOpen(NULL, p, i+1)) / 2;
blubbb wrote:continue makes the loop continue i.e. beginning the next cycle omitting the rest of the lines. So in fact you make your alert pop up only when bar 2 is NOT > 20 pips.
My suggestion (some lines further up rewritten, based on the current version in my thread):Code: Select all
if (MinFactorWicking > 0) for(int i = 0; i < MaxBars; i++) {
double b2 = MathAbs(iClose(NULL, p, i+2) - iOpen(NULL, p, i+2));
if (b2 < 20 * Point) continue;
double b1 = MathAbs(iClose(NULL, p, i+1) - iOpen(NULL, p, i+1));
if (b1 < b2 * MinFactorWicking) continue;
double z = (iClose(NULL, p, i+1) + iOpen(NULL, p, i+1)) / 2;
Ok, Let me give it a try. Does this look right to you?
-------------------------------------
void Check(int p, datetime& t) {
if (iTime(NULL, p, 0) == t) return(0);
if (MinFactorWicking > 0) for(int i = 0; i < MaxBars; i++) {
double b2 = MathAbs(iClose(NULL, p, i+2) - iOpen(NULL, p, i+2));
if (b2 < 20 * Point) continue;
double b1 = MathAbs(iClose(NULL, p, i+1) - iOpen(NULL, p, i+1));
if (b1 < b2 * MinFactorWicking) continue;
double z = (iClose(NULL, p, i+1) + iOpen(NULL, p, i+1)) / 2;
if (Close[0] == iHigh(NULL, p, 0)) {
if (iClose(NULL, p, i+1) > iOpen(NULL, p, i+1)) continue;
if (Close[0] <= z) continue;
if (Old > z) continue;
//if (iOpen(NULL, p, 2) - iClose(NULL, p, 2) > 20*Point) continue;
DisplayAlert("Look for a "+Symbol()+" SHORT on "+PeriodNice(p)+" (wick)");
t = iTime(NULL, p, 0);
return(0);
}
if (Close[0] == iLow(NULL, p, 0)) {
if (iClose(NULL, p, i+1) < iOpen(NULL, p, i+1)) continue;
if (Close[0] >= z) continue;
if (Old < z) continue;
//if (iClose(NULL, p, 2) - iOpen(NULL, p, 2) > 20*Point) continue;
DisplayAlert("Look for a "+Symbol()+" LONG on "+PeriodNice(p)+" (wick)");
t = iTime(NULL, p, 0);
return(0);
}
}
--------------------------------
Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.
Thank you for your support.
Please add www.kreslik.com to your ad blocker white list.
Thank you for your support.
Thank you for your support.