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
+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;
// }
//////////////////////////////////////////////////////////////////////////////////////////