DSSBressertSignAlert - MetaTrader 5脚本
- 显示:
- 1196
- 等级:
- 已发布:
- 2016.12.27 12:28
- 已更新:
- 2023.03.29 14:34
- 需要基于此代码的EA交易或指标吗?请在自由职业者服务中订购 进入自由职业者服务
基于 DSSBressert 指标算法的信号灯信指标, 可以提醒,发送电子邮件和向手机设备发送推送通知。
为了实现提醒,发送电子邮件信息和推送通知,指标的代码做了如下改变:
- 引入了新的输入参数
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]; string sAsk=DoubleToString(Ask,_Digits); string sBid=DoubleToString(Bid,_Digits); string sPeriod=GetStringTimeframe(ChartPeriod()); if(SoundON) Alert("买入信号 \n 卖家报价=",Ask,"\n 买家报价=",Bid,"\n currtime=",text,"\n 交易品种=",Symbol()," 时段=",sPeriod); if(EMailON) SendMail(SignalSirname+": 买入信号提醒","买入信号位于 卖家报价="+sAsk+", 买家报价="+sBid+", 时间="+text+" 交易品种="+Symbol()+" 时段="+sPeriod); if(PushON) SendNotification(SignalSirname+": 买入信号位于 卖家报价="+sAsk+", 买家报价="+sBid+", 时间="+text+" 交易品种="+Symbol()+" 时段="+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]; string sAsk=DoubleToString(Ask,_Digits); string sBid=DoubleToString(Bid,_Digits); string sPeriod=GetStringTimeframe(ChartPeriod()); if(SoundON) Alert("卖出信号 \n 卖家报价=",Ask,"\n 买家报价=",Bid,"\n 时间=",text,"\n 交易品种=",Symbol()," 时段=",sPeriod); if(EMailON) SendMail(SignalSirname+": 卖出信号提醒","卖出信号位于 卖家报价="+sAsk+", 买家报价="+sBid+", 时间="+text+" 交易品种="+Symbol()+" 时段="+sPeriod); if(PushON) SendNotification(SignalSirname+": 卖出信号位于 卖家报价="+sAsk+", 买家报价="+sBid+", 时间="+text+" 交易品种="+Symbol()+" 时段="+sPeriod); } //--- } //+------------------------------------------------------------------+ //| 把时段转换为字符串 | //+------------------------------------------------------------------+ string GetStringTimeframe(ENUM_TIMEFRAMES timeframe) { //---- return(StringSubstr(EnumToString(timeframe),7,-1)); //---- }
- 在OnCalculate()模块指标计算循环中加入了一些对 BuySignal() 和 SellSignal() 函数的调用
//--- BuySignal("DSSBressertSignAlert",BuyBuffer,rates_total,prev_calculated,close,spread); SellSignal("DSSBressertSignAlert",SellBuffer,rates_total,prev_calculated,close,spread); //---
其中 BuyBuffer 和 SellBuffer 是用于保存买入和卖出信号的指标缓冲区的名称,对于指标缓冲区的中的空值,必须设为0或者 EMPTY_VALUE,
在指标代码的 OnCalculate() 模块中,只会调用一个 BuySignal() 和 SellSignal() 函数。
本指标使用了 SmoothAlgorithms.mqh 库中的类 (把它复制到 <terminal_data_folder>\MQL5\Include 目录下),类的使用在文章"不使用额外的缓冲区来平均价格以用于中间计算"有完整描述。
图1. 图表上的 DSSBressertSignAlert 指标
图2. DSSBressertSignAlert 指标。生成提醒。
由MetaQuotes Ltd译自俄语
原代码: https://www.mql5.com/ru/code/16115
CPrice
这个类的实例返回买家报价,卖家报价,最高价,最低价以及当前烛形的开盘价,或者任何其他在参数中指定的数值,以及烛形开启的时间。
Exp_i-SpectrAnalysis_RVIExp_i-SpectrAnalysis_RVI EA 交易是基于 i-SpectrAnalysis_RVI 震荡指标生成的信号的。
BackgroundCandle_PPO_Cloud_HTF
本指标使用 DRAW_FILLING 缓冲区在较大时段中用填充的矩形绘制烛形。
Exp_i-SpectrAnalysis_WPRExp_i-SpectrAnalysis_WPR EA交易时基于 i-SpectrAnalysis_WPR 指标方向的改变的。