Pending Orders

Orders Execution
It automatically opens orders when conditions are reachedChecks for the total of open orders
0 Views
0 Downloads
0 Favorites
Pending Orders
/*-----------------------------+
|			       |
| Shared by www.Aptrafx.com    |
|			       |
+------------------------------*/


void init()
{
   // Create some Orders 
   
   double iBuyPrice = 0;
   double iSellPrice = 0;
   
   iBuyPrice = Ask;
   iSellPrice =  Bid;
   
   iBuyPrice = iBuyPrice - 0.0020;
   iSellPrice = iSellPrice + 0.0020;

   OrderSend(Symbol(), OP_BUYLIMIT, 1, iBuyPrice, 4, 0, 0, "", 123456789, 0 ,Blue);
   OrderSend(Symbol(), OP_BUYLIMIT, 1, iBuyPrice, 4, 0, 0, "", 123456789, 0 ,Blue);
   
   OrderSend(Symbol(), OP_SELLLIMIT, 1, iSellPrice, 4, 0, 0, "", 123456789, 0 ,Blue);
   OrderSend(Symbol(), OP_SELLLIMIT, 1, iSellPrice, 4, 0, 0, "", 123456789, 0 ,Blue);

   Print("Total Pending Orders (init): ", GetTotalPendingOrders());   
}

void start()
{
   // start what?
   
   Print("Total Pending Orders (start): ", GetTotalPendingOrders());
}

int GetTotalPendingOrders()
{
   int iCounter = 0;
   int iSelectedOrderType = 0;
   int iPendingOrders = 0;
   
   for(iCounter = 0; iCounter < OrdersTotal(); iCounter++)
   {      
      if ( OrderSelect(iCounter, SELECT_BY_POS, MODE_TRADES) == true )
      {
         iSelectedOrderType = OrderType();
         
         if ( iSelectedOrderType == OP_BUYLIMIT || iSelectedOrderType == OP_BUYSTOP || iSelectedOrderType == OP_SELLLIMIT || iSelectedOrderType == OP_SELLSTOP )
         {
            iPendingOrders = iPendingOrders + 1;
         }
      }
      else
      {
         Print("Unable to select order: ", iCounter);
      }
      
   }
   
   return (iPendingOrders);
}









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 ---