抛硬币 - MetaTrader 5EA
- 发布者:
- Vladimir Karputov
- 显示:
- 1926
- 等级:
- 已发布:
- 2018.06.25 12:06
- 需要基于此代码的EA交易或指标吗?请在自由职业者服务中订购 进入自由职业者服务
思路来自: Vladimir Gribachev。
MQL5 编码: Vladimir Karputov。
一款不使用任何自定义指标的 EA; 依据伪随机开仓。 EA 可以用两种语言显示当前统计数据:
尾随修改持仓的止损。 在亏损的情况下,使用马丁格尔增加手数。 如何监控亏损: 在 OnTradeTransaction 中,我们捕获交易 DEAL_REASON_SL - 触发止损的信号:
//+------------------------------------------------------------------+ //| TradeTransaction function | //+------------------------------------------------------------------+ void OnTradeTransaction(const MqlTradeTransaction &trans, const MqlTradeRequest &request, const MqlTradeResult &result) { //--- 获取业务类型作为枚举值 ENUM_TRADE_TRANSACTION_TYPE type=trans.type; //--- 如果业务是加仓的结果 if(type==TRADE_TRANSACTION_DEAL_ADD) { long deal_ticket =0; long deal_order =0; long deal_time =0; long deal_time_msc =0; long deal_type =-1; long deal_entry =-1; long deal_magic =0; long deal_reason =-1; long deal_position_id =0; double deal_volume =0.0; double deal_price =0.0; double deal_commission =0.0; double deal_swap =0.0; double deal_profit =0.0; string deal_symbol =""; string deal_comment =""; string deal_external_id =""; if(HistoryDealSelect(trans.deal)) { deal_ticket =HistoryDealGetInteger(trans.deal,DEAL_TICKET); deal_order =HistoryDealGetInteger(trans.deal,DEAL_ORDER); deal_time =HistoryDealGetInteger(trans.deal,DEAL_TIME); deal_time_msc =HistoryDealGetInteger(trans.deal,DEAL_TIME_MSC); deal_type =HistoryDealGetInteger(trans.deal,DEAL_TYPE); deal_entry =HistoryDealGetInteger(trans.deal,DEAL_ENTRY); deal_magic =HistoryDealGetInteger(trans.deal,DEAL_MAGIC); deal_reason =HistoryDealGetInteger(trans.deal,DEAL_REASON); deal_position_id =HistoryDealGetInteger(trans.deal,DEAL_POSITION_ID); deal_volume =HistoryDealGetDouble(trans.deal,DEAL_VOLUME); deal_price =HistoryDealGetDouble(trans.deal,DEAL_PRICE); deal_commission =HistoryDealGetDouble(trans.deal,DEAL_COMMISSION); deal_swap =HistoryDealGetDouble(trans.deal,DEAL_SWAP); deal_profit =HistoryDealGetDouble(trans.deal,DEAL_PROFIT); deal_symbol =HistoryDealGetString(trans.deal,DEAL_SYMBOL); deal_comment =HistoryDealGetString(trans.deal,DEAL_COMMENT); deal_external_id =HistoryDealGetString(trans.deal,DEAL_EXTERNAL_ID); } else return; if(deal_symbol==m_symbol.Name() && deal_magic==m_magic) if(deal_entry==DEAL_ENTRY_OUT) { PrevBars=0; if(deal_reason==DEAL_REASON_SL && deal_commission+deal_swap+deal_profit<0.0) last_lots_sl=deal_volume; else last_lots_sl=0.0; } } }
输入参数
- Stop Loss - 止损;
- Take Profit - 止盈;
- Trailing Stop - 尾随;
- Trailing Step - 尾随步幅;
- Lots - 手数由手工设置 (如果 Lots 大于零,那么 Risk 必须等于零);
- Risk - 自动计算手数 (如果 Risk 高于零, 则 Lots 必须等于零);
- Martingale - 手数增加比率,如果上一笔持仓被止损,且收取的盈利为负;
- Max lots - 最大持仓交易量; 如果超过这个大小,则 EA 非正常终止其操作;
- magic number - EA 的独有标识符。
然后测试中断 (强制从图表中卸载 EA),因为参考手数超过了 Max lots 参数:
由MetaQuotes Ltd译自俄语
原代码: https://www.mql5.com/ru/code/20836
InvertCandle_Plus
当前金融产品的颠倒图表,显示竞卖价 (Ask) 和竞买价 (Bid) 的价位。
AnchoredMomentum_x10AnchoredMomentum_x10 指标显示来自十个不同时间帧的 AnchoredMomentum 指标位置。
BrainTrend2_V2
BrainTrend2 指标在其改变自身颜色时生成警报并发送电子邮件和推送消息。
BrainTrend2Stop_HTF指标 BrainTrend2Stop 在输入参数中提供了时间帧选择选项。