This commit is contained in:
2024-06-22 08:33:18 +03:30
parent 532be35f74
commit 6063d3be61
5 changed files with 597 additions and 57 deletions
+165 -24
View File
@@ -46,6 +46,7 @@ input bool x121EAUseAllSymbols = false;
input bool x121EAUseAllWatchListSymbols = false; // Use All WatchList Symbols
input bool x121EAAllowLong = true; // Allow Long Trades
input bool x121EAAllowShort = true; // Allow Short Trades
input int x121EADelayBetweenTwoSignal = 10; // Delay Between two Same Signals
input int x121EAReuiredSignalVerifications = 5; // Required Verifications for Signals
input bool x121EAGetVerificationFromOtherTimeFrames = true; // Get Verifications from Other Time Frames
@@ -102,9 +103,11 @@ input double x121EAMaxAllowedRecoveryVolume = 0.08; // Max Allowed Recovery Sign
//
input group "Hedging";
input int x121EARestingAfterHedge = 0; // Resting Seconds After Hedge
input double x121EAForceCloseProfit = 15; // Close All Positions Regardless of Policies when Profit Reached
input double x121EAMaxDrawdownForce = 5; // Max Drawdown Force State for Handling Guards
input int x121EAMaxPositionsForce = 15; // Max Number of Positions Force State for Handling Guards
input double x121EAMinRequiredProfitPerTrade = 0.5; // Minimum Required Profit for Hedging
input double x121EAMinRequiredProfitPerVolumeFactor = 0.01; // Minimum Required Profit for Hedging Per Volume
input double x121EAForceCloseProfit = 20; // Close All Positions Regardless of Policies when Profit Reached
//
// Alert ...
@@ -122,6 +125,7 @@ input bool x121EATerminalAlerts = false; // Terminal Alerts
// Local Variables ...
//
string x121EAUsedSymbols[];
XSCX121SetupEA *x121EA;
//
@@ -170,7 +174,11 @@ void OnDeinit(const int reason)
// On Tick Handler ...
void OnTick()
{
//
x121EA.OnTick();
//
X121ReportState();
}
//
@@ -206,13 +214,13 @@ bool InitialEA()
);
//
string symbols[];
Clean(x121EAUsedSymbols);
if (x121EAUseAllSymbols)
{
//
Copy(
allSymbols,
symbols //
x121EAUsedSymbols //
);
}
else if (x121EAUseAllWatchListSymbols)
@@ -220,7 +228,7 @@ bool InitialEA()
//
Copy(
watchListSymbols,
symbols //
x121EAUsedSymbols //
);
}
else if (IsValidSize(inputSymbolsCount))
@@ -228,7 +236,7 @@ bool InitialEA()
//
Copy(
inputSymbols,
symbols //
x121EAUsedSymbols //
);
}
else
@@ -236,10 +244,10 @@ bool InitialEA()
//
Add(
_Symbol,
symbols //
x121EAUsedSymbols //
);
}
int symbolsCount = ArraySize(symbols);
int symbolsCount = ArraySize(x121EAUsedSymbols);
result = IsValidSize(symbolsCount);
if (!result)
{
@@ -259,6 +267,7 @@ bool InitialEA()
// Signals ...
x121EA.AllowLong(x121EAAllowLong);
x121EA.AllowShort(x121EAAllowShort);
x121EA.DelayBetweenTwoSignal(x121EADelayBetweenTwoSignal);
x121EA.ReuiredSignalVerifications(x121EAReuiredSignalVerifications);
x121EA.GetVerificationFromOtherTimeFrames(x121EAGetVerificationFromOtherTimeFrames);
@@ -317,6 +326,8 @@ bool InitialEA()
// Hedging ...
x121EA.ForceCloseProfit(x121EAForceCloseProfit);
x121EA.RestingAfterHedge(x121EARestingAfterHedge);
x121EA.MaxDrawdownForce(x121EAMaxDrawdownForce);
x121EA.MaxPositionsForce(x121EAMaxPositionsForce);
x121EA.MinRequiredProfitPerTrade(x121EAMinRequiredProfitPerTrade);
x121EA.MinRequiredProfitPerVolumeFactor(x121EAMinRequiredProfitPerVolumeFactor);
@@ -333,7 +344,7 @@ bool InitialEA()
// Configure Indicators ...
X121SetupInputs setupInputsDefault;
setupInputsDefault.Default();
PreConfigureStyles(setupInputsDefault);
X121PreConfigureStyles(setupInputsDefault);
//
// Prepare Providers and Add them into mX121EA class ...
@@ -341,7 +352,7 @@ bool InitialEA()
{
//
// Requirements ...
string iSymbol = symbols[i];
string iSymbol = x121EAUsedSymbols[i];
ENUM_TIMEFRAMES iHostPeriod = _Period;
//
@@ -370,25 +381,25 @@ bool InitialEA()
}
//
void PreConfigureStyles(X121SetupInputs &inputs)
void X121PreConfigureStyles(X121SetupInputs &inputs)
{
//
// XPV ...
inputs.pvInputs.showPeaksAndVales = true;
inputs.pvInputs.showPeaksAndVales = false;
inputs.pvInputs.showLevels = false;
inputs.pvInputs.showConsolidations = false;
inputs.pvInputs.showFibo1Levels = true;
inputs.pvInputs.showFibo2Levels = true;
inputs.pvInputs.showFibo3Levels = true;
inputs.pvInputs.showFibo4Levels = true;
inputs.pvInputs.showFibo5Levels = true;
inputs.pvInputs.showFibo1Levels = false;
inputs.pvInputs.showFibo2Levels = false;
inputs.pvInputs.showFibo3Levels = false;
inputs.pvInputs.showFibo4Levels = false;
inputs.pvInputs.showFibo5Levels = false;
//
// XMC ...
inputs.mcInputs.showSar = true;
inputs.mcInputs.showFastMa = true;
inputs.mcInputs.showSlowMa = true;
inputs.mcInputs.showVerifierMa = true;
inputs.mcInputs.showSar = false;
inputs.mcInputs.showFastMa = false;
inputs.mcInputs.showSlowMa = false;
inputs.mcInputs.showVerifierMa = false;
//
// XHK ...
@@ -398,9 +409,9 @@ void PreConfigureStyles(X121SetupInputs &inputs)
//
// XCHE ...
inputs.cheInputs.showLongExit1Line = false;
inputs.cheInputs.showShortExit1Line = true;
inputs.cheInputs.showShortExit1Line = false;
inputs.cheInputs.showLongExit2Line = false;
inputs.cheInputs.showShortExit2Line = true;
inputs.cheInputs.showShortExit2Line = false;
//
// XICH ...
@@ -415,7 +426,7 @@ void PreConfigureStyles(X121SetupInputs &inputs)
//
// XSTR ...
inputs.strInputs.showTrends = true;
inputs.strInputs.showTrends = false;
inputs.strInputs.fillTrends = false;
//
@@ -440,4 +451,134 @@ void PreConfigureStyles(X121SetupInputs &inputs)
inputs.hullInputs.showDownZone = false;
}
//
//
void X121ReportState()
{
//
string comment = NULL;
//
comment =
ShortName + "\n" +
"------------" + "\n" +
"Trading Symbols: " + ToString(ArraySize(x121EAUsedSymbols)) + "\n" + "\n";
//
// Detect What we Want to Show as Comment ...
bool isInForceState = x121EA.ForceState();
double bullishScore = 0; // x121EA.GetBullishScore();
double bearishScore = 0; // x121EA.GetBearishScore();
double drawDownPercent = x121EA.GetDrawdownPercent();
//
comment +=
//
(bullishScore > 0 || bearishScore > 0
? "Scores:" + "\n" +
"------------" + "\n" +
"Bullish: " + ToString(bullishScore) + "\n" +
"Bearish: " + ToString(bearishScore) + "\n" +
"------------" + "\n"
: "") +
"Drawdown: " + ToString(drawDownPercent) + "%" + "\n" +
"------------" + "\n" +
"Force State: " + ToString(isInForceState) + "\n" +
//
""
//
;
//
XPosition positions[];
int positionsCount = x121EA.mTrader.GetPositions(
positions //
);
if (IsValidSize(positionsCount))
{
//
int longs = 0;
double longVolumes = 0;
double longProfits = 0;
//
int shorts = 0;
double shortVolumes = 0;
double shortProfits = 0;
//
// Retrieve Required Informations of Positions ...
CountPositions(
positions,
longs,
longProfits,
longVolumes,
shorts,
shortProfits,
shortVolumes //
);
//
comment +=
//
"------------" + "\n" +
"Positions: " + "\n" +
"------------" + "\n" +
(longs <= 0
? ""
: "\n" + "Longs:" + "\n" +
"------------" + "\n" +
"Count: " + ToString(longs) + "\n" +
"Profits: " + ToString(longProfits) + "\n" +
""
//
) +
//
(shorts <= 0
? ""
: "\n" + "Shorts:" + "\n" +
"------------" + "\n" +
"Count: " + ToString(shorts) + "\n" +
"Profits: " + ToString(shortProfits) + "\n" +
""
//
) +
//
""
//
;
}
//
if (positionsCount > 1 && x121EAMinRequiredProfitPerTrade > 0 && x121EAMinRequiredProfitPerVolumeFactor > 0)
{
//
double profit = SpecifiedCalculatePositionsProfit(
positions //
);
double requiredProfitForHedge = SpecifiedCalculateRequiredProfitForHedge(
positions,
x121EAMinRequiredProfitPerTrade,
x121EAMinRequiredProfitPerVolumeFactor //
);
//
comment +=
//
"\n" + "Hedging: " + "\n" +
"------------" + "\n" +
"Profits: " + ToString(profit) + "\n" +
"RequiredProft: " + ToString(requiredProfitForHedge) + "\n" +
//
""
//
;
}
//
if (IsValid(comment))
{
Comment(comment);
}
}
//