I created small bollinger bands. How to prevent buy orders when the price on it.
....
it does not work
Do you mean that you don't want send buy order when the price closes between upper and lower Bollinger Bands lines? If I'm right you should change your condition in this way:
if((Close[0]>iBands(NULL,0,200,0.15,0,PRICE_CLOSE,MODE_UPPER,0))&&(Close[0]<iBands(NULL,0,200,0.15,0,PRICE_CLOSE,MODE_LOWER,0)))
- Nhựt Phạm: I created small bollinger bands. How to prevent buy orders when the price on it.
if((Close[0]!=iBands(NULL,0,200,0.15,0,PRICE_CLOSE,MODE_UPPER,0))&&(Close[0]!=iBands(NULL,0,200,0.15,0,PRICE_CLOSE,MODE_LOWER,0))
it does not work
- "Doesn't work" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless.
- Doubles are rarely equal. Understand the links in:
The == operand. - MQL4 and MetaTrader 4 - MQL4 programming forum - You want inside or outside, not on.
- Petr Nosek: Do you mean that you don't want send buy order when the price closes between upper and lower Bollinger Bands lines? If I'm right you should change your condition in this way:
if((Close[0]>iBands(NULL,0,200,0.15,0,PRICE_CLOSE,MODE_UPPER,0))&&(Close[0]<iBands(NULL,0,200,0.15,0,PRICE_CLOSE,MODE_LOWER,0)))
Sorry Petr, price will never be above the upper band and below the lower band at the same time.
Are your books one column but two feet wide? No because that is unreadable. They are 6 inches, sometimes two columns, so you can read it easily. So should be your code. I'm not going to go scrolling (or moving my eyes) back and forth trying to read and verify it. Write self-documenting code:
double upper = iBands(NULL,0,200,0.15,0,PRICE_CLOSE,MODE_UPPER,0); double lower = iBands(NULL,0,200,0.15,0,PRICE_CLOSE,MODE_LOWER,0); bool isAbove = Bid > upper; bool isBelow = Bid < lower; bool isInside = !isAbove && !isBelow; bool isOutside = isAbove || isBelow;
Sorry Petr, price will never be above the upper band and below the lower band at the same time.
LOL Thank you for your notice. You are absolutely right and it was my fault. The code should be:
if((Close[0]>iBands(NULL,0,200,0.15,0,PRICE_CLOSE,MODE_UPPER,0))||(Close[0]<iBands(NULL,0,200,0.15,0,PRICE_CLOSE,MODE_LOWER,0)))
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I created small bollinger bands. How to prevent buy orders when the price on it.
....
it does not work