while (buyCondition === true)
I don't know what happens with === instead of ==
Please edit your post and
use the code button (Alt+S) when pasting code
Keith Watford:
I don't know what happens with === instead of ==
Please edit your post and
use the code button (Alt+S) when pasting code
even with == it's still not working
pirokele:
even with == it's still not working
Show the code.
Keith Watford:
use the code button (Alt+S) when pasting code
Keith Watford:
Show the code.
//+------------------------------------------------------------------+ //| abbexpert.mq4 | //| Copyright 2019, MetaQuotes Software Corp. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2019, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property strict bool buytrue; bool selltrue; bool firstbuy; bool firstsell; int nowcount; int counter; //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { buytrue = true; selltrue = true; firstbuy = true; firstsell = true; counter = 1; nowcount=0; return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Expert deinitialization function | //+------------------------------------------------------------------+ void OnDeinit(const int reason) { //--- } //+------------------------------------------------------------------+ //| Expert tick function | //+------------------------------------------------------------------+ void OnTick() { //--- while(Bid > MAsignal()) { closeSellTrade(); selltrue = true; firstsell = true; if(buytrue == true && OrdersTotal() == 0 && firstbuy == true) { openBuyTrade(); buytrue = false; firstbuy = false; } if(buytrue == true && OrdersTotal() == 0 && firstbuy == false) { if(Bid > closedBuyPrice()) { openBuyTrade(); buytrue = false; } } } while(Bid < MAsignal()) { closeBuyTrade(); buytrue = true; firstbuy = true; if(selltrue == true && OrdersTotal() == 0 && firstsell == true) { openSellTrade(); selltrue = false; firstsell = false; } if(selltrue == true && OrdersTotal() == 0 && firstsell == false) { if(Bid > closedSellPrice()) { openSellTrade(); selltrue = false; } } } } //+------------------------------------------------------------------+
The MAsignal() is a function that returns moving average values
-
while(Bid > MAsignal()) {
Perhaps you should read the manual.
After Sleep and between server calls the market will have changed. You must update your Predefined Variables or series arrays before using any of them — you must call RefreshRates.
How To Ask Questions The Smart Way. 2004
How To Interpret Answers.
RTFM and STFW: How To Tell You've Seriously Screwed Up. - pirokele: I am writing an EA that continually execute a function as long as a buy or sell remain true.Stop doing that. Nothing is changing, just return (thus, waiting for the next tick) and then reevaluate using the new information.
but its not working. Please kindly advice me on what to do.
- No sleep means you will be using 100% CPU doing nothing.

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
I am writing an EA that continually execute a function as long as a buy or sell remain true. For example if buy is true, the function will execute and quite. It will check again if buy is still true, if true it will execute again. It will continue the cycle until buy is false. I tried implementing this with something like this:
while (buyCondition === true) {
...
}
but its not working. Please kindly advice me on what to do.