last ...
This commit is contained in:
@@ -5040,115 +5040,143 @@ private:
|
|||||||
// Handle Force State Management ...
|
// Handle Force State Management ...
|
||||||
void EQMHandleForceState()
|
void EQMHandleForceState()
|
||||||
{
|
{
|
||||||
//
|
|
||||||
return;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
XPosition positions[];
|
XPosition positions[];
|
||||||
int positionsCount = mTrader.GetPositions(positions);
|
int positionsCount = mTrader.GetPositions(positions);
|
||||||
if (!IsValidSize(positionsCount))
|
if (!IsValidSize(positionsCount) || positionsCount <= 4)
|
||||||
{
|
|
||||||
//
|
|
||||||
EQMClearAllForceStates();
|
|
||||||
|
|
||||||
//
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Search For Force State Per Each Setup ...
|
|
||||||
//
|
|
||||||
int forceCount = 0;
|
|
||||||
int setupsCount = CountSetups();
|
|
||||||
if (IsValidSize(setupsCount))
|
|
||||||
{
|
|
||||||
//
|
|
||||||
int maxAllowed = MaxAllowedTrades();
|
|
||||||
bool perDirection = UseMaxAllowedPerDirection();
|
|
||||||
|
|
||||||
//
|
|
||||||
for (int i = 0; i < setupsCount; i++)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
string iSymbol = mSetups[i].GetSymbol();
|
|
||||||
ENUM_TIMEFRAMES iPeriod = mSetups[i].GetPeriod();
|
|
||||||
|
|
||||||
//
|
|
||||||
XPosition iPositions[];
|
|
||||||
int iPositionsCount = mTrader.GetPositions(
|
|
||||||
iPositions,
|
|
||||||
iSymbol,
|
|
||||||
NULL, // All Providers ...
|
|
||||||
NULL, // All Periods ...
|
|
||||||
NULL, // All Types ...
|
|
||||||
true // Filter By Magic ...
|
|
||||||
);
|
|
||||||
if (!IsValidSize(iPositionsCount))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
// Counting Positions ...
|
|
||||||
int longs;
|
|
||||||
double longProfits;
|
|
||||||
double longVolumes;
|
|
||||||
|
|
||||||
//
|
|
||||||
int shorts;
|
|
||||||
double shortProfits;
|
|
||||||
double shortVolumes;
|
|
||||||
|
|
||||||
//
|
|
||||||
CountPositions(
|
|
||||||
iPositions,
|
|
||||||
//
|
|
||||||
longs,
|
|
||||||
longProfits,
|
|
||||||
longVolumes,
|
|
||||||
//
|
|
||||||
shorts,
|
|
||||||
shortProfits,
|
|
||||||
shortVolumes //
|
|
||||||
);
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isMaxReached =
|
|
||||||
maxAllowed <= 0
|
|
||||||
? false
|
|
||||||
: !perDirection
|
|
||||||
? longs + shorts >= maxAllowed
|
|
||||||
: longs >= maxAllowed && shorts >= maxAllowed;
|
|
||||||
double volumeSummary = longVolumes + shortVolumes;
|
|
||||||
double profitsSummary = longProfits + shortProfits;
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isIInForce =
|
|
||||||
//
|
|
||||||
maxAllowed <= 0
|
|
||||||
? profitsSummary < 0 &&
|
|
||||||
longVolumes == shortVolumes
|
|
||||||
: isMaxReached &&
|
|
||||||
profitsSummary < 0 &&
|
|
||||||
longVolumes == shortVolumes
|
|
||||||
//
|
|
||||||
;
|
|
||||||
if (isIInForce)
|
|
||||||
{
|
|
||||||
//
|
|
||||||
forceCount++;
|
|
||||||
mSetups[i].ForceState(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
bool isForce = forceCount >= 1;
|
|
||||||
if (!isForce)
|
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
double minRequiredProfitPerTrade = MinRequiredProfitPerTrade();
|
||||||
|
double minRequiredProfitPerVolumeFactor = MinRequiredProfitPerVolumeFactor();
|
||||||
|
|
||||||
|
//
|
||||||
|
double profit = SpecifiedCalculatePositionsProfit(positions);
|
||||||
|
double requiredProfit = SpecifiedCalculateRequiredProfitForHedge(
|
||||||
|
positions,
|
||||||
|
minRequiredProfitPerTrade,
|
||||||
|
minRequiredProfitPerVolumeFactor //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
bool canClose =
|
||||||
|
profit > 0 &&
|
||||||
|
(profit == requiredProfit ||
|
||||||
|
profit >= requiredProfit / 2);
|
||||||
|
if (canClose) {
|
||||||
|
DoEQMForceClose();
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// XPosition positions[];
|
||||||
|
// int positionsCount = mTrader.GetPositions(positions);
|
||||||
|
// if (!IsValidSize(positionsCount))
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// EQMClearAllForceStates();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Search For Force State Per Each Setup ...
|
||||||
|
// //
|
||||||
|
// int forceCount = 0;
|
||||||
|
// int setupsCount = CountSetups();
|
||||||
|
// if (IsValidSize(setupsCount))
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// int maxAllowed = MaxAllowedTrades();
|
||||||
|
// bool perDirection = UseMaxAllowedPerDirection();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// for (int i = 0; i < setupsCount; i++)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// string iSymbol = mSetups[i].GetSymbol();
|
||||||
|
// ENUM_TIMEFRAMES iPeriod = mSetups[i].GetPeriod();
|
||||||
|
|
||||||
|
// //
|
||||||
|
// XPosition iPositions[];
|
||||||
|
// int iPositionsCount = mTrader.GetPositions(
|
||||||
|
// iPositions,
|
||||||
|
// iSymbol,
|
||||||
|
// NULL, // All Providers ...
|
||||||
|
// NULL, // All Periods ...
|
||||||
|
// NULL, // All Types ...
|
||||||
|
// true // Filter By Magic ...
|
||||||
|
// );
|
||||||
|
// if (!IsValidSize(iPositionsCount))
|
||||||
|
// {
|
||||||
|
// continue;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// // Counting Positions ...
|
||||||
|
// int longs;
|
||||||
|
// double longProfits;
|
||||||
|
// double longVolumes;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// int shorts;
|
||||||
|
// double shortProfits;
|
||||||
|
// double shortVolumes;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// CountPositions(
|
||||||
|
// iPositions,
|
||||||
|
// //
|
||||||
|
// longs,
|
||||||
|
// longProfits,
|
||||||
|
// longVolumes,
|
||||||
|
// //
|
||||||
|
// shorts,
|
||||||
|
// shortProfits,
|
||||||
|
// shortVolumes //
|
||||||
|
// );
|
||||||
|
|
||||||
|
// //
|
||||||
|
// bool isMaxReached =
|
||||||
|
// maxAllowed <= 0
|
||||||
|
// ? false
|
||||||
|
// : !perDirection
|
||||||
|
// ? longs + shorts >= maxAllowed
|
||||||
|
// : longs >= maxAllowed && shorts >= maxAllowed;
|
||||||
|
// double volumeSummary = longVolumes + shortVolumes;
|
||||||
|
// double profitsSummary = longProfits + shortProfits;
|
||||||
|
|
||||||
|
// //
|
||||||
|
// bool isIInForce =
|
||||||
|
// //
|
||||||
|
// maxAllowed <= 0
|
||||||
|
// ? profitsSummary < 0 &&
|
||||||
|
// longVolumes == shortVolumes
|
||||||
|
// : isMaxReached &&
|
||||||
|
// profitsSummary < 0 &&
|
||||||
|
// longVolumes == shortVolumes
|
||||||
|
// //
|
||||||
|
// ;
|
||||||
|
// if (isIInForce)
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// forceCount++;
|
||||||
|
// mSetups[i].ForceState(true);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// bool isForce = forceCount >= 1;
|
||||||
|
// if (!isForce)
|
||||||
|
// {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,15 +44,15 @@ input group "Signals";
|
|||||||
//,USDCHFb,EURCHFb,USDJPYb,EURJPYb,GBPUSDb
|
//,USDCHFb,EURCHFb,USDJPYb,EURJPYb,GBPUSDb
|
||||||
// EURUSDb,USDCHFb,EURCHFb,USDJPYb,EURJPYb,GBPUSDb
|
// EURUSDb,USDCHFb,EURCHFb,USDJPYb,EURJPYb,GBPUSDb
|
||||||
// EURUSDb,USDCHFb,EURCHFb,USDJPYb,EURJPYb,GBPUSDb,XAUUSDb,NZDUSDb,AUDUSDb,USDCADb,BTCUSD,ETHUSD
|
// EURUSDb,USDCHFb,EURCHFb,USDJPYb,EURJPYb,GBPUSDb,XAUUSDb,NZDUSDb,AUDUSDb,USDCADb,BTCUSD,ETHUSD
|
||||||
input string x121EASymbols = "EURUSDb,USDCHFb,USDJPYb,GBPUSDb"; // Symbols
|
input string x121EASymbols = "USDCHFb,EURCHFb,USDJPYb,EURJPYb,GBPUSDb"; // Symbols
|
||||||
input bool x121EAUseAllSymbols = false; // Use All Available Symbols
|
input bool x121EAUseAllSymbols = false; // Use All Available Symbols
|
||||||
input bool x121EAUseAllWatchListSymbols = false; // Use All WatchList Symbols
|
input bool x121EAUseAllWatchListSymbols = false; // Use All WatchList Symbols
|
||||||
input bool x121EAAllowLong = true; // Allow Long Trades
|
input bool x121EAAllowLong = true; // Allow Long Trades
|
||||||
input bool x121EAAllowShort = true; // Allow Short Trades
|
input bool x121EAAllowShort = true; // Allow Short Trades
|
||||||
input bool x121EAExecuteSignalsOnBreakout = false; // Execute Signals On Breakouts
|
input bool x121EAExecuteSignalsOnBreakout = false; // Execute Signals On Breakouts
|
||||||
input int x121EADelayBetweenTwoSignal = 5; // Delay Between two Same Signals
|
input int x121EADelayBetweenTwoSignal = 10; // Delay Between two Same Signals
|
||||||
input int x121EAReuiredSignalVerifications = 1; // Required Verifications for Signals
|
input int x121EAReuiredSignalVerifications = 3; // Required Verifications for Signals
|
||||||
input bool x121EAGetVerificationFromOtherTimeFrames = false; // Get Verifications from Other Time Frames
|
input bool x121EAGetVerificationFromOtherTimeFrames = true; // Get Verifications from Other Time Frames
|
||||||
|
|
||||||
//
|
//
|
||||||
// Risk Management ...
|
// Risk Management ...
|
||||||
@@ -60,11 +60,11 @@ input group "Risk Management";
|
|||||||
input double x121EAVolume = 0.01; // Static Volume
|
input double x121EAVolume = 0.01; // Static Volume
|
||||||
input double x121EATPPoint = 1000; // TP Point
|
input double x121EATPPoint = 1000; // TP Point
|
||||||
input double x121EASLPoint = 1000; // SL Point
|
input double x121EASLPoint = 1000; // SL Point
|
||||||
input int x121EAMaxAllowedTrades = 4; // Max Allowed Positions Per Symbol
|
input int x121EAMaxAllowedTrades = 2; // Max Allowed Positions Per Symbol
|
||||||
input int x121EAMinFreeMargingForOpenTrades = 500; // Min Margin For Opening Trades
|
input int x121EAMinFreeMargingForOpenTrades = 500; // Min Margin For Opening Trades
|
||||||
input bool x121EAUseMaxAllowedPerDirection = true; // Use Max Allowed Positions Per Direction
|
input bool x121EAUseMaxAllowedPerDirection = true; // Use Max Allowed Positions Per Direction
|
||||||
input bool x121EAIgnoreSL = true; // Ignore Calculated SL
|
input bool x121EAIgnoreSL = true; // Ignore Calculated SL
|
||||||
input bool x121EAIgnoreTP = false; // Ignore Calculated TP
|
input bool x121EAIgnoreTP = true; // Ignore Calculated TP
|
||||||
|
|
||||||
//
|
//
|
||||||
// Protection ...
|
// Protection ...
|
||||||
@@ -77,43 +77,43 @@ input bool x121EACloseOnOpposit = false; // Close all Positions on Opposit
|
|||||||
//
|
//
|
||||||
input group "Trailling";
|
input group "Trailling";
|
||||||
input bool x121EAAllowTrailStop = false; // Enable Trailling Stop Losses
|
input bool x121EAAllowTrailStop = false; // Enable Trailling Stop Losses
|
||||||
input bool x121EADisableTrailingWhenOpposit = true; // Disable Trailling When has Opposite In Drawdown
|
input bool x121EADisableTrailingWhenOpposit = false; // Disable Trailling When has Opposite In Drawdown
|
||||||
input double x121EAFirstTrailDistance = 100; // Start Trailling Distance
|
input double x121EAFirstTrailDistance = 100; // Start Trailling Distance
|
||||||
input double x121EAFirstTrailPoint = 60; // First Stop Trail
|
input double x121EAFirstTrailPoint = 60; // First Stop Trail
|
||||||
input double x121EANextTrailDistance = 50; // Next Trailling Distance
|
input double x121EANextTrailDistance = 50; // Next Trailling Distance
|
||||||
input double x121EANextTrailPoint = 25; // Next Trailling Step
|
input double x121EANextTrailPoint = 25; // Next Trailling Step
|
||||||
|
|
||||||
//
|
//
|
||||||
input group "Supporting";
|
input group "Supporting";
|
||||||
input bool x121EAAllowSupport = false; // Allow Support Signals
|
input bool x121EAAllowSupport = false; // Allow Support Signals
|
||||||
input bool x121EASupportOnlyForces = false; // Support Only Force Signals
|
input bool x121EASupportOnlyForces = false; // Support Only Force Signals
|
||||||
double x121EASupportDistance = 50; // Supporting Distance
|
double x121EASupportDistance = 0; // Supporting Distance
|
||||||
input int x121EAMaxNumberOfSupports = 1; // Max Number of Support Signals
|
input int x121EAMaxNumberOfSupports = 0; // Max Number of Support Signals
|
||||||
input double x121EASupportVolumeMultiplier = 2.0; // Support Signals Volume Multiplier
|
input double x121EASupportVolumeMultiplier = 2; // Support Signals Volume Multiplier
|
||||||
input double x121EAMaxAllowedSupportVolume = 0.04; // Max Allowed Support Signals Volume
|
input double x121EAMaxAllowedSupportVolume = 0; // Max Allowed Support Signals Volume
|
||||||
|
|
||||||
//
|
//
|
||||||
input group "Grid";
|
input group "Grid";
|
||||||
input bool x121EAAllowGrid = false; // Allow Grid Signals
|
input bool x121EAAllowGrid = false; // Allow Grid Signals
|
||||||
input bool x121EAGridOnlyForces = true; // Grid Only Force Signals
|
input bool x121EAGridOnlyForces = false; // Grid Only Force Signals
|
||||||
input int x121EAMaxNumberOfGrids = 5; // Max Number of Grid Signals
|
input int x121EAMaxNumberOfGrids = 0; // Max Number of Grid Signals
|
||||||
input double x121EAGridDistance = 100; // Grid Distance
|
input double x121EAGridDistance = 0; // Grid Distance
|
||||||
input double x121EAGridVolumeMultiplier = 2.0; // Grid Volume Multiplier
|
input double x121EAGridVolumeMultiplier = 0; // Grid Volume Multiplier
|
||||||
input double x121EAMaxAllowedGridVolume = 0.04; // Max Allowed Grid Signals Volume
|
input double x121EAMaxAllowedGridVolume = 0; // Max Allowed Grid Signals Volume
|
||||||
|
|
||||||
//
|
//
|
||||||
input group "Recovery";
|
input group "Recovery";
|
||||||
input bool x121EAAllowRecovery = false; // Allow Recovery Signals
|
input bool x121EAAllowRecovery = false; // Allow Recovery Signals
|
||||||
input bool x121EARecoverOnlyForces = true; // Recover Only Force Signals
|
input bool x121EARecoverOnlyForces = false; // Recover Only Force Signals
|
||||||
input int x121EAMaxNumberOfRecoveries = 2; // Max Number of Recovery Signals
|
input int x121EAMaxNumberOfRecoveries = 0; // Max Number of Recovery Signals
|
||||||
input double x121EARecoveryDistance = 100; // Recovery Distance
|
input double x121EARecoveryDistance = 0; // Recovery Distance
|
||||||
input double x121EARecoveryVolumeMultiplier = 2; // Recovery Volume Multiplier
|
input double x121EARecoveryVolumeMultiplier = 0; // Recovery Volume Multiplier
|
||||||
input double x121EAMaxAllowedRecoveryVolume = 0.08; // Max Allowed Recovery Signals Volume
|
input double x121EAMaxAllowedRecoveryVolume = 0; // Max Allowed Recovery Signals Volume
|
||||||
|
|
||||||
//
|
//
|
||||||
input group "Hedging";
|
input group "Hedging";
|
||||||
input int x121EARestingAfterHedge = 1000; // Resting Seconds After Hedge
|
input int x121EARestingAfterHedge = 1000; // Resting Seconds After Hedge
|
||||||
input double x121EAMinRequiredProfitPerTrade = 0.5; // Minimum Required Profit for Hedging
|
input double x121EAMinRequiredProfitPerTrade = 0.3; // Minimum Required Profit for Hedging
|
||||||
input double x121EAMinRequiredProfitPerVolumeFactor = 0.01; // Minimum Required Profit for Hedging Per Volume
|
input double x121EAMinRequiredProfitPerVolumeFactor = 0.01; // Minimum Required Profit for Hedging Per Volume
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user