I want to buy or sell when middle bollinger band crossed by lwma (my attempt does not work ).
Where did I do my mistake?
1) You're using a custom indicator for the BB - are you sure you have the parameters in the right places? I suggest trying it with the built in BB first to get it working how you want
2) Use Period() rather than PERIOD_CURRENT (Current returns zero: https://docs.mql4.com/constants/chartconstants/enum_timeframes )

- docs.mql4.com
2 suggestions:
1) You're using a custom indicator for the BB - are you sure you have the parameters in the right places? I suggest trying it with the built in BB first to get it working how you want
2) Use Period() rather than PERIOD_CURRENT (Current returns zero: https://docs.mql4.com/constants/chartconstants/enum_timeframes )
Thank you for your answer!
With the normal Bollinger Bands I seem not to have a value for the middle line.
I attached the better bollinger bands mq4 file.
Could someone give me an advice? It seems that this is never the case: BBBMid == MALine0
salexes: Could someone give me an advice? It seems that this is never the case: BBBMid == MALine0
double MALine0 = iMA(NULL,0,3,0,MODE_LWMA,PRICE_CLOSE,0); ( BBBMid == MALine0 && MALine1 < MALine0) |
|

Look at this there the MALine0 and the BBBMid have the same value. That is the moment when I want to buy/sell.
From what I read in the other thread: "can't do is get the iband value between bars, so if the cross happens between bars Bid will never == iband"
So how do I recognize the crossing then ? Not possible? If yes any tips, so I can try to figure it out myself after that (to learn and understand it)
(Sorry for all the questions I just started to learn MQL (first coding attempts right now))
- No they don't. They are only the same to 5 digits.one is 1.05999000000001 and the other might be 1.05999000000002 and those are not equal.
- Why are you worrying about equality when your title is about "crossed?" Check for a cross:bool wasAbove = BBBMidPrev > MALine0Prev
bool isAbove = BBBMidCurr > MALine0Curr;
bool cross = wasAbove != isAbove;

- 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 want to buy or sell when middle bollinger band crossed by lwma (my attempt does not work ).
Where did I do my mistake?
double BBBMid =iCustom(NULL, PERIOD_CURRENT,"Better Bollinger Bands",20,2.0,0,2,0);
double BBBBot =iCustom(NULL, PERIOD_CURRENT,"Better Bollinger Bands",20,2.0,0,1,0);
double MALine0 = iMA(NULL,0,3,0,MODE_LWMA,PRICE_CLOSE,0);
double MALine1 = iMA(NULL,0,3,0,MODE_LWMA,PRICE_CLOSE,1);
//****
// WRITE HERE THE CONDITION FOR OPENING A PUT
//
//****
if
( BBBMid == MALine0 && MALine1 > MALine0)
{
pIsDirectionUp=false;
return true;
}
//****
// WRITE HERE THE CONDITION FOR OPENING A CALL
//****
if
( BBBMid == MALine0 && MALine1 < MALine0)
{
pIsDirectionUp=true;
return true;
}
return false;
}
regards,
salexes
EDIT:
I might have found the problem, the MA got .00000 5 ditgits while the better bollinger bands only got 4 digits .0000
What should I do now ?
EDIT2: Changed the better bollinger bands to 5 digits. Still it is not working, recommendations ?