| / | Forum |
|
shilox
2010.02.09 14:49
Hello guys, i have an EA that does not close trades when the opposite parameter is met. Need help from programmers on what i should do. Thanks guys. |
|
Automated Trading Championship 2009 Will Not Be Conducted We decided not to conduct the Automated Trading Championship in 2009. Instead of this we will concentrate our efforts on the release of the new MetaTrader 5 platform and next year we will conduct the Championship for Expert Advisors written in MQL5. |
|
gordon
2010.02.09 15:02
What does that mean? Please explain. |
|
shilox
2010.02.09 20:50
Its a Moving Average EA, with TP and SL as usual for a proper EA, but the problem is when the MA recrosses it doesnt exit trade. |
|
cloudbreaker
2010.02.09 21:06
|
|
gordon
2010.02.10 05:13
shilox wrote >>
Its a Moving Average EA, with TP and SL as usual for a proper EA, but the problem is when the MA recrosses it doesnt exit trade. Well that's very nice, but you are asking a general question about code that we can't see. Try to pinpoint your problem (problem with order close loop? problem with close signal logic? etc.) and post the relevant code here. |
|
shilox
2010.02.10 07:50
gordon wrote >>
Well that's very nice, but you are asking a general question about code that we can't see. Try to pinpoint your problem (problem with order close loop? problem with close signal logic? etc.) and post the relevant code here. Attached is the EA. Thanks. |
|
WHRoeder
2010.02.10 16:47
for(cnt = OrdersTotal(); cnt >= 0; cnt--) { OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES); if(OrderSymbol() == symbol && OrderMagicNumber()==Magicbuy) { ticketbuy=OrderTicket();OrderSelect(ticketbuy, SELECT_BY_TICKET, MODE_TRADES); lotsbuy2=OrderLots() ;There is no orderSelect(OrdersTotal()) If you have one (1) order you can only orderSelect(0). You are not checking the return code from order select. Why are you selecting by ticket when you already selected by position? for(int index = OrdersTotal() - 1; index >= 0; index--) if ( OrderSelect(index, SELECT_BY_POS) // Only my orders w/ && OrderMagicNumber() == MagicNumber + Period.index // my magic number && OrderSymbol() == Symbol() ) { // and period and symbolThere is no difference between OrdersTotalMagicbuy and the sell version except for dxPoint and that code should be in Init: //++++ These are adjusted for 5 digit brokers. double pips2points, // slippage 3 pips 3=points 30=points 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; } On a 5 digit broker your slippage of 3 should be 3*pips2points. Check your OrderClose() for errors and add Print() statements. As for your original question, when the stochastics say to buy, where to you call orderclosesell? |
|
shilox
2010.02.10 22:22
WHRoeder wrote >>
There is no orderSelect(OrdersTotal()) If you have one (1) order you can only orderSelect(0). You are not checking the return code from order select. Why are you selecting by ticket when you already selected by position? There is no difference between OrdersTotalMagicbuy and the sell version except for dxPoint and that code should be in Init: On a 5 digit broker your slippage of 3 should be 3*pips2points. Check your OrderClose() for errors and add Print() statements. As for your original question, when the stochastics say to buy, where to you call orderclosesell? I really couln't and cant continue beyond this point where i have posted this. Could you compile it like you are saying? Thanks! |