CloseAllPositive

Orders Execution
Checks for the total of open ordersIt Closes Orders by itself
0 Views
0 Downloads
0 Favorites
CloseAllPositive
//+------------------------------------------------------------------+
//| CloseAllPositive Scripts  by ***NicoMax***                       |
//|                                                                  |
//| Close All Open order with positive profit                        |
//+------------------------------------------------------------------+

//+------------------------------------------------------------------+
//| script program start function                                    |
//+------------------------------------------------------------------+
extern int    Slippage      = 1;

int start()
  {
  bool   Result;
  int    Pos,Error,Total;
  for(int i=1; i<=OrdersTotal(); i++)
  {      
  if (OrderSelect(i-1,SELECT_BY_POS)==true)
      {   
        if ( OrderProfit()>1)
            {
            Pos=OrderType();
            if(Pos==OP_BUY) 
              Result=OrderClose(OrderTicket(),
                                OrderLots(),
                                Bid,
                                Slippage,
                                CLR_NONE);
              else
              Result=OrderClose(OrderTicket(),
                                OrderLots(),
                                Ask,
                                Slippage,
                                CLR_NONE);
             }
          }
      } 
   return(0);
  }
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---