当前位置:网站首页>Mt4/mql4 getting started to be proficient in EA tutorial lesson 6 - common functions of MQL language (VI) - common order function
Mt4/mql4 getting started to be proficient in EA tutorial lesson 6 - common functions of MQL language (VI) - common order function
2022-06-22 08:01:00 【EA development - green shirt code customer】
bool OrderClose()
Closing function , This function is 5 Parameters
bool OrderClose(
int ticket, // The order number
double lots, // Hand count
double price, // Closing price
int slippage, // Slide it
color arrow_color // The arrow color
);
Manually open an order 
The order number is :198463618
Number of hands is :1
The script instance
void OnStart()
{
OrderClose(198463618,1,Bid,3,Red);
}
Run the script 
Order closed successfully !
double OrderClosePrice();
Return the closing price of the order
int OrdersHistoryTotal();
Return the total number of historical transaction orders
bool OrderSelect();
Order identification , There are up to three parameters
bool OrderSelect(
int index, // Order number or custom sort
int select, // Parameter type
int pool=MODE_TRADES // sort order
);
Two parameter form
OrderSelect(12470, // The order number
SELECT_BY_TICKET // Order number sorting
)
Three parameter form
OrderSelect(i, // Custom serial number
SELECT_BY_POS, // Custom sort
MODE_HISTORY // Sort historical orders , Holding bin sort code :MODE_TRADES
)
datetime OrderOpenTime();
Return the opening time of the order
datetime OrderCloseTime();
Return the order closing time
double OrderOpenPrice();
Return the opening price of the order
double OrderClosePrice();
Return the closing price of the order
double OrderProfit();
Return order profit and loss
double OrderLots();
Return the number of orders opened
int OrderTicket();
Return the order number of the order
The script instance
void OnStart()
{
int hstTotal=OrdersHistoryTotal();
Print("hstTotal for the order:", hstTotal);
if(OrderSelect(hstTotal-1,SELECT_BY_POS,MODE_HISTORY)==true)
{
datetime ctm=OrderOpenTime();
if(ctm>0) Print("Open time for the order: ", ctm);
ctm=OrderCloseTime();
if(ctm>0) Print("Close time for the order: ", ctm);
double close=OrderClosePrice();
Print("ClosePrice for the order:", close);
double open=OrderOpenPrice();
Print("OpenPrice for the order:", open);
double profite=OrderProfit();
Print("Profite for the order:", profite);
double lots=OrderLots();
Print("Lots for the order:", lots);
int ticket=OrderTicket();
Print("ticket for the order:", ticket);
}
else
Print("OrderSelect failed error code is",GetLastError());
}
Example results
Print out the information of the last transaction order 

A good workman does his work well , You must sharpen your tools first , The most important thing in trading is to follow the rules , Strictly carry out . Official account , Study MQL Beginner to master EA course , Learn more EA Programming , Write your own EA, Forge your own magic weapon .

边栏推荐
- easy-rule 初窥
- MySQL backup - mysqldump
- C# 接口持有结构体会导致装箱问题
- Example of using listagg in Oracle 11g (splicing the values of a field into a line, separated by commas)
- PostgreSQL common commands and SQL -- continuous update
- Win openfeign from simple to deep
- mysql截取字符串CS0000_1中_后面的字符
- C语言双向链表实现图书管理系统 可读写文件
- ES6 set data type de duplication of array, intersection, union and difference
- Use multithreading to speed up your crawler
猜你喜欢

An example shows the difference between let and VaR

Detailed explanation of subnet mask

Characteristics of industrial Internet

Wx applet vant UI call interface to realize two-level cascade

It operation and maintenance knowledge map

QT QtableView的使用示例

Mystery of power bank

MySQL query group by 1055 is the simplest and most convenient way to solve the problem perfectly

【 Oracle database】 Nursery Mother Tutorial day13 date Function

代码覆盖率测试对编程小白的意义及其使用方法
随机推荐
Layer drawing method
关于菲涅尔现象
【Oracle 数据库】奶妈式教程 day11 数值函数
Expérience électrique en mode - - expérience 2 circuit d'amplification de source commune JFET
JSON使用示例
Vue page caching problem solving (keep alive + page level routing guard + lifecycle activated)
MySQL index
Ugui text spacing textspacing
Wx applet vant UI call interface to realize two-level cascade
Xlua environment configuration
Model electricity experiment -- Experiment 1 transistor common emitter single transistor amplifier
Wechat applets will directly open the parent element when the child element of flex:1 is too long (the text is too long)
MySQL transactions
navicat如何查询已连接的数据库密码信息
对于mysql中数据为NULL引发的一些问题和思考
(8)顺序栈和链栈
Difference between ID instancetype nsobject *
Toyota bz4x canceled the launch conference. Even if the low-temperature charging problem does not exist, how about the product strength?
Characteristics of industrial Internet
【Oracle 数据库】奶妈式教程day15 DDL、DML、索引、视图、序列、死锁这一篇就够了