Add support for Breaked or Rejected Support and Resistance lines in XOHCL struct ...

This commit is contained in:
2024-05-31 00:48:14 +03:30
parent 159717403f
commit 75ecdc6adf
4 changed files with 523 additions and 104 deletions
+134 -70
View File
@@ -7521,28 +7521,30 @@ private:
//
cHasX786
//
||
&&
//
sHasX786
//
||
&&
//
mHasX786
//
||
&&
//
lHasX786
//
||
//
hHasX786
// &&
// //
// hHasX786
//
;
//
if (result)
{
r2r = 1.5;
//
r2r = 1;
sl = cMarket.don.GetLowerH(cIndex);
}
//
@@ -7600,28 +7602,30 @@ private:
//
cHasX121
//
||
&&
//
sHasX121
//
||
&&
//
mHasX121
//
||
&&
//
lHasX121
//
||
//
hHasX121
// &&
// //
// hHasX121
//
;
//
if (result)
{
r2r = 1.5;
//
r2r = 1;
sl = cMarket.mrb.GetSlow(cIndex);
}
//
@@ -8542,80 +8546,138 @@ private:
int pIndex = cIndex + 1;
//
// Current Market ...
double cUpperLow = cMarket.don.GetUpperL(cIndex);
bool cHasX786 = cMarket.HasX786ShortConditions();
//
// Short Market ...
double sUpperLow = sMarket.don.GetUpperL(cIndex);
bool sHasX786 = sMarket.HasX786ShortConditions();
//
// Medium Market ...
double mUpperLow = mMarket.don.GetUpperL(cIndex);
bool mHasX786 = mMarket.HasX786ShortConditions();
//
// Long Market ...
double lUpperLow = lMarket.don.GetUpperL(cIndex);
bool lHasX786 = lMarket.HasX786ShortConditions();
bool hHasX786 = hMarket.HasX786ShortConditions();
//
// Hind Market ...
double hUpperLow = hMarket.don.GetUpperL(cIndex);
bool hHasX786 = hMarket.HasX786ShortConditions();
double cMarketSLe = cMarket.don.GetUpperL(cIndex);
double sMarketSLe = sMarket.don.GetUpperL(cIndex);
double mMarketSLe = mMarket.don.GetUpperL(cIndex);
double lMarketSLe = lMarket.don.GetUpperL(cIndex);
double hMarketSLe = hMarket.don.GetUpperL(cIndex);
//
bool condition1 =
//
((cHasX786 &&
sHasX786)
//
||
//
(cHasX786 &&
mHasX786))
//
;
//
bool condition2 =
//
((sHasX786 &&
mHasX786)
//
||
//
(sHasX786 &&
lHasX786))
//
;
//
bool condition3 =
//
((mHasX786 &&
lHasX786)
//
||
//
(mHasX786 &&
hHasX786))
//
;
//
bool condition4 =
//
(lHasX786 &&
hHasX786)
//
;
//
if (condition1)
{
//
double sls[] = {
cMarketSLe,
sMarketSLe,
mMarketSLe //
};
//
sl = GetAverage(sls);
}
else if (condition2)
{
//
double sls[] = {
sMarketSLe,
mMarketSLe,
lMarketSLe //
};
//
sl = GetAverage(sls);
}
else if (condition3)
{
//
double sls[] = {
mMarketSLe,
lMarketSLe,
hMarketSLe //
};
//
sl = GetAverage(sls);
}
else if (condition4)
{
//
double sls[] = {
lMarketSLe,
hMarketSLe //
};
//
sl = GetAverage(sls);
}
//
result =
//
cHasX786
condition1
//
||
//
sHasX786
condition2
//
||
//
mHasX786
condition3
//
||
//
lHasX786
//
// ||
// //
// hHasX786
condition4
//
;
//
if (result)
{
//
if (cHasX786)
{
sl = cUpperLow;
}
else if (sHasX786)
{
sl = sUpperLow;
}
else if (mHasX786)
{
sl = mUpperLow;
}
else if (lHasX786)
{
sl = lUpperLow;
}
else if (hHasX786)
{
sl = hUpperLow;
}
//
r2r = 2;
r2r = 1;
}
//
@@ -8673,28 +8735,30 @@ private:
//
cHasX121
//
||
&&
//
sHasX121
//
||
&&
//
mHasX121
//
||
&&
//
lHasX121
//
||
//
hHasX121
// ||
// //
// hHasX121
//
;
//
if (result)
{
r2r = 1.5;
//
r2r = 1;
sl = cMarket.mrb.GetFast(cIndex);
}
//
+195 -32
View File
@@ -475,8 +475,8 @@ public:
iSignal.provider == XEQMSupportToken
? true
: isLong
? longs < shorts || longProfits > shortProfits
: shorts < longs || shortProfits > longProfits
? longs < shorts // || longProfits > shortProfits
: shorts < longs // || shortProfits > longProfits
//
;
if (!canAccept)
@@ -789,7 +789,7 @@ public:
{
//
return;
//
// TODO:
// Make them Configurable ...
@@ -1350,40 +1350,40 @@ public:
//
mAlert.Alert(message);
//
XPosition position;
bool isRecieved = mTrader.GetPosition(
track.ticket,
position //
);
if (!isRecieved)
{
return;
}
// //
// XPosition position;
// bool isRecieved = mTrader.GetPosition(
// track.ticket,
// position //
// );
// if (!isRecieved)
// {
// return;
// }
//
XSignal signals[];
// //
// XSignal signals[];
//
XSignal signal;
bool isPrepared = signal.PrepareOpposit(position);
if (!isPrepared)
{
return;
}
// //
// XSignal signal;
// bool isPrepared = signal.PrepareOpposit(position);
// if (!isPrepared)
// {
// return;
// }
//
signal.comment = "";
signal.provider = XEQMSupportToken;
// //
// signal.comment = "";
// signal.provider = XEQMSupportToken;
//
AddRef(
signal,
signals //
);
// //
// AddRef(
// signal,
// signals //
// );
//
HandleEQMState(signals);
// //
// HandleEQMState(signals);
}
//
@@ -1839,6 +1839,169 @@ private:
);
}
//
// Signal Pivots ...
// --------------------------------------------------------
// Here we Save Entry of Positions as Best Pivots ...
// then when bar break down this pivots and reject them ...
// open an Opposit Position:
// - SL the Breaked Down or Up distance;
// - TP using Risk to Reward Ratio 1.5;
//
double XPosition mPositionPivcots[];
//
// Check if Breake Up a Pivot Fill a Signal ...
bool IsPivotBreakUp(XSignal &signal)
{
//
bool result = false;
//
signal.Clean();
//
int pivotsCount = CountPositionPivots();
result = IsValidSize(pivotsCount);
if (!result)
{
return result;
}
//
// Loop Through Pivots ...
for (int i = 0; i < pivotsCount; i++)
{
//
XPosition iPosition = mPositionPivots[i];
//
XOHCL zBar;
result = zBar.Init(
iPosition.symbol,
iPosition.period,
0 //
);
if (!result)
{
continue;
}
//
XOHCL cBar;
result = cBar.Init(
iPosition.symbol,
iPosition.period,
1 //
);
if (!result)
{
continue;
}
//
XOHCL pBar;
result = pBar.Init(
iPosition.symbol,
iPosition.period,
2 //
);
if (!result)
{
continue;
}
//
// Here we have Bar 0, 1 and 2 ...
//
// Check Entry Break Down ...
}
//
return result;
}
//
// Check if Breake Down a Pivot Fill a Signal ...
bool IsPivotBreakDown(XSignal signal)
{
//
bool result = false;
//
signal.Clean();
//
return result;
}
//
// Count Exists Position's Pivots ...
int CountPositionPivots()
{
//
int result = 0;
//
result = ArraySize(mPositionPivots);
//
return result;
}
//
// Add Specific Position's Pivots
void AddPositionPivots(XPosition &position)
{
//
if (!position.IsValid())
{
return;
}
//
AddRef(
position,
mPositionPivots //
);
}
//
// Remove Specific Position's Pivots
bool RemovePositionPivots(XPosition &positions)
{
//
bool result = false;
//
if (!position.IsValid())
{
return result;
}
//
int idx = position.FindIndex(mPositionPivots);
result = idx >= 0;
if (!result)
{
return result;
}
//
result = ArrayRemove(
mPositionPivots,
idx,
1 //
);
//
return result;
}
//
// Tools ...
};
+2 -2
View File
@@ -195,7 +195,7 @@ bool InitialEA()
// Define Signallers ...
ENUM_X121_SIGNAL_PROVIDERS signallers[];
Add(X786, signallers);
Add(X121, signallers);
// Add(X121, signallers);
// Add(X121, signallers);
// Add(X128, signallers);
// Add(X92, signallers);
@@ -238,7 +238,7 @@ bool InitialEA()
iDescriptor.symbol = iSymbol;
iDescriptor.period = iPeriod;
iDescriptor.staticVolume = x121EAVolume;
iDescriptor.allowLong = x121EAAllowLong;
iDescriptor.allowLong = false; // x121EAAllowLong;
iDescriptor.allowShort = x121EAAllowShort;
Copy(
signallers,
+192
View File
@@ -1003,6 +1003,198 @@ struct XOHCL
return result;
}
//
// Check a Support Line Rejected or not ...
bool IsSupportRejected(
double price // Support Price
)
{
//
bool result = false;
//
// this is zBar ...
// so we are try to Recieve CBar ...
XOHCL cBar;
result = this.GetPreviousBar(cBar);
if (!result)
{
return result;
}
//
// Now we are going to Recieve PBar ...
XOHCL pBar;
result = cBar.GetPreviousBar(pBar);
if (!result)
{
return result;
}
//
// We Have this (0) Bar, cBar (1) and pBar (2) ...
//
// pBar Down Shadow must break Price Line ...
// cBar and zBar Close must be Above Price Line ...
// also zBar Open must be Above Price Line ...
result =
//
pBar.low < price &&
cBar.close > price &&
this.close > price &&
this.open > price
//
;
//
return result;
}
//
// Check a Support Line Breaked or not ...
bool IsSupportBreaked(
double price // Support Price
)
{
//
bool result = false;
//
// this is zBar ...
// so we are try to Recieve CBar ...
XOHCL cBar;
result = this.GetPreviousBar(cBar);
if (!result)
{
return result;
}
//
// Now we are going to Recieve PBar ...
XOHCL pBar;
result = cBar.GetPreviousBar(pBar);
if (!result)
{
return result;
}
//
// We Have this (0) Bar, cBar (1) and pBar (2) ...
//
// pBar Down Shadow must break Price Line ...
// cBar and zBar Close must be Below Price Line ...
// also zBar Open must be Below Price Line ...
result =
//
pBar.low < price &&
cBar.close < price &&
this.close < price &&
this.open < price
//
;
//
return result;
}
//
// Check a Resistance Line Rejected or not ...
bool IsResistanceRejected(
double price // Resistance Price
)
{
//
bool result = false;
//
// this is zBar ...
// so we are try to Recieve CBar ...
XOHCL cBar;
result = this.GetPreviousBar(cBar);
if (!result)
{
return result;
}
//
// Now we are going to Recieve PBar ...
XOHCL pBar;
result = cBar.GetPreviousBar(pBar);
if (!result)
{
return result;
}
//
// We Have this (0) Bar, cBar (1) and pBar (2) ...
//
// pBar Up Shadow must break Price Line ...
// cBar and zBar Close must be Under Price Line ...
// also zBar Open must be Under Price Line ...
result =
//
pBar.high > price &&
cBar.close < price &&
this.close < price &&
this.open < price
//
;
//
return result;
}
//
// Check a Resistance Line Breaked or not ...
bool IsResistanceBreaked(
double price // Support Price
)
{
//
bool result = false;
//
// this is zBar ...
// so we are try to Recieve CBar ...
XOHCL cBar;
result = this.GetPreviousBar(cBar);
if (!result)
{
return result;
}
//
// Now we are going to Recieve PBar ...
XOHCL pBar;
result = cBar.GetPreviousBar(pBar);
if (!result)
{
return result;
}
//
// We Have this (0) Bar, cBar (1) and pBar (2) ...
//
// pBar Up Shadow must break Price Line ...
// cBar and zBar Close must be Over Price Line ...
// also zBar Open must be Pver Price Line ...
result =
//
pBar.high > price &&
cBar.close > price &&
this.close > price &&
this.open > price
//
;
//
return result;
}
//
// Check Bar is Inside Previus Bar ...
bool IsInsideBar(