- 显示:
- 1162
- 等级:
- 已发布:
- 2018.11.08 09:00
-
需要基于此代码的EA交易或指标吗?请在自由职业者服务中订购 进入自由职业者服务
实际作者:
Paul Stringer
这个指标定义了 Harami 模式,并且含有提醒、电子邮件和推送通知功能。
在指标代码中做出了如下改变以实现提醒、电子邮件和推送通知功能:
- 引入了新的输入参数
input uint NumberofBar=1;//信号出现的柱的编号 input bool SoundON=true; //启用提醒 input uint NumberofAlerts=2;//提醒次数 input bool EMailON=false; //启用信号邮件 input bool PushON=false; //启用向移动设备发送信号
- 在指标代码末尾增加了三个新函数: BuySignal(), SellSignal() 和 GetStringTimeframe()
//+------------------------------------------------------------------+ //| 买入信号函数 | //+------------------------------------------------------------------+ void BuySignal(string SignalSirname, // 用于电子邮件和推送通知的指标名称文字 double &BuyArrow[], // 买入信号的指标缓冲区 const int Rates_total, // 当前的柱数 const int Prev_calculated, // 前一分时的柱数 const double &Close[], // 收盘价 const int &Spread[]) // 点差 { //--- static uint counter=0; if(Rates_total!=Prev_calculated) counter=0; bool BuySignal=false; bool SeriesTest=ArrayGetAsSeries(BuyArrow); int index; if(SeriesTest) index=int(NumberofBar); else index=Rates_total-int(NumberofBar)-1; if(NormalizeDouble(BuyArrow[index],_Digits) && BuyArrow[index]!=EMPTY_VALUE) BuySignal=true; if(BuySignal && counter<=NumberofAlerts) { counter++; MqlDateTime tm; TimeToStruct(TimeCurrent(),tm); string text=TimeToString(TimeCurrent(),TIME_DATE)+" "+string(tm.hour)+":"+string(tm.min); SeriesTest=ArrayGetAsSeries(Close); if(SeriesTest) index=int(NumberofBar); else index=Rates_total-int(NumberofBar)-1; double Ask=Close[index]; double Bid=Close[index]; SeriesTest=ArrayGetAsSeries(Spread); if(SeriesTest) index=int(NumberofBar); else index=Rates_total-int(NumberofBar)-1; Bid+=Spread[index]*_Point; string sAsk=DoubleToString(Ask,_Digits); string sBid=DoubleToString(Bid,_Digits); string sPeriod=GetStringTimeframe(ChartPeriod()); if(SoundON) Alert("买入信号\n Ask=",Ask,"\n Bid=",Bid,"\n currtime=",text,"\n Symbol=",Symbol()," Period=",sPeriod); if(EMailON) SendMail(SignalSirname+": 买入信号提醒","买入信号 Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod); if(PushON) SendNotification(SignalSirname+": 买入信号 Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod); } //--- } //+------------------------------------------------------------------+ //| 卖出信号函数 | //+------------------------------------------------------------------+ void SellSignal(string SignalSirname, // 用于电子邮件和推送信息的指标名称文字 double &SellArrow[], // 卖出信号的指标缓冲区 const int Rates_total, // 当前的柱数 const int Prev_calculated, // 前一分时的柱数 const double &Close[], // 收盘价 const int &Spread[]) // 点差 { //--- static uint counter=0; if(Rates_total!=Prev_calculated) counter=0; bool SellSignal=false; bool SeriesTest=ArrayGetAsSeries(SellArrow); int index; if(SeriesTest) index=int(NumberofBar); else index=Rates_total-int(NumberofBar)-1; if(NormalizeDouble(SellArrow[index],_Digits) && SellArrow[index]!=EMPTY_VALUE) SellSignal=true; if(SellSignal && counter<=NumberofAlerts) { counter++; MqlDateTime tm; TimeToStruct(TimeCurrent(),tm); string text=TimeToString(TimeCurrent(),TIME_DATE)+" "+string(tm.hour)+":"+string(tm.min); SeriesTest=ArrayGetAsSeries(Close); if(SeriesTest) index=int(NumberofBar); else index=Rates_total-int(NumberofBar)-1; double Ask=Close[index]; double Bid=Close[index]; SeriesTest=ArrayGetAsSeries(Spread); if(SeriesTest) index=int(NumberofBar); else index=Rates_total-int(NumberofBar)-1; Bid+=Spread[index]*_Point; string sAsk=DoubleToString(Ask,_Digits); string sBid=DoubleToString(Bid,_Digits); string sPeriod=GetStringTimeframe(ChartPeriod()); if(SoundON) Alert("卖出信号 \n Ask=",Ask,"\n Bid=",Bid,"\n currtime=",text,"\n Symbol=",Symbol()," Period=",sPeriod); if(EMailON) SendMail(SignalSirname+": 卖出信号提醒","卖出信号 Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod); if(PushON) SendNotification(SignalSirname+": 卖出信号 Ask="+sAsk+", Bid="+sBid+", Date="+text+" Symbol="+Symbol()+" Period="+sPeriod); } //--- } //+------------------------------------------------------------------+ //| 把时段转换为字符串 | //+------------------------------------------------------------------+ string GetStringTimeframe(ENUM_TIMEFRAMES timeframe) { //---- return(StringSubstr(EnumToString(timeframe),7,-1)); //---- }
- 在 OnCalculate() 部分,在指标计算循环之后增加了一些对 BuySignal() 和 SellSignal() 函数的调用
//--- BuySignal("Harami_Alert",BuyBuffer,rates_total,prev_calculated,close,spread); SellSignal("Harami_Alert",SellBuffer,rates_total,prev_calculated,close,spread); //---
其中 BuyBuffer 和 SellBuffer 是用于保存买入和卖出信号的指标缓冲区的名称,指标缓冲区中的空值应当设为0或者 EMPTY_VALUE。
假定在指标代码中的 OnCalcuate() 部分只会调用 BuySignal() 和 SellSignal() 函数一次。
这个指标最初是使用 MQL4 编写,并且于2016年6月14日发布在代码库中。
图 1. 图表上的 Harami_Alert 指标
图 2. Harami_Alert. 生成提醒
由MetaQuotes Ltd译自俄语
原代码: https://www.mql5.com/ru/code/22403

在输入参数中带有时段选择选项的 WPR_Histogram_Vol 指标。

这个指标会画出超过 TimeZonePivots 通道的烛形。

使用交易量把威廉姆斯百分比范围振荡指标(Williams’ Percent Range,WPR)显示为柱形图。

在一个EA中包含了三个独立的交易系统,它们分别使用 BrainTrend_V2, AbsolutelyNoLagLWMA 和 X2MACandle indicators 指标,并且可以根据交易系统中之前的交易结果来调整即将到来交易的交易量。