This commit is contained in:
2024-06-04 05:13:36 +03:30
parent 979036b157
commit 87a165d4a0
3 changed files with 3181 additions and 8 deletions
+195 -2
View File
@@ -22,6 +22,7 @@
//
// Imports ...
#include <Trade/Trade.mqh>
#include "../Libraries/x-saherelm.draw.lib.mq5"
#include "../Libraries/x-saherelm.common.lib.mq5"
#include "../Classes/x-saherelm.xdata-collector.class.mq5"
@@ -1015,7 +1016,7 @@ struct XSignal
IsValid(period) &&
IsValid(symbol) &&
NotEmpty(volume) &&
NotEmpty(entry)
NotEmpty(entry)
//
;
@@ -1109,6 +1110,16 @@ struct XSignal
return result;
}
//
int GetAge()
{
//
return GetAge(
this,
this.period //
);
}
//
// Retrieve Entry Price ...
double GetEntry()
@@ -1480,6 +1491,162 @@ struct XSignal
//
return result;
}
//
// Draw Signal on Chart ...
bool Draw(
long chartID,
int subWindow = 0,
string prefix = NULL,
color entryColor = clrGold,
color bullishColor = clrSpringGreen,
color bearishColor = clrTomato //
)
{
//
bool result = false;
//
result = IsValid();
if (!result)
{
return result;
}
//
bool isLong = IsLong(this.type);
//
prefix =
//
(!IsValid(prefix) ? "" : prefix) +
this.symbol + "_" +
ToString(this.period) + "_" +
this.provider
//
;
//
int age = this.GetAge();
//
// Retrieve Time ...
datetime time0 = iTime(
this.symbol,
this.period,
age //
);
//
// Retrieve 3 Time ...
datetime time3 = iTime(
this.symbol,
this.period,
age + 3 //
);
//
color posColor = isLong
? bullishColor
: bearishColor;
color tpColor = bullishColor;
color slColor = bearishColor;
//
ENUM_LINE_STYLE vLineStyle = STYLE_DOT;
ENUM_LINE_STYLE tpLineStyle = STYLE_SOLID;
ENUM_LINE_STYLE slLineStyle = STYLE_SOLID;
ENUM_LINE_STYLE entryLineStyle = STYLE_SOLID;
//
int lineWidth = 2;
//
// Vertical Line ...
string vlName = prefix + "_" + (string)time;
//
result = DrawVerticalLine(
chartID,
vlName,
subWindow,
time0,
posColor,
vLineStyle,
lineWidth //
);
if (!result)
{
return result;
}
//
// TP ...
double profit = (MathAbs(this.tp - this.entry)) * this.volume;
string tpName = prefix + "_TP_" + (string)profit;
//
result = DrawTrendLine(
chartID,
tpName,
subWindow,
time3,
this.tp,
time0,
this.tp,
tpColor,
tpLineStyle,
lineWidth //
);
if (!result)
{
return result;
}
//
// SL ...
double lost = (MathAbs(this.sl - this.entry)) * this.volume;
string slName = prefix + "_SL_" + (string)lost;
//
result = DrawTrendLine(
chartID,
slName,
subWindow,
time3,
this.sl,
time0,
this.sl,
slColor,
slLineStyle,
lineWidth //
);
if (!result)
{
return result;
}
//
// ENTRY ...
string entryName = prefix + "_ENTRY_" + (string)lost;
//
result = DrawTrendLine(
chartID,
entryName,
subWindow,
time3,
this.entry,
time,
this.entry,
entryColor,
entryLineStyle,
lineWidth //
);
//
return result;
}
};
//
@@ -2888,6 +3055,32 @@ bool IsValid(ENUM_X_ORDER_MODES value)
//
// Ages ...
//
// Retrieve a Position Age ...
int GetAge(
XSignal &signal, // Selected Signal ...
ENUM_TIMEFRAMES period = NULL // Dest Time Frame ...
)
{
//
int result = -1;
//
if (period == NULL)
{
period = _Period;
}
//
result = iBarShift(
signal.symbol,
period,
signal.time);
//
return result;
}
//
// Retrieve a Position Age ...
int GetAge(
@@ -3917,7 +4110,7 @@ int GenerateEQMOrders(
XEQMSupportToken,
position.period,
iEntry,
position.volume,
position.volume,
iSL,
iTP //
);