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 cHasX786
// //
|| &&
// //
sHasX786 sHasX786
// //
|| &&
// //
mHasX786 mHasX786
// //
|| &&
// //
lHasX786 lHasX786
// //
|| // &&
// // //
hHasX786 // hHasX786
// //
; ;
// //
if (result) if (result)
{ {
r2r = 1.5; //
r2r = 1;
sl = cMarket.don.GetLowerH(cIndex);
} }
// //
@@ -7600,28 +7602,30 @@ private:
// //
cHasX121 cHasX121
// //
|| &&
// //
sHasX121 sHasX121
// //
|| &&
// //
mHasX121 mHasX121
// //
|| &&
// //
lHasX121 lHasX121
// //
|| // &&
// // //
hHasX121 // hHasX121
// //
; ;
// //
if (result) if (result)
{ {
r2r = 1.5; //
r2r = 1;
sl = cMarket.mrb.GetSlow(cIndex);
} }
// //
@@ -8542,80 +8546,138 @@ private:
int pIndex = cIndex + 1; int pIndex = cIndex + 1;
// //
// Current Market ...
double cUpperLow = cMarket.don.GetUpperL(cIndex);
bool cHasX786 = cMarket.HasX786ShortConditions(); bool cHasX786 = cMarket.HasX786ShortConditions();
//
// Short Market ...
double sUpperLow = sMarket.don.GetUpperL(cIndex);
bool sHasX786 = sMarket.HasX786ShortConditions(); bool sHasX786 = sMarket.HasX786ShortConditions();
//
// Medium Market ...
double mUpperLow = mMarket.don.GetUpperL(cIndex);
bool mHasX786 = mMarket.HasX786ShortConditions(); bool mHasX786 = mMarket.HasX786ShortConditions();
//
// Long Market ...
double lUpperLow = lMarket.don.GetUpperL(cIndex);
bool lHasX786 = lMarket.HasX786ShortConditions(); bool lHasX786 = lMarket.HasX786ShortConditions();
bool hHasX786 = hMarket.HasX786ShortConditions();
// //
// Hind Market ... double cMarketSLe = cMarket.don.GetUpperL(cIndex);
double hUpperLow = hMarket.don.GetUpperL(cIndex); double sMarketSLe = sMarket.don.GetUpperL(cIndex);
bool hHasX786 = hMarket.HasX786ShortConditions(); 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 = result =
// //
cHasX786 condition1
// //
|| ||
// //
sHasX786 condition2
// //
|| ||
// //
mHasX786 condition3
// //
|| ||
// //
lHasX786 condition4
//
// ||
// //
// hHasX786
// //
; ;
// //
if (result) if (result)
{ {
// r2r = 1;
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;
} }
// //
@@ -8673,28 +8735,30 @@ private:
// //
cHasX121 cHasX121
// //
|| &&
// //
sHasX121 sHasX121
// //
|| &&
// //
mHasX121 mHasX121
// //
|| &&
// //
lHasX121 lHasX121
// //
|| // ||
// // //
hHasX121 // hHasX121
// //
; ;
// //
if (result) if (result)
{ {
r2r = 1.5; //
r2r = 1;
sl = cMarket.mrb.GetFast(cIndex);
} }
// //
+194 -31
View File
@@ -475,8 +475,8 @@ public:
iSignal.provider == XEQMSupportToken iSignal.provider == XEQMSupportToken
? true ? true
: isLong : isLong
? longs < shorts || longProfits > shortProfits ? longs < shorts // || longProfits > shortProfits
: shorts < longs || shortProfits > longProfits : shorts < longs // || shortProfits > longProfits
// //
; ;
if (!canAccept) if (!canAccept)
@@ -1350,40 +1350,40 @@ public:
// //
mAlert.Alert(message); mAlert.Alert(message);
// // //
XPosition position; // XPosition position;
bool isRecieved = mTrader.GetPosition( // bool isRecieved = mTrader.GetPosition(
track.ticket, // track.ticket,
position // // position //
); // );
if (!isRecieved) // if (!isRecieved)
{ // {
return; // return;
} // }
// // //
XSignal signals[]; // XSignal signals[];
// // //
XSignal signal; // XSignal signal;
bool isPrepared = signal.PrepareOpposit(position); // bool isPrepared = signal.PrepareOpposit(position);
if (!isPrepared) // if (!isPrepared)
{ // {
return; // return;
} // }
// // //
signal.comment = ""; // signal.comment = "";
signal.provider = XEQMSupportToken; // signal.provider = XEQMSupportToken;
// // //
AddRef( // AddRef(
signal, // signal,
signals // // 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 ... // Tools ...
}; };
+2 -2
View File
@@ -195,7 +195,7 @@ bool InitialEA()
// Define Signallers ... // Define Signallers ...
ENUM_X121_SIGNAL_PROVIDERS signallers[]; ENUM_X121_SIGNAL_PROVIDERS signallers[];
Add(X786, signallers); Add(X786, signallers);
Add(X121, signallers); // Add(X121, signallers);
// Add(X121, signallers); // Add(X121, signallers);
// Add(X128, signallers); // Add(X128, signallers);
// Add(X92, signallers); // Add(X92, signallers);
@@ -238,7 +238,7 @@ bool InitialEA()
iDescriptor.symbol = iSymbol; iDescriptor.symbol = iSymbol;
iDescriptor.period = iPeriod; iDescriptor.period = iPeriod;
iDescriptor.staticVolume = x121EAVolume; iDescriptor.staticVolume = x121EAVolume;
iDescriptor.allowLong = x121EAAllowLong; iDescriptor.allowLong = false; // x121EAAllowLong;
iDescriptor.allowShort = x121EAAllowShort; iDescriptor.allowShort = x121EAAllowShort;
Copy( Copy(
signallers, signallers,
+192
View File
@@ -1003,6 +1003,198 @@ struct XOHCL
return result; 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 ... // Check Bar is Inside Previus Bar ...
bool IsInsideBar( bool IsInsideBar(