last works ...
This commit is contained in:
@@ -394,14 +394,13 @@ void OnTick()
|
|||||||
eaSignal.time = eaConditions.time;
|
eaSignal.time = eaConditions.time;
|
||||||
eaSignal.symbol = eaConditions.symbol;
|
eaSignal.symbol = eaConditions.symbol;
|
||||||
eaSignal.period = eaConditions.period;
|
eaSignal.period = eaConditions.period;
|
||||||
// eaSignal.partialCloseOnTPLevel = eaConditions.partialCloseOnTPLevel;
|
|
||||||
// eaSignal.partialCloseMultiplier = eaConditions.partialCloseMultiplier;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Copy(
|
// Handling Targets ...
|
||||||
// eaConditions.targets,
|
Copy(
|
||||||
// eaSignal.targets //
|
eaConditions.targets,
|
||||||
// );
|
eaSignal.targets //
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Validate Signal ...
|
// Validate Signal ...
|
||||||
|
|||||||
@@ -492,8 +492,9 @@ struct XTarget
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
// Props ...
|
// Props ...
|
||||||
double target;
|
bool doRF; // Do RF on Target
|
||||||
double volumeMultiplier;
|
double target; // Target Price for Actions
|
||||||
|
double volumeMultiplier; // Volume Multiplier for Partial Close
|
||||||
|
|
||||||
//
|
//
|
||||||
// Constructor ...
|
// Constructor ...
|
||||||
@@ -511,6 +512,7 @@ struct XTarget
|
|||||||
{
|
{
|
||||||
//
|
//
|
||||||
target = 0;
|
target = 0;
|
||||||
|
doRF = false;
|
||||||
volumeMultiplier = 0;
|
volumeMultiplier = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1067,26 +1067,69 @@ class XCXCAEATradeManager : public XCBaseAlert
|
|||||||
|
|
||||||
//
|
//
|
||||||
// Can Risk Free ...
|
// Can Risk Free ...
|
||||||
bool canRF = jTarget.target > 0 &&
|
bool canRF =
|
||||||
(isLong
|
jTarget.doRF &&
|
||||||
? jTarget.target > iPosition.entry
|
jTarget.target > 0 &&
|
||||||
: jTarget.target < iPosition.entry) &&
|
(isLong
|
||||||
(isLong
|
? jTarget.target > iPosition.entry
|
||||||
? iPosition.price > targetDelta
|
: jTarget.target < iPosition.entry) &&
|
||||||
: iPosition.price < targetDelta);
|
(isLong
|
||||||
if (canRF)
|
? iPosition.price > targetDelta
|
||||||
|
: iPosition.price < targetDelta);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Can Partial Close ...
|
||||||
|
bool canPC =
|
||||||
|
jTarget.volumeMultiplier > 0 &&
|
||||||
|
jTarget.target > 0 &&
|
||||||
|
(isLong
|
||||||
|
? jTarget.target > iPosition.entry
|
||||||
|
: jTarget.target < iPosition.entry) &&
|
||||||
|
(isLong
|
||||||
|
? iPosition.price > targetDelta
|
||||||
|
: iPosition.price < targetDelta);
|
||||||
|
bool canRFPC = canRF ||
|
||||||
|
canPC;
|
||||||
|
if (canRFPC)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
double tp = iPosition.tp;
|
// Handle Risk Free ...
|
||||||
double sl = jTarget.target;
|
bool isRFDone = false;
|
||||||
string comment = "RF On Target ...";
|
if (canRF)
|
||||||
bool isModified = trader.Modify(
|
{
|
||||||
iPosition.ticket,
|
//
|
||||||
sl,
|
double tp = iPosition.tp;
|
||||||
tp,
|
double sl = jTarget.target;
|
||||||
comment //
|
string comment = "RF On Target ...";
|
||||||
);
|
isRFDone = trader.Modify(
|
||||||
if (isModified)
|
iPosition.ticket,
|
||||||
|
sl,
|
||||||
|
tp,
|
||||||
|
comment //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Handle Partail Close ...
|
||||||
|
bool isPCDone = false;
|
||||||
|
if (canPC)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
double volume = jTarget.volumeMultiplier * iPosition.volume;
|
||||||
|
volume = NormalizeVolume(volume, iPosition.symbol);
|
||||||
|
string comment = "RF On Target ...";
|
||||||
|
isPCDone = trader.ClosePartial(
|
||||||
|
iPosition.ticket,
|
||||||
|
volume,
|
||||||
|
comment //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Handle Report Action ...
|
||||||
|
bool isRFPCDone = isRFDone ||
|
||||||
|
isPCDone;
|
||||||
|
if (isRFPCDone)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
trades[idx].signal.appliedTargetIDX = j;
|
trades[idx].signal.appliedTargetIDX = j;
|
||||||
@@ -1097,7 +1140,9 @@ class XCXCAEATradeManager : public XCBaseAlert
|
|||||||
ToString(iPosition.type) +
|
ToString(iPosition.type) +
|
||||||
" Position: " +
|
" Position: " +
|
||||||
ToString(iPosition.ticket) +
|
ToString(iPosition.ticket) +
|
||||||
" RF On Traget: " + ToString(jTarget.target) +
|
(isRFDone ? "RF" : "") +
|
||||||
|
(isPCDone ? "PC" : "") +
|
||||||
|
" On Traget: " + ToString(jTarget.target) +
|
||||||
" Successfully ...";
|
" Successfully ...";
|
||||||
HandleReportProtector(message);
|
HandleReportProtector(message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -559,34 +559,6 @@ class XCXCAEASignaller : XCBase
|
|||||||
? entry + reward
|
? entry + reward
|
||||||
: entry - reward;
|
: entry - reward;
|
||||||
|
|
||||||
// //
|
|
||||||
// // Handling RF ...
|
|
||||||
// double rfReward = risk * 1.95;
|
|
||||||
// double rfPrice =
|
|
||||||
// isBullish
|
|
||||||
// ? entry + rfReward
|
|
||||||
// : entry - rfReward;
|
|
||||||
// Add(
|
|
||||||
// rfPrice,
|
|
||||||
// conditions.targets //
|
|
||||||
// );
|
|
||||||
|
|
||||||
// //
|
|
||||||
// rfReward = risk * 2.95;
|
|
||||||
// rfPrice =
|
|
||||||
// isBullish
|
|
||||||
// ? entry + rfReward
|
|
||||||
// : entry - rfReward;
|
|
||||||
// Add(
|
|
||||||
// rfPrice,
|
|
||||||
// conditions.targets //
|
|
||||||
// );
|
|
||||||
|
|
||||||
//
|
|
||||||
// Handling Partial Close ...
|
|
||||||
// conditions.partialCloseOnTPLevel = 1;
|
|
||||||
// conditions.partialCloseMultiplier = 0.5;
|
|
||||||
|
|
||||||
//
|
//
|
||||||
conditions.sl = sl;
|
conditions.sl = sl;
|
||||||
conditions.tp = tp;
|
conditions.tp = tp;
|
||||||
@@ -596,6 +568,58 @@ class XCXCAEASignaller : XCBase
|
|||||||
? X_POSITION_TYPE_LONG
|
? X_POSITION_TYPE_LONG
|
||||||
: X_POSITION_TYPE_SHORT;
|
: X_POSITION_TYPE_SHORT;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Preparing Targets ...
|
||||||
|
XTarget iTarget;
|
||||||
|
double iPrice = 0;
|
||||||
|
double iReward = 0;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Partial Close 25% of Volume in R2R 1 ...
|
||||||
|
iReward = risk * 1;
|
||||||
|
iPrice =
|
||||||
|
isBullish
|
||||||
|
? entry + iReward
|
||||||
|
: entry - iReward;
|
||||||
|
iPrice = NormalizePrice(iPrice, conditions.symbol);
|
||||||
|
iTarget.target = iPrice;
|
||||||
|
iTarget.volumeMultiplier = 0.25;
|
||||||
|
AddRef(
|
||||||
|
iTarget,
|
||||||
|
targets //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Partial Close 25% of Volume in R2R 2 ...
|
||||||
|
iReward = risk * 1.90;
|
||||||
|
iPrice =
|
||||||
|
isBullish
|
||||||
|
? entry + iReward
|
||||||
|
: entry - iReward;
|
||||||
|
iPrice = NormalizePrice(iPrice, conditions.symbol);
|
||||||
|
iTarget.target = iPrice;
|
||||||
|
iTarget.volumeMultiplier = 0.25;
|
||||||
|
AddRef(
|
||||||
|
iTarget,
|
||||||
|
targets //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Risk Free in R2R 3 ...
|
||||||
|
iReward = risk * 2.90;
|
||||||
|
iPrice =
|
||||||
|
isBullish
|
||||||
|
? entry + iReward
|
||||||
|
: entry - iReward;
|
||||||
|
iPrice = NormalizePrice(iPrice, conditions.symbol);
|
||||||
|
// iTarget.doRF = true;
|
||||||
|
iTarget.volumeMultiplier = 0.25;
|
||||||
|
iTarget.target = iPrice;
|
||||||
|
AddRef(
|
||||||
|
iTarget,
|
||||||
|
targets //
|
||||||
|
);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Handling Targets ...
|
// Handling Targets ...
|
||||||
bool hasTargets = HasChild(targets);
|
bool hasTargets = HasChild(targets);
|
||||||
|
|||||||
Reference in New Issue
Block a user