last ...
This commit is contained in:
Vendored
+14
-3
@@ -11,13 +11,14 @@
|
|||||||
"mime": "text/markdown"
|
"mime": "text/markdown"
|
||||||
},
|
},
|
||||||
"details": {
|
"details": {
|
||||||
"content": "- [] Hedge;",
|
"content": "- [] Hedge;\n- [] Protector Start;\n",
|
||||||
"mime": "text/markdown"
|
"mime": "text/markdown"
|
||||||
},
|
},
|
||||||
"id": "89",
|
"id": "89",
|
||||||
"references": [
|
"references": [
|
||||||
"90",
|
"90",
|
||||||
"91"
|
"91",
|
||||||
|
"92"
|
||||||
],
|
],
|
||||||
"title": "Complete Position Protector"
|
"title": "Complete Position Protector"
|
||||||
},
|
},
|
||||||
@@ -34,6 +35,17 @@
|
|||||||
"references": [],
|
"references": [],
|
||||||
"title": "Implement BE Hedge Mechanism"
|
"title": "Implement BE Hedge Mechanism"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"assignedTo": {
|
||||||
|
"name": "Hadi Khazaee Asl"
|
||||||
|
},
|
||||||
|
"creation_time": "2024-09-16T13:08:56.494Z",
|
||||||
|
"id": "92",
|
||||||
|
"references": [],
|
||||||
|
"title": "Implement Protector Start Point"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"testing": [
|
||||||
{
|
{
|
||||||
"assignedTo": {
|
"assignedTo": {
|
||||||
"name": "Hadi Khazaee Asl"
|
"name": "Hadi Khazaee Asl"
|
||||||
@@ -48,7 +60,6 @@
|
|||||||
"title": "Implement HE Hedge mechanism"
|
"title": "Implement HE Hedge mechanism"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"testing": [],
|
|
||||||
"done": [
|
"done": [
|
||||||
{
|
{
|
||||||
"assignedTo": {
|
"assignedTo": {
|
||||||
|
|||||||
@@ -1043,6 +1043,28 @@ class X121SCTradeHandler : public XSCBaseAlert
|
|||||||
mMaxDrawdownPercentForOpenTrades = value;
|
mMaxDrawdownPercentForOpenTrades = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Protector Start ...
|
||||||
|
|
||||||
|
//
|
||||||
|
double ProtectorStartDistanceInPoint()
|
||||||
|
{
|
||||||
|
return mProtectorStartDistanceInPointl
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
void ProtectorStartDistanceInPoint(double value)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
if (value < 0)
|
||||||
|
{
|
||||||
|
value = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
mProtectorStartDistanceInPoint = value;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Hedge Props ...
|
// Hedge Props ...
|
||||||
|
|
||||||
@@ -1849,6 +1871,56 @@ class X121SCTradeHandler : public XSCBaseAlert
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Loop Through Main Positions ...
|
||||||
|
double requiredDistance = ProtectorStartDistanceInPoint();
|
||||||
|
if (requiredDistance <= 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
int protectedPositions = 0;
|
||||||
|
for (int i = 0; i < pPositionsCount; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Check Position is Protectable or not ...
|
||||||
|
XPosition iProtected = pPositions[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
XPosition iPosition = iProtected.main;
|
||||||
|
|
||||||
|
//
|
||||||
|
double iSymbolPoint = GetPoints(iPosition.symbol);
|
||||||
|
double iDistance = MathAbs(iPosition.profit) / iSymbolPoint;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isDistancePassed = iDistance >= requiredDistance;
|
||||||
|
bool isProtected = HandlePositionProtecting(iPosition);
|
||||||
|
if (isProtected)
|
||||||
|
{
|
||||||
|
protectedPositions++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (protectedPositions > 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Renew Data ...
|
||||||
|
Clean(pPositions);
|
||||||
|
int pPositionsCount = GetPositions(
|
||||||
|
pPositions //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Validate Count ...
|
||||||
|
if (!IsValidSize(pPositionsCount))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -2057,6 +2129,21 @@ class X121SCTradeHandler : public XSCBaseAlert
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle Protecting Position ...
|
||||||
|
*/
|
||||||
|
bool HandlePositionProtecting(XPosition &position)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Here we Make Sure this Position has ...
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Private ...
|
// Private ...
|
||||||
private:
|
private:
|
||||||
@@ -2083,6 +2170,9 @@ class X121SCTradeHandler : public XSCBaseAlert
|
|||||||
bool mUseMaxAllowedTradesPerSymbol; // Use Max Allowed Trades Per Symbol
|
bool mUseMaxAllowedTradesPerSymbol; // Use Max Allowed Trades Per Symbol
|
||||||
double mMaxDrawdownPercentForOpenTrades; // Max Drawdown Percent for Open Trades
|
double mMaxDrawdownPercentForOpenTrades; // Max Drawdown Percent for Open Trades
|
||||||
|
|
||||||
|
//
|
||||||
|
double mProtectorStartDistanceInPoint; // Protector Start Distance in Point
|
||||||
|
|
||||||
//
|
//
|
||||||
// Hedging Properties ...
|
// Hedging Properties ...
|
||||||
bool mAllowHedge; // Allow Protector to Hedge Positions
|
bool mAllowHedge; // Allow Protector to Hedge Positions
|
||||||
|
|||||||
@@ -440,15 +440,21 @@ bool InitialEA()
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Configure Position Protector ...
|
// Configure Position Protector ...
|
||||||
|
// TODO: Configure it using Inputs ...
|
||||||
|
|
||||||
|
//
|
||||||
|
eaTradeHandler.ProtectorStartDistanceInPoint(35);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Configure Hedging ...
|
// Configure Hedging ...
|
||||||
// TODO: Configure it using Inputs ...
|
|
||||||
eaTradeHandler.AllowHedge(true);
|
eaTradeHandler.AllowHedge(true);
|
||||||
eaTradeHandler.HedgeMinVolumeStep(0.01);
|
eaTradeHandler.HedgeMinVolumeStep(0.01);
|
||||||
eaTradeHandler.MinimumOpenPositionsForHEHedge(2);
|
eaTradeHandler.MinimumOpenPositionsForHEHedge(2);
|
||||||
eaTradeHandler.HedgeHEMinProfitPerVolumeStep(0.2);
|
eaTradeHandler.HedgeHEMinProfitPerVolumeStep(0.2);
|
||||||
|
|
||||||
|
//
|
||||||
|
// TODO: Implement ...
|
||||||
|
|
||||||
//
|
//
|
||||||
// Configure Strategies ...
|
// Configure Strategies ...
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user