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
Thanks, but...
The last EA I posted has a 3 second lag and 50 (!) pips slippage. Price
12 charts of 3 seconds each - price won't have time to run that far. Or am I misunderstanding something?
Hopefully you can track it down. "Dropping" means about once every 2-3 minutes. If you don't - probably the server is too close, or there computer is too fast. I have part of my CPU taken up by a neural network packet, so MT gets 50%... Now... Here, disabled the neural network (there's a pause button, unlike some other programs). Error number one hasn't gone away, but has become a little less frequent. MT is "eating" 55-99% of CPU. Turning it on... MT gets 1.5 times less CPU time. Error became more frequent too.
double dStopLoss; int nHoursToHold; datetime timePrev = 0; int nBars; int nDelaySeconds = 3; int nSlip = 50; double dLotSize = 0.1; int nMagic = 0; int nDigits; string strTradeSemaphore = "TradeSemaphore"; ////////////////// int init() { nBars = Bars; if(!IsTesting() && !GlobalVariableCheck(strTradeSemaphore)) GlobalVariableSet(strTradeSemaphore, 0.0); dStopLoss = 110 * Point; nHoursToHold = 1; nDigits = MarketInfo( Symbol(), MODE_DIGITS ); if(Symbol() == "EURUSD") nMagic = 1; else if(Symbol() == "EURJPY") nMagic = 2; else if(Symbol() == "USDCHF") nMagic = 3; else if(Symbol() == "GBPUSD") nMagic = 4; else if(Symbol() == "GBPJPY") nMagic = 5; else if(Symbol() == "GBPCHF") nMagic = 6; else if(Symbol() == "USDJPY") nMagic = 7; else if(Symbol() == "AUDUSD") nMagic = 8; else if(Symbol() == "EURGBP") nMagic = 9; else if(Symbol() == "USDCAD") nMagic = 10; else if(Symbol() == "EURCHF") nMagic = 11; else if(Symbol() == "EURAUD") nMagic = 12; return(0); } // ------ int deinit() { return(0); } // ------ int start() { if(Bars < 5) return(0); /* // The previous bar just closed bool bIsBarEnd = false; if(timePrev != Time[0] + nMagic) bIsBarEnd = true; timePrev = Time[0] + nMagic; */ bool bIsBarEnd = false; if(nBars != Bars) { if(IsTesting() || (!IsTesting() && CurTime() > Time[0] + nMagic * nDelaySeconds)) { bIsBarEnd = true; nBars = Bars; } } if(!bIsBarEnd) return(0); // ------ if(!IsTesting()) { while(!IsStopped()) { if(GlobalVariableGet(strTradeSemaphore) == 0.0) GlobalVariableSet(strTradeSemaphore, nMagic); if(GlobalVariableGet(strTradeSemaphore) == nMagic) break; Sleep(1000); } } RefreshRates(); for(int nCnt = OrdersTotal() - 1; nCnt >= 0; nCnt--) { OrderSelect(nCnt, SELECT_BY_POS, MODE_TRADES); if(OrderMagicNumber() == nMagic) { if(CurTime() - OrderOpenTime() > (nHoursToHold - 1) * 60 * 60) { if(OrderType() == OP_BUY) OrderClose(OrderTicket(), OrderLots(), Bid, nSlip, Aqua); else if(OrderType() == OP_SELL) OrderClose(OrderTicket(), OrderLots(), Ask, nSlip, OrangeRed); } } } int nSignal = GetSignal(); if(nSignal == OP_BUY) Buy(); else if(nSignal == OP_SELL) Sell(); if(!IsTesting()) GlobalVariableSet(strTradeSemaphore, 0.0); return(0); } // ------ void Sell() { if(AccountFreeMargin() < 500) return; dLotSize = GetLotSize(); double dNormalizer = MathPow(10, nDigits); double dBid = Bid;//MathFloor(Bid * dNormalizer) / dNormalizer; //NormalizeDouble(Bid, nDigits); double dStop = Bid + dStopLoss;//MathFloor((Bid + dStopLoss) * dNormalizer) / dNormalizer; //NormalizeDouble(Bid + dStopLoss, nDigits); int nResult = OrderSend(Symbol(), OP_SELL, dLotSize, dBid, nSlip, dStop, 0, "Friday", nMagic, 0, OrangeRed); if(nResult == -1) { int nError = GetLastError(); Alert(Symbol() + ", sell: " + dBid + ", Stop: " + dStop + ", error: " + nError); } } // ------ void Buy() { if(AccountFreeMargin() < 500) return; dLotSize = GetLotSize(); double dNormalizer = MathPow(10, nDigits); double dAsk = Ask;//MathFloor(Ask * dNormalizer) / dNormalizer; //NormalizeDouble(Bid, nDigits); double dStop = Ask - dStopLoss;//MathFloor((Ask - dStopLoss) * dNormalizer) / dNormalizer; //NormalizeDouble(Bid + dStopLoss, nDigits); int nResult = OrderSend(Symbol(), OP_BUY, dLotSize, dAsk, nSlip, dStop, 0, "Friday", nMagic, 0, Aqua); if(nResult == -1) { int nError = GetLastError(); Alert(Symbol() + ", buy: " + dAsk + ", Stop: " + dStop + ", error: " + nError); } } // ------ double GetLotSize() { double dLot = 0.1; return(dLot); } // ------ int GetSignal() { int nSignal; if(MathMod(Hour(), 2) == 0) nSignal = OP_BUY; else nSignal = OP_SELL; return(nSignal); }The South is calling, and the new feature will be promptly tested in a week =)))))
...and thank you too, at least someone tried to work out the bugs ;)
Quark, I wrote about the Developer, not the developers. :) Get it? In some religions it's God, in others it's a different address.
Also, I wrote that my 9 EAs work fine on one account. But you're good at finding the conditions when MT4 is shoveling something wrong :)
See you Monday :)
The South is calling and the new f-function will be promptly tested in a week =)))))
A big hello to the South.
...and thank you too, at least someone tried to work out the bugs ;)
With one mistake. And how many of them...
I was only joking :) Although the principle is the same everywhere. If you ask correctly, you get an answer. If you swear, you get banned :)
And I also wrote that my 9 EAs are running fine on the same account. But you're good at finding the conditions when MT4 is shoveling something wrong :)
72 windows with 12 of my councillors - also. Then I added the 13th, and here we go... In general, of course, if I take the last EA posted in this branch and use it at watches instead of minutes, and increase pause from 3 seconds to 30 (as you suggested, by the way) there won't be errors. So the result is achieved, a positive one...
It's a pity about guys from English forum, but I won't translate our posts for them. Not in good health :(
Good luck,
Quark
The problem occurs on different EAs. Logic in all of them was modified with semaphores (as Slava suggested) and delay (Rosh) - so that in given 10 seconds only 1 EA was working. All errors I mentioned above disappeared (so far), except number 6.