MT5CTP程序化交易开发18:获取订单开仓价
MT5CTP的视频教学可以到网站上关于我们栏目的EA邦的各视频平台里观看。这是第18课的代码:
#define __MT5CTP__
// 包含库
#ifdef __MT5CTP__
#include <mt5ctp\mt5toctp.mqh>
#endif
//+------------------------------------------------------------------+
//| Copyright 2020, EA邦 |
//| http://www.eabang.com |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| Script program start function |
//+------------------------------------------------------------------+
void OnStart()
{
//---
Print("空单开仓价=",openJ(1));
}
//+------------------------------------------------------------------+
double openJ(int path) //获取开仓价
{
double a=0;
int ddzs=mt5ctp::MT5PositionsTotal();
for(int i=0; i<ddzs; i++)
{
ulong ticket = 0;
mt5ctp::MT5PositionGetTicket(i,ticket);
MT5CTPOrders order_mt5;
ZeroMemory(order_mt5);
if(!mt5ctp::MT5PositionSelectByTicket(ticket,order_mt5))
continue;
string pos_symbol = ::CharArrayToString(order_mt5.symbol);
int digit_symbol = (int)::SymbolInfoInteger(pos_symbol,SYMBOL_DIGITS);
if(order_mt5.type==path)
{
a=order_mt5.price;
}
//Print("编号=",i);
//Print("品种=",pos_symbol);
//Print("订单号=",order_mt5.ticket);
//Print("开仓时间=",order_mt5.time);
//Print("持仓方向=",order_mt5.type);
//Print("开仓量=",order_mt5.volume);
//Print("开仓价=",order_mt5.price,digit_symbol);
//Print("止损价=",order_mt5.sl,digit_symbol);
//Print("止盈价=",order_mt5.tp,digit_symbol);
//Print("盈亏=",order_mt5.profit);
//Print("魔术码=",order_mt5.magic);
//Print("注释=",CharArrayToString(order_mt5.comment));
}
return(a);
}
唐老师,我不知道怎么联系您,所以只能发在评论里,您的那个砖块图指标我的使用效果很好,但是一段时间后显示期限到了,老师能不能发一份没有期限的?
页:
[1]