the answer is in the log file
7bit:
the answer is in the log file
the answer is in the log file
Replace
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if( OrderSymbol()==Symbol() )
to
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
RefreshRates();
if( OrderSymbol()==Symbol() )
See the error in journal. After you find error's number see https://docs.mql4.com/constants/errors.
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
I made this code to close positions,some positions it quits but not other, anyone know where I'm wrong??
for(cnt=OrdersTotal();cnt>=0;cnt--)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if( OrderSymbol()==Symbol() )
{
if(OrderType()==OP_BUY)
{
if( ExitSignal() == 2 )
{
OrderClose(OrderTicket(),Lots,Bid,0,White);
} // if BUY
if(OrderType()==OP_SELL)
{
// did we make our desired SELL profit?
if ( ExitSignal() == 1 )
{
OrderClose(OrderTicket(),Lots,Ask,0,Red) ;
//Fechado = 1;
}
} //if SELL
} // if(OrderSymbol)
} // for
The function
int ExitSignal()
{
int Trend = 0;
double MA7 = 0;
double MA2 = 0;
MA7 = iMA(Symbol(),0,7,0,MODE_SMA,PRICE_CLOSE, 1);
MA2 = iMA(Symbol(),0,2,0,MODE_SMMA,PRICE_CLOSE,1);
if (MA7 < MA2)
{
Trend = 1;
}
if(MA7 > MA2)
{
Trend = 2;
}
return (Trend);
}