mql4 - 你好,mt4 robot5 在专家中给出的值是 2147483647,但在图形中画得很好
问题描述
这是我的专家代码,它显然在图形窗口中运行良好,它正确绘制图形并在数据面板中正确给出一个值,但是当我尝试在专家中使用它时它返回 2147483647,我知道的意思“空值”....
关于如何修复错误的任何想法?
#property strict
#property indicator_separate_window
#property indicator_label1 "bajista"
#property indicator_type1 DRAW_HISTOGRAM
#property indicator_color1 clrOrange
#property indicator_style1 STYLE_SOLID
#property indicator_width1 3
#property indicator_label2 "alcista"
#property indicator_type2 DRAW_HISTOGRAM
#property indicator_color2 clrRed
#property indicator_style2 STYLE_SOLID
#property indicator_width2 3
//--- input parameters
input int periodos=10;
input int margen=45;
//--- indicator buffers
double buffer0[];
double buffer1[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
SetIndexBuffer(0,buffer0);
SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2,clrGreen);
SetIndexBuffer(1,buffer1);
SetIndexStyle(1,DRAW_HISTOGRAM,STYLE_SOLID,2,clrRed);
//---
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[])
{
int counted_bars=IndicatorCounted();//funcion que devuelve el numero de barras sin cambios (antiguas)
int limit;
limit=(rates_total-prev_calculated);
if(prev_calculated>0)
limit=limit++;
double var1[];
double var2[];
double var3[];
double var4[];
double var5[];
ArrayResize(var1,limit);
ArrayResize(var2,limit);
ArrayResize(var3,limit);
ArrayResize(var4,limit);
ArrayResize(var5,limit);
//PRECALCULAR LA MATRIZ DE VAR4 Y VAR5 , PUNTOS ALCISTAS Y BAJISTAS
for(int i=0; i<limit; i++)
{
var1[i]=iCustom(NULL,0,"ZigZag", periodos,5,3, 0, i); //giros
if(var1[i]<0.1)//maximo, giro bajista
{
var1[i]=0;
}
var2[i]=iCustom(NULL,0,"ZigZag", periodos,5,3, 1, i); //alcista amarillo
if(var2[i]<0.1)//maximo, giro bajista
{
var2[i]=0;
}
var3[i]=iCustom(NULL,0,"ZigZag", periodos,5,3, 2, i); //bajista rojo
if(var3[i]<0.1)//maximo, giro bajista
{
var3[i]=0;
}
if(var1[i]>0.1 && var2[i]>0.1)//maximo, giro bajista
{
var4[i]=var1[i];
}
if(var4[i]<0.1)//maximo, giro bajista
{
var4[i]=0;
}
if(var1[i]>0.1 && var3[i]>0.1)//minimo, giro alcista
{
var5[i]=var1[i];
}
if(var5[i]<0.1)//maximo, giro bajista
{
var5[i]=0;
}
}
for(int i=0; i<limit; i++)
{
for(int j=1; j<=margen; j++)
{
if(iClose(NULL,0,i)>var4[i+j] && var4[i+j]>0.1)
{
buffer1[i]=iClose(NULL,0,i);//rojo alcista
//printf(limit);
}
if(iClose(NULL,0,i)<var5[i+j] && var5[i+j]>0.1)
{
buffer0[i]=iClose(NULL,0,i);//amarillo bajista
//printf(limit);
}
}
}
return(rates_total);
}
非常感谢您的时间 ;-)
解决方案
推荐阅读
- c - 如何在 C 中使用 fread() 读取和传输 PDF 文件
- javascript - 在 React SharePoint WebPart 中,使用“html-react-parser”和使用“dompurify eslint-plugin-risxss”安全地显示 HTML 有什么区别
- python - 从dicts列表导出到excel
- java - JUnit 测试模拟对象返回空值
- python - 如何按年龄范围对数据框的数据进行分组?
- android - 如何从 node.js 服务器向 ionic react 应用程序发送推送通知
- gradle - 如何将 jaxb-gradle-plugin 迁移到 Java 11 支持的较新版本
- r - R - 将数据帧中的值与聚合数据帧进行比较
- ios - 单击 iOS 中的按钮时,如何调整 Firebase SnapshotListener 限制?
- javascript - 使用 axios 和 React FE 将包含文件的 JSON 发送到 Flask BE