there is no error in the code u provided
for(int i=1; i<=OrdersTotal(); i++) // Loop through orders { if (OrderSelect(i-1,SELECT_BY_POS)==true) // If there is the next one if (OrderType()>1) // Pending order found
Orders are indexed from zero to total - 1. Also you must count down when closing/deleting when there are multiple orders (multiple charts). Don't use constants like 1, self-document your code.
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 (OrderType() > OP_SELL) // Pending order
Total++; // Counter of market orders if (Total<1) // No more than one order
The if will never be executed. The Total++ should be inside the for loop braces, the if outside.
Thank you very much
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
Hi everyone, this is my first post. I've begun learning mql for a short time. Today i've tried to make my firs EA and with a big help from this site.
i wrote one but it didn't run so i tried to fix copying from the tutorial but it still doesn't work.
Symb=Symbol(); // Security name
int Total=0; // Amount of orders
for(int i=1; i<=OrdersTotal(); i++) // Loop through orders
{
if (OrderSelect(i-1,SELECT_BY_POS)==true) // If there is the next one
{ // Analyzing orders:
if (OrderSymbol()!=Symb)continue; // Another security
if (OrderType()>1) // Pending order found
{
Alert("Trovato ordine pendente. EA non lavora.");
return; // Exit start()
}
Total++; // Counter of market orders
if (Total<1) // No more than one order
{
Alert("Alcuni ordini trovati al mercato. EA non lavora.");
return; // Exit start()
}
Ticket=OrderTicket(); // Number of selected order
Tip =OrderType(); // Type of selected order
Price =OrderOpenPrice(); // Price of selected order
SL =OrderStopLoss(); // SL of selected order
TP =OrderTakeProfit(); // TP of selected order
Lot =OrderLots(); // Amount of lots
}
}
This is the error showed:
'<=' - assignment expected C:\Programmi\Interbank FX Trader 4\experts\Tripla media.mq4 (64, 17)
Thanks to everyone can help me.