多时间框架指标 - 页 405 1...398399400401402403404405406407408409410411412...1223 新评论 Jonny473 2012.09.13 13:43 #4041 时间框架TDI的合并 嘿,伙计们,嘿,Mladen。 由于你们中的一些人使用TDI作为信号提供者,我遇到了TDI警报系统,如下图所示(当TDI发生交叉时,我只是给出一个信号或甚至EMail警报)。这可能不是什么新鲜事。因为至少用两个时间段(60分钟为基础,5分钟为剥头皮)来交易TDI是比较安全的,我想知道是否可以这样做:我想要的是合并至少两个不同时间段的信号,给我一个整体上更可靠的信号。较大的时间框架被用作基础,向上或向下为较小的时间框架提供方向。如果同样的信号出现在较小的时间框架上,这就是交易;交易的退出信号只取决于较小的时间框架。 这就是我所说的创建信号的指标;你们怎么看,或者类似的东西已经发布了吗? Jonny473 2012.09.13 13:43 #4042 Jonny473: 嘿,伙计们,嘿,Mladen。由于你们中的一些人使用TDI作为信号提供者,我遇到了TDI警报系统,如下图所示(当TDI发生交叉时,我只是给出一个信号或甚至EMail警报)。这可能不是什么新鲜事。因为至少用两个时间段(60分钟为基础,5分钟为剥头皮)来交易TDI是比较安全的,我想知道是否可以这样做:我想要的是合并至少两个不同时间段的信号,给我一个整体上更可靠的信号。较大的时间框架被用作基础,向上或向下为较小的时间框架提供方向。如果同样的信号出现在较小的时间框架上,这就是一笔交易;交易的退出信号只取决于较小的时间框架。 这就是我说的创建信号的指标;你们怎么看,或者类似的东西已经发布了? 我马上就会把指标贴出来... secretcode 2012.09.13 15:36 #4043 mladen: FxTrendsTrader 给你 亲爱的Mladen 您是否可以在该指标中加入 "斜率着色"? 预先感谢 秘密代码 Tarpan 2012.09.13 17:01 #4044 Jonny473: 稍后将发布指标... 心脏病发作....?... Jonny473 2012.09.13 18:16 #4045 fxnewbie: 心脏病发作....? ... 没有,没有心脏病发作。下面是代码,只要复制它并创建指标,找不到文件。 /*------------------------------------------------------------------------------------ 名称:xTDI-Arrow.mq4 版权所有:2010年,Xaphod,Forex Whiz 说明: -为TDI的交叉点绘制箭头 - 为上述三条线的交叉点提供警报。 更改日志。 2010-10-19.Xaphod, v1.00 - 初次发布 -------------------------------------------------------------------------------------*/ // 指标属性 #property copyright "Copyright ?2010, Xaphod" #property link "http://forexwhiz.appspot.com" #属性 indicator_chart_window #属性 indicator_buffers 4 #属性 indicator_color1 LimeGreen #属性 indicator_color2 红色 #属性 indicator_color3 绿色 #属性指示器_颜色4 火砖 #属性指示器宽度1 1 #属性指示器宽度2 1 #属性指示器宽度3 1 #perty indicator_width4 1 #属性 indicator_maximum 1 #perty indicator_minimum 0 // 常量定义 #define INDICATOR_NAME "xTDI-Arrow" #define INDICATOR_VERSION "v1.00" #define BAR_HEIGHT 1.00 #define TDI_INDI "Traders_Dynamic_Index" #define ARROW_THIN_UP 225 #define ARROW_THIN_DN 226 #define ARROW_THICK_UP 233 #define ARROW_THICK_DN 234 #define ARROW_HOLLOW_UP 241 #define ARROW_HOLLOW_DN 242 #define ARROW_ROUND_UP 221 #define ARROW_ROUND_DN 222 // 指示器参数 extern string Indi.Copyright= "?2010, forexwhiz.appspot.com"; extern string Indi.Version= INDICATOR_VERSION; extern string Show.Settings="????????????????????????????????????"; extern int Show.TimeFrame=0; // 使用的时间框架。当前时间框架=0。 extern bool Show.MarketBaseLine=true; // 用不同的颜色显示市场基线上方/下方的交叉点。 extern int Show.ArrowType=0; // 0=薄,1=厚,2=空,3=圆。 外部int Show.ArrowSize=1; // 箭头的大小(1-5)。 Extern int Show.ArrowOffset=10; // 从蜡烛的末端开始显示箭头的偏移。 extern string TDI.Settings="????????????????????????????????????"; extern int TDI.RSIPeriod = 13; // 周期。建议的值。8-25 extern int TDI.RSIPrice = 0; // 0=close, 1=open, 2=high, 3=low, 4=median, 5=TYPICAL, 6=WEIGHTED extern int TDI.VolatilityBand = 34; // 建议值:20-40 extern int TDI.RSIPriceLine = 2; //周期 extern int TDI.RSIPriceType = 0; // 0=SMA, 1=EMA, 2=SSMA, 3=LWMA extern int TDI.TradeSignalLine = 7; // 期间 extern int TDI.TradeSignalType = 0; // 0=SMA, 1=EMA, 2=SSMA, 3=LWMA extern string Alert.Settings="????????????????????????????????????"; extern bool Alert.RSIPriceLine=true; // 如果RSI价格越过信号线则发出警报。绿色与红色相交。 extern bool Alert.MarketBaseLine=true; // 如果RSI价格越过信号线和市场基础线,则发出警报。绿色穿过红色和黄色 extern bool Alert.NewBarOnly=true; // True=当新条形线被打开时发出警报。False=任何时候线条交叉都会发出警报 extern int Alert.Timeout=60; // 在发出警报后N秒内停用警报。只有当Alert.NewBarOnly=false的时候。 extern bool Alert.Popup=true; // 警报时弹出窗口和声音。 extern bool Alert.Email=false; // 警报时发送电子邮件。 // 全局模块变量 double dBuffer0[]; double dBuffer1[]; double dBuffer2[]; double dBuffer3[]; bool bStartup。 void SetArrowType(int& iArrowUp, int& iArrowDn) { switch (Show.ArrowType) { case 1: // Thin iArrowDn=ARROW_THIN_DN; iArrowUp=ARROW_THIN_UP。 突破。 case 2: // 中空 iArrowDn=ARROW_HOLLOW_DN; iArrowUp=ARROW_HOLLOW_UP。 break; case 3: // 圆形 iArrowDn=ARROW_ROUND_DN; iArrowUp=ARROW_ROUND_UP。 break; 默认情况下。// 厚 iArrowDn=ARROW_THICK_DN; iArrowUp=ARROW_THICK_UP。 break; } } //----------------------------------------------------------------------------- // 函数: init() // 说明。自定义指标初始化函数。 //----------------------------------------------------------------------------- int init() { int iArrowUp; int iArrowDn; string sType; string sTF; SetArrowType(iArrowUp, iArrowDn ); SetIndexStyle(0,DRAW_ARROW,EMPTY,Show.ArrowSize)。 SetIndexBuffer(0,dBuffer0); SetIndexLabel(0, "TDI:Mkt-Up")。 SetIndexArrow(0, iArrowUp); SetIndexStyle(1,DRAW_ARROW,EMPTY,Show.ArrowSize)。 SetIndexBuffer(1,dBuffer1); SetIndexLabel(1, "TDI:Mkt-Dn")。 SetIndexArrow(1, iArrowDn); SetIndexStyle(2,DRAW_ARROW,EMPTY,Show.ArrowSize)。 SetIndexBuffer(2,dBuffer2); SetIndexLabel(2, "TDI:Sig-Up")。 SetIndexArrow(2, iArrowUp); SetIndexStyle(3,DRAW_ARROW,EMPTY,Show.ArrowSize)。 SetIndexBuffer(3,dBuffer3); SetIndexLabel(3, "TDI:Sig-Dn")。 SetIndexArrow(3, iArrowDn)。 如果(Show.TimeFrame==0) sTF=""。 否则 sTF=TF2Str(Show.TimeFrame)。 IndicatorShortName(INDICATOR_NAME+" "+sTF)。 bStartup=true。 返回(0)。 } //----------------------------------------------------------------------------- // 函数: deinit() // 说明。自定义指标去初始化函数。 //----------------------------------------------------------------------------- int deinit() { 返回(0)。 } ///----------------------------------------------------------------------------- // 函数: start() // 说明。自定义指标迭代函数。 //----------------------------------------------------------------------------- int start() { int iNewBars; int iCountedBars; int i; double dVBHighLine; // 上波动区间--上蓝线 double dVBLowLine; // 下波动区间--下蓝线 double dMarketBaseLine0; // 市场基本线--黄线 double dRSIPriceLine0; // RSI价格线 - 绿线 double dTradeSignalLine0; // 交易信号线--红线 静态双数 dMarketBaseLine1; // 市场基本线--黄线 静态双数 dRSIPriceLine1; // RSI价格线--绿线 静态双数 dTradeSignalLine1; // 交易信号线 - 红线 双重dOffset。 // 获得未处理的点位 iCountedBars=IndicatorCounted()。 if(iCountedBars < 0) return (-1); 如果(iCountedBars>0) iCountedBars--; iNewBars=Bars-iCountedBars。 for(i=iNewBars; i>=0; i--) { //获取之前的TDI数据 //if (Time!=tCurTime) { //tCurTime=时间。 Multi Timeframe Indicators 问吧! 编码帮助 Jonny473 2012.09.13 18:19 #4046 dMarketBaseLine1=iCustom(NULL,Show.TimeFrame,TDI_INDI,TDI.RSIPeriod,TDI.RSIPrice,TDI.VolatilityBand,TDI.RSIPriceLine, TDI.RSIPriceType,TDI.TradeSignalLine,TDI.TradeSignalType,2,i+1); //黄线 dRSIPriceLine1=iCustom(NULL,Show.TimeFrame,TDI_INDI,TDI.RSIPeriod,TDI.RSIPrice,TDI.VolatilityBand,TDI.RSIPriceLine。 TDI.RSIPriceType,TDI.TradeSignalLine,TDI.TradeSignalType,4,i+1); // 绿线 dTradeSignalLine1=iCustom(NULL,Show.TimeFrame,TDI_INDI,TDI.RSIPeriod,TDI.RSIPrice,TDI.VolatilityBand,TDI.RSIPriceLine。 TDI.RSIPriceType,TDI.TradeSignalLine,TDI.TradeSignalType,5,i+1); // 红线 //} // 获取当前的TDI数据 dMarketBaseLine0=iCustom(NULL,Show.TimeFrame,TDI_INDI,TDI.RSIPeriod,TDI.RSIPrice,TDI.VolatilityBand,TDI.RSIPriceLine。 TDI.RSIPriceType,TDI.TradeSignalLine,TDI.TradeSignalType,2,i); //黄线 dRSIPriceLine0=iCustom(NULL,Show.TimeFrame,TDI_INDI,TDI.RSIPeriod,TDI.RSIPrice,TDI.VolatilityBand,TDI.RSIPriceLine。 TDI.RSIPriceType,TDI.TradeSignalLine,TDI.TradeSignalType,4,i); // 绿线 dTradeSignalLine0=iCustom(NULL,Show.TimeFrame,TDI_INDI,TDI.RSIPeriod,TDI.RSIPrice,TDI.VolatilityBand,TDI.RSIPriceLine。 TDI.RSIPriceType,TDI.TradeSignalLine,TDI.TradeSignalType,5,i); // 红线 // 清除当前的显示缓冲区 dBuffer0 =EMPTY_VALUE; dBuffer1 = EMPTY_VALUE; dBuffer2 = EMPTY_VALUE; dBuffer3 = EMPTY_VALUE; dOffset=Point*(10*Show.ArrowOffset/MarketInfo(Symbol(),MODE_TICKVALUE) )。 如果(dRSIPriceLine0>dMarketBaseLine0 && dRSIPriceLine1dTradeSignalLine0 && Show.MarketBaseLine) dBuffer0 = Low-dOffset; 否则,如果(dRSIPriceLine0>dTradeSignalLine0 && dRSIPriceLine1<dTradeSignalLine1) dBuffer2 = Low-dOffset。 如果(dRSIPriceLine0dMarketBaseLine1 && dRSIPriceLine0<dTradeSignalLine0 && Show.MarketBaseLine) dBuffer1=High+dOffset。 否则,如果(dRSIPriceLine0dTradeSignalLine1) dBuffer3 = High+dOffset; // 检查警报 如果(i==0) AlertCheck()。 } // 重置启动标志 如果(bStartup)bStartup=false; // 再见了 return(0); } //+------------------------------------------------------------------+ //----------------------------------------------------------------------------- //函数。TF2Str() // 描述。将时间框架转换为一个字符串 //----------------------------------------------------------------------------- string TF2Str(int iPeriod) { switch(iPeriod) { case PERIOD_M1: return("M1"); case PERIOD_M5: return("M5"); case PERIOD_M15: return("M15"); case PERIOD_M30: return("M30"); case PERIOD_H1: return("H1"); case PERIOD_H4: return("H4"); case PERIOD_D1: return("D1"); case PERIOD_W1: return("W1"); case PERIOD_MN1: return("MN1"); 默认情况:返回("M "+iPeriod)。 } } //----------------------------------------------------------------------------- //函数。AlertCheck() // 描述。检查警报条件并执行警报 //----------------------------------------------------------------------------- void AlertCheck() { string sAlertMsg; static datetime tCurTime=0; 静态int iAlertTimer[2]; 静态int iAlertStatus[2]; double dMarketBaseLine[2]; // 市场基本线-黄线 double dRSIPriceLine[2]; // RSI价格线 - 绿线 double dTradeSignalLine[2]; // 交易信号线 - 红线 int i,j; bool bNewBar=false; // 如果指标刚刚启动就放弃 如果 (bStartup) { tCurTime=Time[0]; return(0); } // 检查是否有警报 如果(Alert.RSIPriceLine || Alert.MarketBaseLine) { // 如果只有新条理,则发出警报 if (Alert.NewBarOnly) { // 重置时间 如果(tCurTime!=Time[0]) { tCurTime=Time[0]; bNewBar=true; // 获取新条的TDI数据,即条1和条2 for (i=0; i<2; i++) { j=i+1; dMarketBaseLine=iCustom(NULL,Show.TimeFrame,TDI_INDI,TDI.RSIPeriod,TDI.RSIPrice,TDI.VolatilityBand,TDI.RSIPriceLine, TDI.RSIPriceType,TDI.TradeSignalLine,TDI.TradeSignalType,2,j); // 黄线 dRSIPriceLine=iCustom(NULL,Show.TimeFrame,TDI_INDI,TDI.RSIPeriod,TDI.RSIPrice,TDI.VolatilityBand,TDI.RSIPriceLine。 TDI.RSIPriceType,TDI.TradeSignalLine,TDI.TradeSignalType,4,j); // 绿线 dTradeSignalLine=iCustom(NULL,Show.TimeFrame,TDI_INDI,TDI.RSIPeriod,TDI.RSIPrice,TDI.VolatilityBand,TDI.RSIPriceLine。 TDI.RSIPriceType,TDI.TradeSignalLine,TDI.TradeSignalType,5,j); // 红线 }//结束 }//endif } 否则 { // 获取当前条形的TDI数据,即条形0和1 for (i=0; i<2; i++) { dMarketBaseLine=iCustom(NULL,Show.TimeFrame,TDI_INDI,TDI.RSIPeriod,TDI.RSIPrice,TDI.VolatilityBand,TDI.RSIPriceLine, TDI.RSIPriceType,TDI.TradeSignalLine,TDI.TradeSignalType,2,i); //黄线 dRSIPriceLine=iCustom(NULL,Show.TimeFrame,TDI_INDI,TDI.RSIPeriod,TDI.RSIPrice,TDI.VolatilityBand,TDI.RSIPriceLine。 TDI.RSIPriceType,TDI.TradeSignalLine,TDI.TradeSignalType,4,i); // 绿线 dTradeSignalLine=iCustom(NULL,Show.TimeFrame,TDI_INDI,TDI.RSIPeriod,TDI.RSIPrice,TDI.VolatilityBand,TDI.RSIPriceLine。 TDI.RSIPriceType,TDI.TradeSignalLine,TDI.TradeSignalType,5,i); // 红线 }//结束 }//结束 if(Alert.NewBarOnly) 如果(bNewBar || (!Alert.NewBarOnly &&iAlertTimer[0]<GetTickCount())){ //警报 RSIPriceLine > TradeSignalLine 如果(dRSIPriceLine[0]>dTradeSignalLine[0] && dRSIPriceLine[1]<dTradeSignalLine[1] && Alert.RSIPriceLine){ if (!Alert.NewBarOnly) iAlertTimer[0]=GetTickCount()+Alert.Timeout*1000。 sAlertMsg="TDI警报 - "+Symbol()+" "+TF2Str(Period())+" 。RSIPriceLine高于TradeSignalLine。"。 如果(Alert.Popup)警报(sAlertMsg)。 if (Alert.Email) SendMail( sAlertMsg, "MT4警报!/n" + TimeToStr(TIME_DATE|TIME_SECONDS )+"/n "+sAlertMsg)。 }//end if //警告 RSIPriceLine < TradeSignalLine 如果(dRSIPriceLine[0]dTradeSignalLine[1] && Alert.RSIPriceLine) { //打印D("RSIPriceLine < TradeSignalLine")。 if (!Alert.NewBarOnly) iAlertTimer[0]=GetTickCount()+Alert.Timeout*1000; sAlertMsg="TDI警报 - "+Symbol()+" "+TF2Str(Period())+" 。RSIPriceLine低于TradeSignalLine。"。 如果(Alert.Popup)Alert(sAlertMsg)。 如果(Alert.Email)SendMail( sAlertMsg, "MT4警报!/n" + TimeToStr(TIME_DATE|TIME_SECONDS )+"/n "+sAlertMsg) 。 }//end if }//end if 如果 (bNewBar || (!Alert.NewBarOnly &&iAlertTimer[1]<GetTickCount()){ //如果RSIPriceLine > TradeSignalLine && dMarketBaseLine就发出警报。 如果(dRSIPriceLine[0]>dMarketBaseLine[0] && dRSIPriceLine[1]<dMarketBaseLine[1] && Alert.MarketBaseLine) { 如果(dRSIPriceLine[0]>dTradeSignalLine[0] && dRSIPriceLine[1]<dTradeSignalLine[1]) { if (!Alert.NewBarOnly) iAlertTimer[1]=GetTickCount()+Alert.Timeout*1000; sAlertMsg="TDI警报 - "+Symbol()+" "+TF2Str(Period())+"。RSIPriceLine高于TradeSignalLine和MarketBaseLine。"。 如果(Alert.Popup)Alert(sAlertMsg)。 if (Alert.Email) SendMail( sAlertMsg, "MT4警报!/n" + TimeToStr(TIME_DATE|TIME_SECONDS )+"/n "+sAlertMsg)。 }//end if }//end if //如果RSIPriceLine < TradeSignalLine && dMarketBaseLine时发出警报 如果(dRSIPriceLine[0]dMarketBaseLine[1] && Alert.MarketBaseLine) { 如果(dRSIPriceLine[0]dTradeSignalLine[1]) { if (!Alert.NewBarOnly) iAlertTimer[1]=GetTickCount()+Alert.Timeout*1000。 sAlertMsg="TDI警报 - "+Symbol()+" "+TF2Str(Period())+" 。RSIPriceLine低于TradeSignalLine和MarketBaseLine。" 。 如果(Alert.Popup)Alert(sAlertMsg)。 如果(Alert.Email)SendMail( sAlertMsg, "MT4警报!/n" + TimeToStr(TIME_DATE|TIME_SECONDS )+"/n "+sAlertMsg)。 }//end if }//end if }//end if }//end if(Alert.RSIPriceLine || Alert.MarketBaseLine) 返回(0)。 } 提醒:由于10K政策,我把代码分成了两部分;所以只要把这两部分复制到一起,就可以创建指标了! Multi Timeframe Indicators Alert when candle opens 编码帮助 Jonny473 2012.09.13 18:49 #4047 好了,伙计们,你们来了,对不起,所有的公式都是这样的! 附加的文件: tdi-2.mq4 4 kb Jonny473 2012.09.13 18:52 #4048 错了 刚刚把正确的代码复制到另一个文件中,覆盖了一个旧的代码,编译后,文件仍在使用旧的代码?不明白;无论如何,代码是正确的。 Jonny473 2012.09.13 18:55 #4049 Jonny473: 错误的 只是把正确的代码复制到另一个代码中,覆盖了一个旧的代码,编译后,文件仍在使用旧的代码?不明白;无论如何,代码是正确的。 我之前发布的代码.... Jonny473 2012.09.13 20:15 #4050 在我的旧笔记本电脑上有一个Vista版本,这就是为什么mq4文件不断消失的原因;现在它应该可以工作了。 附加的文件: tdi-2.mq4 4 kb 1...398399400401402403404405406407408409410411412...1223 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录
时间框架TDI的合并
嘿,伙计们,嘿,Mladen。
由于你们中的一些人使用TDI作为信号提供者,我遇到了TDI警报系统,如下图所示(当TDI发生交叉时,我只是给出一个信号或甚至EMail警报)。这可能不是什么新鲜事。因为至少用两个时间段(60分钟为基础,5分钟为剥头皮)来交易TDI是比较安全的,我想知道是否可以这样做:我想要的是合并至少两个不同时间段的信号,给我一个整体上更可靠的信号。较大的时间框架被用作基础,向上或向下为较小的时间框架提供方向。如果同样的信号出现在较小的时间框架上,这就是交易;交易的退出信号只取决于较小的时间框架。
这就是我所说的创建信号的指标;你们怎么看,或者类似的东西已经发布了吗?
嘿,伙计们,嘿,Mladen。
由于你们中的一些人使用TDI作为信号提供者,我遇到了TDI警报系统,如下图所示(当TDI发生交叉时,我只是给出一个信号或甚至EMail警报)。这可能不是什么新鲜事。因为至少用两个时间段(60分钟为基础,5分钟为剥头皮)来交易TDI是比较安全的,我想知道是否可以这样做:我想要的是合并至少两个不同时间段的信号,给我一个整体上更可靠的信号。较大的时间框架被用作基础,向上或向下为较小的时间框架提供方向。如果同样的信号出现在较小的时间框架上,这就是一笔交易;交易的退出信号只取决于较小的时间框架。
这就是我说的创建信号的指标;你们怎么看,或者类似的东西已经发布了?我马上就会把指标贴出来...
FxTrendsTrader 给你
亲爱的Mladen
您是否可以在该指标中加入 "斜率着色"?
预先感谢
秘密代码
稍后将发布指标...
心脏病发作....?...
心脏病发作....? ...
没有,没有心脏病发作。下面是代码,只要复制它并创建指标,找不到文件。
/*------------------------------------------------------------------------------------
名称:xTDI-Arrow.mq4
版权所有:2010年,Xaphod,Forex Whiz
说明: -为TDI的交叉点绘制箭头
- 为上述三条线的交叉点提供警报。
更改日志。
2010-10-19.Xaphod, v1.00
- 初次发布
-------------------------------------------------------------------------------------*/
// 指标属性
#property copyright "Copyright ?2010, Xaphod"
#property link "http://forexwhiz.appspot.com"
#属性 indicator_chart_window
#属性 indicator_buffers 4
#属性 indicator_color1 LimeGreen
#属性 indicator_color2 红色
#属性 indicator_color3 绿色
#属性指示器_颜色4 火砖
#属性指示器宽度1 1
#属性指示器宽度2 1
#属性指示器宽度3 1
#perty indicator_width4 1
#属性 indicator_maximum 1
#perty indicator_minimum 0
// 常量定义
#define INDICATOR_NAME "xTDI-Arrow"
#define INDICATOR_VERSION "v1.00"
#define BAR_HEIGHT 1.00
#define TDI_INDI "Traders_Dynamic_Index"
#define ARROW_THIN_UP 225
#define ARROW_THIN_DN 226
#define ARROW_THICK_UP 233
#define ARROW_THICK_DN 234
#define ARROW_HOLLOW_UP 241
#define ARROW_HOLLOW_DN 242
#define ARROW_ROUND_UP 221
#define ARROW_ROUND_DN 222
// 指示器参数
extern string Indi.Copyright= "?2010, forexwhiz.appspot.com";
extern string Indi.Version= INDICATOR_VERSION;
extern string Show.Settings="????????????????????????????????????";
extern int Show.TimeFrame=0; // 使用的时间框架。当前时间框架=0。
extern bool Show.MarketBaseLine=true; // 用不同的颜色显示市场基线上方/下方的交叉点。
extern int Show.ArrowType=0; // 0=薄,1=厚,2=空,3=圆。
外部int Show.ArrowSize=1; // 箭头的大小(1-5)。
Extern int Show.ArrowOffset=10; // 从蜡烛的末端开始显示箭头的偏移。
extern string TDI.Settings="????????????????????????????????????";
extern int TDI.RSIPeriod = 13; // 周期。建议的值。8-25
extern int TDI.RSIPrice = 0; // 0=close, 1=open, 2=high, 3=low, 4=median, 5=TYPICAL, 6=WEIGHTED
extern int TDI.VolatilityBand = 34; // 建议值:20-40
extern int TDI.RSIPriceLine = 2; //周期
extern int TDI.RSIPriceType = 0; // 0=SMA, 1=EMA, 2=SSMA, 3=LWMA
extern int TDI.TradeSignalLine = 7; // 期间
extern int TDI.TradeSignalType = 0; // 0=SMA, 1=EMA, 2=SSMA, 3=LWMA
extern string Alert.Settings="????????????????????????????????????";
extern bool Alert.RSIPriceLine=true; // 如果RSI价格越过信号线则发出警报。绿色与红色相交。
extern bool Alert.MarketBaseLine=true; // 如果RSI价格越过信号线和市场基础线,则发出警报。绿色穿过红色和黄色
extern bool Alert.NewBarOnly=true; // True=当新条形线被打开时发出警报。False=任何时候线条交叉都会发出警报
extern int Alert.Timeout=60; // 在发出警报后N秒内停用警报。只有当Alert.NewBarOnly=false的时候。
extern bool Alert.Popup=true; // 警报时弹出窗口和声音。
extern bool Alert.Email=false; // 警报时发送电子邮件。
// 全局模块变量
double dBuffer0[];
double dBuffer1[];
double dBuffer2[];
double dBuffer3[];
bool bStartup。
void SetArrowType(int& iArrowUp, int& iArrowDn) {
switch (Show.ArrowType) {
case 1: // Thin
iArrowDn=ARROW_THIN_DN;
iArrowUp=ARROW_THIN_UP。
突破。
case 2: // 中空
iArrowDn=ARROW_HOLLOW_DN;
iArrowUp=ARROW_HOLLOW_UP。
break;
case 3: // 圆形
iArrowDn=ARROW_ROUND_DN;
iArrowUp=ARROW_ROUND_UP。
break;
默认情况下。// 厚
iArrowDn=ARROW_THICK_DN;
iArrowUp=ARROW_THICK_UP。
break;
}
}
//-----------------------------------------------------------------------------
// 函数: init()
// 说明。自定义指标初始化函数。
//-----------------------------------------------------------------------------
int init() {
int iArrowUp;
int iArrowDn;
string sType;
string sTF;
SetArrowType(iArrowUp, iArrowDn );
SetIndexStyle(0,DRAW_ARROW,EMPTY,Show.ArrowSize)。
SetIndexBuffer(0,dBuffer0);
SetIndexLabel(0, "TDI:Mkt-Up")。
SetIndexArrow(0, iArrowUp);
SetIndexStyle(1,DRAW_ARROW,EMPTY,Show.ArrowSize)。
SetIndexBuffer(1,dBuffer1);
SetIndexLabel(1, "TDI:Mkt-Dn")。
SetIndexArrow(1, iArrowDn);
SetIndexStyle(2,DRAW_ARROW,EMPTY,Show.ArrowSize)。
SetIndexBuffer(2,dBuffer2);
SetIndexLabel(2, "TDI:Sig-Up")。
SetIndexArrow(2, iArrowUp);
SetIndexStyle(3,DRAW_ARROW,EMPTY,Show.ArrowSize)。
SetIndexBuffer(3,dBuffer3);
SetIndexLabel(3, "TDI:Sig-Dn")。
SetIndexArrow(3, iArrowDn)。
如果(Show.TimeFrame==0)
sTF=""。
否则
sTF=TF2Str(Show.TimeFrame)。
IndicatorShortName(INDICATOR_NAME+" "+sTF)。
bStartup=true。
返回(0)。
}
//-----------------------------------------------------------------------------
// 函数: deinit()
// 说明。自定义指标去初始化函数。
//-----------------------------------------------------------------------------
int deinit() {
返回(0)。
}
///-----------------------------------------------------------------------------
// 函数: start()
// 说明。自定义指标迭代函数。
//-----------------------------------------------------------------------------
int start() {
int iNewBars;
int iCountedBars;
int i;
double dVBHighLine; // 上波动区间--上蓝线
double dVBLowLine; // 下波动区间--下蓝线
double dMarketBaseLine0; // 市场基本线--黄线
double dRSIPriceLine0; // RSI价格线 - 绿线
double dTradeSignalLine0; // 交易信号线--红线
静态双数 dMarketBaseLine1; // 市场基本线--黄线
静态双数 dRSIPriceLine1; // RSI价格线--绿线
静态双数 dTradeSignalLine1; // 交易信号线 - 红线
双重dOffset。
// 获得未处理的点位
iCountedBars=IndicatorCounted()。
if(iCountedBars < 0) return (-1);
如果(iCountedBars>0) iCountedBars--;
iNewBars=Bars-iCountedBars。
for(i=iNewBars; i>=0; i--) {
//获取之前的TDI数据
//if (Time!=tCurTime) {
//tCurTime=时间。
dMarketBaseLine1=iCustom(NULL,Show.TimeFrame,TDI_INDI,TDI.RSIPeriod,TDI.RSIPrice,TDI.VolatilityBand,TDI.RSIPriceLine,
TDI.RSIPriceType,TDI.TradeSignalLine,TDI.TradeSignalType,2,i+1); //黄线
dRSIPriceLine1=iCustom(NULL,Show.TimeFrame,TDI_INDI,TDI.RSIPeriod,TDI.RSIPrice,TDI.VolatilityBand,TDI.RSIPriceLine。
TDI.RSIPriceType,TDI.TradeSignalLine,TDI.TradeSignalType,4,i+1); // 绿线
dTradeSignalLine1=iCustom(NULL,Show.TimeFrame,TDI_INDI,TDI.RSIPeriod,TDI.RSIPrice,TDI.VolatilityBand,TDI.RSIPriceLine。
TDI.RSIPriceType,TDI.TradeSignalLine,TDI.TradeSignalType,5,i+1); // 红线
//}
// 获取当前的TDI数据
dMarketBaseLine0=iCustom(NULL,Show.TimeFrame,TDI_INDI,TDI.RSIPeriod,TDI.RSIPrice,TDI.VolatilityBand,TDI.RSIPriceLine。
TDI.RSIPriceType,TDI.TradeSignalLine,TDI.TradeSignalType,2,i); //黄线
dRSIPriceLine0=iCustom(NULL,Show.TimeFrame,TDI_INDI,TDI.RSIPeriod,TDI.RSIPrice,TDI.VolatilityBand,TDI.RSIPriceLine。
TDI.RSIPriceType,TDI.TradeSignalLine,TDI.TradeSignalType,4,i); // 绿线
dTradeSignalLine0=iCustom(NULL,Show.TimeFrame,TDI_INDI,TDI.RSIPeriod,TDI.RSIPrice,TDI.VolatilityBand,TDI.RSIPriceLine。
TDI.RSIPriceType,TDI.TradeSignalLine,TDI.TradeSignalType,5,i); // 红线
// 清除当前的显示缓冲区
dBuffer0 =EMPTY_VALUE;
dBuffer1 = EMPTY_VALUE;
dBuffer2 = EMPTY_VALUE;
dBuffer3 = EMPTY_VALUE;
dOffset=Point*(10*Show.ArrowOffset/MarketInfo(Symbol(),MODE_TICKVALUE) )。
如果(dRSIPriceLine0>dMarketBaseLine0 && dRSIPriceLine1dTradeSignalLine0 && Show.MarketBaseLine)
dBuffer0 = Low-dOffset;
否则,如果(dRSIPriceLine0>dTradeSignalLine0 && dRSIPriceLine1<dTradeSignalLine1)
dBuffer2 = Low-dOffset。
如果(dRSIPriceLine0dMarketBaseLine1 && dRSIPriceLine0<dTradeSignalLine0 && Show.MarketBaseLine)
dBuffer1=High+dOffset。
否则,如果(dRSIPriceLine0dTradeSignalLine1)
dBuffer3 = High+dOffset;
// 检查警报
如果(i==0) AlertCheck()。
}
// 重置启动标志
如果(bStartup)bStartup=false;
// 再见了
return(0);
}
//+------------------------------------------------------------------+
//-----------------------------------------------------------------------------
//函数。TF2Str()
// 描述。将时间框架转换为一个字符串
//-----------------------------------------------------------------------------
string TF2Str(int iPeriod) {
switch(iPeriod) {
case PERIOD_M1: return("M1");
case PERIOD_M5: return("M5");
case PERIOD_M15: return("M15");
case PERIOD_M30: return("M30");
case PERIOD_H1: return("H1");
case PERIOD_H4: return("H4");
case PERIOD_D1: return("D1");
case PERIOD_W1: return("W1");
case PERIOD_MN1: return("MN1");
默认情况:返回("M "+iPeriod)。
}
}
//-----------------------------------------------------------------------------
//函数。AlertCheck()
// 描述。检查警报条件并执行警报
//-----------------------------------------------------------------------------
void AlertCheck() {
string sAlertMsg;
static datetime tCurTime=0;
静态int iAlertTimer[2];
静态int iAlertStatus[2];
double dMarketBaseLine[2]; // 市场基本线-黄线
double dRSIPriceLine[2]; // RSI价格线 - 绿线
double dTradeSignalLine[2]; // 交易信号线 - 红线
int i,j;
bool bNewBar=false;
// 如果指标刚刚启动就放弃
如果 (bStartup) {
tCurTime=Time[0];
return(0);
}
// 检查是否有警报
如果(Alert.RSIPriceLine || Alert.MarketBaseLine) {
// 如果只有新条理,则发出警报
if (Alert.NewBarOnly) {
// 重置时间
如果(tCurTime!=Time[0]) {
tCurTime=Time[0];
bNewBar=true;
// 获取新条的TDI数据,即条1和条2
for (i=0; i<2; i++) {
j=i+1;
dMarketBaseLine=iCustom(NULL,Show.TimeFrame,TDI_INDI,TDI.RSIPeriod,TDI.RSIPrice,TDI.VolatilityBand,TDI.RSIPriceLine,
TDI.RSIPriceType,TDI.TradeSignalLine,TDI.TradeSignalType,2,j); // 黄线
dRSIPriceLine=iCustom(NULL,Show.TimeFrame,TDI_INDI,TDI.RSIPeriod,TDI.RSIPrice,TDI.VolatilityBand,TDI.RSIPriceLine。
TDI.RSIPriceType,TDI.TradeSignalLine,TDI.TradeSignalType,4,j); // 绿线
dTradeSignalLine=iCustom(NULL,Show.TimeFrame,TDI_INDI,TDI.RSIPeriod,TDI.RSIPrice,TDI.VolatilityBand,TDI.RSIPriceLine。
TDI.RSIPriceType,TDI.TradeSignalLine,TDI.TradeSignalType,5,j); // 红线
}//结束
}//endif
}
否则 {
// 获取当前条形的TDI数据,即条形0和1
for (i=0; i<2; i++) {
dMarketBaseLine=iCustom(NULL,Show.TimeFrame,TDI_INDI,TDI.RSIPeriod,TDI.RSIPrice,TDI.VolatilityBand,TDI.RSIPriceLine,
TDI.RSIPriceType,TDI.TradeSignalLine,TDI.TradeSignalType,2,i); //黄线
dRSIPriceLine=iCustom(NULL,Show.TimeFrame,TDI_INDI,TDI.RSIPeriod,TDI.RSIPrice,TDI.VolatilityBand,TDI.RSIPriceLine。
TDI.RSIPriceType,TDI.TradeSignalLine,TDI.TradeSignalType,4,i); // 绿线
dTradeSignalLine=iCustom(NULL,Show.TimeFrame,TDI_INDI,TDI.RSIPeriod,TDI.RSIPrice,TDI.VolatilityBand,TDI.RSIPriceLine。
TDI.RSIPriceType,TDI.TradeSignalLine,TDI.TradeSignalType,5,i); // 红线
}//结束
}//结束 if(Alert.NewBarOnly)
如果(bNewBar || (!Alert.NewBarOnly &&iAlertTimer[0]<GetTickCount())){
//警报 RSIPriceLine > TradeSignalLine
如果(dRSIPriceLine[0]>dTradeSignalLine[0] && dRSIPriceLine[1]<dTradeSignalLine[1] && Alert.RSIPriceLine){
if (!Alert.NewBarOnly) iAlertTimer[0]=GetTickCount()+Alert.Timeout*1000。
sAlertMsg="TDI警报 - "+Symbol()+" "+TF2Str(Period())+" 。RSIPriceLine高于TradeSignalLine。"。
如果(Alert.Popup)警报(sAlertMsg)。
if (Alert.Email) SendMail( sAlertMsg, "MT4警报!/n" + TimeToStr(TIME_DATE|TIME_SECONDS )+"/n "+sAlertMsg)。
}//end if
//警告 RSIPriceLine < TradeSignalLine
如果(dRSIPriceLine[0]dTradeSignalLine[1] && Alert.RSIPriceLine) {
//打印D("RSIPriceLine < TradeSignalLine")。
if (!Alert.NewBarOnly) iAlertTimer[0]=GetTickCount()+Alert.Timeout*1000;
sAlertMsg="TDI警报 - "+Symbol()+" "+TF2Str(Period())+" 。RSIPriceLine低于TradeSignalLine。"。
如果(Alert.Popup)Alert(sAlertMsg)。
如果(Alert.Email)SendMail( sAlertMsg, "MT4警报!/n" + TimeToStr(TIME_DATE|TIME_SECONDS )+"/n "+sAlertMsg) 。
}//end if
}//end if
如果 (bNewBar || (!Alert.NewBarOnly &&iAlertTimer[1]<GetTickCount()){
//如果RSIPriceLine > TradeSignalLine && dMarketBaseLine就发出警报。
如果(dRSIPriceLine[0]>dMarketBaseLine[0] && dRSIPriceLine[1]<dMarketBaseLine[1] && Alert.MarketBaseLine) {
如果(dRSIPriceLine[0]>dTradeSignalLine[0] && dRSIPriceLine[1]<dTradeSignalLine[1]) {
if (!Alert.NewBarOnly) iAlertTimer[1]=GetTickCount()+Alert.Timeout*1000;
sAlertMsg="TDI警报 - "+Symbol()+" "+TF2Str(Period())+"。RSIPriceLine高于TradeSignalLine和MarketBaseLine。"。
如果(Alert.Popup)Alert(sAlertMsg)。
if (Alert.Email) SendMail( sAlertMsg, "MT4警报!/n" + TimeToStr(TIME_DATE|TIME_SECONDS )+"/n "+sAlertMsg)。
}//end if
}//end if
//如果RSIPriceLine < TradeSignalLine && dMarketBaseLine时发出警报
如果(dRSIPriceLine[0]dMarketBaseLine[1] && Alert.MarketBaseLine) {
如果(dRSIPriceLine[0]dTradeSignalLine[1]) {
if (!Alert.NewBarOnly) iAlertTimer[1]=GetTickCount()+Alert.Timeout*1000。
sAlertMsg="TDI警报 - "+Symbol()+" "+TF2Str(Period())+" 。RSIPriceLine低于TradeSignalLine和MarketBaseLine。" 。
如果(Alert.Popup)Alert(sAlertMsg)。
如果(Alert.Email)SendMail( sAlertMsg, "MT4警报!/n" + TimeToStr(TIME_DATE|TIME_SECONDS )+"/n "+sAlertMsg)。
}//end if
}//end if
}//end if
}//end if(Alert.RSIPriceLine || Alert.MarketBaseLine)
返回(0)。
}
好了,伙计们,你们来了,对不起,所有的公式都是这样的!
错了
刚刚把正确的代码复制到另一个文件中,覆盖了一个旧的代码,编译后,文件仍在使用旧的代码?不明白;无论如何,代码是正确的。
错误的
我之前发布的代码....
在我的旧笔记本电脑上有一个Vista版本,这就是为什么mq4文件不断消失的原因;现在它应该可以工作了。