Thread: How to code?
View Single Post
  #118 (permalink)  
Old 06-25-2006, 02:14 AM
Aaragorn's Avatar
Aaragorn Aaragorn is offline
Senior Member
 
Join Date: Jun 2006
Location: USA
Posts: 801
Aaragorn is on a distinguished road
PHP Code:
if(AccountEquity()<AccountBalance()) { 
{
  
int ttotal OrdersTotal();
  for(
int i=ttotal-1;i>=0;i--)
  {
    
OrderSelect(iSELECT_BY_POS);
    
int type   OrderType();

    
bool result false;
    
    switch(
type)
    {
      
//Close opened long positions
      
case OP_BUY       result OrderCloseOrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_BID), 5Red );
                          break;
      
      
//Close opened short positions
      
case OP_SELL      result OrderCloseOrderTicket(), OrderLots(), MarketInfo(OrderSymbol(), MODE_ASK), 5Red );
                          
    }
    
    if(
result == false)
    {
      
Alert("Order " OrderTicket() , " failed to close. Error:" GetLastError() );
      
Sleep(3000);
    }  
  }
  
  return(
0);
}
}

ok this is what I tried ..it's mostly copied from another code someone else here made...but it's just closing everything as fast as they open and not paying any attention to the 'if' condition before executing closes....oy I'm not good at this....I obviously don't have the part that is doing the closing of orders sufficiently attached to the conditional line that compares the account equity to the account balance. Could someone please help me with this?

Last edited by Aaragorn; 06-25-2006 at 03:42 AM.
Reply With Quote