If it compiles without any error(!) use the debugger and check where and why it doe not do what you want it to do.
If there are no errors, why are you posting? Just because it compiles doesn't mean it does what you want.
If there are no errors, why are you posting? Just because it compiles doesn't mean it does what you want.
You want MA1 to cross the 3 others on the same candle ? It's very unlikely to happen.
You want MA1 to cross the 3 others on the same candle ? It's very unlikely to happen.
no the crossover is only between ma1 and ma2 if the crossover happen ma should be>ma4 an >ma3
no the crossover is only between ma1 and ma2 if the crossover happen ma should be>ma4 an >ma3
Ok.
Additionally you want crossup to =0 and to be true. It will never happen for sure.
if((canbuy==true)&&(crossup==0)&& (isthiscandleswingh())&& maxswingcandle<=2)
Hi im writing an ea to check if moving average crossed then to check if the trigger candle is the highest or lowest candle out of 8 , there is only chance for two candles max after trigger to be swing high if not the trade will be false , but my code dos not work for some reason can you please look at it i attach photo and the mql4 any help will be appreciated thanks
Just a newbie myself, but one point might be that our comments here should reflect our code. Be precise, avoid unneccesary work and check for
errors. "My code does not work.." is just asking for trouble on here ;) And few will want to delve into dozens of lines of code to solve
your problem.
Perhaps a method to test that your code is doing what it should - after each line, after each function call, if necessary - is whats needed. And experience has told me making your code more elegant and easy to read will save time later!
Looking at the very first function. As an aside, my understanding is that bars on chart is not the best way to check a new bar. Search "mql4 best new bar
detection". And I'd be tempted to put the newbar code inside OnTick().
bool isthisnewcandle(){ static int barsonchart=0; if (Bars==barsonchart) return (false); barsonchart=Bars; return(true);} // I'd find this easier to read void OnTick(){ static int barsonchart=0; if (Bars==barsonchart)return; barsonchart=Bars; // rest of code }
I know this doesn't solve the problem in your code, but it's more about us finding ways to solve our own problems...
Ok.
Additionally you want crossup to =0 and to be true. It will never happen for sure.
wait, i comment out /*&&(isthiscandleswingl()) && minswingcandle<=2*/ and it work fine both crossup and
have different function they are no associated by any mean , please explain your point,thanks
Just a newbie myself, but one point might be that our comments here should reflect our code. Be precise, avoid unneccesary work and check
for errors. "My code does not work.." is just asking for trouble on here ;) And few will want to delve into dozens of lines of code to
solve your problem.
Perhaps a method to test that your code is doing what it should - after each line, after each function call, if necessary - is whats needed. And experience has told me making your code more elegant and easy to read will save time later!
Looking at the very first function. As an aside, my understanding is that bars on chart is not the best way to check a new bar. Search "mql4 best
new bar detection. I'd be tempted to put the newbar function inside OnTick().
I know this doesn't solve the problem in your code, but it's more about us finding ways to solve our own problems...
i checked every function by it own the checking for new bar function work but i will take your advise,about my ea dont work ,im not trying to be rude or untitled im front of my code 6 hours now after 4 hour of trying to figure out what is wrong i posted my issue here am i not doing enough?? am i rude for asking for help

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi im writing an ea to check if moving average crossed then to check if the trigger candle is the highest or lowest candle out of 8 , there is only chance for two candles max after trigger to be swing high if not the trade will be false , but my code dos not work for some reason i know the problem is in isthiscandleswingh() and isthiscandleswingh() because the ea work fine without them can you please look at it i attach photo and the mql4 any help will be appreciated thanks