Initial Commit ...
This commit is contained in:
@@ -0,0 +1,203 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL4 Global Library
|
||||
// ---------------------------------------------
|
||||
// saherelm useful tools and definitions ...
|
||||
//
|
||||
//
|
||||
// Maintainer:
|
||||
// ------------
|
||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||
//
|
||||
//////////////////////////////////////////////////////
|
||||
#property library
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://www.saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property strict
|
||||
|
||||
|
||||
//
|
||||
// Includes Logger library ...
|
||||
#include "../Libraries/x-saherelm.log.lib.mq4"
|
||||
|
||||
//
|
||||
// Includes Drawing library ...
|
||||
#include "../Libraries/x-saherelm.draw.lib.mq4"
|
||||
|
||||
//
|
||||
// START Functions ...
|
||||
//
|
||||
|
||||
//
|
||||
// Determines current working is New Bar or not ...
|
||||
bool IsNewBar() {
|
||||
//
|
||||
static datetime lastbar;
|
||||
datetime curbar = (datetime)SeriesInfoInteger(_Symbol, _Period, SERIES_LASTBAR_DATE);
|
||||
|
||||
//
|
||||
if(lastbar != curbar) {
|
||||
//
|
||||
lastbar = curbar;
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// this function check crossing up two Buffers ...
|
||||
bool IsCrossedOver(
|
||||
double &arr1[],
|
||||
double &arr2[],
|
||||
int index1,
|
||||
int index2 = -1
|
||||
) {
|
||||
//
|
||||
// Normalize Index 2 Value ...
|
||||
if (index2 < 0) {
|
||||
index2 = index1 + 1;
|
||||
}
|
||||
|
||||
//
|
||||
bool result = (arr1[index1] > arr2[index1]) && !(arr1[index2] > arr2[index2]);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// this function check crossing down two Buffers ...
|
||||
bool IsCrossedUnder(
|
||||
double &arr1[],
|
||||
double &arr2[],
|
||||
int index1,
|
||||
int index2 = -1
|
||||
) {
|
||||
//
|
||||
// Normalize Index 2 Value ...
|
||||
if (index2 < 0) {
|
||||
index2 = index1 + 1;
|
||||
}
|
||||
|
||||
//
|
||||
bool result = (arr1[index1] < arr2[index1]) && !(arr1[index2] < arr2[index2]);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Convert points to Actual Point ...
|
||||
double PointsToDouble(int points) {
|
||||
//
|
||||
double result = points * _Point;
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Converts Pips to Points ...
|
||||
int PipsToPoints(int pips) {
|
||||
//
|
||||
int result = pips * ((_Digits == 3 || _Digits == 5) ? 10 : 1);
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Converts Pips to Double ...
|
||||
double PipsToDouble(int pips) {
|
||||
//
|
||||
double result = PointsToDouble(PipsToPoints(pips));
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Multiply two Buffer ...
|
||||
void MultiplyBuffer(
|
||||
const double &buffer1[],
|
||||
const double &buffer2[],
|
||||
double &result[]
|
||||
) {
|
||||
//
|
||||
int buffer1Size = ArraySize(buffer1);
|
||||
int buffer2Size = ArraySize(buffer2);
|
||||
|
||||
//
|
||||
int size = MathMax(buffer1Size, buffer2Size);
|
||||
|
||||
//
|
||||
ArrayResize(result, size);
|
||||
ArrayFill(result, 0, size, 0.0);
|
||||
|
||||
//
|
||||
for (int i = 0; i < size; i++) {
|
||||
result[i] = buffer1[i] * buffer2[i];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate SMA ...
|
||||
double iSMA(
|
||||
const double &src[],
|
||||
const int len = 7,
|
||||
const int bar_index = 0
|
||||
) {
|
||||
//
|
||||
double result = 0.0;
|
||||
|
||||
//
|
||||
for (int i = bar_index + (len - 1); i >= bar_index; i--) {
|
||||
result += src[bar_index] / len;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Calculat VMA ...
|
||||
double iVWMA(
|
||||
const double &src[],
|
||||
const long &volume[],
|
||||
const int len = 7,
|
||||
const int bar_index = 0
|
||||
) {
|
||||
//
|
||||
double result = 0.0;
|
||||
|
||||
//
|
||||
// double volume ...
|
||||
int volumeSize = ArraySize(volume);
|
||||
double dVolume[];
|
||||
ArrayResize(dVolume, volumeSize);
|
||||
ArrayFill(dVolume, 0, volumeSize, 0.0);
|
||||
for (int i = 0; i < volumeSize; i++) {
|
||||
dVolume[i] = volume[i] * 1.0;
|
||||
};
|
||||
|
||||
|
||||
//
|
||||
double multipliedSourceVolume[];
|
||||
MultiplyBuffer(
|
||||
src,
|
||||
dVolume,
|
||||
multipliedSourceVolume
|
||||
);
|
||||
|
||||
//
|
||||
result = iSMA(
|
||||
multipliedSourceVolume,
|
||||
len
|
||||
) / iSMA(
|
||||
dVolume,
|
||||
len
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
//
|
||||
// END Functions ...
|
||||
//
|
||||
@@ -0,0 +1,271 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL4 Models Global Library
|
||||
// ---------------------------------------------
|
||||
// saherelm useful tools and definitions ...
|
||||
//
|
||||
//
|
||||
// Maintainer:
|
||||
// ------------
|
||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||
//
|
||||
//////////////////////////////////////////////////////
|
||||
#property library
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://www.saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// Start Models ...
|
||||
//
|
||||
|
||||
//
|
||||
// Used Indicators List ...
|
||||
const string slIndicatorName = "x-saherelm.sl";
|
||||
const string tpIndicatorName = "x-saherelm.tp";
|
||||
const string maIndicatorName = "x-saherelm.ma";
|
||||
const string xmaIndicatorName = "x-saherelm.xma";
|
||||
const string oscIndicatorName = "x-saherelm.osc";
|
||||
const string sslIndicatorName = "x-saherelm.ssl";
|
||||
const string pcrtIndicatorName = "x-saherelm.pcrt";
|
||||
const string volumeIndicatorName = "x-saherelm.volume";
|
||||
const string zigZagIndicatorName = "x-saherelm.zigzag";
|
||||
|
||||
//
|
||||
// Direction ...
|
||||
enum X_DIRECTION {
|
||||
X_UP,
|
||||
X_DOWN
|
||||
};
|
||||
|
||||
//
|
||||
// these are different signal types ...
|
||||
enum X_SIGNAL_TYPE {
|
||||
X_NONE,
|
||||
X_LONG,
|
||||
X_SHORT,
|
||||
};
|
||||
|
||||
//
|
||||
// Define an Specific Arrow Code enum ...
|
||||
enum X_ARROW_CODE {
|
||||
//
|
||||
X_ARROW_UP = OBJ_ARROW_UP,
|
||||
X_ARROW_DOWN = OBJ_ARROW_DOWN,
|
||||
//
|
||||
X_ARROW_THUMB_UP = OBJ_ARROW_THUMB_UP,
|
||||
X_ARROW_THUMB_DOWN = OBJ_ARROW_THUMB_DOWN,
|
||||
//
|
||||
X_ARROW_BUY = OBJ_ARROW_BUY,
|
||||
X_ARROW_SELL = OBJ_ARROW_SELL,
|
||||
//
|
||||
X_ARROW_STOP = OBJ_ARROW_STOP,
|
||||
X_ARROW_CHECK = OBJ_ARROW_CHECK,
|
||||
//
|
||||
X_ARROW_LEFT_PRICE = OBJ_ARROW_LEFT_PRICE,
|
||||
X_ARROW_RIGHT_PRICE = OBJ_ARROW_RIGHT_PRICE,
|
||||
};
|
||||
|
||||
//
|
||||
// Pricae Action Theory Candle Types ...
|
||||
enum X_P_CANDLE_TYPE {
|
||||
X_P_CT_BULLISH = 1,
|
||||
X_P_CT_NEUTRAL = 2,
|
||||
X_P_CT_BEARISH = 3,
|
||||
};
|
||||
|
||||
//
|
||||
// Candlestick Theory Candle Types ...
|
||||
enum X_CANDLE_TYPE {
|
||||
X_CT_DOJI = 1,
|
||||
X_CT_EVENING_STAR = 2,
|
||||
X_CT_MORNING_STAR = 3,
|
||||
X_CT_SHOOTING_STAR = 4,
|
||||
X_CT_HAMMER = 5,
|
||||
X_CT_INVERTED_HAMMER = 6,
|
||||
X_CT_BEARISH_HARAMI = 7,
|
||||
X_CT_BULLISH_HARAMI = 8,
|
||||
X_CT_BEARISH_ENGULFING = 9,
|
||||
X_CT_BULLISH_ENGULFING = 10,
|
||||
X_CT_PRICE_LINE = 11,
|
||||
X_CT_BULLISH_BELT = 12,
|
||||
X_CT_BULLISH_KICKER = 13,
|
||||
X_CT_BEARISH_KICKER = 14,
|
||||
X_CT_HANGING_MAN = 15,
|
||||
X_CT_DARK_CLOUD_COVER = 16
|
||||
};
|
||||
|
||||
//
|
||||
// we model OSC Return Data ...
|
||||
struct XOSCState {
|
||||
//
|
||||
double fastOSC;
|
||||
double fastOSCPrev;
|
||||
|
||||
//
|
||||
double slowOSC;
|
||||
double slowOSCPrev;
|
||||
|
||||
//
|
||||
double powerOSC;
|
||||
double powerOSCPrev;
|
||||
|
||||
//
|
||||
double varOSC;
|
||||
double varOSCPrev;
|
||||
|
||||
//
|
||||
double tanFSOSC;
|
||||
};
|
||||
|
||||
//
|
||||
// we Model MACD State ...
|
||||
struct XMACDState {
|
||||
double MACD;
|
||||
double signal;
|
||||
};
|
||||
|
||||
//
|
||||
// model ssl State ...
|
||||
struct XSSLState {
|
||||
//
|
||||
double sslUp;
|
||||
double sslUpPrev;
|
||||
|
||||
//
|
||||
double sslDown;
|
||||
double sslDownPrev;
|
||||
};
|
||||
|
||||
//
|
||||
// Model Volume Indicator Result ...
|
||||
struct XVolumeState {
|
||||
double buyVolume;
|
||||
double sellVolume;
|
||||
};
|
||||
|
||||
//
|
||||
// Signal Info Model ...
|
||||
struct XSignalInfo {
|
||||
//
|
||||
bool hasSignal;
|
||||
//
|
||||
bool hasLongSignal;
|
||||
bool hasShortSignal;
|
||||
};
|
||||
|
||||
//
|
||||
// Model SLs as this ...
|
||||
struct XSLInfo {
|
||||
double longSL;
|
||||
double shortSL;
|
||||
};
|
||||
|
||||
//
|
||||
// Model TPs as this ...
|
||||
struct XTPInfo {
|
||||
double longTP;
|
||||
double shortTP;
|
||||
};
|
||||
|
||||
//
|
||||
// ZigZag State ...
|
||||
struct XZigZagState {
|
||||
//
|
||||
double zigZag;
|
||||
datetime zigZagTime;
|
||||
|
||||
//
|
||||
double zigZagPrev;
|
||||
datetime zigZagPrevTime;
|
||||
|
||||
//
|
||||
double low;
|
||||
int lowBarIndex;
|
||||
datetime lowTime;
|
||||
|
||||
//
|
||||
double high;
|
||||
int highBarIndex;
|
||||
datetime highTime;
|
||||
|
||||
//
|
||||
double delta;
|
||||
|
||||
//
|
||||
bool isWaitForTrendUp;
|
||||
bool isWaitForTrendDown;
|
||||
|
||||
//
|
||||
bool isLowIsLastLow;
|
||||
bool isHighIsLastHigh;
|
||||
};
|
||||
|
||||
//
|
||||
// we Model each signals as this type ...
|
||||
struct XSignal {
|
||||
int id;
|
||||
X_SIGNAL_TYPE type;
|
||||
double tp;
|
||||
double sl;
|
||||
string symbol;
|
||||
datetime time;
|
||||
double entryPrice;
|
||||
};
|
||||
|
||||
//
|
||||
// this is Signal Request Response model ...
|
||||
struct XSignalRequest {
|
||||
bool hasSignal;
|
||||
X_SIGNAL_TYPE type;
|
||||
XSignal signal;
|
||||
};
|
||||
|
||||
//
|
||||
// State of Market based on XMA ...
|
||||
struct XMAState {
|
||||
//
|
||||
double xmaFast;
|
||||
double xmaFastPrev;
|
||||
|
||||
//
|
||||
double xmaSlow;
|
||||
double xmaSlowPrev;
|
||||
|
||||
//
|
||||
bool isBullishTrend;
|
||||
bool isBearishTrend;
|
||||
|
||||
//
|
||||
double trendPower;
|
||||
|
||||
//
|
||||
double xmaHigh;
|
||||
double xmaHighPrev;
|
||||
|
||||
//
|
||||
double xmaLow;
|
||||
double xmaLowPrev;
|
||||
|
||||
//
|
||||
bool isFlowUp;
|
||||
bool isFlowDown;
|
||||
|
||||
//
|
||||
double xmaMark;
|
||||
|
||||
//
|
||||
double xmaMid;
|
||||
double xmaMidPrev;
|
||||
};
|
||||
|
||||
//
|
||||
// Define an enum for Detection Rules on Candlestick Indicator ...
|
||||
enum X_CD_DETECTION_RULES {
|
||||
X_PRICE_50_SMA,
|
||||
X_PRICE_50_200_SMA
|
||||
};
|
||||
//
|
||||
// End Models ...
|
||||
//
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,138 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL4 Models Global Library
|
||||
// ---------------------------------------------
|
||||
// saherelm useful tools and definitions ...
|
||||
//
|
||||
//
|
||||
// Maintainer:
|
||||
// ------------
|
||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||
//
|
||||
//////////////////////////////////////////////////////
|
||||
#property library
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://www.saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// Start Models ...
|
||||
//
|
||||
|
||||
//
|
||||
// Used Indicators List ...
|
||||
const string xmaIndicatorName = "x-saherelm.xma";
|
||||
|
||||
//
|
||||
// these are different signal types ...
|
||||
enum X_SIGNAL_TYPE {
|
||||
X_NONE,
|
||||
X_LONG,
|
||||
X_SHORT,
|
||||
};
|
||||
|
||||
//
|
||||
// we Model each signals as this type ...
|
||||
struct XSignal {
|
||||
int id;
|
||||
X_SIGNAL_TYPE type;
|
||||
double tp;
|
||||
double sl;
|
||||
string symbol;
|
||||
datetime time;
|
||||
double entryPrice;
|
||||
};
|
||||
|
||||
//
|
||||
// this is Signal Request Response model ...
|
||||
struct XSignalRequest {
|
||||
bool hasSignal;
|
||||
X_SIGNAL_TYPE type;
|
||||
XSignal signal;
|
||||
};
|
||||
|
||||
//
|
||||
// Define a Model to Represent Snapshot of XMA Indicator ...
|
||||
struct XMAState {
|
||||
//
|
||||
// Short Cycle ...
|
||||
//
|
||||
// FAST ...
|
||||
double scFast;
|
||||
double scFastPrev;
|
||||
|
||||
//
|
||||
// SLOW ...
|
||||
double scSlow;
|
||||
double scSlowPrev;
|
||||
|
||||
//
|
||||
bool isSCTrendUp;
|
||||
bool isSCTrendDown;
|
||||
bool isSCFastCrossOverSlow;
|
||||
bool isSCFastCrossUnderSlow;
|
||||
|
||||
//
|
||||
// Medium Cycle ...
|
||||
//
|
||||
// FAST ...
|
||||
double mcFast;
|
||||
double mcFastPrev;
|
||||
|
||||
//
|
||||
// SLOW ...
|
||||
double mcSlow;
|
||||
double mcSlowPrev;
|
||||
|
||||
//
|
||||
bool isMCTrendUp;
|
||||
bool isMCTrendDown;
|
||||
bool isMCFastCrossOverSlow;
|
||||
bool isMCFastCrossUnderSlow;
|
||||
|
||||
//
|
||||
// Long Cycle ...
|
||||
//
|
||||
// FAST ...
|
||||
double lcFast;
|
||||
double lcFastPrev;
|
||||
|
||||
//
|
||||
// SLOW ...
|
||||
double lcSlow;
|
||||
double lcSlowPrev;
|
||||
|
||||
//
|
||||
bool isLCTrendUp;
|
||||
bool isLCTrendDown;
|
||||
bool isLCFastCrossOverSlow;
|
||||
bool isLCFastCrossUnderSlow;
|
||||
|
||||
//
|
||||
// MIDDLEAGE ...
|
||||
double marketMiddleage;
|
||||
double marketMiddleagePrev;
|
||||
|
||||
//
|
||||
// Hot Cross Points ...
|
||||
//
|
||||
bool isHotCrossOver;
|
||||
bool isHottestCrossOver;
|
||||
|
||||
//
|
||||
bool isHotCrossUnder;
|
||||
bool isHottestCrossUnder;
|
||||
|
||||
//
|
||||
// Signal ...
|
||||
bool hasSignal;
|
||||
bool hasLongSignal;
|
||||
bool hasShortSignal;
|
||||
|
||||
//
|
||||
XSignal signal;
|
||||
};
|
||||
//
|
||||
// End Models ...
|
||||
//
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,84 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center XMMA Models Library
|
||||
// ---------------------------------------------
|
||||
// contains all data model definitions related to
|
||||
// an specific Indicator/Oscillator/Expert ...
|
||||
//
|
||||
//
|
||||
// Maintainer:
|
||||
// ------------
|
||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||
//
|
||||
//////////////////////////////////////////////////////
|
||||
#property library
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://www.saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property description "SaherElm XMMA Models Library"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// START Models ...
|
||||
//
|
||||
|
||||
//
|
||||
// Used Indicators List ...
|
||||
const string xmmaIndicatorName = "x-saherelm.xmma";
|
||||
|
||||
//
|
||||
// these are different signal types ...
|
||||
enum X_SIGNAL_TYPE {
|
||||
X_NONE,
|
||||
X_LONG,
|
||||
X_SHORT,
|
||||
};
|
||||
|
||||
//
|
||||
// we Model each signals as this type ...
|
||||
struct XSignal {
|
||||
int id;
|
||||
X_SIGNAL_TYPE type;
|
||||
double tp;
|
||||
double sl;
|
||||
string symbol;
|
||||
datetime time;
|
||||
double entryPrice;
|
||||
};
|
||||
|
||||
//
|
||||
// this is Signal Request Response model ...
|
||||
struct XSignalRequest {
|
||||
bool hasSignal;
|
||||
X_SIGNAL_TYPE type;
|
||||
XSignal signal;
|
||||
};
|
||||
|
||||
//
|
||||
struct XMMAState {
|
||||
//
|
||||
double fast;
|
||||
double fastPrev;
|
||||
|
||||
//
|
||||
double slow;
|
||||
double slowPrev;
|
||||
|
||||
//
|
||||
double mid;
|
||||
|
||||
//
|
||||
double longSL;
|
||||
double shortSL;
|
||||
|
||||
//
|
||||
bool isCrossOver;
|
||||
bool isCrossUnder;
|
||||
|
||||
//
|
||||
bool isTrendUp;
|
||||
bool isTrendDown;
|
||||
};
|
||||
//
|
||||
// END Models ...
|
||||
//
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user