This commit is contained in:
2024-06-23 17:11:07 +03:30
parent b65fcdcb01
commit 43ea4edc42
4 changed files with 735 additions and 421 deletions
+17 -18
View File
@@ -404,6 +404,18 @@ public:
return cCycle.GetPeriod();
}
//
bool ForceState()
{
return forceState;
}
//
void ForceState(bool value)
{
forceState = value;
}
//
bool CanProcessBar(
ENUM_X_MARKET_CYCLES cycle = X_MARKET_CYCLE_UNKNOWN //
@@ -776,6 +788,9 @@ private:
//
X121SetupInputs inputs; // Cycles Configurations
//
bool forceState; // Force State
//
// Bar Trackers ...
XBarTracker cBarTracker;
@@ -794,7 +809,8 @@ private:
//
void FillNextBarTime(
datetime &next,
XBarTracker &tracker)
XBarTracker &tracker //
)
{
//
next = iTime(
@@ -803,23 +819,6 @@ private:
0) +
PeriodSeconds(tracker.period);
}
// //
// bool ProcessCurrentMarket(
// XSignal &signal,
// X121SetupConditions &conditions,
// int &pushers,
// string &provider,
// int barIndex = 0,
// int loopback = 5 //
// )
// {
// //
// bool result = false;
// //
// return result;
// }
};
//
File diff suppressed because it is too large Load Diff
+245
View File
@@ -3605,3 +3605,248 @@
// hConditions //
// );
// }
////////////////////////////////////////////////////////////////////////////////
// //
// double profits = SpecifiedCalculatePositionsProfit(positions);
// //
// // Checking Force Sate Conditions ...
// if (ForceState())
// {
// //
// // Check Force State Hedging ...
// bool isHedged = DoEQMForceClose();
// if (isHedged)
// {
// //
// ForceState(false);
// return;
// }
// //
// // Handle Act Based On Drawdow ...
// if (mMaxDrawdownForce > 0)
// {
// //
// double drawdown = CalculateMaxDrawdown();
// if (drawdown > mMaxDrawdownForce)
// {
// //
// // Try to Hedge ...
// if (profits > 0)
// {
// //
// bool isHedged = DoEQMForceClose(profits);
// if (isHedged)
// {
// //
// ForceState(false);
// return;
// }
// }
// //
// // Close Max In Drawdown Position ...
// int maxInDIDX = FindMaxDrawdownIndex(positions);
// if (IsValidIndex(maxInDIDX))
// {
// //
// string comment = XEQMSupportToken + " Max In D ...";
// //
// bool isClosed = mTrader.Close(
// positions[maxInDIDX].ticket,
// comment //
// );
// if (isClosed)
// {
// //
// string message = XEQMSupportToken + " Close " + ToString(positions[maxInDIDX].ticket) + " Due Max In Drawdown ...";
// //
// Alert(message);
// }
// //
// return;
// }
// //
// return;
// }
// }
// //
// // Handle Act Based on Positions Count ...
// if (mMaxPositionsForce > 0 && positionsCount > mMaxPositionsForce)
// {
// //
// double requiredProfit = SpecifiedCalculateRequiredProfitForHedge(
// positions,
// MinRequiredProfitPerTrade(),
// MinRequiredProfitPerVolumeFactor() //
// );
// //
// double halfProfit = requiredProfit / 2;
// if (halfProfit > 0 && profits > halfProfit)
// {
// //
// bool isHedged = DoEQMForceClose(halfProfit);
// if (isHedged)
// {
// //
// ForceState(false);
// return;
// }
// }
// //
// // Close Min In Profit Position ...
// int minInPIDX = FindMinProfitIndex(positions);
// if (IsValidIndex(minInPIDX))
// {
// //
// string comment = XEQMSupportToken + " Min In P ...";
// //
// bool isClosed = mTrader.Close(
// positions[minInPIDX].ticket,
// comment //
// );
// if (isClosed)
// {
// //
// string message = XEQMSupportToken + " Close " + ToString(positions[minInPIDX].ticket) + " Due Min In Profit ...";
// //
// Alert(message);
// //
// return;
// }
// }
// //
// // Close Max In Drawdown Position ...
// int maxInDIDX = FindMaxDrawdownIndex(positions);
// if (IsValidIndex(maxInDIDX))
// {
// //
// string comment = XEQMSupportToken + " Max In D ...";
// //
// bool isClosed = mTrader.Close(
// positions[maxInDIDX].ticket,
// comment //
// );
// if (isClosed)
// {
// //
// string message = XEQMSupportToken + "Close " + ToString(positions[maxInDIDX].ticket) + " Due Max In Drawdown ...";
// //
// Alert(message);
// }
// //
// return;
// }
// //
// return;
// }
// //
// return;
// }
// //
// 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 //
// );
// //
// // Retrieve Youngest Age ...
// XPosition youngest;
// int youngestAge = GetYoungest(
// youngest,
// positions //
// );
// //
// // Now Comparing items for enabling force State ...
// bool isForceState =
// //
// youngestAge >= 20 &&
// //
// (longProfits + shortProfits < 0)
// //
// ;
// if (isForceState)
// {
// //
// ForceState(true);
// //
// return;
// }
// //
// XPosition supports[];
// int supportsCount = ExtractSupports(
// positions,
// supports //
// );
// if (!IsValidSize(supportsCount))
// {
// return;
// }
// //
// int maxSupports = mTradeHandler.EnableSupport()
// ? MaxNumberOfSupports()
// : 0;
// int maxGrids = mTradeHandler.EnableGrid()
// ? MaxNumberOfGrids()
// : 0;
// int maxRecoveries = mTradeHandler.EnableRecovery()
// ? MaxNumberOfRecoveries()
// : 0;
// //
// // Supporting Force States ...
// bool isProtectionForce =
// supportsCount >= 1;
// if (isProtectionForce)
// {
// //
// ForceState(true);
// //
// return;
// }
//////////////////////////////////////////////////////////////////////////////////////////
+50 -6
View File
@@ -21,6 +21,8 @@
//
// Imports ...
#include "../Helpers/x-saherelm.xct.helper.mq5"
#include "../Helpers/x-saherelm.xcc.helper.mq5"
#include "../Classes/x-saherelm.x121.setup.xea.mq5"
//
@@ -42,7 +44,7 @@ input group "Signals";
//,USDCHFb,EURCHFb,USDJPYb,EURJPYb,GBPUSDb
// EURUSDb,USDCHFb,EURCHFb,USDJPYb,EURJPYb,GBPUSDb
// EURUSDb,USDCHFb,EURCHFb,USDJPYb,EURJPYb,GBPUSDb,XAUUSDb,NZDUSDb,AUDUSDb,USDCADb,BTCUSD,ETHUSD
input string x121EASymbols = "EURUSDb"; // Symbols
input string x121EASymbols = "EURUSDb,USDCHFb,EURCHFb,USDJPYb,EURJPYb,GBPUSDb"; // Symbols
input bool x121EAUseAllSymbols = false; // Use All Available Symbols
input bool x121EAUseAllWatchListSymbols = false; // Use All WatchList Symbols
input bool x121EAAllowLong = true; // Allow Long Trades
@@ -54,10 +56,11 @@ input bool x121EAGetVerificationFromOtherTimeFrames = true; // Get Verifications
//
// Risk Management ...
input group "Risk Management";
input double x121EAVolume = 0.02; // Static Volume
input double x121EAVolume = 0.01; // Static Volume
input double x121EATPPoint = 1000; // TP Point
input double x121EASLPoint = 1000; // SL Point
input int x121EAMaxAllowedTrades = 2; // Max Allowed Positions
input int x121EAMaxAllowedTrades = 1; // Max Allowed Positions Per Symbol
input bool x121EAUseMaxAllowedPerDirection = true; // Use Max Allowed Positions Per Direction
input bool x121EAIgnoreSL = true; // Ignore Calculated SL
input bool x121EAIgnoreTP = false; // Ignore Calculated TP
@@ -72,6 +75,7 @@ input bool x121EACloseOnOpposit = false; // Close all Positions on Opposit
//
input group "Trailling";
input bool x121EAAllowTrailStop = true; // Enable Trailling Stop Losses
input bool x121EADisableTrailingWhenOpposit = true; // Disable Trailling When has Opposite In Drawdown
input double x121EAFirstTrailDistance = 100; // Start Trailling Distance
input double x121EAFirstTrailPoint = 60; // First Stop Trail
input double x121EANextTrailDistance = 50; // Next Trailling Distance
@@ -132,6 +136,10 @@ input bool x121EATerminalAlerts = false; // Terminal Alerts
string x121EAUsedSymbols[];
XSCX121SetupEA *x121EA;
//
XSCXCTHelper *x121EACTHelper;
XSCXCCHelper *x121EACCHelper;
//
// Event Handlers ...
@@ -172,6 +180,10 @@ void OnDeinit(const int reason)
//
// De Initialize XSampleEA Providers ...
delete x121EA;
//
delete x121EACTHelper;
delete x121EACCHelper;
}
//
@@ -194,6 +206,36 @@ bool InitialEA()
//
bool result = false;
//
// Bar Timer ...
XCTInputs ctInputs;
ctInputs.Default();
x121EACTHelper = new XSCXCTHelper();
result = x121EACTHelper.Init(
_Symbol,
_Period,
ctInputs //
);
if (!result)
{
return result;
}
//
// Bar Styles ...
XCCInputs ccInputs;
ccInputs.Default();
x121EACCHelper = new XSCXCCHelper();
result = x121EACCHelper.Init(
_Symbol,
_Period,
ccInputs //
);
if (!result)
{
return result;
}
//
// TesterHideIndicators(true);
@@ -283,6 +325,7 @@ bool InitialEA()
x121EA.IgnoreSL(x121EAIgnoreSL);
x121EA.IgnoreTP(x121EAIgnoreTP);
x121EA.MaxAllowedTrades(x121EAMaxAllowedTrades);
x121EA.UseMaxAllowedPerDirection(x121EAUseMaxAllowedPerDirection);
//
// Protection ...
@@ -301,6 +344,7 @@ bool InitialEA()
x121EA.FirstTrailPoint(x121EAFirstTrailPoint);
x121EA.NextTrailDistance(x121EANextTrailDistance);
x121EA.FirstTrailDistance(x121EAFirstTrailDistance);
x121EA.DisableTrailingWhenOpposit(x121EADisableTrailingWhenOpposit);
//
// Supporting ...
@@ -489,7 +533,7 @@ void X121ReportState()
//
// Detect What we Want to Show as Comment ...
bool isInForceState = x121EA.ForceState();
// bool isInForceState = x121EA.ForceState();
double bullishScore = 0; // x121EA.GetBullishScore();
double bearishScore = 0; // x121EA.GetBearishScore();
double drawDownPercent = x121EA.GetDrawdownPercent();
@@ -505,8 +549,8 @@ void X121ReportState()
"------------" + "\n"
: "") +
"Drawdown: " + ToString(drawDownPercent) + "%" + "\n" +
"------------" + "\n" +
"Force State: " + ToString(isInForceState) + "\n" +
// "------------" + "\n" +
// "Force State: " + ToString(isInForceState) + "\n" +
//
""
//