Author: Copyright 2015, MetaQuotes Software Corp.
Orders Execution
It automatically opens orders when conditions are reached
0 Views
0 Downloads
0 Favorites
buy_order
//+------------------------------------------------------------------+
//|                                                    buy_order.mq4 |
//|                        Copyright 2015, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2015, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//#include <HPCS_libfunctions_include.mqh>
bool check = true;
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int count = 0;
int OnInit()
 {
 
 EventSetTimer(1);
 
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
 /* while(CloseAllMarketOrders(16772,20)==0)
  {
   Print("calling Sleep______________");
   Sleep(20);
  }*/
  
  }
//+------------------------------------------------------------------+
void OnTimer()
{
 if(TimeSeconds(TimeCurrent())==count)
 { 
 string timesec = IntegerToString(TimeSeconds(TimeCurrent()));
 int ticket = OrderSend(Symbol(),OP_BUY,0.01,Ask,3,0,0,timesec,16772,0,clrGreen);
 if(ticket>0)
 Print("Buy Order Placed");
 else
 Print("OrderSend failed, error#",GetLastError());
 count++;
 if(count>59)
 ExpertRemove();
 }
}

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