<div class=\"blockcode\"><div id=\"code_vzf\"><ol>int start()
{
double MACD_1 = iMACD( Symbol(), 0, 200, 400, 9, PRICE_CLOSE, MODE_MAIN, 1 );
double MACD_2 = iMACD( Symbol(), 0, 200, 400, 9, PRICE_CLOSE, MODE_MAIN, 2 );//快线
double MACD_3 = iMACD( Symbol(), 0, 200, 400, 9, PRICE_CLOSE, MODE_SIGNAL, 1 );//慢线
double MACD_4 = iMACD( Symbol(), 0, 200, 400, 9, PRICE_CLOSE, MODE_SIGNAL, 2 );
int _GetLastError = 0, _OrdersTotal = OrdersTotal();
for ( int z = _OrdersTotal - 1; z >= 0; z -- )
{
if ( !OrderSelect( z, SELECT_BY_POS ) )
{
_GetLastError = GetLastError();
Print( \"OrderSelect( \", z, \", SELECT_BY_POS ) - 错误#\", _GetLastError );
continue;
}
if ( OrderSymbol() != Symbol() ) continue;
if ( OrderType() == OP_BUY )
{
if ( NormalizeDouble( MACD_1, Digits + 1 ) < NormalizeDouble( MACD_3, Digits + 1 ) &&
NormalizeDouble( MACD_2, Digits + 1 ) >= NormalizeDouble( MACD_4, Digits + 1 ))
{
if ( !OrderClose( OrderTicket(), OrderLots(), Bid, 5, Green ) )
{
_GetLastError = GetLastError();
Alert( \"错误 OrderClose # \", _GetLastError );
return(-1);
}
}
else return(0);
}
if ( OrderType() == OP_SELL )
{
if ( NormalizeDouble( MACD_1, Digits + 1 ) > NormalizeDouble( MACD_3, Digits + 1 ) &&
NormalizeDouble( MACD_2, Digits + 1 ) 1 ) > 0.0 &&
NormalizeDouble( MACD_2, Digits + 1 ) 0.0 &&
NormalizeDouble( MACD_2, Digits + 1 ) > 0.0 &&
NormalizeDouble( MACD_3, Digits + 1 ) > 0.0 &&
NormalizeDouble( MACD_4, Digits + 1 ) > 0.0 &&
NormalizeDouble( MACD_1, Digits + 1 ) > NormalizeDouble( MACD_3, Digits + 1 ) &&
NormalizeDouble( MACD_2, Digits + 1 ) |