add MQL5Test Workspace Content as BKP Solution ...
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
|
||||
//
|
||||
// Support Signals ...
|
||||
void GenerateSupportSignals(
|
||||
XSignal &result[], // Hold Result ...
|
||||
const XSignal &source // Source Signal to Use for Generation ...
|
||||
)
|
||||
{
|
||||
//
|
||||
// Here we must Prepare all Signals ...
|
||||
|
||||
//
|
||||
Clean(result);
|
||||
|
||||
//
|
||||
if (source.entry <= 0 ||
|
||||
(ArraySize(source.supportAndResistance.sup) == 0 &&
|
||||
ArraySize(source.supportAndResistance.res) == 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
double priceOf10Points = PointToPrice(
|
||||
source.symbol,
|
||||
10);
|
||||
|
||||
//
|
||||
double tmpSupRes[];
|
||||
int supResCount = ArraySize(source.supportAndResistance.sup) +
|
||||
ArraySize(source.supportAndResistance.res);
|
||||
ArrayResize(
|
||||
tmpSupRes,
|
||||
supResCount);
|
||||
ArrayCopy(
|
||||
tmpSupRes,
|
||||
source.supportAndResistance.sup);
|
||||
ArrayCopy(
|
||||
tmpSupRes,
|
||||
source.supportAndResistance.res,
|
||||
0,
|
||||
ArraySize(source.supportAndResistance.sup) - 1);
|
||||
|
||||
//
|
||||
bool isLong = IsLong(source.type);
|
||||
|
||||
//
|
||||
ENUM_POSITION_TYPE signalReverseType = isLong
|
||||
? POSITION_TYPE_SELL
|
||||
: POSITION_TYPE_BUY;
|
||||
|
||||
//
|
||||
// Template Variables ...
|
||||
double sl;
|
||||
double tp;
|
||||
double entry;
|
||||
ENUM_POSITION_TYPE type;
|
||||
ENUM_X_ORDER_MODES mode;
|
||||
double r2r = 1.5;
|
||||
double volume = NormalizeVolume(
|
||||
source.volume, // * 1.5,
|
||||
source.symbol);
|
||||
string symbol = source.symbol;
|
||||
ENUM_TIMEFRAMES period = source.period;
|
||||
double riskAmount = source.riskAmount; // * 1.5;
|
||||
|
||||
//
|
||||
XSignal tmpSignal;
|
||||
Clean(tmpSignal);
|
||||
|
||||
//
|
||||
// since SL is Lower Sup or Higher Res ...
|
||||
// we have to add a Reversal Support for SL ...
|
||||
if (source.sl > 0)
|
||||
{
|
||||
//
|
||||
// Sl Type Signals are Reversal ...
|
||||
type = signalReverseType;
|
||||
|
||||
//
|
||||
// Finding Entry Price ...
|
||||
entry = source.sl - priceOf10Points;
|
||||
sl = !isLong
|
||||
? FindLesserThanValue(entry, tmpSupRes)
|
||||
: FindBiggerThanValue(entry, tmpSupRes);
|
||||
double riskPrice = sl > 0
|
||||
? MathAbs(entry - sl)
|
||||
: MathAbs(entry - priceOf10Points);
|
||||
double riskPoint = PriceToPoint(
|
||||
symbol,
|
||||
riskPrice);
|
||||
double rewardPoint = r2r * riskPoint;
|
||||
double rewardPrice = PointToPrice(
|
||||
symbol,
|
||||
rewardPoint);
|
||||
tp = !isLong
|
||||
? entry + rewardPrice
|
||||
: entry - rewardPrice;
|
||||
|
||||
//
|
||||
mode = X_ORDER_MODE_STOP;
|
||||
|
||||
//
|
||||
// Fill ...
|
||||
tmpSignal.sl = sl;
|
||||
tmpSignal.tp = tp;
|
||||
tmpSignal.r2r = r2r;
|
||||
tmpSignal.type = type;
|
||||
tmpSignal.mode = mode;
|
||||
tmpSignal.entry = entry;
|
||||
tmpSignal.symbol = symbol;
|
||||
tmpSignal.volume = volume;
|
||||
tmpSignal.period = period;
|
||||
tmpSignal.riskAmount = riskAmount;
|
||||
|
||||
//
|
||||
Add(
|
||||
tmpSignal,
|
||||
result);
|
||||
Clean(tmpSignal);
|
||||
}
|
||||
|
||||
//
|
||||
// add MidTerm Support Signal ...
|
||||
// TODO:
|
||||
|
||||
//
|
||||
// TODO: Implement another Support Scenarios ...
|
||||
}
|
||||
Reference in New Issue
Block a user