pullend:
Without rigorously checking your ( ) braces . . . it looks OK to me.Hoping someone might point out to me what I am doing wrong here. I want to express the Buffer condition such that it is true if (all the conditions in the 2nd line are true) and at the same time conditions in the (3rd line combined with the 4th) or (3rd combined with the 5th) or (3rd combined with the 6th) or (3rd combined with 7th) or (3rd combined with the 8th) are true The code compiles ok but I am not achieving my desired outcome.
I am obviously expressing it wrong and need some help
Thanks in advance
Try breaking the logic into parts and then recombine them later:
bool mandatory = false, optional = false; //must satisfy ALL of these conditions mandatory = c1>0 && c2>0 && c3>0 && Close[i]>High[i+1] && iSAR(NULL,0,0.01,0.2,i)<Low[i] && c4>BB_min_Width && c5<c6 && c5>c7 && Close[i]<c7; //must satisfy ONE OR MORE of these conditions optional = Close[i+1]<(iMA(Symbol(),0,20,0,MODE_SMA,PRICE_CLOSE,i+1)-2*iStdDev(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,i+1)) || Close[i+2]<(iMA(Symbol(),0,20,0,MODE_SMA,PRICE_CLOSE,i+2)-2*iStdDev(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,i+2)) || Close[i+3]<(iMA(Symbol(),0,20,0,MODE_SMA,PRICE_CLOSE,i+3)-2*iStdDev(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,i+3)) || Close[i+4]<(iMA(Symbol(),0,20,0,MODE_SMA,PRICE_CLOSE,i+4)-2*iStdDev(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,i+4)) || Close[i+5]<(iMA(Symbol(),0,20,0,MODE_SMA,PRICE_CLOSE,i+5)-2*iStdDev(NULL,0,20,0,MODE_SMA,PRICE_CLOSE,i+5)); if(mandatory && optional) ExtMapBuffer1[i]=Low[i]-(PipBuffer)*Point;
Untested code crudely thrown together in notepad... but you should get the idea?
wabbit:
brilliant thanks for help
Try breaking the logic into parts and then recombine them later:
Untested code crudely thrown together in notepad... but you should get the idea?
RaptorUK:
Without rigorously checking your ( ) braces . . . it looks OK to me.
Without rigorously checking your ( ) braces . . . it looks OK to me.
thanks Raptor, you were right.
I am not sure how you experts do it, but by cutting and pasting the code into Microsoft word and using the find function, I eventually found and evened up the missing brackets
now I can start working on getting the working code a lot less sloppy
thanks
dave
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
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