apply trail stop and break even ...
This commit is contained in:
@@ -102,27 +102,23 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
void Destroy() override
|
||||
{
|
||||
//
|
||||
// XSupDemOBS ...
|
||||
RemoveX121SMCXSupDemOBSDraws();
|
||||
mX121SMCXSupDemOBSConditions.Clean();
|
||||
Clean(mX121SMCXSupDemOBSConditionsCollection);
|
||||
RemoveX121SMCXSupDemOBSWorkingZoneDraws();
|
||||
|
||||
//
|
||||
// ZeroMemory(mTriggerCycleHelper);
|
||||
ZeroMemory(mDecisionCycleHelper);
|
||||
ZeroMemory(mAnalyseCycleHelper);
|
||||
// ZeroMemory(mVerificationCycleHelper);
|
||||
ZeroMemory(mConsolidationCycleHelper);
|
||||
ZeroMemory(mVisionCycleHelper);
|
||||
|
||||
//
|
||||
// delete mTriggerCycleHelper;
|
||||
delete mDecisionCycleHelper;
|
||||
delete mAnalyseCycleHelper;
|
||||
// delete mVerificationCycleHelper;
|
||||
delete mConsolidationCycleHelper;
|
||||
delete mVisionCycleHelper;
|
||||
|
||||
//
|
||||
RemoveX121SMCXSupDemOBSDraws();
|
||||
RemoveX121SMCXSupDemOBSWorkingZoneDraws();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -205,10 +201,14 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
|
||||
//
|
||||
// XSupDemOBS Signal ...
|
||||
X121SMCStrategyXSupDemOBSSignalConditions mXSupDemOBSConditions;
|
||||
if (useXSupDemOBSSignal && !hasSignal)
|
||||
{
|
||||
//
|
||||
hasXSupDemOBSSignal = DetectXSupDemOBSSignal(conditions);
|
||||
hasXSupDemOBSSignal = DetectXSupDemOBSSignal(
|
||||
conditions,
|
||||
mXSupDemOBSConditions //
|
||||
);
|
||||
hasSignal = hasXSupDemOBSSignal;
|
||||
}
|
||||
|
||||
@@ -317,46 +317,107 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
//
|
||||
if (result)
|
||||
{
|
||||
//
|
||||
// Configure Signal Protector ...
|
||||
// if (useXSTRPVSignal)
|
||||
// {
|
||||
// //
|
||||
// signal.trailSL = false;
|
||||
// signal.fullTPLevel = r2r;
|
||||
// signal.partialCloseOnTPLevel = 2;
|
||||
// signal.partialCloseMultiplier = 0.5;
|
||||
// signal.trailSLStartOnReachTPLevel = 2;
|
||||
// }
|
||||
|
||||
//
|
||||
// TODO: Remove this ...
|
||||
// XCSignalObject *iObj;
|
||||
// mPOIDrawer.DrawSignal(signal, iObj);
|
||||
// Print("");
|
||||
|
||||
//
|
||||
if (useXSupDemOBSSignal &&
|
||||
hasXSupDemOBSSignal)
|
||||
{
|
||||
//
|
||||
// double sR2R = signal.GetRiskRewardRatio();
|
||||
// double risk = signal.GetRisk();
|
||||
|
||||
//
|
||||
// double tp = signal.tp;
|
||||
// double target = signal.tp + (risk * sR2R);
|
||||
// Re Draw Working Zone ...
|
||||
RemoveX121SMCXSupDemOBSWorkingZoneDraws();
|
||||
DrawX121SMCXSupDemOBSWorkingZone(
|
||||
mXSupDemOBSConditions,
|
||||
mVisionCycleHelper.mPOIDrawer //
|
||||
);
|
||||
|
||||
//
|
||||
// signal.tp = target;
|
||||
// signal.target = tp;
|
||||
// Re Draw Working Zone ...
|
||||
RemoveX121SMCXSupDemOBSDraws();
|
||||
DrawX121SMCXSupDemOBSConditions(
|
||||
mXSupDemOBSConditions,
|
||||
mVisionCycleHelper.mPOIDrawer //
|
||||
);
|
||||
|
||||
//
|
||||
// Configuring Amount Percent and ETC ...
|
||||
bool ignoreEAVolume = mXSupDemOBSConditions.reward > 0 &&
|
||||
mXSupDemOBSConditions.amountPercent > 0;
|
||||
if (ignoreEAVolume)
|
||||
{
|
||||
//
|
||||
double cReward = mXSupDemOBSConditions.reward;
|
||||
double cAmountPercent = mXSupDemOBSConditions.amountPercent;
|
||||
|
||||
//
|
||||
double cRiskReward = risk * cReward;
|
||||
double cTP = hasLong
|
||||
? entry + cRiskReward
|
||||
: entry - cRiskReward;
|
||||
|
||||
//
|
||||
double balance = mAccount.GetBalance();
|
||||
double cRiskAmount = balance * cAmountPercent / 100;
|
||||
double cRiskInPoints = risk / points;
|
||||
double cVolume = mAccount.CalculateVolume(
|
||||
signal.symbol,
|
||||
cRiskAmount,
|
||||
cRiskInPoints //
|
||||
);
|
||||
cVolume = NormalizeVolume(cVolume, signal.symbol);
|
||||
|
||||
//
|
||||
if (cVolume > 0)
|
||||
{
|
||||
//
|
||||
signal.ignoreEAVolume = ignoreEAVolume;
|
||||
signal.volume = cVolume;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Fix Signal TP Based On Working Zone ...
|
||||
double maxAllowedTP =
|
||||
hasLong
|
||||
? mXSupDemOBSConditions.workingZone.upper
|
||||
: mXSupDemOBSConditions.workingZone.lower;
|
||||
bool canApplyMaxAlowedTP = (hasLong &&
|
||||
signal.tp > maxAllowedTP) ||
|
||||
(!hasLong && signal.tp < maxAllowedTP);
|
||||
if (canApplyMaxAlowedTP)
|
||||
{
|
||||
signal.tp = maxAllowedTP;
|
||||
}
|
||||
|
||||
//
|
||||
// Configuring Global Protector ...
|
||||
signal.trailSL = true;
|
||||
signal.fullTPLevel = r2r;
|
||||
signal.partialCloseOnTPLevel = 0;
|
||||
signal.partialCloseMultiplier = 0;
|
||||
signal.trailSLStartOnReachTPLevel = 3;
|
||||
signal.fullTPLevel = signal.GetRiskRewardRatio();
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Signal Oject ...
|
||||
XCSignalObject *iSignalObj;
|
||||
bool isCreated = mVisionCycleHelper
|
||||
.mPOIDrawer
|
||||
.DrawSignal(signal, iSignalObj);
|
||||
if (isCreated)
|
||||
{
|
||||
//
|
||||
mSignalDrawnObjects.Add(iSignalObj);
|
||||
|
||||
//
|
||||
int maxAllowedDrawnSignals = 15;
|
||||
int count = mSignalDrawnObjects.Total();
|
||||
if (count > maxAllowedDrawnSignals)
|
||||
{
|
||||
//
|
||||
int to = count - maxAllowedDrawnSignals;
|
||||
mSignalDrawnObjects.DeleteRange(
|
||||
0,
|
||||
to //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -365,6 +426,9 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
hasShort = false;
|
||||
}
|
||||
|
||||
//
|
||||
mXSupDemOBSConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
@@ -431,6 +495,7 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
|
||||
//
|
||||
// Props ...
|
||||
CArrayObj mSignalDrawnObjects;
|
||||
|
||||
//
|
||||
// XC121SMCCycleHelper *mTriggerCycleHelper;
|
||||
@@ -449,7 +514,8 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
//
|
||||
// XSupDemOBS Signal ...
|
||||
bool DetectXSupDemOBSSignal(
|
||||
X121SMCStrategyConditions &conditions //
|
||||
X121SMCStrategyConditions &conditions,
|
||||
X121SMCStrategyXSupDemOBSSignalConditions &xSupDemOBSConditions //
|
||||
)
|
||||
{
|
||||
//
|
||||
@@ -599,10 +665,8 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
mTmpConditions[i],
|
||||
symbol,
|
||||
period,
|
||||
// mTriggerCycleHelper,
|
||||
mDecisionCycleHelper,
|
||||
mAnalyseCycleHelper,
|
||||
// mVerificationCycleHelper,
|
||||
mConsolidationCycleHelper,
|
||||
mVisionCycleHelper //
|
||||
);
|
||||
@@ -673,6 +737,12 @@ class XCX121SMCStrategy : public XCX121SMCBaseStrategy
|
||||
conditions.signalDir = mConditions.dir;
|
||||
conditions.target = mConditions.target;
|
||||
|
||||
//
|
||||
xSupDemOBSConditions = mConditions;
|
||||
|
||||
//
|
||||
mConditions.Clean();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user