- Your tradeallowed, is lost as soon as you exit the closing brace.
- Instead just make a global (so you remember it between calls,) datetime, put the date there on close, and test at
the start of the next tick.
Find bar of the same time one day ago - Simple Trading Strategies - MQL4 programming forum
- Your tradeallowed, is lost as soon as you exit the closing brace.
- Instead just make a global (so you remember it between calls,) datetime, put the date there on close, and
test at the start of the next tick.
Find bar of the same time one day ago - Simple Trading Strategies - MQL4 programming forum
hmm damn i dont understand how to solv it i read your link.
if you want to reset the value of the bool on the new D! candle.
datetime time;
if(time!=iTime(Symbol(),PERIOD_D1,0)) { tradeallowed =1; time=iTime(Symbol(),PERIOD_D1,0); }
But you have to declare the bool tradeallowed outside of the function.
bool tradeallowed = false;
if(Open_Orders_Profit()>=TakeProfitInput) { CloseAllPositions(); tradeallowed = false; }
Just
as with the time variable.
i have just checked but seems not working. I have make a function reset. and put it in OnTick.
void reset() { if(time!=iTime(Symbol(),PERIOD_D1,0)) { tradeallowed = true; time=iTime(Symbol(),PERIOD_D1,0); } }
i have put global variable
datetime time; bool tradeallowed = true;
i have changed it
if(Open_Orders_Profit()>=TakeProfitInput) { CloseAllPositions(); tradeallowed = false; }
before my ordersend i check if tradeallowed is true
if (!tradeallowed) return;
We can't see your broken code. There are no mind readers here and our crystal balls are cracked.
ähhh i cannot get that working
Place an order in freelance
Place an order in freelance
🤣
ähhh i cannot get that working
More seriously, when you post your code, try to post complete functions or even complete files (best, because that'll allow the curious people here to test run and tell you straight away what is wrong). Otherwise your question will only be met with guesses...
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- 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,
can someone help how to to teach an ea when xxx amount of open orders reached than do not open trades for the rest of the day and start on next day.
I am counting my openorders right now like this
Now if CloseAllPositions() is called EA have to skip opening new trades..so i have set the bool tradeallowed to true.
But know how can i code ea that the bool will automatically set to true on next trading session by server time?