为稳定盈利 提供动力

这里是我的工作总结和我感性上的碎碎念 3BFund Quant leader CFA 从业6Y Email: wongmanc@88.com

CFD成交量跟踪Volume Sorter (源码)


//+——————————————————————+
//| Volume Sorter EA |
//| 王满仓 |
//| https://www.wongmanc.com |
//+——————————————————————+
#property copyright “by王满仓源码获取连接↓”
#property link “https://www.wongmanc.com/”
#property version “1.0”
#property strict
#property description “EA-震荡指示器与成交量监控”

input int RSI_Period = 60; // 指标计算周期
input double Upper_Limit = 55.0; // 指标上限值
input double Lower_Limit = 45.0; // 指标下限值
input ENUM_TIMEFRAMES TimeFrame = PERIOD_H1; // 使用的时间框架
input ENUM_APPLIED_PRICE AppliedPrice = PRICE_CLOSE; // 使用的价格类型
input int UpdateInterval = 60; // 更新间隔(秒)
input long VolumeThreshold = 500000; // 成交量阈值

struct SymbolVolume {
string symbol;
long volume;
};
SymbolVolume volumes[];

//+——————————————————————+
//| Expert initialization function |
//+——————————————————————+
int OnInit() {
EventSetTimer(UpdateInterval);
return INIT_SUCCEEDED;
}

//+——————————————————————+
//| Timer event handling function |
//+——————————————————————+
void OnTimer() {
int totalSymbols = SymbolsTotal(true);
ArrayResize(volumes, totalSymbols);
int index = 0;

for(int i = 0; i < totalSymbols; i++) {
string symbol = SymbolName(i, true);
double rsi = iRSI(symbol, TimeFrame, RSI_Period, AppliedPrice, 0);
if(rsi >= Lower_Limit && rsi <= Upper_Limit) {
long volume = iVolume(symbol, TimeFrame, 0) * 1440;
volumes[index].symbol = symbol;
volumes[index].volume = volume;
index++;
}
}

for (int i = 0; i < index – 1; i++) {
for (int j = 0; j < index – i – 1; j++) {
if (volumes[j].volume > volumes[j + 1].volume) {
SymbolVolume temp = volumes[j];
volumes[j] = volumes[j + 1];
volumes[j + 1] = temp;
}
}
}

for (int i = 0; i < totalSymbols; i++) {
string labelName = “VolumeLabel_” + IntegerToString(i);
ObjectDelete(labelName);
}

for (int i = 0; i < index; i++) {
string labelName = “VolumeLabel_” + IntegerToString(i);
ObjectCreate(labelName, OBJ_LABEL, 0, 0, 0);
ObjectSet(labelName, OBJPROP_CORNER, 0);
ObjectSet(labelName, OBJPROP_XDISTANCE, 10);
ObjectSet(labelName, OBJPROP_YDISTANCE, 30 + i * 20);
color textColor = volumes[i].volume > VolumeThreshold ? clrRed : clrAqua;
ObjectSetText(labelName, volumes[i].symbol + “: Volume = ” + IntegerToString(volumes[i].volume), 9, “Arial”, textColor);
}
}

//+——————————————————————+
//| Expert deinitialization function |
//+——————————————————————+
void OnDeinit(const int reason) {
EventKillTimer();
int totalSymbols = SymbolsTotal(true);
for (int i = 0; i < totalSymbols; i++) {
string labelName = “VolumeLabel_” + IntegerToString(i);
ObjectDelete(labelName);
}
}
//+——————————————————————+


发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注