mql4 - 有没有一种方法可以在数组中找到彼此最近的数字
问题描述
我现在代码中的逻辑是这样的
步骤1。扫描过去的 100 个或更多烛台
第2步。收集并存储所有 100 个烛台的日期,以找出每个烛台的最高点
第三步。浏览所有烛台高数据并找到彼此靠近的数据(仍然不知道我会怎么做)
第4步。绘制 H 线
现在我遇到的第一个问题是我将如何对其进行编码,以便我能够找到哪些烛台数字彼此接近以绘制 HLine。
extern int candleCount = 100;
int totalHigh;
int FinishingTotalHigh;
int totalLow;
int FinishingTotalLow;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//---
//---
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//---
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
totalHigh = 0;
totalLow = 0;
// Initializing the variables.
double Highest = High[0];
double Lowest = Low[0];
Alert("");
Alert("");
Alert("");
Alert("");
Alert("");
// Scan the 100 candles and update the values of the highest and lowest.
for (int i = 0; i <= candleCount; i++)
{
//Alert(i+"Index Data: "+High[i]);
totalHigh = High[i] + totalHigh;
totalLow = Low[i] + totalLow;
if (High[i] > Highest) Highest = High[i];
if (Low[i] < Lowest) Lowest = Low[i];
}
FinishingTotalHigh = totalHigh/candleCount;
FinishingTotalLow = totalLow/candleCount;
// Print the result.
Alert("Highest price found is "+Highest);
Alert("Lowest price found is "+Lowest);
Alert("TotalHigh: "+FinishingTotalHigh);
Alert("TotalLow: "+FinishingTotalLow);
}
//+------------------------------------------------------------------+
解决方案
推荐阅读
- python - 在 Eve-SQLAlchemy 中使用 WHERE 时出错:TypeError: find() got an unexpected keyword argument 'perform_count'
- wso2 - 带有开关中介的 API REST 端点
- javascript - 反应 js Socket.io 和状态
- c# - 上下 2d 斜坡(像素艺术)
- java - Ffmpeg- 在 android 中将视频分割成 30 秒的部分
- webstorm - 在 WebStorm 中调试 Cypress
- python - 如何在Python中获取二维列表不同类型对角线上的所有元素
- r - 使用 R 计算矩阵中最丰富的物种(案例)
- sql - 查询 jsonb 列中的数组值
- .net - 从字符串 yyyyMMddHHmmss 到整数类型的转换无效