Fix all Refactors issues on X121SMC for start Implementing Strategy ...
This commit is contained in:
@@ -449,6 +449,348 @@ class XCBarAnalyser : public XCBase
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Bar Has Bullish Trend or not ...
|
||||
*
|
||||
* @param bar: XOHCL instance ...
|
||||
* @param forceAll: Boolean ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasBullishTrend(
|
||||
XOHCL &bar,
|
||||
bool forceAll = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL tmpHSW[];
|
||||
XOHCL tmpLSW[];
|
||||
|
||||
//
|
||||
bool trend1 = bar.HasBullishTrend(
|
||||
tmpHSW,
|
||||
tmpLSW,
|
||||
true //
|
||||
);
|
||||
|
||||
//
|
||||
bool trend2 = bar.HasBullishTrend(
|
||||
tmpHSW,
|
||||
tmpLSW,
|
||||
false //
|
||||
);
|
||||
|
||||
//
|
||||
if (!forceAll)
|
||||
{
|
||||
//
|
||||
result = trend1;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
trend1 ||
|
||||
trend2;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Bar Has Bearish Trend or not ...
|
||||
*
|
||||
* @param bar: XOHCL instance ...
|
||||
* @param forceAll: Boolean ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasBearishTrend(
|
||||
XOHCL &bar,
|
||||
bool forceAll = false //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
XOHCL tmpHSW[];
|
||||
XOHCL tmpLSW[];
|
||||
|
||||
//
|
||||
bool trend1 = bar.HasBearishTrend(
|
||||
tmpHSW,
|
||||
tmpLSW,
|
||||
true //
|
||||
);
|
||||
|
||||
//
|
||||
bool trend2 = bar.HasBearishTrend(
|
||||
tmpHSW,
|
||||
tmpLSW,
|
||||
false //
|
||||
);
|
||||
|
||||
//
|
||||
if (!forceAll)
|
||||
{
|
||||
//
|
||||
result = trend1;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
trend1 ||
|
||||
trend2;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Specified Bar Has Bullish Pattern or not ...
|
||||
*
|
||||
* @param bar: XOHCL instance, Specified Bar ...
|
||||
* @param loopback: Integer, Loopback Length for Patterns ...
|
||||
* @param verifications: Integer, Number of Given Verifications ...
|
||||
* @param checkHammer: Boolean, Specified Check Hammer Pattern ...
|
||||
* @param checkMorningStar: Boolean, Specified Check Morning Star Pattern ...
|
||||
* @param checkBullishMarubozu: Boolean, Specified Check Marubozu Pattern ...
|
||||
* @param checkBullishEngulfing: Boolean, Specified Check Engulfing Pattern ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasBullishPattern(
|
||||
XOHCL &bar,
|
||||
int loopback = 0,
|
||||
int verifications = 1,
|
||||
bool checkHammer = true,
|
||||
bool checkMorningStar = true,
|
||||
bool checkBullishMarubozu = true,
|
||||
bool checkBullishEngulfing = true //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (verifications <= 0)
|
||||
{
|
||||
verifications = 1;
|
||||
}
|
||||
|
||||
//
|
||||
int founded = 0;
|
||||
|
||||
//
|
||||
int idx = bar.Index();
|
||||
for (int i = idx; i <= idx + loopback; i++)
|
||||
{
|
||||
//
|
||||
XOHCL iBar;
|
||||
result = iBar.Init(
|
||||
bar.symbol,
|
||||
bar.period,
|
||||
i //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
bool isHammer =
|
||||
!checkHammer
|
||||
? false
|
||||
: iBar.IsHammer();
|
||||
if (isHammer)
|
||||
{
|
||||
founded++;
|
||||
}
|
||||
|
||||
//
|
||||
bool isMorningStar =
|
||||
!checkMorningStar
|
||||
? false
|
||||
: iBar.IsMorningStar();
|
||||
if (isMorningStar)
|
||||
{
|
||||
founded++;
|
||||
}
|
||||
|
||||
//
|
||||
bool isBullishMarubozu =
|
||||
!checkBullishMarubozu
|
||||
? false
|
||||
: iBar.IsBullishMarubozu();
|
||||
if (isBullishMarubozu)
|
||||
{
|
||||
founded++;
|
||||
}
|
||||
|
||||
//
|
||||
bool isBullishEngulfing =
|
||||
!checkBullishEngulfing
|
||||
? false
|
||||
: iBar.IsBullishEngulfing();
|
||||
if (isBullishEngulfing)
|
||||
{
|
||||
founded++;
|
||||
}
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
result &&
|
||||
founded >= verifications;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check Specified Bar Has Bearish Pattern or not ...
|
||||
*
|
||||
* @param bar: XOHCL instance, Specified Bar ...
|
||||
* @param loopback: Integer, Loopback Length for Patterns ...
|
||||
* @param verifications: Integer, Number of Given Verifications ...
|
||||
* @param checkShootingStar: Boolean, Specified Check Shooting Star Pattern ...
|
||||
* @param checkEveningStar: Boolean, Specified Check Evening Star Pattern ...
|
||||
* @param checkBearishMarubozu: Boolean, Specified Check Marubozu Pattern ...
|
||||
* @param checkBearishEngulfing: Boolean, Specified Check Engulfing Pattern ...
|
||||
*
|
||||
* @return ( bool )
|
||||
*/
|
||||
bool HasBearishPattern(
|
||||
XOHCL &bar,
|
||||
int loopback = 0,
|
||||
int verifications = 1,
|
||||
bool checkShootingStar = true,
|
||||
bool checkEveningStar = true,
|
||||
bool checkBearishMarubozu = true,
|
||||
bool checkBearishEngulfing = true //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = bar.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (verifications <= 0)
|
||||
{
|
||||
verifications = 1;
|
||||
}
|
||||
|
||||
//
|
||||
int founded = 0;
|
||||
|
||||
//
|
||||
int idx = bar.Index();
|
||||
for (int i = idx - 1; i <= idx + loopback; i++)
|
||||
{
|
||||
//
|
||||
XOHCL iBar;
|
||||
result = iBar.Init(
|
||||
bar.symbol,
|
||||
bar.period,
|
||||
i //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
bool isShootingStar =
|
||||
!checkShootingStar
|
||||
? false
|
||||
: iBar.IsShootingStar();
|
||||
if (isShootingStar)
|
||||
{
|
||||
founded++;
|
||||
}
|
||||
|
||||
//
|
||||
bool isEveningStar =
|
||||
!checkEveningStar
|
||||
? false
|
||||
: iBar.IsEveningStar();
|
||||
if (isEveningStar)
|
||||
{
|
||||
founded++;
|
||||
}
|
||||
|
||||
//
|
||||
bool isBearishMarubozu =
|
||||
!checkBearishMarubozu
|
||||
? false
|
||||
: iBar.IsBearishMarubozu();
|
||||
if (isBearishMarubozu)
|
||||
{
|
||||
founded++;
|
||||
}
|
||||
|
||||
//
|
||||
bool isBearishEngulfing =
|
||||
!checkBearishEngulfing
|
||||
? false
|
||||
: iBar.IsBearishEngulfing();
|
||||
if (isBearishEngulfing)
|
||||
{
|
||||
founded++;
|
||||
}
|
||||
|
||||
//
|
||||
}
|
||||
|
||||
//
|
||||
result =
|
||||
result &&
|
||||
founded >= verifications;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Commons ...
|
||||
|
||||
|
||||
Reference in New Issue
Block a user