当前位置:网站首页>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,锻造属于自己的神兵利器.
边栏推荐
猜你喜欢
OpenSceneGraph3.5.1编译
JDBC technology (3) - use Druid database connection pool test
seaborn 笔记: 绘制分类数据
torchversion.transforms的使用
How js implements array deduplication (7 kinds)
力扣刷题记录3.1-----977. 有序数组的平方
The server quit without updating PID file (/usr/local/mysql/data/localhost.pid).
多语种翻译-免费多语种翻译软件
使用百度EasyDL实现智能垃圾箱
HCIP-R&S By Wakin自用笔记(3)OSPF之各类LSA及LSA更新规则
随机推荐
The server quit without updating PID file (/usr/local/mysql/data/localhost.pid).
基于机器学习之模型树短期负荷预测(Matlab代码实现)
Go-12-结构体
Group DETR:分组一对多匹配是加速DETR收敛的关键
力扣刷题记录3.1-----977. 有序数组的平方
LeetCode每日两题02:轮转数组 (均1200道)
Go-11-流程控制
Z-Game on grid(牛客多校赛)
New Swagger3.0 tutorial, OAS3 quick configuration guide, to automate API interface documentation!
Observer pattern
What is the difference between a project manager and a product manager?
智能视频监控设计摄像头部分
[机缘参悟-65]:《兵者,诡道也》-6-孙子兵法解读-并战计
Go-8-Gin framework
力扣刷题记录10.1-----19. 删除链表的倒数第 N 个结点
VOIP使用单端口替换动态端口池进行UDP通信
mysql连接超过八小时报错
低代码开发创新企业应用构建模式
Using ngrok on Raspberry Pi (Extra 2)
[Signal denoising] Based on Sage-Husa adaptive Kalman filter to realize the suppression of ocean wave magnetic field noise and the generation of ocean wave magnetic field noise with matlab code