last works on Testing XPivot and XZone structures in test ea ...
This commit is contained in:
+303
-143
@@ -25,6 +25,7 @@
|
||||
//
|
||||
// Imports ...
|
||||
#include "../Test/x-saherelm.test.xea.mq5"
|
||||
#include "../Libraries/x-saherelm.tools.mq5"
|
||||
#include "../Helpers/x-saherelm.xct.helper.mq5"
|
||||
#include "../Helpers/x-saherelm.xcc.helper.mq5"
|
||||
|
||||
@@ -48,6 +49,16 @@ XSCXTestSetup *iSetup;
|
||||
XSCXCTHelper *mCTHelper;
|
||||
XSCXCCHelper *mCCHelper;
|
||||
|
||||
//
|
||||
// For Pivot Checking ...
|
||||
XPivot lastSupportPivot;
|
||||
XPivot lastResistancePivot;
|
||||
|
||||
//
|
||||
// For Zone Checking ...
|
||||
XZone lastSupportZone;
|
||||
XZone lastResistanceZone;
|
||||
|
||||
//
|
||||
// Event Handlers ...
|
||||
|
||||
@@ -119,138 +130,12 @@ void OnTick()
|
||||
}
|
||||
|
||||
//
|
||||
XTestConditions conditions;
|
||||
bool hasConditions = iSetup.GetConditions(
|
||||
conditions,
|
||||
0,
|
||||
5 //
|
||||
);
|
||||
if (hasConditions)
|
||||
{
|
||||
//
|
||||
bool isCHMAOverUnder1 =
|
||||
//
|
||||
(conditions.chmaConditions.isFastOverMin &&
|
||||
conditions.chmaConditions.isFastUnderMin)
|
||||
//
|
||||
;
|
||||
//
|
||||
bool isCHMAOverUnder2 =
|
||||
//
|
||||
(conditions.chmaConditions.isSlowOverMin &&
|
||||
conditions.chmaConditions.isSlowUnderMin)
|
||||
//
|
||||
;
|
||||
//
|
||||
bool isCHMAOverUnder3 =
|
||||
//
|
||||
(conditions.chmaConditions.isFastOverMax &&
|
||||
conditions.chmaConditions.isFastUnderMax)
|
||||
//
|
||||
;
|
||||
//
|
||||
bool isCHMAOverUnder4 =
|
||||
//
|
||||
(conditions.chmaConditions.isSlowOverMax &&
|
||||
conditions.chmaConditions.isSlowUnderMax)
|
||||
//
|
||||
;
|
||||
//
|
||||
if (isCHMAOverUnder1 || isCHMAOverUnder2 || isCHMAOverUnder3 || isCHMAOverUnder4)
|
||||
{
|
||||
Print("isCHMAOverUnder");
|
||||
}
|
||||
}
|
||||
// Check Pivots ...
|
||||
// HandleCheckPivots();
|
||||
|
||||
// //
|
||||
// XOHCL cBar;
|
||||
// bool isInit = cBar.Init(
|
||||
// _Symbol,
|
||||
// _Period,
|
||||
// 1 //
|
||||
// );
|
||||
// if (!isInit)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// //
|
||||
// datetime time1 = iTime(
|
||||
// _Symbol,
|
||||
// _Period,
|
||||
// 2 //
|
||||
// );
|
||||
|
||||
// //
|
||||
// double fib382 = 0;
|
||||
|
||||
// //
|
||||
// bool isHammer = cBar.IsHammer();
|
||||
// if (isHammer)
|
||||
// {
|
||||
// //
|
||||
// fib382 = GetFibonacciLevel(
|
||||
// cBar.high,
|
||||
// cBar.low,
|
||||
// 0.382,
|
||||
// -1 //
|
||||
// );
|
||||
// DrawTrendLine(
|
||||
// ChartID(),
|
||||
// "HMR_TR",
|
||||
// 0,
|
||||
// time1,
|
||||
// fib382,
|
||||
// cBar.time,
|
||||
// fib382,
|
||||
// clrYellow //
|
||||
// );
|
||||
// Print("Hammer ...");
|
||||
// eaBarTracker.Waits();
|
||||
// }
|
||||
|
||||
// //
|
||||
// bool isShootingStar = cBar.IsShootingStar();
|
||||
// if (isShootingStar)
|
||||
// {
|
||||
// //
|
||||
// fib382 = GetFibonacciLevel(
|
||||
// cBar.high,
|
||||
// cBar.low,
|
||||
// 0.382,
|
||||
// 1 //
|
||||
// );
|
||||
// DrawTrendLine(
|
||||
// ChartID(),
|
||||
// "HMR_TR",
|
||||
// 0,
|
||||
// time1,
|
||||
// fib382,
|
||||
// cBar.time,
|
||||
// fib382,
|
||||
// clrYellow //
|
||||
// );
|
||||
// Print("ShootingStar ...");
|
||||
// eaBarTracker.Waits();
|
||||
// }
|
||||
|
||||
// //
|
||||
// bool isBullishEngulf = cBar.IsBullishEngulf();
|
||||
// if (isBullishEngulf)
|
||||
// {
|
||||
// //
|
||||
// Print("Bullish Engulf ...");
|
||||
// eaBarTracker.Waits();
|
||||
// }
|
||||
|
||||
// //
|
||||
// bool isBearishEngulf = cBar.IsBearishEngulf();
|
||||
// if (isBearishEngulf)
|
||||
// {
|
||||
// //
|
||||
// Print("Bearish Engulf ...");
|
||||
// eaBarTracker.Waits();
|
||||
// }
|
||||
//
|
||||
// Check Zones ...
|
||||
HandleCheckZones();
|
||||
}
|
||||
|
||||
//
|
||||
@@ -457,18 +342,293 @@ void PreConfigureStyles(XTestInputs &inputs)
|
||||
|
||||
//
|
||||
// XCHMA ...
|
||||
inputs.chmaInputs.showFast = true;
|
||||
inputs.chmaInputs.showSlow = true;
|
||||
inputs.chmaInputs.showCCFast = true;
|
||||
inputs.chmaInputs.showCCSlow = true;
|
||||
inputs.chmaInputs.showSCFast = true;
|
||||
inputs.chmaInputs.showSCSlow = true;
|
||||
inputs.chmaInputs.showMCFast = true;
|
||||
inputs.chmaInputs.showMCSlow = true;
|
||||
inputs.chmaInputs.showLCFast = true;
|
||||
inputs.chmaInputs.showLCSlow = true;
|
||||
inputs.chmaInputs.showHCFast = true;
|
||||
inputs.chmaInputs.showHCSlow = true;
|
||||
inputs.chmaInputs.showFast = false;
|
||||
inputs.chmaInputs.showSlow = false;
|
||||
inputs.chmaInputs.showCCFast = false;
|
||||
inputs.chmaInputs.showCCSlow = false;
|
||||
inputs.chmaInputs.showSCFast = false;
|
||||
inputs.chmaInputs.showSCSlow = false;
|
||||
inputs.chmaInputs.showMCFast = false;
|
||||
inputs.chmaInputs.showMCSlow = false;
|
||||
inputs.chmaInputs.showLCFast = false;
|
||||
inputs.chmaInputs.showLCSlow = false;
|
||||
inputs.chmaInputs.showHCFast = false;
|
||||
inputs.chmaInputs.showHCSlow = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Custom Testing Functions ...
|
||||
|
||||
//
|
||||
void HandleCheckPivots()
|
||||
{
|
||||
//
|
||||
XOHCL cBar;
|
||||
bool isInited = cBar.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
1 //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
// Check Resistance ...
|
||||
if (!lastResistancePivot.isResistance)
|
||||
{
|
||||
//
|
||||
isInited = lastResistancePivot.FindLastResistance(
|
||||
_Symbol,
|
||||
_Period //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
//
|
||||
lastResistancePivot.Clean();
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
bool isDrawn = lastResistancePivot.Draw(ChartID());
|
||||
if (isDrawn)
|
||||
{
|
||||
Print("Valid Resistance ...");
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Check Support ...
|
||||
if (!lastSupportPivot.isSupport)
|
||||
{
|
||||
//
|
||||
isInited = lastSupportPivot.FindLastSupport(
|
||||
_Symbol,
|
||||
_Period //
|
||||
);
|
||||
if (!isInited)
|
||||
{
|
||||
//
|
||||
lastSupportPivot.Clean();
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
bool isDrawn = lastSupportPivot.Draw(ChartID());
|
||||
if (isDrawn)
|
||||
{
|
||||
Print("Valid Support ...");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
bool isBreaked = lastSupportPivot.IsBreaked();
|
||||
bool isRejected = lastSupportPivot.IsRejected();
|
||||
|
||||
//
|
||||
if (isBreaked)
|
||||
{
|
||||
//
|
||||
lastSupportPivot.Clean();
|
||||
Print("Support Breaked ...");
|
||||
}
|
||||
|
||||
//
|
||||
if (isRejected)
|
||||
{
|
||||
//
|
||||
lastSupportPivot.Clean();
|
||||
Print("Support Rejected ...");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
void HandleCheckZones() {
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Find Last Support Zone ...
|
||||
if (!lastSupportZone.IsValid()) {
|
||||
//
|
||||
result = lastSupportZone.FindLastSupportZone(
|
||||
_Symbol,
|
||||
_Period //
|
||||
);
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
result = lastSupportZone.Draw(ChartID());
|
||||
if (result) {
|
||||
Print("Valid Support Zone ...");
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// Find Last Resistance Zone ...
|
||||
if (!lastResistanceZone.IsValid()) {
|
||||
//
|
||||
result = lastResistanceZone.FindLastResistanceZone(
|
||||
_Symbol,
|
||||
_Period //
|
||||
);
|
||||
if (!result) {
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
result = lastResistanceZone.Draw(ChartID());
|
||||
if (result) {
|
||||
Print("Valid Resistance Zone ...");
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
void OldTests()
|
||||
{
|
||||
// //
|
||||
// XTestConditions conditions;
|
||||
// bool hasConditions = iSetup.GetConditions(
|
||||
// conditions,
|
||||
// 0,
|
||||
// 5 //
|
||||
// );
|
||||
// if (hasConditions)
|
||||
// {
|
||||
// //
|
||||
// bool isCHMAOverUnder1 =
|
||||
// //
|
||||
// (conditions.chmaConditions.isFastOverMin &&
|
||||
// conditions.chmaConditions.isFastUnderMin)
|
||||
// //
|
||||
// ;
|
||||
// //
|
||||
// bool isCHMAOverUnder2 =
|
||||
// //
|
||||
// (conditions.chmaConditions.isSlowOverMin &&
|
||||
// conditions.chmaConditions.isSlowUnderMin)
|
||||
// //
|
||||
// ;
|
||||
// //
|
||||
// bool isCHMAOverUnder3 =
|
||||
// //
|
||||
// (conditions.chmaConditions.isFastOverMax &&
|
||||
// conditions.chmaConditions.isFastUnderMax)
|
||||
// //
|
||||
// ;
|
||||
// //
|
||||
// bool isCHMAOverUnder4 =
|
||||
// //
|
||||
// (conditions.chmaConditions.isSlowOverMax &&
|
||||
// conditions.chmaConditions.isSlowUnderMax)
|
||||
// //
|
||||
// ;
|
||||
// //
|
||||
// if (isCHMAOverUnder1 || isCHMAOverUnder2 || isCHMAOverUnder3 || isCHMAOverUnder4)
|
||||
// {
|
||||
// Print("isCHMAOverUnder");
|
||||
// }
|
||||
// }
|
||||
|
||||
// //
|
||||
// XOHCL cBar;
|
||||
// bool isInit = cBar.Init(
|
||||
// _Symbol,
|
||||
// _Period,
|
||||
// 1 //
|
||||
// );
|
||||
// if (!isInit)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// //
|
||||
// datetime time1 = iTime(
|
||||
// _Symbol,
|
||||
// _Period,
|
||||
// 2 //
|
||||
// );
|
||||
|
||||
// //
|
||||
// double fib382 = 0;
|
||||
|
||||
// //
|
||||
// bool isHammer = cBar.IsHammer();
|
||||
// if (isHammer)
|
||||
// {
|
||||
// //
|
||||
// fib382 = GetFibonacciLevel(
|
||||
// cBar.high,
|
||||
// cBar.low,
|
||||
// 0.382,
|
||||
// -1 //
|
||||
// );
|
||||
// DrawTrendLine(
|
||||
// ChartID(),
|
||||
// "HMR_TR",
|
||||
// 0,
|
||||
// time1,
|
||||
// fib382,
|
||||
// cBar.time,
|
||||
// fib382,
|
||||
// clrYellow //
|
||||
// );
|
||||
// Print("Hammer ...");
|
||||
// eaBarTracker.Waits();
|
||||
// }
|
||||
|
||||
// //
|
||||
// bool isShootingStar = cBar.IsShootingStar();
|
||||
// if (isShootingStar)
|
||||
// {
|
||||
// //
|
||||
// fib382 = GetFibonacciLevel(
|
||||
// cBar.high,
|
||||
// cBar.low,
|
||||
// 0.382,
|
||||
// 1 //
|
||||
// );
|
||||
// DrawTrendLine(
|
||||
// ChartID(),
|
||||
// "HMR_TR",
|
||||
// 0,
|
||||
// time1,
|
||||
// fib382,
|
||||
// cBar.time,
|
||||
// fib382,
|
||||
// clrYellow //
|
||||
// );
|
||||
// Print("ShootingStar ...");
|
||||
// eaBarTracker.Waits();
|
||||
// }
|
||||
|
||||
// //
|
||||
// bool isBullishEngulf = cBar.IsBullishEngulf();
|
||||
// if (isBullishEngulf)
|
||||
// {
|
||||
// //
|
||||
// Print("Bullish Engulf ...");
|
||||
// eaBarTracker.Waits();
|
||||
// }
|
||||
|
||||
// //
|
||||
// bool isBearishEngulf = cBar.IsBearishEngulf();
|
||||
// if (isBearishEngulf)
|
||||
// {
|
||||
// //
|
||||
// Print("Bearish Engulf ...");
|
||||
// eaBarTracker.Waits();
|
||||
// }
|
||||
}
|
||||
|
||||
//
|
||||
@@ -498,16 +498,19 @@ string FindObjectName(
|
||||
|
||||
//
|
||||
int objectsCount = ObjectsTotal(chartId, subWindow);
|
||||
if (objectsCount <= 0) {
|
||||
if (objectsCount <= 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = objectsCount - 1; i >= 0; i--) {
|
||||
for (int i = objectsCount - 1; i >= 0; i--)
|
||||
{
|
||||
//
|
||||
string iObjectName = ObjectName(chartId, i, subWindow);
|
||||
bool isExists = StringFind(iObjectName, suggest) >= 0;
|
||||
if (isExists) {
|
||||
if (isExists)
|
||||
{
|
||||
//
|
||||
result = iObjectName;
|
||||
break;
|
||||
@@ -1000,7 +1003,16 @@ bool DrawRectangle(
|
||||
|
||||
//
|
||||
// Create a rectangle by the given coordinates ...
|
||||
result = ObjectCreate(chartID, name, OBJ_RECTANGLE, subWindow, time1, price1, time2, price2);
|
||||
result = ObjectCreate(
|
||||
chartID,
|
||||
name,
|
||||
OBJ_RECTANGLE,
|
||||
subWindow,
|
||||
time1,
|
||||
price1,
|
||||
time2,
|
||||
price2 //
|
||||
);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
|
||||
+874
-164
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user