style: normalize indentation in Orchestrator.mqh via clang-format
Whitespace-only: consistent 3-space indentation throughout (was a mix of 3/4/5/6.. spaces). Repo conventions preserved: for(/if( spacing, access labels, attached braces. Adds .clang-format so the style is reproducible (run: clang-format -i --style=file <file>). Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
co-authored by
Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
parent
a8b4a7d3ff
commit
bb670836e1
@@ -0,0 +1,15 @@
|
|||||||
|
BasedOnStyle: LLVM
|
||||||
|
IndentWidth: 3
|
||||||
|
TabWidth: 3
|
||||||
|
UseTab: Never
|
||||||
|
ColumnLimit: 0
|
||||||
|
BreakBeforeBraces: Attach
|
||||||
|
AllowShortFunctionsOnASingleLine: All
|
||||||
|
AllowShortBlocksOnASingleLine: Always
|
||||||
|
AllowShortIfStatementsOnASingleLine: true
|
||||||
|
AllowShortLoopsOnASingleLine: true
|
||||||
|
SortIncludes: false
|
||||||
|
SpaceBeforeParens: Never
|
||||||
|
IndentCaseLabels: true
|
||||||
|
AccessModifierOffset: -3
|
||||||
|
PointerAlignment: Right
|
||||||
@@ -233,21 +233,25 @@ public:
|
|||||||
|
|
||||||
int OpenTradeCount() const {
|
int OpenTradeCount() const {
|
||||||
int c = 0;
|
int c = 0;
|
||||||
for(int i=0; i<maxOpenTrades; i++) if(openTrades[i].active) c++;
|
for(int i = 0; i < maxOpenTrades; i++)
|
||||||
|
if(openTrades[i].active) c++;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
int OpenTradeCount(bool isBuy) const {
|
int OpenTradeCount(bool isBuy) const {
|
||||||
int c = 0;
|
int c = 0;
|
||||||
for(int i=0; i<maxOpenTrades; i++) if(openTrades[i].active && openTrades[i].isBuy == isBuy) c++;
|
for(int i = 0; i < maxOpenTrades; i++)
|
||||||
|
if(openTrades[i].active && openTrades[i].isBuy == isBuy) c++;
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
bool HasOpenTrade() const { return OpenTradeCount() > 0; }
|
bool HasOpenTrade() const { return OpenTradeCount() > 0; }
|
||||||
int OpenTicket() const {
|
int OpenTicket() const {
|
||||||
for(int i=0; i<maxOpenTrades; i++) if(openTrades[i].active) return openTrades[i].ticket;
|
for(int i = 0; i < maxOpenTrades; i++)
|
||||||
|
if(openTrades[i].active) return openTrades[i].ticket;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
double EntryPrice() const {
|
double EntryPrice() const {
|
||||||
for(int i=0; i<maxOpenTrades; i++) if(openTrades[i].active) return openTrades[i].entryPrice;
|
for(int i = 0; i < maxOpenTrades; i++)
|
||||||
|
if(openTrades[i].active) return openTrades[i].entryPrice;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
void ResetTradeState() {
|
void ResetTradeState() {
|
||||||
@@ -373,13 +377,21 @@ public:
|
|||||||
int TotalAgents() const { return agentCount; }
|
int TotalAgents() const { return agentCount; }
|
||||||
|
|
||||||
double Analyze(const MarketData &data) {
|
double Analyze(const MarketData &data) {
|
||||||
if(agentCount == 0) { combinedZ = 0; return 0; }
|
if(agentCount == 0) {
|
||||||
|
combinedZ = 0;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
double zs[MAX_AGENTS], ws[MAX_AGENTS], corrSign[MAX_AGENTS];
|
double zs[MAX_AGENTS], ws[MAX_AGENTS], corrSign[MAX_AGENTS];
|
||||||
|
|
||||||
// Fase 1: Analisi individuale
|
// Fase 1: Analisi individuale
|
||||||
for(int i = 0; i < agentCount; i++) {
|
for(int i = 0; i < agentCount; i++) {
|
||||||
if(!agents[i].enabled) { zs[i] = 0; ws[i] = 0; corrSign[i] = 1.0; continue; }
|
if(!agents[i].enabled) {
|
||||||
|
zs[i] = 0;
|
||||||
|
ws[i] = 0;
|
||||||
|
corrSign[i] = 1.0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
zs[i] = agents[i].Analyze(data);
|
zs[i] = agents[i].Analyze(data);
|
||||||
double rho = GetCorrelation(i);
|
double rho = GetCorrelation(i);
|
||||||
// Competenza = |correlazione| segnale/ritorni (con floor weightMin, così
|
// Competenza = |correlazione| segnale/ritorni (con floor weightMin, così
|
||||||
@@ -401,21 +413,25 @@ public:
|
|||||||
|
|
||||||
// Fase 3: Neural o Softmax Gating
|
// Fase 3: Neural o Softmax Gating
|
||||||
// Se la rete neurale è attiva e addestrata, usa forward pass
|
// Se la rete neurale è attiva e addestrata, usa forward pass
|
||||||
bool neuralReady = m_useNeural && m_neuralNet != NULL
|
bool neuralReady = m_useNeural && m_neuralNet != NULL && m_neuralNet.IsInitialized() && m_neuralNet.EpochsTrained() > 0;
|
||||||
&& m_neuralNet.IsInitialized()
|
|
||||||
&& m_neuralNet.EpochsTrained() > 0;
|
|
||||||
|
|
||||||
if(neuralReady) {
|
if(neuralReady) {
|
||||||
// Estrai feature vector: [z_Hurst, z_ADX, z_MA, z_Mom, z_Consensus, z_Pattern, agreement, trendStrength]
|
// Estrai feature vector: [z_Hurst, z_ADX, z_MA, z_Mom, z_Consensus, z_Pattern, agreement, trendStrength]
|
||||||
vector nnInput(NN_FEATURES);
|
vector nnInput(NN_FEATURES);
|
||||||
for(int f = 0; f < NN_FEATURES; f++) nnInput[f] = 0.0;
|
for(int f = 0; f < NN_FEATURES; f++) nnInput[f] = 0.0;
|
||||||
for(int i = 0; i < agentCount; i++) {
|
for(int i = 0; i < agentCount; i++) {
|
||||||
if(agents[i].name == "Hurst") nnInput[0] = agents[i].lastZScore;
|
if(agents[i].name == "Hurst")
|
||||||
else if(agents[i].name == "ADX") nnInput[1] = agents[i].lastZScore;
|
nnInput[0] = agents[i].lastZScore;
|
||||||
else if(agents[i].name == "MA") nnInput[2] = agents[i].lastZScore;
|
else if(agents[i].name == "ADX")
|
||||||
else if(agents[i].name == "Momentum") nnInput[3] = agents[i].lastZScore;
|
nnInput[1] = agents[i].lastZScore;
|
||||||
else if(agents[i].name == "Consensus") nnInput[4] = agents[i].lastZScore;
|
else if(agents[i].name == "MA")
|
||||||
else if(agents[i].name == "Hunter") nnInput[5] = agents[i].lastZScore;
|
nnInput[2] = agents[i].lastZScore;
|
||||||
|
else if(agents[i].name == "Momentum")
|
||||||
|
nnInput[3] = agents[i].lastZScore;
|
||||||
|
else if(agents[i].name == "Consensus")
|
||||||
|
nnInput[4] = agents[i].lastZScore;
|
||||||
|
else if(agents[i].name == "Hunter")
|
||||||
|
nnInput[5] = agents[i].lastZScore;
|
||||||
}
|
}
|
||||||
nnInput[6] = SHARED_regimeAgreement;
|
nnInput[6] = SHARED_regimeAgreement;
|
||||||
nnInput[7] = SHARED_trendStrength;
|
nnInput[7] = SHARED_trendStrength;
|
||||||
@@ -505,7 +521,10 @@ public:
|
|||||||
// Trova slot libero
|
// Trova slot libero
|
||||||
int idx = -1;
|
int idx = -1;
|
||||||
for(int i = 0; i < maxOpenTrades; i++) {
|
for(int i = 0; i < maxOpenTrades; i++) {
|
||||||
if(!openTrades[i].active) { idx = i; break; }
|
if(!openTrades[i].active) {
|
||||||
|
idx = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(idx < 0) { // non dovrebbe mai succedere dopo EnsureTradeCapacity
|
if(idx < 0) { // non dovrebbe mai succedere dopo EnsureTradeCapacity
|
||||||
Print("ERROR: slot non disponibile nonostante capacity expansion");
|
Print("ERROR: slot non disponibile nonostante capacity expansion");
|
||||||
@@ -531,12 +550,18 @@ public:
|
|||||||
// Feature vector per NN
|
// Feature vector per NN
|
||||||
for(int f = 0; f < NN_FEATURES; f++) openTrades[idx].entryFeatures[f] = 0.0;
|
for(int f = 0; f < NN_FEATURES; f++) openTrades[idx].entryFeatures[f] = 0.0;
|
||||||
for(int i = 0; i < agentCount; i++) {
|
for(int i = 0; i < agentCount; i++) {
|
||||||
if(agents[i].name == "Hurst") openTrades[idx].entryFeatures[0] = agents[i].lastZScore;
|
if(agents[i].name == "Hurst")
|
||||||
else if(agents[i].name == "ADX") openTrades[idx].entryFeatures[1] = agents[i].lastZScore;
|
openTrades[idx].entryFeatures[0] = agents[i].lastZScore;
|
||||||
else if(agents[i].name == "MA") openTrades[idx].entryFeatures[2] = agents[i].lastZScore;
|
else if(agents[i].name == "ADX")
|
||||||
else if(agents[i].name == "Momentum") openTrades[idx].entryFeatures[3] = agents[i].lastZScore;
|
openTrades[idx].entryFeatures[1] = agents[i].lastZScore;
|
||||||
else if(agents[i].name == "Consensus") openTrades[idx].entryFeatures[4] = agents[i].lastZScore;
|
else if(agents[i].name == "MA")
|
||||||
else if(agents[i].name == "Hunter") openTrades[idx].entryFeatures[5] = agents[i].lastZScore;
|
openTrades[idx].entryFeatures[2] = agents[i].lastZScore;
|
||||||
|
else if(agents[i].name == "Momentum")
|
||||||
|
openTrades[idx].entryFeatures[3] = agents[i].lastZScore;
|
||||||
|
else if(agents[i].name == "Consensus")
|
||||||
|
openTrades[idx].entryFeatures[4] = agents[i].lastZScore;
|
||||||
|
else if(agents[i].name == "Hunter")
|
||||||
|
openTrades[idx].entryFeatures[5] = agents[i].lastZScore;
|
||||||
}
|
}
|
||||||
openTrades[idx].entryFeatures[6] = SHARED_regimeAgreement;
|
openTrades[idx].entryFeatures[6] = SHARED_regimeAgreement;
|
||||||
openTrades[idx].entryFeatures[7] = SHARED_trendStrength;
|
openTrades[idx].entryFeatures[7] = SHARED_trendStrength;
|
||||||
@@ -600,7 +625,10 @@ void OnTradeClose(int ticket, double closePrice, string exitReason = "MANUAL") {
|
|||||||
// Trova il trade nell'array
|
// Trova il trade nell'array
|
||||||
int idx = -1;
|
int idx = -1;
|
||||||
for(int i = 0; i < maxOpenTrades; i++) {
|
for(int i = 0; i < maxOpenTrades; i++) {
|
||||||
if(openTrades[i].active && openTrades[i].ticket == ticket) { idx = i; break; }
|
if(openTrades[i].active && openTrades[i].ticket == ticket) {
|
||||||
|
idx = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(idx < 0) return;
|
if(idx < 0) return;
|
||||||
|
|
||||||
@@ -673,15 +701,21 @@ UpdateCorrelation(i, openTrades[idx].entryZScores[i], actualReturnZ);
|
|||||||
double target[NN_TARGETS];
|
double target[NN_TARGETS];
|
||||||
for(int f = 0; f < NN_FEATURES; f++) features[f] = openTrades[idx].entryFeatures[f];
|
for(int f = 0; f < NN_FEATURES; f++) features[f] = openTrades[idx].entryFeatures[f];
|
||||||
|
|
||||||
target[0] = 0; target[1] = 0; target[2] = 0;
|
target[0] = 0;
|
||||||
|
target[1] = 0;
|
||||||
|
target[2] = 0;
|
||||||
int tradeDir = openTrades[idx].isBuy ? 1 : -1;
|
int tradeDir = openTrades[idx].isBuy ? 1 : -1;
|
||||||
|
|
||||||
if(actualReturn > 0) {
|
if(actualReturn > 0) {
|
||||||
if(tradeDir == 1) target[0] = 1;
|
if(tradeDir == 1)
|
||||||
else target[2] = 1;
|
target[0] = 1;
|
||||||
|
else
|
||||||
|
target[2] = 1;
|
||||||
} else {
|
} else {
|
||||||
if(tradeDir == 1) target[2] = 1;
|
if(tradeDir == 1)
|
||||||
else target[0] = 1;
|
target[2] = 1;
|
||||||
|
else
|
||||||
|
target[0] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
double sampleWeight = MathAbs(actualReturn) + 1.0; // trade profittevoli/perdenti pesano di più
|
double sampleWeight = MathAbs(actualReturn) + 1.0; // trade profittevoli/perdenti pesano di più
|
||||||
@@ -970,7 +1004,10 @@ UpdateHealth(actualReturn);
|
|||||||
bool allHaveSamples = true;
|
bool allHaveSamples = true;
|
||||||
maxDeltaRho = 0;
|
maxDeltaRho = 0;
|
||||||
for(int i = 0; i < agentCount; i++) {
|
for(int i = 0; i < agentCount; i++) {
|
||||||
if(corrCount[i] < corrMinSamples) { allHaveSamples = false; break; }
|
if(corrCount[i] < corrMinSamples) {
|
||||||
|
allHaveSamples = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
double rho = GetCorrelation(i);
|
double rho = GetCorrelation(i);
|
||||||
double delta = MathAbs(rho - prevCorr[i]);
|
double delta = MathAbs(rho - prevCorr[i]);
|
||||||
if(delta > maxDeltaRho) maxDeltaRho = delta;
|
if(delta > maxDeltaRho) maxDeltaRho = delta;
|
||||||
@@ -1007,8 +1044,7 @@ UpdateHealth(actualReturn);
|
|||||||
// z_0.95 ≈ invNormalCDF(0.95) tramite approssimazione di Abramowitz & Stegun 26.2.23
|
// z_0.95 ≈ invNormalCDF(0.95) tramite approssimazione di Abramowitz & Stegun 26.2.23
|
||||||
double p05 = 0.95;
|
double p05 = 0.95;
|
||||||
double t = MathSqrt(-2.0 * MathLog(1.0 - p05));
|
double t = MathSqrt(-2.0 * MathLog(1.0 - p05));
|
||||||
double z095 = t - (2.515517 + 0.802853*t + 0.010328*t*t)
|
double z095 = t - (2.515517 + 0.802853 * t + 0.010328 * t * t) / (1.0 + 1.432788 * t + 0.189269 * t * t + 0.001308 * t * t * t);
|
||||||
/ (1.0 + 1.432788*t + 0.189269*t*t + 0.001308*t*t*t);
|
|
||||||
if(sharpeZ > z095)
|
if(sharpeZ > z095)
|
||||||
Print(" ✓ Sharpe significativamente positivo (z=", StringFormat("%.2f", sharpeZ), ")");
|
Print(" ✓ Sharpe significativamente positivo (z=", StringFormat("%.2f", sharpeZ), ")");
|
||||||
}
|
}
|
||||||
@@ -1078,7 +1114,10 @@ UpdateHealth(actualReturn);
|
|||||||
double maxTotalRisk = bal * m_riskTotal;
|
double maxTotalRisk = bal * m_riskTotal;
|
||||||
double usedRisk = TotalRiskUsed();
|
double usedRisk = TotalRiskUsed();
|
||||||
double remainingRisk = maxTotalRisk - usedRisk;
|
double remainingRisk = maxTotalRisk - usedRisk;
|
||||||
if(remainingRisk <= 0) { Print(" Risk budget esaurito (", StringFormat("%.2f", usedRisk), "/", StringFormat("%.2f", maxTotalRisk), ")"); return 0; }
|
if(remainingRisk <= 0) {
|
||||||
|
Print(" Risk budget esaurito (", StringFormat("%.2f", usedRisk), "/", StringFormat("%.2f", maxTotalRisk), ")");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
riskAmount = MathMin(riskAmount, remainingRisk);
|
riskAmount = MathMin(riskAmount, remainingRisk);
|
||||||
|
|
||||||
// Costo in valuta conto per 1 lotto a questa distanza SL
|
// Costo in valuta conto per 1 lotto a questa distanza SL
|
||||||
@@ -1115,8 +1154,10 @@ UpdateHealth(actualReturn);
|
|||||||
int jj = (ii - lag + MAX_HISTORY) % MAX_HISTORY;
|
int jj = (ii - lag + MAX_HISTORY) % MAX_HISTORY;
|
||||||
double x = history[ii].combinedZ;
|
double x = history[ii].combinedZ;
|
||||||
double y = history[jj].combinedZ;
|
double y = history[jj].combinedZ;
|
||||||
sum += x; sumSq += x*x;
|
sum += x;
|
||||||
sumShift += y; sumSqShift += y*y;
|
sumSq += x * x;
|
||||||
|
sumShift += y;
|
||||||
|
sumSqShift += y * y;
|
||||||
sumCov += x * y;
|
sumCov += x * y;
|
||||||
}
|
}
|
||||||
double mean = sum / cnt, meanS = sumShift / cnt;
|
double mean = sum / cnt, meanS = sumShift / cnt;
|
||||||
@@ -1188,8 +1229,10 @@ UpdateHealth(actualReturn);
|
|||||||
string fn = (m_modelFilename != "") ? m_modelFilename
|
string fn = (m_modelFilename != "") ? m_modelFilename
|
||||||
: "TR_Agent_NN_" + Symbol() + "_" + EnumToString(Period()) + "_" + m_runTimestamp + ".dat";
|
: "TR_Agent_NN_" + Symbol() + "_" + EnumToString(Period()) + "_" + m_runTimestamp + ".dat";
|
||||||
bool ok = m_neuralNet.Save(fn);
|
bool ok = m_neuralNet.Save(fn);
|
||||||
if(ok) Print("NN model saved: ", fn);
|
if(ok)
|
||||||
else Print("NN model save FAILED: ", fn);
|
Print("NN model saved: ", fn);
|
||||||
|
else
|
||||||
|
Print("NN model save FAILED: ", fn);
|
||||||
return ok;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1209,9 +1252,7 @@ UpdateHealth(actualReturn);
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool IsNeuralReady() const {
|
bool IsNeuralReady() const {
|
||||||
return m_useNeural && m_neuralNet != NULL
|
return m_useNeural && m_neuralNet != NULL && m_neuralNet.IsInitialized() && m_neuralNet.EpochsTrained() > 0;
|
||||||
&& m_neuralNet.IsInitialized()
|
|
||||||
&& m_neuralNet.EpochsTrained() > 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
string NeuralInfo() const {
|
string NeuralInfo() const {
|
||||||
@@ -1230,10 +1271,7 @@ UpdateHealth(actualReturn);
|
|||||||
int biasN = agents[i].predictionError.Count();
|
int biasN = agents[i].predictionError.Count();
|
||||||
double rho = agents[i].predCorr.Ready() ? agents[i].predCorr.Correlation() : 0;
|
double rho = agents[i].predCorr.Ready() ? agents[i].predCorr.Correlation() : 0;
|
||||||
int rhoN = agents[i].predCorr.Count();
|
int rhoN = agents[i].predCorr.Count();
|
||||||
FileWriteString(fh, agents[i].name + ","
|
FileWriteString(fh, agents[i].name + "," + StringFormat("%+.6f", bias) + "," + (string)biasN + "," + StringFormat("%+.6f", rho) + "," + (string)rhoN + "," + StringFormat("%.6f", agents[i].weight) + "\r\n");
|
||||||
+ StringFormat("%+.6f", bias) + "," + (string)biasN + ","
|
|
||||||
+ StringFormat("%+.6f", rho) + "," + (string)rhoN + ","
|
|
||||||
+ StringFormat("%.6f", agents[i].weight) + "\r\n");
|
|
||||||
}
|
}
|
||||||
FileClose(fh);
|
FileClose(fh);
|
||||||
Print("Agent learning CSV saved: ", fn);
|
Print("Agent learning CSV saved: ", fn);
|
||||||
@@ -1390,7 +1428,10 @@ UpdateHealth(actualReturn);
|
|||||||
void SaveAnalysisCSV(string symbol, ENUM_TIMEFRAMES tf) const {
|
void SaveAnalysisCSV(string symbol, ENUM_TIMEFRAMES tf) const {
|
||||||
string fn = "TR_Agent_Analysis_" + symbol + "_" + EnumToString(tf) + "_" + m_runTimestamp + ".csv";
|
string fn = "TR_Agent_Analysis_" + symbol + "_" + EnumToString(tf) + "_" + m_runTimestamp + ".csv";
|
||||||
int fh = FileOpen(fn, FILE_TXT | FILE_WRITE | FILE_COMMON);
|
int fh = FileOpen(fn, FILE_TXT | FILE_WRITE | FILE_COMMON);
|
||||||
if(fh == INVALID_HANDLE) { Print("SaveAnalysis: errore apertura ", fn); return; }
|
if(fh == INVALID_HANDLE) {
|
||||||
|
Print("SaveAnalysis: errore apertura ", fn);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// ===================== INTESTAZIONE =====================
|
// ===================== INTESTAZIONE =====================
|
||||||
FileWriteString(fh, "=== TR_Agent Analysis Report ===\r\n");
|
FileWriteString(fh, "=== TR_Agent Analysis Report ===\r\n");
|
||||||
@@ -1516,7 +1557,10 @@ UpdateHealth(actualReturn);
|
|||||||
void SaveBarHistoryCSV(string symbol, ENUM_TIMEFRAMES tf) const {
|
void SaveBarHistoryCSV(string symbol, ENUM_TIMEFRAMES tf) const {
|
||||||
string fn = "BarHistory_" + symbol + "_" + EnumToString(tf) + "_" + m_runTimestamp + ".csv";
|
string fn = "BarHistory_" + symbol + "_" + EnumToString(tf) + "_" + m_runTimestamp + ".csv";
|
||||||
int fh = FileOpen(fn, FILE_TXT | FILE_WRITE | FILE_COMMON);
|
int fh = FileOpen(fn, FILE_TXT | FILE_WRITE | FILE_COMMON);
|
||||||
if(fh == INVALID_HANDLE) { Print("BarHistoryCSV: errore apertura ", fn); return; }
|
if(fh == INVALID_HANDLE) {
|
||||||
|
Print("BarHistoryCSV: errore apertura ", fn);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
string header = "bar,time,combinedZ";
|
string header = "bar,time,combinedZ";
|
||||||
string agentNames[MAX_AGENTS];
|
string agentNames[MAX_AGENTS];
|
||||||
@@ -1550,7 +1594,10 @@ UpdateHealth(actualReturn);
|
|||||||
void SaveTradeHistoryCSV(string symbol, ENUM_TIMEFRAMES tf) const {
|
void SaveTradeHistoryCSV(string symbol, ENUM_TIMEFRAMES tf) const {
|
||||||
string fn = "TradeHistory_" + symbol + "_" + EnumToString(tf) + "_" + m_runTimestamp + ".csv";
|
string fn = "TradeHistory_" + symbol + "_" + EnumToString(tf) + "_" + m_runTimestamp + ".csv";
|
||||||
int fh = FileOpen(fn, FILE_TXT | FILE_WRITE | FILE_COMMON);
|
int fh = FileOpen(fn, FILE_TXT | FILE_WRITE | FILE_COMMON);
|
||||||
if(fh == INVALID_HANDLE) { Print("TradeHistoryCSV: errore apertura ", fn); return; }
|
if(fh == INVALID_HANDLE) {
|
||||||
|
Print("TradeHistoryCSV: errore apertura ", fn);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
string header = "ticket,isBuy,entryTime,closeTime,barsHeld,entryPrice,closePrice,entryATR,entryZ,slPrice,highestPrice,lowestPrice,maeATR,mfeATR,actualReturn,exitReason";
|
string header = "ticket,isBuy,entryTime,closeTime,barsHeld,entryPrice,closePrice,entryATR,entryZ,slPrice,highestPrice,lowestPrice,maeATR,mfeATR,actualReturn,exitReason";
|
||||||
string agentNames[MAX_AGENTS];
|
string agentNames[MAX_AGENTS];
|
||||||
@@ -1618,7 +1665,10 @@ UpdateHealth(actualReturn);
|
|||||||
void SaveAgentInteractionCSV(string symbol, ENUM_TIMEFRAMES tf) const {
|
void SaveAgentInteractionCSV(string symbol, ENUM_TIMEFRAMES tf) const {
|
||||||
string fn = "AgentInteraction_" + symbol + "_" + EnumToString(tf) + "_" + m_runTimestamp + ".csv";
|
string fn = "AgentInteraction_" + symbol + "_" + EnumToString(tf) + "_" + m_runTimestamp + ".csv";
|
||||||
int fh = FileOpen(fn, FILE_TXT | FILE_WRITE | FILE_COMMON);
|
int fh = FileOpen(fn, FILE_TXT | FILE_WRITE | FILE_COMMON);
|
||||||
if(fh == INVALID_HANDLE) { Print("AgentInteractionCSV: errore apertura ", fn); return; }
|
if(fh == INVALID_HANDLE) {
|
||||||
|
Print("AgentInteractionCSV: errore apertura ", fn);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
string header = "bar,time,combinedZ";
|
string header = "bar,time,combinedZ";
|
||||||
for(int i = 0; i < agentCount; i++) {
|
for(int i = 0; i < agentCount; i++) {
|
||||||
@@ -1651,7 +1701,10 @@ UpdateHealth(actualReturn);
|
|||||||
void SaveDecisionLogCSV(string symbol, ENUM_TIMEFRAMES tf) const {
|
void SaveDecisionLogCSV(string symbol, ENUM_TIMEFRAMES tf) const {
|
||||||
string fn = "DecisionLog_" + symbol + "_" + EnumToString(tf) + "_" + m_runTimestamp + ".csv";
|
string fn = "DecisionLog_" + symbol + "_" + EnumToString(tf) + "_" + m_runTimestamp + ".csv";
|
||||||
int fh = FileOpen(fn, FILE_TXT | FILE_WRITE | FILE_COMMON);
|
int fh = FileOpen(fn, FILE_TXT | FILE_WRITE | FILE_COMMON);
|
||||||
if(fh == INVALID_HANDLE) { Print("DecisionLogCSV: errore apertura ", fn); return; }
|
if(fh == INVALID_HANDLE) {
|
||||||
|
Print("DecisionLogCSV: errore apertura ", fn);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
FileWriteString(fh, "time,action,direction,zScore,combinedZ,price,ticket,agreeingCount,totalAgents,confidence,minZ\r\n");
|
FileWriteString(fh, "time,action,direction,zScore,combinedZ,price,ticket,agreeingCount,totalAgents,confidence,minZ\r\n");
|
||||||
for(int d = 0; d < decisionCount; d++) {
|
for(int d = 0; d < decisionCount; d++) {
|
||||||
|
|||||||
Reference in New Issue
Block a user