- BABABABA10:
so need help to close the position as soon as candle closedfor(pos = OrdersTotal()-1; pos >= 0 ; pos--) if ( OrderSelect(pos, SELECT_BY_POS) // Only my orders w/ && OrderMagicNumber() == magic.number // my magic number && OrderSymbol() == Symbol() // and my pair. && Time[0] > OrderOpenTime() // New Candle ){ if (!OrderClose( OrderTicket(), OrderLots, OrderClosePrice(), Slippage.Pips*pips2points) Alert("OrderClose(ticket=", OrderTicket(), ", ...) failed: ", GetLastError()); }
- Why use the more complicated function calls
double current_openprice = iOpen(Symbol(), NULL, 0); // Open[0] double previous_highprice_3 = iHigh(Symbol(), NULL, 3); // High[3] datetime current_time = iTime(Symbol(),NULL , 0); // Time[0]
WHRoeder:
- BABABABA10:
so need help to close the position as soon as candle closed - Why use the more complicated function calls
to WHRoeder
he i am new to mql4 prg. so don't have more knowldge about complicated function calls
can u tell me pleas where i can post that code into ea int start() ya define a new funcation can u pleas help me to put that code into ea please
so ea will work fine .. please help
You used:
double current_openprice = iOpen(Symbol(), NULL, 0);The simpler version:
double current_openprice = Open[0];likewise the others mentioned.
WHRoeder:
You used: The simpler version: likewise the others mentioned.
You used: The simpler version: likewise the others mentioned.
i got that u point but i am asking
about this code u given me where i can post that code in to ea so ea will work fine i am confuse about it so asking u . pleas help
for(pos = OrdersTotal()-1; pos >= 0 ; pos--) if ( OrderSelect(pos, SELECT_BY_POS) // Only my orders w/ && OrderMagicNumber() == magic.number // my magic number && OrderSymbol() == Symbol() // and my pair. && Time[0] > OrderOpenTime() // New Candle ){ if (!OrderClose( OrderTicket(), OrderLots, OrderClosePrice(), Slippage.Pips*pips2points) Alert("OrderClose(ticket=", OrderTicket(), ", ...) failed: ", GetLastError()); }
int pips2points; // slippage 3 pips 3=points 30=points double pips2dbl; // Stoploss 15 pips 0.0015 0.00150 int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips) int init(){ if (Digits == 5 || Digits == 3){ // Adjust for five (5) digit brokers. pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } } int start(){ int count=0; for(pos = OrdersTotal()-1; pos >= 0 ; pos--) if ( OrderSelect(pos, SELECT_BY_POS) // Only my orders w/ && OrderMagicNumber() == magic.number // my magic number && OrderSymbol() == Symbol() ){ // and my pair. if (Time[0] > OrderOpenTime()){ // New Candle since open if (OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(), Slippage.Pips*pips2points)){// Successful closing. RefreshRates(); // About to open new. continue; // No count, it's closed } Alert("OrderClose(ticket=", OrderTicket(), ", ...) failed: ", GetLastError()); // Complain and count. } count++; // Order is still open. } // For if (count != 0) return(0); // Order(s) open, wait for a new candle. // No open orders, open a new one. double current_openprice = Open[0]; // iOpen(Symbol(), NULL, 0); ...
WHRoeder:
thank you fore reply :)
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
need help in ea code
ea has to open one order per candle and close the position after candle is closed
so need help to close the position as soon as candle closed