求助找一个MT5的函数

 

我想做一个固定百分比止损的函数,比如说固定1%仓位止损的函数,在MT4上可以实现

double Xdl(double ysc)  //ysc是入场位与止损位的差值
  {
   double xdc,xds,sjd;//xdc下单占总仓位的%,xds下单手数,sjd实际点数
   xdc=AccountBalance()/100*1;   //1%的仓位
   sjd=ysc/MarketInfo(Symbol(),MODE_TICKSIZE);//
   xds=NormalizeDouble(xdc/sjd/ MarketInfo(Symbol(),MODE_TICKVALUE),1);//1%仓位
   return(xds);
  }

MarketInfo(Symbol(),MODE_TICKVALUE)其中这句

MODE_TICKVALUE

16

Tick value in the deposit curreny


在MT5里面没有对应的函数

SYMBOL_TRADE_TICK_VALUE

Value of SYMBOL_TRADE_TICK_VALUE_PROFIT

double

SYMBOL_TRADE_TICK_VALUE_PROFIT

Calculated tick price for a profitable position

double

SYMBOL_TRADE_TICK_VALUE_LOSS

Calculated tick price for a losing position

double


找到以上3个名字近似的函数,经过计算好像都不是

请教一下论坛里的高手,我上面的MT4函数怎么转换到MT上,或者告诉我 MT5里面有没有对应函数?

 
使用
 SymbolInfoDouble(SYMBOL_TRADE_TICK_VALUE);
 

所有的Symbol或者SYMBOL开头的函数说的都是你交易的这个金融产品本身的特性, 和你的账户资金以及你的仓位盈亏没有一毛钱关系.

和账户有关的:

https://www.mql5.com/en/docs/account/accountinfodouble

https://www.mql5.com/en/docs/constants/environment_state/accountinformation#enum_account_info_double

和仓位有关的:

https://www.mql5.com/en/docs/trading/positiongetdouble

https://www.mql5.com/en/docs/constants/tradingconstants/positionproperties#enum_position_property_double

上面四个链接是最核心也是最低要求, 真要完成完整的实盘可用代码还需要把大部分相关文档都啃下来, 否则早晚会莫名其妙掉进哪个坑里.

Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Account Properties
Documentation on MQL5: Constants, Enumerations and Structures / Environment State / Account Properties
  • www.mql5.com
Account Properties - Environment State - Constants, Enumerations and Structures - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 

用OrderSend,把request中必要项正确赋值,发送交易指令
bool  
OrderSend(
   MqlTradeRequest&  request,      // query structure
   MqlTradeResult&   result        // structure of the answer
   );