last works ...

This commit is contained in:
2024-06-14 05:39:49 +03:30
parent a525a2e2cd
commit e12f7f72c5
7 changed files with 655 additions and 97 deletions
+243 -25
View File
@@ -25,9 +25,8 @@
//
#include "../Libraries/x-saherelm.xtrade.lib.mq5"
//
#include "../Classes/x-saherelm.xalert.class.mq5"
#include "../Classes/x-saherelm.xczone.class.mq5"
//
#include "../Helpers/x-saherelm.xtd.helper.mq5"
@@ -727,6 +726,30 @@ struct X121SignalGenerator
{
//
string version;
double hotLevels[];
//
// Constructor ...
void X121SignalGenerator()
{
//
Add(
0.25,
hotLevels //
);
//
Add(
0.20,
hotLevels //
);
//
Add(
0.15,
hotLevels //
);
}
//
// Retrieve OSC Based Long Verifications ...
@@ -1326,8 +1349,8 @@ struct X121SignalGenerator
result =
//
pusher >= 1 &&
!isOSCShortVerified &&
bullishScore > bearishScore * 2 &&
// !isOSCShortVerified &&
// bullishScore > bearishScore * 2 &&
(
//
long1
@@ -1923,8 +1946,8 @@ struct X121SignalGenerator
result =
//
pusher >= 1 &&
!isOSCLongVerified &&
bearishScore > bullishScore * 2 &&
// !isOSCLongVerified &&
// bearishScore > bullishScore * 2 &&
(
//
short1
@@ -2014,7 +2037,7 @@ struct X121SignalGenerator
//
// TODO Filter ...
result = provider == ToString(PROVIDER_XVLM);
result = true; // provider == ToString(PROVIDER_XVLM);
//
return result;
@@ -2033,7 +2056,7 @@ struct X121SignalGenerator
//
// TODO Filter ...
result = provider == ToString(PROVIDER_XVLM);
result = true; // provider == ToString(PROVIDER_XVLM);
//
return result;
@@ -2186,6 +2209,39 @@ struct X121SignalGenerator
return result;
}
//
// Calculate Ticks Zone ...
XSCZones *zones = new XSCZones(
signal.symbol,
signal.period //
);
//
XSCZonesInput zonesInput;
zonesInput.length = 71;
zonesInput.numberOfZones = 10;
//
zonesInput.AddLevelColor(
hotLevels[0],
clrRed //
);
zonesInput.AddLevelColor(
hotLevels[1],
clrOrange //
);
zonesInput.AddLevelColor(
hotLevels[2],
clrLightCoral //
);
//
bool canUseZones = zones.Init(zonesInput);
if (canUseZones)
{
signal.zones = zones;
}
//
// Generate Support Signals ...
if (_useSupport)
@@ -2203,40 +2259,202 @@ struct X121SignalGenerator
//
void GenerateSupportSignals(
XSignal &signal // Source Signal for Support Generating ...
) {
)
{
//
// Validate Signal ...
if (!signal.IsValid()) {
if (!signal.IsValid())
{
return;
}
//
// Retrieve Signal Direction ...
bool isLong = IsLong(signal.type);
//
bool canUseZones = signal.zones != NULL;
//
// Check Signal Has TP and SL ...
if (signal.tp > 0 && signal.sl > 0) {
if (signal.tp > 0 && signal.sl > 0)
{
//
// Here we Can Provide Orders based on Signal TP and SL ...
//
// Retrieve Signal Direction ...
bool isLong = IsLong(signal.type);
//
// Calculate TP/Entry Distance ...
double tpDistance =
isLong
? signal.tp - signal.entry
: signal.entry - signal.tp;
double tpDistance =
isLong
? signal.tp - signal.entry
: signal.entry - signal.tp;
//
// Calculate Recovery Zone Step ...
double slDistance =
isLong
? signal.entry - signal.sl
: signal.sl - signal.entry;
? signal.entry - signal.sl
: signal.sl - signal.entry;
}
//
// Add Zone Based Signals ...
if (canUseZones)
{
//
// Calculate Ticks Zone ...
// signal.zones.DrawZones();
//
// Try to Find a Hot Level based on Signal Direction
// as Resistance ...
//
XSignal rSignal; // Recovery Signal ...
//
double rSL = 0; // Recovery Stop Loss ...
double rTP = 0; // Recovery Take Profit ...
double rEntry = 0; // Recovery Entry Point ...
double rVolume = signal.volume * 2; // Recovery Volume ...
ENUM_POSITION_TYPE rType; // Recovery Signal Type ...
ENUM_X_ORDER_MODES rMode; // Recovery Signal Mode ...
bool isSignalPrepared = false; // Check Signal Preparation Succeed ...
//
double onePointValue = PointToPrice(1, signal.symbol);
//
for (int i = 0; i < signal.zones.CountZones(); i++)
{
//
// Retrieve Indexed Zone ...
XSCZone *iZone = signal.zones.GetZone(i);
//
// Check Zone is Hot Zone or not ...
bool isHotZone = false;
for (int j = 0; j < ArraySize(hotLevels); j++)
{
//
isHotZone = (iZone.percent / 100 >= hotLevels[j]);
if (isHotZone)
{
break;
}
}
//
// Prevent Moving Forward if there isn't Hot Zone ...
if (!isHotZone)
{
continue;
}
//
if (iZone.high > signal.entry && iZone.low > signal.entry)
{
//
// Here we can Use Resistance Zone as SL Recovery for
// Short Positions ...
if (!isLong &&
(signal.sl <= 0
? true
: iZone.high < signal.sl && iZone.low < signal.sl))
{
//
// Opposit Support on Resistance Upper ...
//
rTP = signal.sl <= 0
? iZone.high - (onePointValue * 15)
: signal.sl;
rSL = signal.entry;
rType = POSITION_TYPE_BUY;
rEntry = iZone.high + (onePointValue * 2);
rMode = X_ORDER_MODE_STOP;
//
isSignalPrepared = rSignal.Prepare(
signal.symbol,
signal.provider,
signal.period,
rType,
rMode,
rEntry,
rVolume,
rSL,
rTP //
);
if (isSignalPrepared)
{
//
AddRef(
rSignal,
signal.supports //
);
//
rSignal.Clean();
//
rSL = 0;
rTP = 0;
rEntry = 0;
isSignalPrepared = false;
}
//
// Support Directional on Resistance Lower ...
//
rTP = signal.entry;
rSL = signal.sl <= 0
? signal.entry - (onePointValue * 15)
: signal.sl;
rEntry = iZone.low - (onePointValue * 2);
rVolume = signal.volume * 3;
rType = POSITION_TYPE_SELL;
rMode = X_ORDER_MODE_LIMIT;
//
isSignalPrepared = rSignal.Prepare(
signal.symbol,
signal.provider,
signal.period,
rType,
rMode,
rEntry,
rVolume,
rSL,
rTP //
);
if (isSignalPrepared)
{
//
AddRef(
rSignal,
signal.supports //
);
//
rSignal.Clean();
//
rSL = 0;
rTP = 0;
rEntry = 0;
isSignalPrepared = false;
rVolume = signal.volume * 2;
}
}
}
//
if (iZone.high < signal.entry && iZone.low < signal.entry)
{
//
}
}
}
}