下载MetaTrader 5

请观看如何免费下载自动交易

有趣的脚本?
因此发布一个链接 -
让其他人评价

喜欢这个脚本? 在MetaTrader 5客户端尝试它

2015.02.06 15:30
程序库

依据净值百分比计算最大风险 - MetaTrader 5程序库

| Chinese English Русский Español Deutsch 日本語 Português

显示:
388
等级:
投票: 27
RPTrade.mqh (2.63 KB)预览

这段代码允许您设置依据净值百分比计算的最大风险。

它检查买卖手数是否与风险相适。若否, 自动调整到与设置风险相适的手数。

代码:

bool UseMaximumPercentageRisk=true;
double MaximumPercentageRisk=25;

#include <Trade\SymbolInfo.mqh>
//+------------------------------------------------------------------+
//|  GetLotSize RPTrade                                              |
//+------------------------------------------------------------------+
double GetLotSize(double lotsize)
  {
//--- Gets pair specs  
   CSymbolInfo symInfo;
   int  digits_bn=symInfo.Digits();
   double  points_bn=symInfo.Point();
   string symbol_bn=_Symbol;
//--- adjust lot 
   int tmpdecimal=1;
   double old_lot=lotsize;
//---
   if((NormalizeDouble(AccountInfoDouble(ACCOUNT_FREEMARGIN)*(MaximumPercentageRisk/100)/1000.0,tmpdecimal)<lotsize) && UseMaximumPercentageRisk) //is lot fitting risk ?
     {
      lotsize=NormalizeDouble(AccountInfoDouble(ACCOUNT_FREEMARGIN)*(MaximumPercentageRisk/100)/1000.0,tmpdecimal);  //Claculates new Lotsize 

      if(lotsize<SymbolInfoDouble(symbol_bn,SYMBOL_VOLUME_MIN)) //is LotSize fitting minimum broker LotSize ?
        {
         lotsize=SymbolInfoDouble(symbol_bn,SYMBOL_VOLUME_MIN);   //No! Setting LotSize to minimum's broker LS
         Print(_Symbol," Lot adjusted from ",old_lot," to minimum size allowed by the server of ",lotsize);
        }
      else
        {
         Print(_Symbol," Lot adjusted from ",old_lot," to ",lotsize," to comply with Maximum Risk condition. Each trade can risk only ",MaximumPercentageRisk,"% of free margin.");   //Yes! 
         if(MathAbs(lotsize/SymbolInfoDouble(symbol_bn,SYMBOL_VOLUME_STEP)-MathRound(lotsize/SymbolInfoDouble(symbol_bn,SYMBOL_VOLUME_STEP)))>1.0E-10) //Is LotSize fitting Broker's allowed step ?
           {
            lotsize=SymbolInfoDouble(symbol_bn,SYMBOL_VOLUME_STEP)*NormalizeDouble(lotsize/SymbolInfoDouble(symbol_bn,SYMBOL_VOLUME_STEP),0);   //NO! recalculates LotSize.    
            Print("M-",_Symbol," Warning: Your calculated percentage at risk lot size of was not a multiple of minimal step",SymbolInfoDouble(symbol_bn,SYMBOL_VOLUME_STEP),". Lot size changed to",lotsize);
           }
        }
     }
   return(lotsize);
  }


由MetaQuotes Software Corp.从英文翻译成
官方代码: https://www.mql5.com/en/code/2142

Exp_BlauSMStochastic Exp_BlauSMStochastic

本交易系统采用 BlauSMStochastic 振荡器。

ColorCCI ColorCCI

带有彩色信号级别的经典 CCI。在时间的某个瞬间,当 CCI 指标处于超卖和超买区,则指标改变颜色与趋势方向相应。不断增长的趋势,指标颜色为菜绿色,下降则为红色。

改变图表和时间帧 改变图表和时间帧

改编的脚本,通过热键在所有图表之间快速切换,图表(下一个, 前一个) 和时间帧(更高, 更低)。

MFI_HTF MFI_HTF

此 MFI 振荡器在输入参数中有时间帧选项。