论坛全局菜单下方 - TICKMILL 285X70论坛全局菜单下方 - ThinkMarkets285X70论坛全局菜单下方 - 荔枝返现285X70论坛全局菜单下方 -  icmarkets285X70
查看:1073回复:2
goodxauusa
注册时间2015-02-14
[求助]不懂语言帮忙转换下MT5上的换成MT4上用
楼主发表于:2015-05-11 03:11只看该作者倒序浏览
1楼 电梯直达
电梯直达
//+------------------------------------------------------------------+ //| MACD_On_Chart.mq5 | //| Copyright ?2007, Khashayar Talebi | //| http://www.stct.info | //+------------------------------------------------------------------+ //--- Copyright #property copyright "Copyright ?2007, Khashayar Talebi" //--- link to the website of the author #property link "http://www.stct.info" //--- Indicator version #property version "1.00" //--- drawing the indicator in the main window #property indicator_chart_window //--- two buffers are used for calculating and drawing the indicator #property indicator_buffers 2 //--- two plots are used #property indicator_plots 2 //+----------------------------------------------+ //| Parameters of drawing the bearish indicator | //+----------------------------------------------+ //--- drawing the indicator 1 as a symbol #property indicator_type1 DRAW_ARROW //---- pink is used for the color of the bearish indicator line #property indicator_color1 clrMagenta //---- indicator 1 line width is equal to 4 #property indicator_width1 4 //---- indicator bullish label display #property indicator_label1 "MACD_On_Chart Sell" //+----------------------------------------------+ //| Bullish indicator drawing parameters | //+----------------------------------------------+ //--- drawing the indicator 2 as a symbol #property indicator_type2 DRAW_ARROW //---- green color is used as the color of the indicator bullish line #property indicator_color2 clrLime //---- indicator 2 line width is equal to 4 #property indicator_width2 4 //---- bearish indicator label display #property indicator_label2 "MACD_On_Chart Buy" //+----------------------------------------------+ //| declaring constants | //+----------------------------------------------+ #define RESET 0 // A constant for returning the indicator recalculation command to the terminal //+----------------------------------------------+ //| Indicator input parameters | //+----------------------------------------------+ input uint FastEMA=12; input uint SlowEMA=26; input uint SignalSMA=9; input ENUM_APPLIED_PRICE Applied_Price=PRICE_CLOSE; //+----------------------------------------------+ //--- declaration of dynamic arrays that //--- will be used as indicator buffers double SellBuffer; double BuyBuffer; //--- declaration of integer variables for the indicators handles int Macd_Handle,ATR_Handle; //--- declaration of integer variables for the start of data calculation int min_rates_total; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- initialization of global variables int ATR_Period=15; min_rates_total=int(MathMax(FastEMA,SlowEMA)+SignalSMA+1); min_rates_total=int(MathMax(min_rates_total,ATR_Period)); //--- getting the handle of the iMACD indicator Macd_Handle=iMACD(Symbol(),PERIOD_CURRENT,FastEMA,SlowEMA,SignalSMA,Applied_Price); if(Macd_Handle==INVALID_HANDLE) { Print(" Failed to get the handle of iMACD"); return(INIT_FAILED); } //---- getting the handle of the ATR indicator ATR_Handle=iATR(Symbol(),PERIOD_CURRENT,ATR_Period); if(ATR_Handle==INVALID_HANDLE) { Print(" Failed to get handle of the ATR indicator"); return(INIT_FAILED); } //--- set dynamic array as an indicator buffer SetIndexBuffer(0,SellBuffer,INDICATOR_DATA); //--- shifting the start of drawing the indicator 1 PlotIndexSetInteger(0,PLOT_DRAW_BEGIN,min_rates_total); //--- indicator symbol PlotIndexSetInteger(0,PLOT_ARROW,234); //--- Indexing elements in the buffer as in timeseries ArraySetAsSeries(SellBuffer,true); //--- Set dynamic array as an indicator buffer SetIndexBuffer(1,BuyBuffer,INDICATOR_DATA); //--- shifting the starting point of calculation of drawing of the indicator 2 PlotIndexSetInteger(1,PLOT_DRAW_BEGIN,min_rates_total); //--- indicator symbol PlotIndexSetInteger(1,PLOT_ARROW,233); //--- Indexing elements in the buffer as in timeseries ArraySetAsSeries(BuyBuffer,true); //--- setting the format of accuracy of displaying the indicator IndicatorSetInteger(INDICATOR_DIGITS,_Digits); //--- name for the data window and the label for sub-windows string short_name="MACD_On_Chart"; IndicatorSetString(INDICATOR_SHORTNAME,short_name); //--- initialization end return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate(const int rates_total, const int prev_calculated, const datetime &time, const double &open, const double &high, const double &low, const double &close, const long &tick_volume, const long &volume, const int &spread) { //--- checking if the number of bars is enough for the calculation if(BarsCalculated(Macd_Handle)rates_total || prev_calculated<=0)// Checking for the first start of the indicator calculation { limit=rates_total-min_rates_total-1; // Starting index for calculation of all bars } else { limit=rates_total-prev_calculated; // starting index for calculation of new bars } to_copy=limit+2; // calculated number of copied bars //--- copy newly appeared data in the arrays if(CopyBuffer(Macd_Handle,MAIN_LINE,0,to_copy,MACD)<=0) return(RESET); if(CopyBuffer(Macd_Handle,SIGNAL_LINE,0,to_copy,SIGN)<=0) return(RESET); to_copy--; if(CopyBuffer(ATR_Handle,MAIN_LINE,0,to_copy,ATR)<=0) return(RESET); //--- indexing elements in arrays as in timeseries ArraySetAsSeries(MACD,true); ArraySetAsSeries(SIGN,true); ArraySetAsSeries(ATR,true); ArraySetAsSeries(high,true); ArraySetAsSeries(low,true); //--- main indicator calculation loop for(bar=limit; bar>=0 && !IsStopped(); bar--) { BuyBuffer[bar]=0.0; SellBuffer[bar]=0.0; if(MACD[bar]>SIGN[bar] && MACD[bar+1]<= SIGN[bar+1]) BuyBuffer [bar]=low [bar]-ATR[bar]*3/8; if(MACD[bar]= SIGN[bar+1]) SellBuffer[bar]=high[bar]+ATR[bar]*3/8; } //--- return(rates_total); } //+------------------------------------------------------------------+
TK29帖子1楼右侧xm竖版广告90-240
个性签名

韬客社区www.talkfx.co

广告
TK30+TK31帖子一樓廣告
TK30+TK31帖子一樓廣告
scalping
注册时间2015-01-14
发表于:2015-05-11 05:58只看该作者
2楼
你试一试MACD_On_Chart.mq4
个性签名

韬客社区www.talkfx.co

广告
论坛谏言--外汇交易不应是你投资的全部,交易外汇也不应是你生活的全部
scalping
注册时间2015-01-14
发表于:2015-05-11 08:20只看该作者
3楼
本帖最后由 scalping 于 2015-5-11 16:32 编辑 我简单写了个EA测了一下,如果是H4的还行,再小就要结合别的指标比如均线等把骗子筛选掉才能用。 H4 USDJPY 4月1日-4月30 点差1.4 0.01手 500$ TEST3_MACD_On_Chart_EA.jpgTEST3_MACD_On_Chart_EA.jpgTEST2_MACD_On_Chart_EA.jpgTEST2_MACD_On_Chart_EA.jpgTEST1_MACD_On_Chart_EA.jpgTEST1_MACD_On_Chart_EA.jpg

本站免责声明:

1、本站所有广告及宣传信息均与韬客无关,如需投资请依法自行决定是否投资、斟酌资金安全及交易亏损风险;

2、韬客是独立的、仅为投资者提供交流的平台,网友发布信息不代表韬客的观点与意思表示,所有因网友发布的信息而造成的任何法律后果、风险与责任,均与韬客无关;

3、金融交易存在极高法律风险,未必适合所有投资者,请不要轻信任何高额投资收益的诱导而贸然投资;投资保证金交易导致的损失可能超过您投入的资金和预期。请您考虑自身的投资经验及风险承担能力,进行合法、理性投资;

4、所有投资者的交易帐户应仅限本人使用,不应交由第三方操作,对于任何接受第三方喊单、操盘、理财等操作的投资和交易,由此导致的任何风险、亏损及责任由投资者个人自行承担;

5、韬客不隶属于任何券商平台,亦不受任何第三方控制,韬客不邀约客户投资任何保证金交易,不接触亦不涉及投资者的任何资金及账户信息,不代理任何交易操盘行为,不向客户推荐任何券商平台,亦不存在其他任何推荐行为。投资者应自行选择券商平台,券商平台的任何行为均与韬客无关。投资者注册及使用韬客即表示其接受和认可上述声明,并自行承担法律风险。

版权所有:韬客外汇论坛 www.talkfx.com 联络我们:[email protected]