1,000,000$ 交易计划
以量化交易为生

// 快速创建买单脚本
// 接受一个magic参数, 发送订单时使用这个参数
// 接受一个volume参数, 默认为0.01手
#property copyright "Copyright 2024, MetaQuotes Ltd."
#property link "https://www.mql5.com"
#property version "1.00"
#property script_show_inputs
#property strict

input int magic = 0;
input double volume = 0.01;

void OnStart()
{
double price = MarketInfo(Symbol(), MODE_ASK);
double sl = 0;
double tp = 0;
int ticket = OrderSend(Symbol(), OP_BUY, volume, price, 30, sl, tp, "Buy script", magic);
if(ticket > 0)
{
Print("Order opened: ", ticket);
}
else
{
Print("Failed to open order: ", GetLastError());
}

}

// 快速创建卖单脚本
// 接受一个magic参数, 发送订单时使用这个参数
// 接受一个volume参数, 默认为0.01手
#property copyright "Copyright 2024, MetaQuotes Ltd."
#property link "https://www.mql5.com"
#property version "1.00"
#property script_show_inputs
#property strict

input int magic = 0;
input double volume = 0.01;

void OnStart()
{
double price = MarketInfo(Symbol(), MODE_BID);
double sl = 0;
double tp = 0;
int ticket = OrderSend(Symbol(), OP_SELL, volume, price, 30, sl, tp, "Sell script", magic);
if(ticket > 0)
{
Print("Order opened: ", ticket);
}
else
{
Print("Failed to open order: ", GetLastError());
}

}

 

发表回复 取消回复