Files
MQL5Data/Experts/x-saherelm.xpoi.test.ea.mq5
T

237 lines
5.1 KiB
Plaintext

//+------------------------------------------------------------------+
//| x-saherelm.xpoi.test.ea.mq5 |
//| SaherElm IT Center |
//| https://www.saherelm.ir |
//+------------------------------------------------------------------+
#property copyright "SaherElm IT Center"
#property link "https://www.saherelm.ir"
#property version "1.00"
//
// #include "../Classes/x-saherelm.x-poi.class.mq5"
// #include "../Classes/x-saherelm.x-poi.drawer.class.mq5"
// #include "../Libraries/x-saherelm.x-poi.extensions.lib.mq5"
// #include "../Libraries/x-saherelm.x-poi.state.lib.mq5"
//
#include "../Classes/x-saherelm.x-bar.analyser.class.mq5"
//
// Global Variables ...
//
// XCPOIDrawer *mPOIDrawer;
//
// XCPOIDetector *mPOIDetector;
XBarTracker mBarTracker;
XCBarAnalyser *mBarAnalyser;
//
bool useDetector = false;
bool useBarAnalyser = true;
//+------------------------------------------------------------------+
//| Expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
//
// mPOIDetector = new XCPOIDetector(
// _Symbol,
// _Period //
// );
//
// mPOIDrawer = new XCPOIDrawer();
//
mBarAnalyser = new XCBarAnalyser();
//
mBarTracker.Init(
_Symbol,
_Period //
);
//
return (INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
//| Expert deinitialization function |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
{
//
// ZeroMemory(mPOIDrawer);
// ZeroMemory(mPOIDetector);
ZeroMemory(mBarAnalyser);
}
//+------------------------------------------------------------------+
//| Expert tick function |
//+------------------------------------------------------------------+
void OnTick()
{
//
DetectBarAnalyser();
//
DetectPOIState();
}
//+------------------------------------------------------------------+
//| Custom Functions |
//+------------------------------------------------------------------+
/**
* Detect POI(s) Using Bar Analyser Class ...
*/
void DetectBarAnalyser()
{
//
if (!useBarAnalyser)
{
return;
}
//
if (!mBarTracker.IsNewBar())
{
return;
}
//
XOHCL zBar;
bool isInited = zBar.Init(
_Symbol,
_Period,
0 //
);
if (!isInited)
{
//
zBar.Clean();
return;
}
//
XOHCL cBar;
isInited = zBar.GetPreviousBar(cBar);
if (!isInited)
{
//
zBar.Clean();
cBar.Clean();
return;
}
//
// Check Big Change in Price ...
ENUM_X_DIRECTION dir;
bool isBigChange = mBarAnalyser.IsBigChange(
zBar, // Bar ...
dir, // Change Direction ...
X_PRICE_CLOSE, // Price Change Type ...
true, // Force Use Body for Range Calculation ...
1.0 // Range Extend Multiplier ...
);
if (isBigChange)
{
// Print("Big Price Change Detected: ", ToString(dir));
}
//
// Check Big Change in Price ...
bool isSpike = mBarAnalyser.IsSpike(
zBar, // Bar ...
dir, // Change Direction ...
X_PRICE_CLOSE, // Price Change Type ...
true, // Force Use Body for Range Calculation ...
1.0, // Range Extend Multiplier ...
3 // Same Bars ...
);
if (isSpike)
{
// Print("Spike Detected: ", ToString(dir));
}
//
// Check Doji Pattern ...
bool isDoji = mBarAnalyser.IsDoji(
cBar,
dir //
);
if (isDoji)
{
Print(ToString(dir), " Doji Detected ...");
}
//
// Check Hammer Pattern ...
bool isHammer = mBarAnalyser.IsHammer(
cBar,
dir //
);
if (isHammer)
{
Print(ToString(dir), " Hammer Detected ...");
}
//
// Check Engulf Pattern ...
bool isEngulfed = mBarAnalyser.IsEngulfed(
cBar,
dir //
);
if (isEngulfed)
{
Print(ToString(dir), " Engulfed Detected ...");
}
//
// Check Momentum Pattern ...
bool isMomentum = mBarAnalyser.IsMomentum(
cBar,
dir //
);
if (isMomentum)
{
Print(ToString(dir), " Momentum Detected ...");
}
//
// Check Pullback Pattern ...
bool isPullback = mBarAnalyser.IsPullback(
cBar,
dir //
);
if (isMomentum)
{
Print(ToString(dir), " Pullback Detected ...");
}
//
// Cleanup Resources ...
//
zBar.Clean();
cBar.Clean();
}
/**
* Detect POI(s) Using POIDetector Class ...
*/
void DetectPOIState()
{
//
if (!useDetector)
{
return;
}
}
//
//+------------------------------------------------------------------+