MT4自定义指标不报错但是前台不显示,源码哪里有问题 新评论 Yu Fu 2022.12.04 14:00 //+------------------------------------------------------------------+ //| test-1.mq4 | //| Copyright 2022, Fu Yu. | //| https://www.mql5.com/zh/users/ciciboy3/seller | //+------------------------------------------------------------------+ #property copyright "Copyright 2022, Fu Yu." #property link "https://www.mql5.com/zh/users/ciciboy3/seller" #property version "1.00" #property strict #property indicator_chart_window #property indicator_buffers 2 #property indicator_plots 2 //--- plot buy #property indicator_label1 "buy" #property indicator_type1 DRAW_ARROW #property indicator_color1 clrAqua #property indicator_style1 STYLE_SOLID #property indicator_width1 1 //--- plot sell #property indicator_label2 "sell" #property indicator_type2 DRAW_ARROW #property indicator_color2 clrRed #property indicator_style2 STYLE_SOLID #property indicator_width2 1 //--- indicator buffers int InpKPeriod0=9; // K period int InpDPeriod0=3; // D period int InpSlowing0=3; // Slowing double buyBuffer[]; double sellBuffer[]; double isto9k[]; double isto9d[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int OnInit() { //--- indicator buffers mapping SetIndexBuffer(0,buyBuffer); SetIndexBuffer(1,sellBuffer); //--- setting a code from the Wingdings charset as the property of PLOT_ARROW SetIndexArrow(0,116); SetIndexArrow(1,234); //--- 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[]) { //--- if(rates_total<InpKPeriod0 ||rates_total<InpDPeriod0 ||rates_total<InpSlowing0) { return (0); } int i=0; int limit; limit=rates_total-prev_calculated; if(prev_calculated>0) limit++; for(i=0; i<limit; i++) { isto9k[i]=iStochastic(NULL,0,InpKPeriod0,InpDPeriod0,InpSlowing0,0,0,MODE_MAIN,i); isto9d[i]=iStochastic(NULL,0,InpKPeriod0,InpDPeriod0,InpSlowing0,0,0,MODE_SIGNAL,i); if(isto9k[i]<isto9d[i]) { buyBuffer[i]=close[i]; } } //--- return value of prev_calculated for next call return(rates_total); } //+------------------------------------------------------------------+ Hung Wen Lin 2022.12.04 23:44 #1 isto9k[i] isto9d[i] 數組超出範圍 編譯沒抱錯並不表示代碼沒問題 只能說代碼的語法沒問題 這兩個不需要設為數組來做計算的 新评论 您错过了交易机会: 免费交易应用程序 8,000+信号可供复制 探索金融市场的经济新闻 注册 登录 拉丁字符(不带空格) 密码将被发送至该邮箱 发生错误 使用 Google 登录 您同意网站政策和使用条款 如果您没有帐号,请注册 可以使用cookies登录MQL5.com网站。 请在您的浏览器中启用必要的设置,否则您将无法登录。 忘记您的登录名/密码? 使用 Google 登录