I am doing an EA of triangular arbitrage.. when profit reach 22 or above the orders should be close but when I'm trying to close the orders I got an error of 129..
- Stop Loss in Close [1]
- orderclose problem
- Problem with MetaTrader Client Terminal Ver 4.0 Build 185
for(cnt=OrdersTotal();cnt>=0;cnt--) { OrderSelect(cnt, SELECT_BY_POS); if(magic == OrderMagicNumber())
- Position is OrdersTotal() - 1 to zero so your the first orderSelect always fails and everything thing else is bogus.
- Always test return codes.
- No need to indent 3 levels
for(int iPos = OrdersTotal()-1; iPos >= 0; iPos--) if ( OrderSelect(iPos, SELECT_BY_POS) && OrderSymbol() == chart.symbol // This pair/Any TF.
if(set<3){ : set++; } RefreshRates(); if(set == 3)...
simplify code where possibleif(set<3){ : set++; continue; } RefreshRates(); // if(set == 3)...
No need for refreshRates there as you haven't done any server calls since start. You DO need refreshRates between each server call. IF(A){} IF(not A) could be IF(A){} else {.. but since your in a loop, just continue until you have the right count.
WHRoeder:
- Position is OrdersTotal() - 1 to zero so your the first orderSelect always fails and everything thing else is bogus.
- Always test return codes.
- No need to indent 3 levels
-
simplify code where possible
No need for refreshRates there as you haven't done any server calls since start. You DO need refreshRates between each server call. IF(A){} IF(not A) could be IF(A){} else {.. but since your in a loop, just continue until you have the right count.
thanks for your reply, but it still don't close orders.. I there anything else that I need to change.. I'm new in doing this EA
RaptorUK:
You seem to be closing Sell orders on EURJPY at bid_eurjpy and Buy orders on EURJPY at ask_eurjpy
You seem to be closing Sell orders on EURJPY at bid_eurjpy and Buy orders on EURJPY at ask_eurjpy
thanks for your reply I think it's right coz when I open the orders for eurjpy when the set is sell I open it with bid so when I close the orders I should also close it with bid...same as buy..
jam04:
No . . you need to close a Sell with a Buy . . and a Buy is taken at Ask . . not Bid . . . look at "your" code for USDJPY and EURUSD, you close those Sells at Ask, and those Buys at Bid . . .
thanks for your reply I think it's right coz when I open the orders for eurjpy when the set is sell I open it with bid so when I close the orders I should also close it with bid...same as buy..
RaptorUK:
No . . you need to close a Sell with a Buy . . and a Buy is taken at Ask . . not Bid . . . look at "your" code for USDJPY and EURUSD, you close those Sells at Ask, and those Buys at Bid . . .
No . . you need to close a Sell with a Buy . . and a Buy is taken at Ask . . not Bid . . . look at "your" code for USDJPY and EURUSD, you close those Sells at Ask, and those Buys at Bid . . .
but when I put profit=22; before print profit the orders are close.. but when I wait for the profit to reach 22 base on the movement of the chart when it reach 22 it just give me an error of 129 "Invalid price"..
RaptorUK:
What pairs does it give you an Error 129 on ?
What pairs does it give you an Error 129 on ?
all pairs
RaptorUK:
What pairs does it give you an Error 129 on ?
Is it possible that the reason that I got this error is because the ea open too many orders per tick?
What pairs does it give you an Error 129 on ?
jam04:
all pairs
Can you copy and paste some entries from the Experts tab/Journal tab to show this.
all pairs
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