fix x786 ...
This commit is contained in:
@@ -7602,46 +7602,26 @@ private:
|
||||
// Current Market ...
|
||||
double cLowerHigh = cMarket.don.GetLowerH(cIndex);
|
||||
bool cHasX786 = cMarket.HasX786LongConditions();
|
||||
if (cHasX786)
|
||||
{
|
||||
sl = cLowerHigh;
|
||||
}
|
||||
|
||||
//
|
||||
// Short Market ...
|
||||
double sLowerHigh = sMarket.don.GetLowerH(cIndex);
|
||||
bool sHasX786 = sMarket.HasX786LongConditions();
|
||||
if (sHasX786)
|
||||
{
|
||||
sl = sLowerHigh;
|
||||
}
|
||||
|
||||
//
|
||||
// Medium Market ...
|
||||
double mLowerHigh = mMarket.don.GetLowerH(cIndex);
|
||||
bool mHasX786 = mMarket.HasX786LongConditions();
|
||||
if (mHasX786)
|
||||
{
|
||||
sl = mLowerHigh;
|
||||
}
|
||||
|
||||
//
|
||||
// Long Market ...
|
||||
double lLowerHigh = lMarket.don.GetLowerH(cIndex);
|
||||
bool lHasX786 = lMarket.HasX786LongConditions();
|
||||
if (lHasX786)
|
||||
{
|
||||
sl = lLowerHigh;
|
||||
}
|
||||
|
||||
//
|
||||
// Hind Market ...
|
||||
double hLowerHigh = hMarket.don.GetLowerH(cIndex);
|
||||
bool hHasX786 = hMarket.HasX786LongConditions();
|
||||
if (hHasX786)
|
||||
{
|
||||
sl = hLowerHigh;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
@@ -7669,6 +7649,28 @@ private:
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
if (cHasX786)
|
||||
{
|
||||
sl = cLowerHigh;
|
||||
}
|
||||
else if (sHasX786)
|
||||
{
|
||||
sl = sLowerHigh;
|
||||
}
|
||||
else if (mHasX786)
|
||||
{
|
||||
sl = mLowerHigh;
|
||||
}
|
||||
else if (lHasX786)
|
||||
{
|
||||
sl = lLowerHigh;
|
||||
}
|
||||
else if (hHasX786)
|
||||
{
|
||||
sl = hLowerHigh;
|
||||
}
|
||||
|
||||
//
|
||||
r2r = 2;
|
||||
}
|
||||
@@ -8753,46 +8755,26 @@ private:
|
||||
// Current Market ...
|
||||
double cUpperLow = cMarket.don.GetUpperL(cIndex);
|
||||
bool cHasX786 = cMarket.HasX786ShortConditions();
|
||||
if (cHasX786)
|
||||
{
|
||||
sl = cUpperLow;
|
||||
}
|
||||
|
||||
//
|
||||
// Short Market ...
|
||||
double sUpperLow = sMarket.don.GetUpperL(cIndex);
|
||||
bool sHasX786 = sMarket.HasX786ShortConditions();
|
||||
if (sHasX786)
|
||||
{
|
||||
sl = sUpperLow;
|
||||
}
|
||||
|
||||
//
|
||||
// Medium Market ...
|
||||
double mUpperLow = mMarket.don.GetUpperL(cIndex);
|
||||
bool mHasX786 = mMarket.HasX786ShortConditions();
|
||||
if (mHasX786)
|
||||
{
|
||||
sl = mUpperLow;
|
||||
}
|
||||
|
||||
//
|
||||
// Long Market ...
|
||||
double lUpperLow = lMarket.don.GetUpperL(cIndex);
|
||||
bool lHasX786 = lMarket.HasX786ShortConditions();
|
||||
if (lHasX786)
|
||||
{
|
||||
sl = lUpperLow;
|
||||
}
|
||||
|
||||
//
|
||||
// Hind Market ...
|
||||
double hUpperLow = hMarket.don.GetUpperL(cIndex);
|
||||
bool hHasX786 = hMarket.HasX786ShortConditions();
|
||||
if (hHasX786)
|
||||
{
|
||||
sl = hUpperLow;
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
@@ -8820,6 +8802,28 @@ private:
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
if (cHasX786)
|
||||
{
|
||||
sl = cUpperLow;
|
||||
}
|
||||
else if (sHasX786)
|
||||
{
|
||||
sl = sUpperLow;
|
||||
}
|
||||
else if (mHasX786)
|
||||
{
|
||||
sl = mUpperLow;
|
||||
}
|
||||
else if (lHasX786)
|
||||
{
|
||||
sl = lUpperLow;
|
||||
}
|
||||
else if (hHasX786)
|
||||
{
|
||||
sl = hUpperLow;
|
||||
}
|
||||
|
||||
//
|
||||
r2r = 2;
|
||||
}
|
||||
|
||||
@@ -418,54 +418,106 @@ public:
|
||||
void HandleEQMState(XSignal &signals[])
|
||||
{
|
||||
//
|
||||
XSignal accepted[];
|
||||
bool equityReached = !mTrader.CheckEquityForTrade();
|
||||
bool maxAllowedReached = !mTrader.CheckPositionsForTrade();
|
||||
bool enableEQM = equityReached || maxAllowedReached;
|
||||
// if (!enableEQM)
|
||||
// {
|
||||
// //
|
||||
// return;
|
||||
// }
|
||||
if (!enableEQM)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
int signalsCount = ArraySize(signals);
|
||||
if (IsValidSize(signalsCount))
|
||||
{
|
||||
//
|
||||
Print("Cnverts " + ToString(signalsCount) + " Signal using SupRes ...");
|
||||
// Extract required Data ...
|
||||
XPosition positions[];
|
||||
int positionsCount = mTrader.GetPositions(
|
||||
positions);
|
||||
if (!IsValidSize(positionsCount))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
int longs = 0;
|
||||
double longProfits = 0;
|
||||
double longVolumes = 0;
|
||||
|
||||
//
|
||||
int shorts = 0;
|
||||
double shortProfits = 0;
|
||||
double shortVolumes = 0;
|
||||
|
||||
//
|
||||
CountPositions(
|
||||
positions,
|
||||
longs,
|
||||
longProfits,
|
||||
longVolumes,
|
||||
shorts,
|
||||
shortProfits,
|
||||
shortVolumes //
|
||||
);
|
||||
|
||||
//
|
||||
for (int i = 0; i < signalsCount; i++)
|
||||
{
|
||||
//
|
||||
XSignal iSignal = signals[i];
|
||||
bool isLong = IsLong(iSignal.type);
|
||||
|
||||
//
|
||||
bool canAccept =
|
||||
//
|
||||
isLong
|
||||
? longs == 0
|
||||
: shorts == 0
|
||||
//
|
||||
;
|
||||
if (!canAccept)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
iSignal.provider = XEQMSupportToken;
|
||||
|
||||
//
|
||||
AddRef(
|
||||
iSignal,
|
||||
accepted //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
int acceptedCount = ArraySize(accepted);
|
||||
if (!IsValidSize(acceptedCount))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Execute EQM Signals ...
|
||||
ENUM_X_SIGNAL_EXECUTION_RESULT reasons[];
|
||||
int executed = mTrader.ExecuteSignals(
|
||||
accepted,
|
||||
reasons,
|
||||
ORDER_TIME_GTC,
|
||||
NULL,
|
||||
false //
|
||||
);
|
||||
if (executed > 0)
|
||||
{
|
||||
//
|
||||
string message = "EQM Execute " + ToString(executed) + " Signals ...";
|
||||
|
||||
//
|
||||
mAlert.Alert(message);
|
||||
}
|
||||
}
|
||||
|
||||
// //
|
||||
// string mSymbols[];
|
||||
// XSCPositionHolder *mHolders[];
|
||||
// int symbolsCount = FilterSymbolBasedPositions(
|
||||
// mSymbols,
|
||||
// mHolders //
|
||||
// );
|
||||
|
||||
// //
|
||||
// for (int i = 0; i < symbolsCount; i++)
|
||||
// {
|
||||
// //
|
||||
// string iSymbol = mSymbols[i];
|
||||
// XSCPositionHolder *iHolder = mHolders[i];
|
||||
|
||||
// //
|
||||
// // We Can Select Multiple Positions for Place EQM Supports ...
|
||||
|
||||
// //
|
||||
// // Select Max In Drawdown Position and Protect it ...
|
||||
// XPosition iSelectedPosition;
|
||||
// bool iHasPosition = iHolder.GetMaxInDrawdown(iSelectedPosition);
|
||||
// if (iHasPosition)
|
||||
// {
|
||||
// //
|
||||
// // Try to Protect Max In Drawdown Positions Position ...
|
||||
// PlaceEQMOrders(iSelectedPosition);
|
||||
// }
|
||||
// }
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
@@ -730,7 +782,7 @@ public:
|
||||
}
|
||||
|
||||
//
|
||||
void HandleTrailManagement(XPosition &positions[])
|
||||
void HandleTrailManagement(XPosition &positions[])
|
||||
{
|
||||
//
|
||||
// TODO:
|
||||
@@ -761,7 +813,8 @@ public:
|
||||
//
|
||||
bool canManageState =
|
||||
//
|
||||
iPosition.provider != XEQMSupportToken
|
||||
true
|
||||
// iPosition.provider != XEQMSupportToken
|
||||
// &&
|
||||
// iPosition.provider != "WSC"
|
||||
//
|
||||
@@ -818,7 +871,7 @@ public:
|
||||
// IsLong(iPosition.type)
|
||||
// ? iPosition.sl + appliedSL
|
||||
// : iPosition.sl - appliedSL;
|
||||
|
||||
|
||||
//
|
||||
double sl =
|
||||
IsLong(iPosition.type)
|
||||
@@ -1130,6 +1183,9 @@ public:
|
||||
// Cleaning Source ...
|
||||
Clean(signals);
|
||||
|
||||
//
|
||||
XSignal mEQMManaged[];
|
||||
|
||||
//
|
||||
// Loop through Signals for Management ...
|
||||
for (int i = 0; i < tmpsCount; i++)
|
||||
@@ -1186,38 +1242,31 @@ public:
|
||||
//
|
||||
continue;
|
||||
}
|
||||
else if (positionsCount < 4)
|
||||
//
|
||||
else if (positionsCount < GetMaxAllowedPositions())
|
||||
{
|
||||
//
|
||||
// Next Signal in a While of Specific Provider ...
|
||||
|
||||
//
|
||||
// Find Longest Position and Check it's Age ...
|
||||
// Compare it by min age for same provider signals ...
|
||||
XPosition youngest;
|
||||
int youngestAge = GetYoungest(
|
||||
youngest,
|
||||
positions //
|
||||
);
|
||||
if (youngestAge == -1 || youngestAge < minDistanceBetweenTwoSameProviderSignal)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
AddRef(
|
||||
iSignal,
|
||||
signals //
|
||||
);
|
||||
|
||||
// //
|
||||
// if (youngest.profit > 0)
|
||||
// {
|
||||
// }
|
||||
|
||||
//
|
||||
continue;
|
||||
}
|
||||
//
|
||||
else
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iSignal,
|
||||
mEQMManaged //
|
||||
);
|
||||
}
|
||||
|
||||
// else if (profit > 0 && symbolProfit > 0)
|
||||
// {
|
||||
// //
|
||||
@@ -1228,6 +1277,12 @@ public:
|
||||
// }
|
||||
}
|
||||
|
||||
//
|
||||
if (IsValidSize(ArraySize(mEQMManaged)))
|
||||
{
|
||||
HandleEQMState(mEQMManaged);
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(signals);
|
||||
|
||||
@@ -1352,6 +1407,56 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
void ManageUnExecutedSignals(
|
||||
ENUM_X_SIGNAL_EXECUTION_RESULT &states[],
|
||||
XSignal &unExecutedSignals[] //
|
||||
) override
|
||||
{
|
||||
//
|
||||
XSignal filteredSignals[];
|
||||
|
||||
//
|
||||
int unExecutedSignalsCount = ArraySize(unExecutedSignals);
|
||||
if (!IsValidSize(unExecutedSignalsCount))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < unExecutedSignalsCount; i++)
|
||||
{
|
||||
//
|
||||
ENUM_X_SIGNAL_EXECUTION_RESULT iState = states[i];
|
||||
bool isStateValid =
|
||||
//
|
||||
iState == X_SIGNAL_EXECUTION_FAILED_NO_EQUITY ||
|
||||
iState == X_SIGNAL_EXECUTION_FAILED_MAX_REACHED
|
||||
//
|
||||
;
|
||||
if (!isStateValid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
AddRef(
|
||||
unExecutedSignals[i],
|
||||
filteredSignals //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
int filteredSignalsCount = ArraySize(filteredSignals);
|
||||
if (!IsValidSize(filteredSignalsCount))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
HandleEQMState(filteredSignals);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
|
||||
@@ -2746,6 +2746,15 @@ public:
|
||||
return 0;
|
||||
}
|
||||
|
||||
//
|
||||
// When Some Errors happens in Executing Signals ...
|
||||
virtual void ManageUnExecutedSignals(
|
||||
ENUM_X_SIGNAL_EXECUTION_RESULT &states[],
|
||||
XSignal &unExecutedSignals[] //
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Execute Provided Signals ...
|
||||
virtual void HandleSignalsExecution(XSignal &signals[])
|
||||
@@ -2800,9 +2809,11 @@ public:
|
||||
|
||||
//
|
||||
// Try to Execute Signals ...
|
||||
XSignal notExecuteds[];
|
||||
ENUM_X_SIGNAL_EXECUTION_RESULT reasons[];
|
||||
int executedSignalsCount = mTrader.ExecuteSignals(
|
||||
int executedSignalsCount = mTrader.ExecuteSpecifiedSignals(
|
||||
filteredSignals,
|
||||
notExecuteds, // Not Executed Signals
|
||||
reasons
|
||||
//
|
||||
);
|
||||
@@ -2837,6 +2848,16 @@ public:
|
||||
message = "(" + ToString(executedSignalsCount) + ") Signals Executed Successfully ...";
|
||||
}
|
||||
|
||||
//
|
||||
if (ArraySize(notExecuteds) > 0)
|
||||
{
|
||||
//
|
||||
ManageUnExecutedSignals(
|
||||
reasons,
|
||||
notExecuteds //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
if (IsValid(message))
|
||||
{
|
||||
|
||||
@@ -1390,6 +1390,63 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int ExecuteSpecifiedSignals(
|
||||
XSignal &signals[], // Collection of Signal for Execution
|
||||
XSignal ¬Executeds[], // Not Executed Signal
|
||||
ENUM_X_SIGNAL_EXECUTION_RESULT &states[], // Signal Execution Result
|
||||
ENUM_ORDER_TYPE_TIME lifetime = ORDER_TIME_GTC, // Order LifeTime
|
||||
datetime expiration = NULL, // order expiration time
|
||||
bool checkPolicies = true // Check Account Policies
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
Clean(states);
|
||||
Clean(notExecuteds);
|
||||
|
||||
//
|
||||
int signalsCount = ArraySize(signals);
|
||||
if (signalsCount <= 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
ArrayResize(states, signalsCount);
|
||||
ArrayInitialize(states, X_SIGNAL_EXECUTION_UNKNOWN);
|
||||
for (int i = 0; i < signalsCount; i++)
|
||||
{
|
||||
//
|
||||
bool isExecuted = ExecuteSignal(
|
||||
signals[i],
|
||||
states[i],
|
||||
lifetime,
|
||||
expiration
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
if (isExecuted)
|
||||
{
|
||||
result++;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
signals[i],
|
||||
notExecuteds //
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Regular Trade Actions ...
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
// Inputs ...
|
||||
long x121EAMagicNumber = 78692110; // Magic Number
|
||||
int x121EASlippage = 10; // Slippgae
|
||||
string x121EASymbols = "EURUSDb"; // Symbols
|
||||
string x121EASymbols = "XAUUSDb"; // Symbols
|
||||
//
|
||||
bool x121EAAllowLong = true; // Allow Long Trades
|
||||
bool x121EAAllowShort = true; // Allow Short Trades
|
||||
@@ -41,7 +41,7 @@ int x121EAManageInterval = 0; // Manager Check Intervals Second
|
||||
int x121EAMaxAllowedPositions = 5; // Max Allowed Positions
|
||||
double x121EAMaxAllowedSpread = 0; // Max Allowed Spred for Opening Trades
|
||||
double x121EAMinProfitPerTrade = 0; // Min Profit Per Trade based On Volume Factor (Hedge)
|
||||
double x121EAMinProfitPerVolumeFactor = 0.0; // Min Volume Factor for Calculating Profit (Hedge)
|
||||
double x121EAMinProfitPerVolumeFactor = 0.0; // Min Volume Factor for Calculating Profit (Hedge)
|
||||
double x121EAMaxAllowedDrawdownFactor = 0.002; // Max Allowed Drawdown Factor
|
||||
//
|
||||
double x121EAVolume = 0.01; // Static Volume
|
||||
@@ -317,8 +317,8 @@ void ConfigureDescriptor(
|
||||
//
|
||||
// XICH ...
|
||||
iDescriptor.inputs.ichInputs.showKumo = false;
|
||||
iDescriptor.inputs.ichInputs.showKijunSen = false;
|
||||
iDescriptor.inputs.ichInputs.showTenkanSen = false;
|
||||
iDescriptor.inputs.ichInputs.showKijunSen = true;
|
||||
iDescriptor.inputs.ichInputs.showTenkanSen = true;
|
||||
iDescriptor.inputs.ichInputs.showChikouSpan = false;
|
||||
iDescriptor.inputs.ichInputs.showSenkouSpanA = false;
|
||||
iDescriptor.inputs.ichInputs.showSenkouSpanB = false;
|
||||
@@ -337,11 +337,11 @@ void ConfigureDescriptor(
|
||||
iDescriptor.inputs.pvInputs.showPeaksAndVales = true;
|
||||
iDescriptor.inputs.pvInputs.showLevels = false;
|
||||
iDescriptor.inputs.pvInputs.showConsolidations = false;
|
||||
iDescriptor.inputs.pvInputs.showFibo1Levels = false;
|
||||
iDescriptor.inputs.pvInputs.showFibo2Levels = false;
|
||||
iDescriptor.inputs.pvInputs.showFibo3Levels = false;
|
||||
iDescriptor.inputs.pvInputs.showFibo4Levels = false;
|
||||
iDescriptor.inputs.pvInputs.showFibo5Levels = false;
|
||||
iDescriptor.inputs.pvInputs.showFibo1Levels = true;
|
||||
iDescriptor.inputs.pvInputs.showFibo2Levels = true;
|
||||
iDescriptor.inputs.pvInputs.showFibo3Levels = true;
|
||||
iDescriptor.inputs.pvInputs.showFibo4Levels = true;
|
||||
iDescriptor.inputs.pvInputs.showFibo5Levels = true;
|
||||
|
||||
//
|
||||
// XZG ...
|
||||
|
||||
@@ -4110,3 +4110,58 @@ int GenerateEQMOrders(
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Count Positions from a Collection ...
|
||||
void CountPositions(
|
||||
const XPosition &positions[],
|
||||
int &longs,
|
||||
double &longProfits,
|
||||
double &longVolumes, //
|
||||
//
|
||||
int &shorts,
|
||||
double &shortProfits,
|
||||
double &shortVolumes //
|
||||
)
|
||||
{
|
||||
//
|
||||
longs = 0;
|
||||
longProfits = 0;
|
||||
longVolumes = 0;
|
||||
|
||||
//
|
||||
shorts = 0;
|
||||
shortProfits = 0;
|
||||
shortVolumes = 0;
|
||||
|
||||
//
|
||||
int positionsCount = ArraySize(positions);
|
||||
if (!IsValidSize(positionsCount))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < positionsCount; i++)
|
||||
{
|
||||
//
|
||||
XPosition iPosition = positions[i];
|
||||
|
||||
//
|
||||
bool isLong = IsLong(iPosition.type);
|
||||
if (isLong)
|
||||
{
|
||||
//
|
||||
longs++;
|
||||
longProfits += iPosition.profit;
|
||||
longVolumes = iPosition.volume;
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
shorts++;
|
||||
shortProfits += iPosition.profit;
|
||||
shortVolumes = iPosition.volume;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user