thanks, is this also possible w/ a sleep command after the buy/sell condition?
fex. sleep = 86400;
how to allow 1 trade per day only?
Once per day or once after 24 hours? (open 2358, open 0002, 2 trades within 4 minutes but only once per day)
Open once per day or open after the last trade closes?
Saving the time in a static/global will not survive a terminal restart. Sleep will also not survive a terminal restart.
Once per day or once after 24 hours? (open 2358, open 0002, 2 trades within 4 minutes but only once per day)
Open once per day or open after the last trade closes?
Saving the time in a static/global will not survive a terminal restart. Sleep will also not survive a terminal restart.
i found this but getting a lot of unbalanced right parenthesis errors, how can this be fixed?
static datetime tradingAllowed; int newCount = HistoryTotal(); static int prevCount; if (newCount != prevCount){ prevCount = newCount; datetime lastClose; for(int pos=newCount-1; pos >= 0; pos--) if ( OrderSelect(pos, SELECT_BY_POS, MODE_HISTORY) // Only orders w/ && OrderCloseTime() > lastClose // not yet processed, && OrderMagicNumber() == magic.number // my magic number && OrderSymbol() == Symbol() // and my pair. && OrderType() <= OP_SELL){ // Avoid cr/bal forum.mql4.com/32363 lastClose = OrderCloseTime(); } datetime lastClosePlus24Hrs = lastClose + 24 * 3600; datetime lastCloseNextDay = lastClose % 86400 + 86400 tradingAllowed = lastcloseNextDay; } if (TimeCurrent() => tradingAllowed){ ... }
i found this but getting a lot of unbalanced right parenthesis errors, how can this be fixed?
You are here working with OrderCloseTime
I wanna ask what is 1 trade per day only reading here
I get somehow the feeling that it is allowed to open a new trade when the last opened trade is opened atleast for 86400
seconds ago.... So OrderOpenTime but if the last one is still open and a day old is it then also allowed to do a new trade ?
compiling is working now, but not open any order ... it should block 2h from the last order
static datetime tradingAllowed; int newCount = HistoryTotal(); static int prevCount; if (newCount != prevCount){ prevCount = newCount; datetime lastClose; for(int pos=newCount-1; pos >= 0; pos--) if ( OrderSelect(pos, SELECT_BY_POS, MODE_HISTORY) // Only orders w/ && OrderCloseTime() > lastClose // not yet processed, && OrderMagicNumber() == Reference // my magic number && OrderSymbol() == Symbol() // and my pair. && OrderType() <= OP_SELL){ // Avoid cr/bal forum.mql4.com/32363 lastClose = OrderCloseTime(); } datetime lastClosePlus24Hrs = lastClose + 2 * 3600; tradingAllowed = lastClosePlus24Hrs; } if (TimeCurrent() >= tradingAllowed) return(0);
Perhaps you mean . . .
if (TimeCurrent() <= tradingAllowed) return(0); // don't do anything else, return
Perhaps you mean . . .
thanks, but could it be that it does not work at BT?
2011.01.20 21:14 buy 1 0.10 0.99661 0.00000 0.00000 0.00 750.003
2011.01.20 21:24 close 1 0.10 0.99773 0.99291 0.99781 11.23 761.23
2011.01.20 21:24 sell 2 0.10 0.99773 0.00000 0.00000 0.00 761.23
thanks, but could it be that it does not work at BT?
2011.01.20 21:14 buy 1 0.10 0.99661 0.00000 0.00000 0.00 750.003
2011.01.20 21:24 close 1 0.10 0.99773 0.99291 0.99781 11.23 761.23
2011.01.20 21:24 sell 2 0.10 0.99773 0.00000 0.00000 0.00 761.23
I don't know . . . test it, debug it, fix any issues . .
Of course it also depends on where in your code you have placed WHRoeder's code . . .
compiling is working now, but not open any order ... it should block 2h from the last order
Then I think you have to look to two different conditions for the time new tradingAllowed
if (time > OrderOpentime last trade + 86400 && time > OrderClosetime last trade + 2 * 3600)
then make tradingAllowed the biggest value of the two conditions
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use