各位大老 帮忙看看 跨周期 引用数据 不能得到相应 数据 新评论 Jinhua Wu 2019.06.17 02:49 #property copyright "Copyright 2019, MetaQuotes Software Corp." #property link "https://www.mql5.com" #property version "1.00" #property indicator_chart_window #property indicator_buffers 2 #property indicator_plots 2 #property indicator_type1 DRAW_LINE #property indicator_color1 clrWhite #property indicator_width1 1 #property indicator_label1 "M15" double M15Buffer[]; #property indicator_type2 DRAW_LINE #property indicator_color2 clrYellow #property indicator_width2 1 #property indicator_label2 "M30" double M30Buffer[]; /* #property indicator_type3 DRAW_LINE #property indicator_color3 clrLime #property indicator_width3 1 #property indicator_label3 "H1" double M20Buffer[]; #property indicator_type4 DRAW_LINE #property indicator_color4 clrPurple #property indicator_width4 1 #property indicator_label4 "H2" double M40Buffer[]; */ int M15Handle; int M30Handle; //int H20Handle; //int H40Handle; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit(){ //--- indicator buffers mapping SetIndexBuffer( 0, M15Buffer, INDICATOR_DATA ); SetIndexBuffer( 1, M30Buffer, INDICATOR_DATA ); //SetIndexBuffer( 2, M20Buffer, INDICATOR_DATA ); //SetIndexBuffer( 3, M40Buffer, INDICATOR_DATA ); ArraySetAsSeries( M15Buffer, true ); ArraySetAsSeries( M30Buffer, true ); M15Handle = iMA( NULL, PERIOD_M15, 5, 0, MODE_LWMA, PRICE_CLOSE ); M30Handle = iMA( NULL, PERIOD_M30, 5, 0, MODE_LWMA, PRICE_CLOSE ); //--- return(INIT_SUCCEEDED); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int OnCalculate ( const int rates_total, // 价格[] 数组的大小 const int prev_calculated, // 前一次调用处理的柱 const int begin, // 有效数据起始位置 const double& price[] // 计算的数组 ) { //--- // 得到 市场报价中品种数量 int _curencyNumber = SymbolsTotal( true ); /* Print( " 市场把价中品种数量:", _curencyNumber ); for( int i = 0 ; i < _curencyNumber; i++ ){ Print( " SymbolName( i, true ) ", i, " ", SymbolName( i, true ) ); } */ //--- we can copy not all data int _toCopy = 0; if( prev_calculated > rates_total || prev_calculated < 0 ){ _toCopy = rates_total; } else { _toCopy = rates_total - prev_calculated; if( prev_calculated > 0 ){ _toCopy++; } } FillArrayFromBuffer( M15Buffer, 0, M15Handle, _toCopy ); FillArrayFromBuffer( M30Buffer, 0, M30Handle, _toCopy ); //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ bool FillArrayFromBuffer( double &values[], // 移动平均值的指标缓冲区 int shift, // 移动 int indHandle, // iMA指标的处理程序 int amount // 复制值的数量 ){ ResetLastError(); if( CopyBuffer( indHandle, 0, shift, amount, values ) < 0 ){ PrintFormat("Failed to copy data from the iMA indicator, error code %d",GetLastError()); return false; } return true; } 新评论 原因: 取消 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录