当前位置:网站首页>MT4/MQL4 Getting Started to Mastering EA Tutorial Lesson 1 - MQL Language Common Functions (1) OrderSend() Function
MT4/MQL4 Getting Started to Mastering EA Tutorial Lesson 1 - MQL Language Common Functions (1) OrderSend() Function
2022-08-09 02:04:00 【EA Development - Blue Shirt Coder】
int OrderSend()
The function is used to open a new order,它有11个参数.`
int OrderSend(
string symbol, // 交易品种
int cmd, // 买单、Sell order type
double volume, // Order lot size
double price, // 开仓价格
int slippage, // 点差
double stoploss, // 止损
double takeprofit, // 止盈
string comment=NULL, // Order Notes
int magic=0, // Order magic code
datetime expiration=0, // 时限
color arrow_color=clrNONE // The open position shows the arrow color
)
;
Use script instance:
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//--- place market order to buy 1 lot
int ticket=OrderSend(Symbol(),OP_BUY,1,Ask,0,0,0,"My order",16384,0,clrGreen);
if(ticket<0)
{
Print("OrderSend failed with error #",GetLastError());
}
else
Print("OrderSend placed successfully");
//---
}
实例代码实现 Open a buy order at the current price(Buy)No take profit止损.
OrderSend(Symbol(), // 当前交易品种
OP_BUY, // 开一个多单BUY ,Corresponding to the empty ordersell的代码是OP_SELL
1, // The open lot size is1
Ask, // The opening price is the current priceAsk
0, // 点差0
0, // 不设止损
0, // No take profit
"My order",// Order Notes“My order”
16384, // 订单代码16384
0, // 不设时限,This parameter is generally set for pending orders
clrGreen // The open position chart shows a green arrow
);
Example function diagram:
工欲善其事,必先利其器,交易最重要的是遵守规则,严格执行.关注公众号,学习MQL入门到精通EA教程,学习更多EA编程,畅写属于自己的EA,锻造属于自己的神兵利器.
边栏推荐
猜你喜欢
『Another Redis DeskTop Manager』用了这款Redis可视化工具,分析效率提升12倍
JDBC技术(三)——使用Druid数据库连接池测试
在树莓派上使用cpolar(番外篇2)
Summary of Database Design
Grid布局介绍
typescripet92-添加任务功能优化
Group DETR:分组一对多匹配是加速DETR收敛的关键
Likou Brush Question Record 8.1-----206. Reverse linked list
How js implements array deduplication (7 kinds)
HCIP-R&S By Wakin自用笔记(3)OSPF之各类LSA及LSA更新规则
随机推荐
2022护眼产品展,北京眼健康展,眼科医学展,近视矫正设备展
日文翻译-在线免费日文翻译软件
Qt中QFile、QByteArray QDataStream和QTextStream区别
js实现数组去重的方式(7种)
谷歌翻译下载-免费谷歌翻译软件下载
史上最猛“员工”,疯狂吐槽亿万富翁老板小扎:那么有钱,还总穿着同样的衣服!
Go-10-模块与包
Several ways to use JS to achieve array flattening
typescript90-使用类型文件声明类型
电磁辐射安全标准及检测方法
The 7 taboos of time management summarized by the postgraduate students, how many have you won?
KQL和Lucene的区别
gstreamer 记录
增额终身寿险哪家最好呢?真的安全吗?
NPDP改版前最后一次考试!请注意
基于机器学习之模型树短期负荷预测(Matlab代码实现)
qps tps rps 区别
Introduction to LVGL (based on v8.1-8.2)
最新豆瓣top250爬虫案例代码分析[注释齐全]
HCIP-R&S By Wakin自用笔记(3)OSPF之各类LSA及LSA更新规则