Apply Last Fixes on TWPV Strategy Method 1 ...
This commit is contained in:
@@ -265,6 +265,14 @@ class XCZone : public XCBasePOI
|
|||||||
return mUpper;
|
return mUpper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Zone Upper Boundary ...
|
||||||
|
*/
|
||||||
|
void Upper(double value)
|
||||||
|
{
|
||||||
|
mUpper = value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get Zone Lower Boundary ...
|
* Get Zone Lower Boundary ...
|
||||||
*
|
*
|
||||||
@@ -275,6 +283,14 @@ class XCZone : public XCBasePOI
|
|||||||
return mLower;
|
return mLower;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set Zone Lower Boundary ...
|
||||||
|
*/
|
||||||
|
void Lower(double value)
|
||||||
|
{
|
||||||
|
mLower = value;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retrieve Zone Range ...
|
* Retrieve Zone Range ...
|
||||||
*
|
*
|
||||||
@@ -4763,6 +4779,42 @@ struct XConsolidationZone
|
|||||||
//
|
//
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts a Consolidation Zone ...
|
||||||
|
*
|
||||||
|
* @param zone: XConsolidationZone instance Reference ...
|
||||||
|
* @param dest: XCZone pointer Reference ...
|
||||||
|
*
|
||||||
|
* @return ( bool )
|
||||||
|
*/
|
||||||
|
bool ToZone(
|
||||||
|
XConsolidationZone &zone,
|
||||||
|
XCZone *&dest //
|
||||||
|
)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
bool result = false;
|
||||||
|
|
||||||
|
//
|
||||||
|
dest = NULL;
|
||||||
|
|
||||||
|
//
|
||||||
|
result = zone.IsValid();
|
||||||
|
if (!result)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
dest = new XCZone();
|
||||||
|
dest.Upper(zone.upper);
|
||||||
|
dest.Lower(zone.lower);
|
||||||
|
result = dest.IsValidBoundary();
|
||||||
|
|
||||||
|
//
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Model Value Changed ...
|
// Model Value Changed ...
|
||||||
struct XValueChange
|
struct XValueChange
|
||||||
|
|||||||
@@ -129,15 +129,16 @@ enum ENUM_X_POSITION_SELECT_METHODS
|
|||||||
enum ENUM_X_SIGNAL_EXECUTION_RESULT
|
enum ENUM_X_SIGNAL_EXECUTION_RESULT
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
X_SIGNAL_EXECUTION_UNKNOWN, // Unknown
|
X_SIGNAL_EXECUTION_UNKNOWN, // Unknown
|
||||||
X_SIGNAL_EXECUTION_SUCCEED, // Succed
|
X_SIGNAL_EXECUTION_SUCCEED, // Succed
|
||||||
X_SIGNAL_EXECUTION_FAILED_SPREAD, // Spread more than Max Allowed
|
X_SIGNAL_EXECUTION_FAILED_SPREAD, // Spread more than Max Allowed
|
||||||
X_SIGNAL_EXECUTION_FAILED_NOT_ALLOWED, // Not Allowed Trade Type
|
X_SIGNAL_EXECUTION_FAILED_NOT_ALLOWED, // Not Allowed Trade Type
|
||||||
X_SIGNAL_EXECUTION_FAILED_NO_EQUITY, // No Equity for Trade
|
X_SIGNAL_EXECUTION_FAILED_NO_EQUITY, // No Equity for Trade
|
||||||
X_SIGNAL_EXECUTION_FAILED_PRICE_ERROR, // Price Error
|
X_SIGNAL_EXECUTION_FAILED_PRICE_ERROR, // Price Error
|
||||||
X_SIGNAL_EXECUTION_FAILED_MAX_REACHED, // Max Allowed Positions Reached
|
X_SIGNAL_EXECUTION_FAILED_PREV_PROFIT_ERROR, // Prev Profit Error
|
||||||
X_SIGNAL_EXECUTION_FAILED_DELAY_NOT_PASSED, // Same Positions Delay Not Passed
|
X_SIGNAL_EXECUTION_FAILED_MAX_REACHED, // Max Allowed Positions Reached
|
||||||
X_SIGNAL_EXECUTION_FAILED_INVALID_PARAMS, // Invalid Params
|
X_SIGNAL_EXECUTION_FAILED_DELAY_NOT_PASSED, // Same Positions Delay Not Passed
|
||||||
|
X_SIGNAL_EXECUTION_FAILED_INVALID_PARAMS, // Invalid Params
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -5328,6 +5329,11 @@ string ToString(ENUM_X_SIGNAL_EXECUTION_RESULT value)
|
|||||||
result = "Price Error";
|
result = "Price Error";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
//
|
||||||
|
case X_SIGNAL_EXECUTION_FAILED_PREV_PROFIT_ERROR:
|
||||||
|
result = "Previous Position Profit not Passed for Accept Next";
|
||||||
|
break;
|
||||||
|
|
||||||
//
|
//
|
||||||
case X_SIGNAL_EXECUTION_FAILED_MAX_REACHED:
|
case X_SIGNAL_EXECUTION_FAILED_MAX_REACHED:
|
||||||
result = "Max Allowed Positions Reached";
|
result = "Max Allowed Positions Reached";
|
||||||
|
|||||||
@@ -2637,11 +2637,11 @@ class XC121SMCCycleHelper : public XCBase
|
|||||||
|
|
||||||
//
|
//
|
||||||
if (hasConsolidation &&
|
if (hasConsolidation &&
|
||||||
!mActioveConsolidationZone.IsValid())
|
!mActiveConsolidationZone.IsValid())
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Initialize Consolidation Zone ...
|
// Initialize Consolidation Zone ...
|
||||||
bool isInited = mActioveConsolidationZone.Init(
|
bool isInited = mActiveConsolidationZone.Init(
|
||||||
changeBar.symbol,
|
changeBar.symbol,
|
||||||
changeBar.period,
|
changeBar.period,
|
||||||
upper,
|
upper,
|
||||||
@@ -2652,23 +2652,23 @@ class XC121SMCCycleHelper : public XCBase
|
|||||||
|
|
||||||
//
|
//
|
||||||
if (!hasConsolidation &&
|
if (!hasConsolidation &&
|
||||||
mActioveConsolidationZone.IsValid())
|
mActiveConsolidationZone.IsValid())
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
mActioveConsolidationZone.Update();
|
mActiveConsolidationZone.Update();
|
||||||
bool isBreaked = mActioveConsolidationZone.IsBreaked();
|
bool isBreaked = mActiveConsolidationZone.IsBreaked();
|
||||||
|
|
||||||
//
|
//
|
||||||
if (isBreaked)
|
if (isBreaked)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Add Active to List ...
|
// Add Active to List ...
|
||||||
bool isInited = AddConsolidationZone(mActioveConsolidationZone);
|
bool isInited = AddConsolidationZone(mActiveConsolidationZone);
|
||||||
if (isInited)
|
if (isInited)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Clean Active Zone ...
|
// Clean Active Zone ...
|
||||||
mActioveConsolidationZone.Clean();
|
mActiveConsolidationZone.Clean();
|
||||||
|
|
||||||
//
|
//
|
||||||
Add(
|
Add(
|
||||||
@@ -2678,6 +2678,23 @@ class XC121SMCCycleHelper : public XCBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Draw ...
|
||||||
|
// if (mActiveConsolidationZone.IsValid())
|
||||||
|
// {
|
||||||
|
// //
|
||||||
|
// if (mActiveConsolidationZoneObj != NULL)
|
||||||
|
// {
|
||||||
|
// mActiveConsolidationZoneObj.Delete();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// bool isCreated = mPOIDetector.mDrawer.CreateConsolidationZone(
|
||||||
|
// mActiveConsolidationZone,
|
||||||
|
// mActiveConsolidationZoneObj //
|
||||||
|
// );
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@@ -3128,7 +3145,8 @@ class XC121SMCCycleHelper : public XCBase
|
|||||||
//
|
//
|
||||||
int mConsolidationLoopback; // Consolidation Loopback Length ...
|
int mConsolidationLoopback; // Consolidation Loopback Length ...
|
||||||
XConsolidationZone mConsolidationZones[]; // Holds Consolidation Zones ...
|
XConsolidationZone mConsolidationZones[]; // Holds Consolidation Zones ...
|
||||||
XConsolidationZone mActioveConsolidationZone; // Holds Actiove Consolidation Zone ...
|
XConsolidationZone mActiveConsolidationZone; // Holds Actiove Consolidation Zone ...
|
||||||
|
// XCConsolidationZoneObject *mActiveConsolidationZoneObj;
|
||||||
|
|
||||||
//
|
//
|
||||||
int mValidPivotRepetition; // Valid Pivot Point's Repetition ...
|
int mValidPivotRepetition; // Valid Pivot Point's Repetition ...
|
||||||
|
|||||||
@@ -2914,7 +2914,7 @@ class XC121SMCTradeHandler : public XCBaseAlert
|
|||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
state = X_SIGNAL_EXECUTION_FAILED_PRICE_ERROR;
|
state = X_SIGNAL_EXECUTION_FAILED_PREV_PROFIT_ERROR;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -646,12 +646,6 @@ bool DetectX121SMCXTWPVSiganlSetup(
|
|||||||
//
|
//
|
||||||
// Setup Conditions ...
|
// Setup Conditions ...
|
||||||
|
|
||||||
// //
|
|
||||||
// // Select Sources ...
|
|
||||||
// XC121SMCCycleHelper *helper = analyseCycleHelper;
|
|
||||||
// X121SMCCycleConditions helperConditions = analyseConditions;
|
|
||||||
// XPOIState helperState = analyseState;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
XOHCL analyseCBar;
|
XOHCL analyseCBar;
|
||||||
result = analyseCycleHelper.GetBar(
|
result = analyseCycleHelper.GetBar(
|
||||||
@@ -895,6 +889,62 @@ bool DetectX121SMCXTWPVSiganlSetup(
|
|||||||
priceInsideZonesCount = conditions.CountPriceInsideZones();
|
priceInsideZonesCount = conditions.CountPriceInsideZones();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Check Price Inside Consolidation Zone ...
|
||||||
|
XConsolidationZone cZone;
|
||||||
|
bool hasConsolidationZone = conditions
|
||||||
|
.HasConsolidationZone();
|
||||||
|
if (!hasConsolidationZone)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
hasConsolidationZone = triggerCycleHelper
|
||||||
|
.GetLastConsolidationZone(cZone);
|
||||||
|
//
|
||||||
|
if (!hasConsolidationZone)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XConsolidationZone cZones[];
|
||||||
|
int count = triggerCycleHelper
|
||||||
|
.FillConsolidationZones(cZones);
|
||||||
|
if (IsValidSize(count))
|
||||||
|
{
|
||||||
|
//
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
XConsolidationZone iZone = cZones[i];
|
||||||
|
|
||||||
|
//
|
||||||
|
XCZone *iCZone;
|
||||||
|
bool isInited = ToZone(iZone, iCZone);
|
||||||
|
if (!isInited)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
bool isValid = IsPriceInsideZone(
|
||||||
|
cBar,
|
||||||
|
iCZone //
|
||||||
|
);
|
||||||
|
if (isValid)
|
||||||
|
{
|
||||||
|
cZone = iZone;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
conditions.consolidationZone = cZone;
|
||||||
|
hasConsolidationZone = conditions
|
||||||
|
.HasConsolidationZone();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (hasConsolidationZone)
|
||||||
|
{
|
||||||
|
conditions.consolidationZone = cZone;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// PV Conditions ...
|
// PV Conditions ...
|
||||||
|
|
||||||
@@ -1221,18 +1271,6 @@ bool DetectX121SMCXTWPVSiganlSetup(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
if (isBullish)
|
|
||||||
{
|
|
||||||
Print("Bullish ...");
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
if (isBearish)
|
|
||||||
{
|
|
||||||
Print("Bearish ...");
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
conditions.setupTime = cTime;
|
conditions.setupTime = cTime;
|
||||||
conditions.dir =
|
conditions.dir =
|
||||||
@@ -1461,16 +1499,6 @@ bool DetectX121SMCXTWPVSiganlTrigger(
|
|||||||
//
|
//
|
||||||
// Trigger Conditions ...
|
// Trigger Conditions ...
|
||||||
|
|
||||||
// //
|
|
||||||
// isBullish =
|
|
||||||
// isBullish &&
|
|
||||||
// false;
|
|
||||||
|
|
||||||
// //
|
|
||||||
// isBearish =
|
|
||||||
// isBearish &&
|
|
||||||
// false;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
result = isBullish ||
|
result = isBullish ||
|
||||||
isBearish;
|
isBearish;
|
||||||
@@ -1490,34 +1518,34 @@ bool DetectX121SMCXTWPVSiganlTrigger(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
// //
|
||||||
// Detect Consolidation ...
|
// // Detect Consolidation ...
|
||||||
bool hasConsolidationZone = conditions.HasConsolidationZone();
|
// bool hasConsolidationZone = conditions.HasConsolidationZone();
|
||||||
if (hasConsolidationZone)
|
// if (hasConsolidationZone)
|
||||||
{
|
// {
|
||||||
//
|
// //
|
||||||
hasConsolidationZone = triggerCycleHelper
|
// hasConsolidationZone = triggerCycleHelper
|
||||||
.GetLastConsolidationZone(conditions.consolidationZone);
|
// .GetLastConsolidationZone(conditions.consolidationZone);
|
||||||
|
|
||||||
//
|
// //
|
||||||
if (hasConsolidationZone)
|
// if (hasConsolidationZone)
|
||||||
{
|
// {
|
||||||
//
|
// //
|
||||||
hasConsolidationZone =
|
// hasConsolidationZone =
|
||||||
isBullish
|
// isBullish
|
||||||
? conditions.consolidationZone.upper <= conditions.point
|
// ? conditions.consolidationZone.upper <= conditions.point
|
||||||
: conditions.consolidationZone.lower >= conditions.point;
|
// : conditions.consolidationZone.lower >= conditions.point;
|
||||||
|
|
||||||
//
|
// //
|
||||||
if (!hasConsolidationZone)
|
// if (!hasConsolidationZone)
|
||||||
{
|
// {
|
||||||
//
|
// //
|
||||||
conditions
|
// conditions
|
||||||
.consolidationZone
|
// .consolidationZone
|
||||||
.Clean();
|
// .Clean();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
|
|
||||||
//
|
//
|
||||||
// Detect Nearest Pivot Point ...
|
// Detect Nearest Pivot Point ...
|
||||||
@@ -1589,7 +1617,13 @@ bool DetectX121SMCXTWPVSiganlTrigger(
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Filling SL Candidates ...
|
// Filling SL Candidates ...
|
||||||
|
double atr = triggerConditions.x121Conditions.atrBuffer[1];
|
||||||
|
|
||||||
|
//
|
||||||
double sls[];
|
double sls[];
|
||||||
|
|
||||||
|
//
|
||||||
|
bool hasConsolidationZone = conditions.HasConsolidationZone();
|
||||||
if (hasConsolidationZone)
|
if (hasConsolidationZone)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
@@ -1773,30 +1807,28 @@ bool DetectX121SMCXTWPVSiganlTrigger(
|
|||||||
|
|
||||||
//
|
//
|
||||||
double sl = isBullish
|
double sl = isBullish
|
||||||
? slsMin
|
? slsMin - atr
|
||||||
: slsMax;
|
: slsMax + atr;
|
||||||
double risk = MathAbs(entry - sl);
|
double risk = MathAbs(entry - sl);
|
||||||
double targetDelta = 2 * (risk / 3);
|
double targetDelta = 2 * (risk / 3);
|
||||||
if (target == 0)
|
if (target == 0)
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
int minTargetPint = 50;
|
||||||
|
double minTargetPointValue = minTargetPint * points;
|
||||||
|
if (targetDelta < minTargetPointValue)
|
||||||
|
{
|
||||||
|
targetDelta = minTargetPointValue;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Force Target On Half Risk ...
|
// Force Target On Half Risk ...
|
||||||
target =
|
target =
|
||||||
isBullish
|
isBullish
|
||||||
? entry + targetDelta
|
? entry + targetDelta
|
||||||
: entry - targetDelta;
|
: entry - targetDelta;
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
if (isBullish)
|
|
||||||
{
|
|
||||||
Print("Bullish ...");
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
if (isBearish)
|
|
||||||
{
|
|
||||||
Print("Bearish ...");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user