Hello;
, the problem is that this code do not open any trade on backtests .
Why ? is it because the conditions needed to open an order are not met ? is it because the order is not placed correctly ? what have you discovered already ?
I have no idea .
I just modifed those parts of the initial code .
---->first
I declared stop and magicnumber ((no problem))
extern double StopLoss = 50; extern int MagicNumber = 12345;
---->inside int start() declared two other variable
int compteur=0; string aide=Symbol();
----> Then calculated the number of trades by currency and added a condition for opening just one trade by currency
total=OrdersTotal(); for(int i=0; i<total; i++) { if(OrderSelect(i, SELECT_BY_POS)==false) continue; if(OrderSymbol()==aide) compteur++; }
if(compteur<1)
---> ordersend with stop loss and magicnumber
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,"macd sample",MagicNumber,0,Green); and ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Bid+StopLoss*Point,Bid-TakeProfit*Point,"macd sample",MagicNumber,0,Red);
I have no idea .
Don't you think you should try to find out ? Maybe add some print statements, re-run the code, see what the results of the print statements tell you ? it's not rocket science . . .
For example . . .
Print("MacdCurrent= ",MacdCurrent," SignalCurrent= ",SignalCurrent," MacdPrevious= ",MacdPrevious," SignalPrevious= ",SignalPrevious," MathAbs(MacdCurrent)= ",MathAbs(MacdCurrent), " (MACDOpenLevel*Point)= ",(MACDOpenLevel*Point)); // <---------------------------------------------- if(MacdCurrent<0 && MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious && MathAbs(MacdCurrent)>(MACDOpenLevel*Point) && MaCurrent>MaPrevious) { Print("Try to open Buy order"); // <---------------------------------------------- ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point,"macd sample",MagicNumber,0,Green); if(ticket>0)
I will add comments, but firstly the EA must work, I don't know what is the problem !!!, the initial EA has good result in backtests and forward tests but it open only one trade in one currency and does not use stop loss, I really don't know why metaquotes programmer coded the EA in this way .
Is it openning trades in your MT4 !!
I will add comments, but firstly the EA must work, I don't know what is the problem !!!,
Ok I will see that then I will be back .
Thank you for your help RaptorUK .
thank you very much raptoruk now I have found the mistake and it's trading .

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hello;
I want to modify the known expert advisor ((Macd Sample)), I have added a stop loss and a magicnumber and modified the code to allow trading in multiple currency pairs in the same time by adding a variable ((compteur)), the problem is that this code do not open any trade on backtests .
The code is in attached files.
Sorry for mistakes because English is my fifth language.
Thank You for help.