2017/5/6
MT5入门到精通之十六(系统自带跟单操作)
一 跟单signal (mt5软件要一直打开)
1.订阅与取消订阅
2.充值
3.代码实现查询和订阅
3.1前提条件,需要允许才可以订阅成功
3.2信号查询,订阅和取消代码实现
//+------------------------------------------------------------------+
//| operateSignalScript.mq5 |
//| Copyright 2017, MetaQuotes Software Corp. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link "https://www.mql5.com"
#property version "1.00"
#property script_show_inputs
//+------------------------------------------------------------------+
//| |
//+------------------------------------------------------------------+
void OnStart()
{
//1.遍历信号
int total=SignalBaseTotal();
for(int i=0;i<total;i++)
{
if(SignalBaseSelect(i)==true)
{
//2.1 信号名称
string name=SignalBaseGetString(SIGNAL_BASE_NAME);
//2.2Return on Investment (%)
double roi=SignalBaseGetDouble(SIGNAL_BASE_ROI);
//2.3 Number of subscribers
int subscribers_num=SignalBaseGetInteger(SIGNAL_BASE_SUBSCRIBERS);
//2.4 Account maximum drawdown
double max_drawdown=SignalBaseGetDouble(SIGNAL_BASE_MAX_DRAWDOWN);
//2.5 Signal subscription price
double subscription_price=SignalBaseGetDouble(SIGNAL_BASE_PRICE);
//2.6 Signal ID
int signal_id=SignalBaseGetInteger(SIGNAL_BASE_ID);
//3.订阅指定条件的信号
if(roi>80 && subscribers_num>20 && subscription_price==0)
{
//3.1信号一些个性化参数设置
//Agree to terms of use of Signals service
SignalInfoSetInteger(SIGNAL_INFO_TERMS_AGREE,1);
//Copy trades by subscription
SignalInfoSetInteger(SIGNAL_INFO_SUBSCRIPTION_ENABLED,1);
//Copy Stop Loss and Take Profit flag
SignalInfoSetInteger(SIGNAL_INFO_COPY_SLTP,1);
//The flag enables synchronization without confirmation dialog
SignalInfoSetInteger(SIGNAL_INFO_CONFIRMATIONS_DISABLED,1);
//Deposit percent
SignalInfoSetInteger(SIGNAL_INFO_DEPOSIT_PERCENT,70);
//Equity limit
SignalInfoSetDouble(SIGNAL_INFO_EQUITY_LIMIT,1000);
//Slippage
SignalInfoSetDouble(SIGNAL_INFO_SLIPPAGE,3.5);
//3.2订阅信号
if(SignalSubscribe(signal_id)==false)
{
printf(GetLastError());
}
}
int a=0;
}
}
}
//+------------------------------------------------------------------+
3.3订阅成功后如下显示
如果您发现本文对你有所帮助,如果您认为其他人也可能受益,请把它分享出去。