refactor libraries issues for new version compiling ...

This commit is contained in:
2025-08-05 16:56:38 +03:30
parent 6db303b53f
commit f260ccc8de
21 changed files with 636 additions and 4026 deletions
-506
View File
@@ -1,506 +0,0 @@
/**
* XColor Tools Module ...
* a module for handle colorify text contents in node js ...
*
* Maintainer
*
* Hadi Khazaee Asl <https://saherelm.ir> (hadi_khazaee_asl@yahoo.com)
*/
//
//#region Module Imports ...
const XValueTools = require("./x-value.tools");
//#endregion
//
//#region Constants ...
/**
* these are available style which can applied to an string ...
*/
const AVAILABLE_STYLES = {
//
Bold: "\x1b[1m",
Dim: "\x1b[2m",
Underlined: "\x1b[4m",
Blink: "\x1b[5m",
ReverseFandB: "\x1b[7m",
Hidden: "\x1b[8m",
//
// Commonly used for reset all Styles ...
Reset: "\x1b[0m"
};
/**
* these are available foreground colors which can applied to an string ...
*/
const AVAILABLE_FOREGROUND_COLORS = {
Default: "\x1b[39m",
Black: "\x1b[30m",
Red: "\x1b[31m",
Green: "\x1b[32m",
Yellow: "\x1b[33m",
Blue: "\x1b[34m",
Magenta: "\x1b[35m",
Cyan: "\x1b[36m",
LightGray: "\x1b[37m",
DarkGray: "\x1b[90m",
LightRed: "\x1b[91m",
LightGreen: "\x1b[92m",
LightYellow: "\x1b[93m",
LightBlue: "\x1b[94m",
LightMagenta: "\x1b[95m",
LightCyan: "\x1b[96m",
White: "\x1b[97m",
};
/**
* these are available background colors which can applied to an string ...
*/
const AVAILABLE_BACKGROUND_COLORS = {
Default: "\x1b[49m",
Black: "\x1b[40m",
Red: "\x1b[41m",
Green: "\x1b[42m",
Yellow: "\x1b[43m",
Blue: "\x1b[44m",
Magenta: "\x1b[45m",
Cyan: "\x1b[46m",
LightGray: "\x1b[47m",
DarkGray: "\x1b[100m",
LightRed: "\x1b[101m",
LightGreen: "\x1b[102m",
LightYellow: "\x1b[103m",
LightBlue: "\x1b[104m",
LightMagenta: "\x1b[105m",
LightCyan: "\x1b[106m",
White: "\x1b[107m",
};
/**
* these are available style names, which exports from module and
* users can use them ...
*/
const STYLE_NAMES = {
Bold: "Bold",
Dim: "Dim",
Underlined: "Underlined",
Blink: "Blink",
ReverseFandB: "ReverseFandB",
Hidden: "Hidden",
Reset: "Reset",
};
/**
* these are available color names, which exports from module and
* users can use them ...
*/
const COLOR_NAMES = {
Default: "Default",
Black: "Black",
Red: "Red",
Green: "Green",
Yellow: "Yellow",
Blue: "Blue",
Magenta: "Magenta",
Cyan: "Cyan",
LightGray: "LightGray",
DarkGray: "DarkGray",
LightRed: "LightRed",
LightGreen: "LightGreen",
LightYellow: "LightYellow",
LightBlue: "LightBlue",
LightMagenta: "LightMagenta",
LightCyan: "LightCyan",
White: "White",
};
//#endregion
//
//#region Actions ...
/**
* apply specified style and color on a content ...
*
* @param {string} content specified content for styling ...
* @param {string} color specific color name for using to styling ...
* @param {string} style soecufic style name to use ...
* @param {boolean} toForeground apply specified color as foreground ...
* @param {boolean} toBackground apply specified color as background ...
* @returns {string} styled content ...
*/
function apply(
content,
color,
style,
toForeground = true,
toBackground = false
) {
//
let result = content;
//
// Validate Arg ...
if (!XValueTools.isValidArg(content)) {
return result;
}
//
// Detect and Validate Style and Apply it ...
let eStyle = AVAILABLE_STYLES[style];
if (XValueTools.isValidArg(eStyle)) {
result = `${eStyle}${result}${AVAILABLE_STYLES.Reset}`;
}
//
// Detect and Validate Foreground Color and Apply it ...
let eFColor = AVAILABLE_FOREGROUND_COLORS[color];
if (
!!toForeground
&& XValueTools.isValidArg(eFColor)
) {
result = `${eFColor}${result}${AVAILABLE_STYLES.Reset}`;
}
//
// Detect and Validate Background Color and Apply it ...
let eBColor = AVAILABLE_BACKGROUND_COLORS[color];
if (
!!toBackground
&& XValueTools.isValidArg(eBColor)
) {
result = `${eBColor}${result}${AVAILABLE_STYLES.Reset}`;
}
}
/**
* apply specific style on a content ...
*
* @param {string} content specific content which going to styled ...
* @param {string} style a member of STYLE_NAMES which specified that which style going to applied to content ...
* @returns {string} styled content ...
*/
function applyStyle(content, style) {
//
// Validate Arg ...
if (!XValueTools.isValidArg(content)) {
return content;
}
//
let eStyle = AVAILABLE_STYLES[style];
if (eStyle === undefined) {
return content;
}
//
return `${eStyle}${content}${AVAILABLE_STYLES.Reset}`;
}
/**
* apply specific foreground color on a content ...
*
* @param {string} content specific content which going to colorified ...
* @param {string} color a member of COLOR_NAMES which specified that which color going to applied to content ...
* @returns {string} colorified content ...
*/
function applyForegroundColor(content, color) {
//
// Validate Arg ...
if (!XValueTools.isValidArg(content)) {
return content;
}
//
let eColor = AVAILABLE_FOREGROUND_COLORS[color];
if (eColor === undefined) {
return content;
}
//
return `${eColor}${content}${AVAILABLE_STYLES.Reset}`;
}
/**
* apply specific background color on a content ...
*
* @param {string} content specific content which going to colorified ...
* @param {string} color a member of COLOR_NAMES which specified that which color going to applied to content ...
* @returns {string} colorified content ...
*/
function applyBackgroundColor(content, color) {
//
// Validate Arg ...
if (!XValueTools.isValidArg(content)) {
return content;
}
//
let eColor = AVAILABLE_BACKGROUND_COLORS[color];
if (eColor === undefined) {
return content;
}
//
return `${eColor}${content}${AVAILABLE_STYLES.Reset}`;
}
/**
* generate style and color applier expression ...
*
* @param {string} color specific color name for using to styling ...
* @param {string} style soecufic style name to use ...
* @param {boolean} reset close applier string by reset styles ...
* @param {boolean} toForeground apply specified color as foreground ...
* @param {boolean} toBackground apply specified color as background ...
* @returns {string} style and color applier string ...
*/
function getApplier(
style = "",
color = "",
reset = false,
toForeground = true,
toBackground = false
) {
//
let result = "";
//
// Detect and Validate Style and Apply it ...
let eStyle = AVAILABLE_STYLES[style];
if (XValueTools.isValidArg(eStyle)) {
result = `${eStyle}`;
}
//
// Detect and Validate Foreground Color and Apply it ...
let eFColor = AVAILABLE_FOREGROUND_COLORS[color];
if (
!!toForeground
&& XValueTools.isValidArg(eFColor)
) {
result = `${eFColor}`;
}
//
// Detect and Validate Background Color and Apply it ...
let eBColor = AVAILABLE_BACKGROUND_COLORS[color];
if (
!!toBackground
&& XValueTools.isValidArg(eBColor)
) {
result = `${eBColor}`;
}
//
if (
!!reset &&
result.length > 0
) {
result = `${result}${AVAILABLE_STYLES.Reset}`;
}
//
return result;
}
/**
* generate style applier expression ...
*
* @param {string} style soecufic style name to use ...
* @param {boolean} reset close applier string by reset styles ...
* @returns {string} style applier string ...
*/
function getStyleApplier(
style = "",
reset = false
) {
//
let result = "";
//
// Detect and Validate Style and Apply it ...
let eStyle = AVAILABLE_STYLES[style];
if (XValueTools.isValidArg(eStyle)) {
result = `${eStyle}`;
}
//
if (
!!reset &&
result.length > 0
) {
result = `${result}${AVAILABLE_STYLES.Reset}`;
}
//
return result;
}
/**
* generate color applier expression ...
*
* @param {string} color specific color name for using to styling ...
* @param {boolean} reset close applier string by reset styles ...
* @param {boolean} toForeground apply specified color as foreground ...
* @param {boolean} toBackground apply specified color as background ...
* @returns {string} color applier string ...
*/
function getColorApplier(
color = "",
reset = false,
toForeground = true,
toBackground = false
) {
//
let result = "";
//
// Detect and Validate Foreground Color and Apply it ...
let eFColor = AVAILABLE_FOREGROUND_COLORS[color];
if (
!!toForeground
&& XValueTools.isValidArg(eFColor)
) {
result = `${eFColor}`;
}
//
// Detect and Validate Background Color and Apply it ...
let eBColor = AVAILABLE_BACKGROUND_COLORS[color];
if (
!!toBackground
&& XValueTools.isValidArg(eBColor)
) {
result = `${eBColor}`;
}
//
if (
!!reset &&
result.length > 0
) {
result = `${result}${AVAILABLE_STYLES.Reset}`;
}
//
return result;
}
/**
* colorified specific content ...
*
* @param {string} content specified content for styling ...
* @param {string} color specific color name for using to styling ...
* @param {boolean} toForeground apply specified color as foreground ...
* @param {boolean} toBackground apply specified color as background ...
* @returns {string}
*/
function colorifyContent(
content = "",
color = "",
toForeground = true,
toBackground = false
) {
//
let result = content;
//
if (!XValueTools.isValidArg(content)) {
return result;
}
//
// Finde Colors ...
//
// Detect and Validate Foreground Color and Apply it ...
let eFColor = AVAILABLE_FOREGROUND_COLORS[color];
if (
!!toForeground
&& XValueTools.isValidArg(eFColor)
) {
result = `${eFColor}${result}`;
}
//
// Detect and Validate Background Color and Apply it ...
let eBColor = AVAILABLE_BACKGROUND_COLORS[color];
if (
!!toBackground
&& XValueTools.isValidArg(eBColor)
) {
result = `${eBColor}${result}`;
}
//
if (
result.length > 0
&& (
XValueTools.isValidArg(eFColor) ||
XValueTools.isValidArg(eBColor)
)
) {
result = `${result}${AVAILABLE_STYLES.Reset}`;
}
//
return result;
}
/**
* apply style on specific content ...
*
* @param {string} content specified content for styling ...
* @param {string} style soecufic style name to use ...
* @returns {string}
*/
function stylifiyContent(
content = "",
style = "",
) {
//
let result = content;
//
if (!XValueTools.isValidArg(content)) {
return result;
}
//
// Detect and Validate Style and Apply it ...
let eStyle = AVAILABLE_STYLES[style];
if (XValueTools.isValidArg(eStyle)) {
result = `${eStyle}${result}`;
}
//
if (
result.length > 0
&& XValueTools.isValidArg(eStyle)
) {
result = `${result}${AVAILABLE_STYLES.Reset}`;
}
//
return result;
}
//#endregion
//
//#region Module Exports ...
module.exports = {
//
STYLE_NAMES,
COLOR_NAMES,
//
apply,
applyStyle,
getApplier,
getColorApplier,
getStyleApplier,
colorifyContent,
stylifiyContent,
applyForegroundColor,
applyBackgroundColor,
}
//#endregion
-887
View File
@@ -1,887 +0,0 @@
/**
* XFile Tools Module ...
* a module for handle all file/folder manipulating task in node js ...
*
* Maintainer
*
* Hadi Khazaee Asl <https://saherelm.ir> (hadi_khazaee_asl@yahoo.com)
*/
//
//#region Module Imports ...
const fs = require('fs');
const os = require('os');
const Path = require('path');
const http = require('http');
const https = require('https');
const XValueTools = require('./x-value.tools');
//#endregion
//
//#region Constants ...
/**
* current os path separators ...
*/
const PathSeparator = Path.sep;
/**
* current directory ...
*/
const CurrentDir = __dirname;
//#endregion
//
//#region Actions ...
//
//#region Global ...
/**
* retrieve a path status ...
*
* @param {string} path a path value to check ...
* @returns an stat object ...
*/
function getStatus(path = '') {
//
if (!XValueTools.isValidArg(path)) {
return undefined;
}
//
return fs.statSync(path);
}
/**
* retrieve user's Home path ...
*
* @returns {string} a path ...
*/
function getHomePath() {
return os.homedir();
}
//#endregion
//
//#region Path ...
/**
* retrieve the base name of specific address path ...
*
* @param {string} path address of file or folder ...
* @returns string ...
*/
function basename(path = '') {
//
if (!XValueTools.isValidArg(path)) {
return '';
}
//
const result = Path.basename(path);
return result;
}
/**
* join several path segments together ...
*
* @param {...string} path path params ...
* @returns a joined paths ...
*/
function joinPath(...path) {
return Path.join(...path);
}
/**
* resolve a relative path to absolute ...
*
* @param {string[]} path a path value to check ...
* @returns {string}
*/
function resolvePath(...path) {
return Path.resolve(...path);
}
//#endregion
//
//#region File ...
/**
* determines a path destination is a file or not ...
*
* @param {string} path a path value to check ...
* @returns a boolean value ...
*/
function isFileExists(path = '') {
//
if (!XValueTools.isValidArg(path)) {
return false;
}
//
try {
const stat = getStatus(path);
if (!stat) {
return false;
}
//
return stat.isFile();
} catch {
return false;
}
}
/**
* remove a file ...
*
* @param {string} path a file path ...
* @returns {Promise<boolean>} action done or not ...
*/
function removeFile(path = '') {
return new Promise((resolve) => {
//
if (!isFileExists(path)) {
resolve(false);
}
//
fs.unlink(path, (err) => {
//
if (err) {
resolve(false);
return;
}
//
resolve(true);
});
});
}
/**
* copy a file to destination path ...
*
* @param {string} source source file path ...
* @param {string} dest dest folder path ...
* @returns {Promise<boolean>} action done or not ...
*/
function copyFile(
source = '',
dest = ''
) {
return new Promise((resolve) => {
//
if (
!isFileExists(source) ||
!isDirectoryExists(dest)
) {
resolve(false);
return;
}
//
const destFilePath = Path.join(dest, Path.basename(source));
fs.copyFile(source, destFilePath, (err) => {
//
if (err) {
resolve(false);
return;
}
//
resolve(true);
});
});
}
/**
* reading specified file content ...
*
* @param {string} path a file path ...
* @returns {Promise<string>} file content ...
*/
function readFile(path = '') {
return new Promise((resolve) => {
//
if (!isFileExists(path)) {
resolve('');
return;
}
//
fs.readFile(path, 'utf8', (err, content) => {
//
if (err) {
resolve(undefined);
return;
}
//
resolve(content);
});
});
}
/**
* write content to a file ...
*
* @param {string} path a file path ...
* @param {string} content the content which going to write to the file ...
* @param {bool} overwrite determines file overwrite if exists ...
* @returns {Promise<boolean>} action done or not ...
*/
function writeFile(
path = '',
content = '',
overwrite = true
) {
return new Promise((resolve) => {
//
if (isFileExists(path) && !overwrite) {
//
resolve(false);
return;
}
//
// Normalize Content ...
content = XValueTools.isValidArg(content) ?
content :
'';
//
fs.writeFile(path, content, (err) => {
//
if (err) {
//
resolve(false);
return;
}
//
resolve(true);
});
});
}
/**
* create a file ...
*
* @param {string} path file path ...
* @param {string} fileName file name ...
* @returns {Promise<boolean>} action done or not ...
*/
function createFile(
path = '',
fileName = ''
) {
return new Promise((resolve) => {
//
const filePath = Path.join(path, fileName);
if (
isFileExists(filePath) ||
!XValueTools.isValidArg(path) ||
!XValueTools.isValidArg(fileName)
) {
//
resolve(false);
return;
}
//
fs.writeFile(filePath, '', (err) => {
//
if (err) {
//
resolve(false);
return;
}
//
resolve(true);
});
});
}
/**
* remove a file name extension ...
*
* @param {string} name
* @returns {string} name without extension ...
*/
function removeFileExtension(name = '') {
return name.substring(0, name.lastIndexOf('.')) || name;
}
/**
* retrieve a file extension ...
*
* @param {string} path a path which locate a file ...
* @returns {string}
*/
function getFileExtension(path = '') {
//
let result = "";
//
// Validate Arg ...
if (
!XValueTools.isValidArg(path)
|| !isFileExists(path)
) {
return result;
}
//
// Retrieve just file name ...
const fileName = basename(path);
result = fileName.replace(
removeFileExtension(fileName),
""
);
//
return result;
}
/**
* retrieve all files list recursively from specific path ...
*
* @param {string} path a source folder path ...
* @param {string[]} extensions which file extensions need to be listed, live empty for all files ...
* @returns {Promise<string[]>}
*/
async function getRecursiveFilesList(
path = "",
extensions = []
) {
//
let result = [];
//
// Validate Args ...
if (
!XValueTools.isValidArg(path)
|| !isDirectoryExists(path)
) {
return result;
}
//
const contents = await getDirectoryContents(path);
for (const item of contents) {
//
const itemPath = joinPath(
path,
item
);
//
const isItemFile = isFileExists(itemPath);
if (isItemFile) {
//
const itemFileExtension = getFileExtension(itemPath);
const isFileInSupportedExtensions =
extensions === undefined || extensions.length === 0
? true
: extensions.includes(itemFileExtension)
;
if (isFileInSupportedExtensions) {
result.push(itemPath);
}
} else if (isDirectoryExists(itemPath)) {
//
const itemPathFiles = await getRecursiveFilesList(itemPath, extensions);
result.push(...itemPathFiles);
}
}
//
return result;
}
/**
* Extract Specific files from a folder and it's content ...
*
* @param {string} path Folder Path ...
* @returns
*/
async function extractFiles(path = "", ext = [], excludeWorkspaceFolders = []) {
//
const result = [];
//
if (!ext || ext.length == 0) {
return result;
}
//
const pathContent = await getDirectoryContents(path);
if (!pathContent || pathContent.length == 0) {
return result;
}
//
// Loop through Content ...
for (const c of pathContent) {
//
// Prepare full path ...
const cPath = joinPath(path, c);
//
// check content path is file or not ...
const isCFile = isFileExists(cPath);
const isCDirectory = isDirectoryExists(cPath);
if (isCFile) {
//
// Check it is MQL file or not ...
const cExt = getFileExtension(cPath);
if (ext.includes(cExt)) {
result.push(cPath);
}
} else if (isCDirectory) {
//
const destFolderName = basename(cPath);
const isExcluded = excludeWorkspaceFolders.includes(destFolderName);
if (isExcluded) {
continue;
}
//
const cFiles = await extractFiles(cPath, ext);
if (cFiles && cFiles.length > 0) {
result.push(...cFiles);
}
}
}
//
return result;
}
//#endregion
//
//#region Directory ...
/**
* create a directory ...
*
* @param {string} path destination path including dir name ...
* @param {boolean} recursive create directories recursively ...
* @returns action done or not ...
*/
function createDirectory(
path = '',
recursive = true
) {
//
let result = false;
//
if (
isDirectoryExists(path) ||
!XValueTools.isValidArg(path)
) {
return false;
}
//
try {
//
fs.mkdirSync(path, { recursive: recursive });
result = true;
return result;
} catch {
return false;
}
}
/**
* remove a directory ...
*
* @param {string} path destination path including dir name ...
* @param {boolean} recursive removes directories recursively ...
* @returns {Promise<boolean>} action done or not ...
*/
function removeDirectory(
path = '',
recursive = false
) {
return new Promise((resolve) => {
//
if (!isDirectoryExists(path)) {
resolve(false);
return;
}
//
fs.rm(path, {
recursive
}, (err) => {
//
if (err) {
resolve(false);
return;
}
//
resolve(true);
});
});
}
/**
* determines a path destination is a directory or not ...
*
* @param {string} path a folder path ...
* @returns represent destnation path is Directory or not ...
*/
function isDirectoryExists(path = '') {
//
if (!XValueTools.isValidArg(path)) {
return false;
}
//
try {
//
const isExists = fs.existsSync(path);
if (!isExists) {
return false;
}
//
const stat = getStatus(path);
if (!stat) {
return false;
}
//
const result = stat.isDirectory();
return result;
} catch {
return false;
}
}
/**
* retrieve a directory content ...
*
* @param {string} path a folder path ...
* @returns {Promise<string[]>} a collection of folder files ...
*/
function getDirectoryContents(path = '') {
return new Promise((resolve) => {
//
if (!isDirectoryExists(path)) {
resolve([]);
return;
}
//
fs.readdir(path, (err, content) => {
//
if (err) {
resolve([]);
return;
}
//
resolve(content);
});
});
}
/**
* retrieve a directory files ...
*
* @param {string} path a folder path ...
* @returns {Promise<string[]>} a collection of folder files ...
*/
function getDirectoryFiles(
path = '',
containsHiddenFiles = false
) {
return new Promise((resolve) => {
//
if (!isDirectoryExists(path)) {
resolve([]);
return;
}
//
fs.readdir(path, (err, content) => {
//
if (err) {
resolve([]);
return;
}
//
if (!containsHiddenFiles) {
content = content.filter(c => !c.startsWith('.'));
}
//
const result = [];
content
.forEach(c => {
//
const cPath = Path.join(path, c);
if (isFileExists(cPath)) {
result.push(c);
}
});
//
resolve(result);
});
});
}
/**
* retrieve a directory folders ...
*
* @param {string} path a folder path ...
* @returns {Promise<string[]>} a collection of folder names ...
*/
function getDirectoryFolders(path = '') {
return new Promise((resolve) => {
//
if (!isDirectoryExists(path)) {
resolve([]);
return;
}
//
fs.readdir(path, (err, content) => {
//
if (err) {
resolve([]);
return;
}
//
const result = [];
content.forEach(c => {
//
const cPath = Path.join(path, c);
if (isDirectoryExists(cPath)) {
result.push(c);
}
});
//
resolve(result);
});
});
}
/**
* copy a folder with all of it's content to dest ...
*
* @param {string} source source folder path ...
* @param {string} dest dest folder path ...
* @returns {Promise<boolean>} action done or not ...
*/
async function copyFolder(
source = '',
dest = ''
) {
//
if (
!isDirectoryExists(source) ||
!XValueTools.isValidArg(dest) ||
!XValueTools.isValidArg(source)
) {
return false;
}
//
const folderName = Path.basename(source);
const destPath = Path.join(dest, folderName);
//
// Create Dest Path folder if not exists ...
if (!isDirectoryExists(destPath)) {
//
let result = createDirectory(destPath, true);
if (!result) {
return false;
}
}
//
// Files ...
const files = await getDirectoryFiles(source);
if (files && files.constructor === Array && files.length > 0) {
//
const filesPromises = files.map(file => copyFile(Path.join(source, file), destPath));
const filesResult = (await Promise.all(filesPromises)).every(r => !!r);
if (!filesResult) {
return false;
}
}
//
// Folders ...
const folders = await getDirectoryFolders(source);
if (folders && folders.constructor === Array && folders.length > 0) {
//
const folderPromises = folders.map(folder => copyFolder(Path.join(source, folder), destPath));
const filesResult = (await Promise.all(folderPromises)).every(r => !!r);
if (!filesResult) {
return false;
}
}
//
return true;
}
//#endregion
//
//#region Downloader ...
/**
* download a file from specific url and store it ...
*
* @param {string} filepath the file name and path which required to put download file on it ...
* @param {string} url the web url for downloading ...
*/
function download(filepath, url) {
//
// Validate Args ...
if (
!XValueTools.isValidArg(url)
|| !XValueTools.isValidURL(url)
|| !XValueTools.isValidArg(filepath)
) {
return;
}
//
var file = fs.createWriteStream(filepath);
//
if (url.startsWith('https:')) {
https.get(url, function (response) {
response.pipe(file);
});
} else if (url.startsWith('http:')) {
http.get(url, function (response) {
response.pipe(file);
});
}
}
//#endregion
//
//#region JSON ...
/**
* read and parse a JSON content from a file ...
*
* @param {string} path source file path ...
* @returns {any}
*/
function readJSON(path = "") {
//
// Validate Args ...
if (!isFileExists(path)) {
return undefined;
}
//
let result = undefined;
try {
result = require(path);
} catch {
result = undefined;
}
//
return result;
}
/**
* write a JSON Object content into a file ...
*
* @param {string} path dest file path ...
* @param {any} content an object which required to write to file ...
* @returns {Promise<boolean>}
*/
async function writeJSON(
path = "",
content = undefined
) {
//
let result = false;
//
// Validate Args ...
if (!XValueTools.isValidArg(path)) {
return result;
}
//
// Normallize Content ...
if (content === undefined) {
content = {};
}
//
const contentString = XValueTools.beautifyJSON(content);
//
result = await writeFile(
path,
contentString,
true
);
//
return result;
}
//#endregion
//#endregion
//
//#region Module Exports ...
module.exports = {
//
CurrentDir,
PathSeparator,
//
getStatus,
getHomePath,
//
basename,
joinPath,
resolvePath,
//
download,
//
readJSON,
writeJSON,
//
copyFile,
readFile,
writeFile,
createFile,
removeFile,
isFileExists,
getFileExtension,
removeFileExtension,
getRecursiveFilesList,
extractFiles,
//
copyFolder,
createDirectory,
removeDirectory,
isDirectoryExists,
getDirectoryFiles,
getDirectoryFolders,
getDirectoryContents,
};
//#endregion
-494
View File
@@ -1,494 +0,0 @@
/**
* XProject Tools Module ...
* a module for handle MQL5 Projects Compile and Packing ...
*
* Maintainer
*
* Hadi Khazaee Asl <https://saherelm.ir> (hadi_khazaee_asl@yahoo.com)
*/
//
// Import Requirements ...
const execSync = require("child_process").execSync;
const XFileTools = require("./Documents/JsModules/x-file.tools");
const XShellTools = require("./Documents/JsModules/x-shell.tools");
const XColorTools = require("./Documents/JsModules/x-color.tools");
const XTypeTools = require("./Documents/JsModules/x-type-detector.tools");
//
// Definitions ...
const packsPath = XFileTools.joinPath(".", "Packs");
const workspacePaths = [
"Classes", // Required Classes
"Experts", // Expert Advisers
"Helpers", // Indicator's Helpers Classes
"Indicators", // Required Indicators
"Libraries", // Required Libraries
"XCATBEA", // XCATBEA Projects ...
];
//
//#region Tools ...
/**
* Handle Compile and Pack Projects ...
*
* @param {string} projectName
* @param {string[]} resources
* @param {boolean} forceCleanup
* @param {boolean} forceCompileIndicators
*/
async function prepareProject(
projectName = "",
resources = [],
forceCleanup = true,
forceCompileIndicators = true
) {
//
// Check Resources Has Child ...
let isValidArgs =
resources.length > 0 &&
XTypeTools.isArray(resources);
if (!isValidArgs) {
//
// Log ...
console.log(
XColorTools.applyForegroundColor("Invalid Resource List ...", XColorTools.COLOR_NAMES.Red)
);
}
//
// Check Project Name is Valid ...
isValidArgs =
projectName.length > 0 &&
XTypeTools.isString(projectName);
if (!isValidArgs) {
//
// Log ...
console.log(
XColorTools.applyForegroundColor("Empty Project Name ...", XColorTools.COLOR_NAMES.Red)
);
}
//
// Extract Required to Compile Resources List ...
let compileList = await extractResources(resources, true);
if (!compileList || compileList.length == 0) {
//
// Log ...
console.log(
XColorTools.applyForegroundColor("Resource List Extraction to Compile Failed ...", XColorTools.COLOR_NAMES.Red)
);
//
return;
}
//
// Compile Resources Files ...
for (const f of compileList) {
//
// Log ...
console.log(
XColorTools.applyForegroundColor("try to Compile: ", XColorTools.COLOR_NAMES.Yellow),
XColorTools.applyForegroundColor(f, XColorTools.COLOR_NAMES.Blue)
);
//
await recursiveTriesToCompileFile(f, 0);
}
//
// Extract Required to Pack Resources List ...
let packList = await extractResources(resources, false);
if (!packList || packList.length == 0) {
//
// Log ...
console.log(
XColorTools.applyForegroundColor("Resource List Extraction to Pack Failed ...", XColorTools.COLOR_NAMES.Red)
);
//
return;
}
//
// Prepare Pack Folder Exists ...
let isExists = XFileTools.isDirectoryExists(packsPath);
if (!isExists) {
XFileTools.createDirectory(packsPath);
}
//
// Check Folder Exists or not ...
// if Exists Remove it ...
// Create Project Folder on Packs ...
const prjFolderOnPacks = XFileTools.joinPath(packsPath, projectName);
isExists = XFileTools.isDirectoryExists(prjFolderOnPacks);
if (isExists) {
await XFileTools.removeDirectory(prjFolderOnPacks, true);
}
XFileTools.createDirectory(prjFolderOnPacks);
//
// Loop through Files ...
for (const f of packList) {
//
// Prepare Destination Path ...
const fBasePath = XFileTools.basename(f);
let fDestPath = f.replace(fBasePath, "");
fDestPath = fDestPath.substring(0, fDestPath.length - 1);
fDestPath = XFileTools.joinPath(prjFolderOnPacks, fDestPath);
//
const isFDestPathExists = XFileTools.isDirectoryExists(fDestPath);
if (!isFDestPathExists) {
XFileTools.createDirectory(fDestPath);
}
//
// Log ...
console.log(
XColorTools.applyForegroundColor("try to copy: ", XColorTools.COLOR_NAMES.Yellow),
XColorTools.applyForegroundColor(f, XColorTools.COLOR_NAMES.Blue),
XColorTools.applyForegroundColor(" to : ", XColorTools.COLOR_NAMES.Yellow),
XColorTools.applyForegroundColor(fDestPath, XColorTools.COLOR_NAMES.Magenta)
);
//
let result = await XFileTools.copyFile(f, fDestPath);
if (result) {
//
const msg = "copy successfully ...";
console.log(
XColorTools.applyForegroundColor(msg, XColorTools.COLOR_NAMES.Green)
);
} else {
//
const msg = "copy failed ...";
console.log(XColorTools.applyForegroundColor(msg, XColorTools.COLOR_NAMES.Red));
throw msg;
}
}
//
// Log ...
console.log(
XColorTools.applyForegroundColor("Project: ", XColorTools.COLOR_NAMES.Green),
XColorTools.applyForegroundColor(projectName, XColorTools.COLOR_NAMES.Yellow),
XColorTools.applyForegroundColor(" Compiled and Packed Successfully ...", XColorTools.COLOR_NAMES.Green),
);
//
// Cleanup WorkSpace if Provided ...
if (forceCleanup) {
await cleanupWorkSpace();
}
//
// Compile Indicators ...
if (forceCompileIndicators) {
await compile("Indicators");
}
}
/**
* Extract required Files List ...
*
* @param {boolean} forCompile
*
* @returns Promise<string[]>
*/
async function extractResources(
resources = [],
forCompile = true
) {
//
let result = [];
//
// Loop Through Project Resources and Extract Files List to Compile ...
for (const resource of resources) {
//
// Prepare Normalized Resource Path ...
let resourcePath = XFileTools.joinPath(".", resource);
//
// Handle Wild Card Resources ...
if (resourcePath.endsWith("//*") ||
resourcePath.endsWith("\\*")) {
//
resourcePath = resourcePath.substring(0, resourcePath.length - 2);
const files = await XFileTools.extractFiles(
resourcePath,
forCompile ? [".mq5", ".mq4"] : [".ex5", ".ex4"]
);
//
result = result.concat(files);
}
//
// Handle Direct File Resources ...
else {
//
// Check MQL 5 Version ...
let fileResourcePath = resourcePath + (forCompile ? ".mq5" : ".ex5");
//
// Check File Exists ...
let isExists = XFileTools.isFileExists(fileResourcePath);
if (!isExists) {
//
// Check MQL 4 Version ...
fileResourcePath = resourcePath + (forCompile ? ".mq4" : ".ex4");
isExists = XFileTools.isFileExists(fileResourcePath);
}
//
// Add File Path to Files List if Exists ...
if (isExists) {
result.push(fileResourcePath);
}
}
}
//
return result;
}
/**
* try to compile a file ...
* @param {string} f
* @param {number} numberOfTries
*/
async function recursiveTriesToCompileFile(f = "", numberOfTries = 0) {
//
let result = await handleFileCompile(f);
if (result) {
//
const msg = "compiled successfully ...";
console.log(XColorTools.applyForegroundColor(msg, XColorTools.COLOR_NAMES.Green));
return result;
} else {
//
if (numberOfTries < 10) {
//
numberOfTries++;
//
const msg = "retry (" + (numberOfTries + 1) + ") ...";
console.log(XColorTools.applyForegroundColor(msg, XColorTools.COLOR_NAMES.LightMagenta));
await recursiveTriesToCompileFile(f, numberOfTries);
} else {
//
const msg = "failed ...";
console.log(XColorTools.applyForegroundColor(msg, XColorTools.COLOR_NAMES.Red));
throw msg;
//
return false;
}
}
}
/**
* execute compile task on Specific File ...
* @param {string} f file path to Execute Compile task ...
* @returns
*/
async function handleFileCompile(f = "") {
//
let result = false;
//
let exResult = await compileMQLFile(f);
if (exResult.includes("0 errors")) {
result = true;
} else {
result = false;
}
//
return result;
}
/**
* Compile Specific MQL File ...
*
* @param {string} path MQL file path ...
* @returns
*/
async function compileMQLFile(path = "") {
//
// Check File Exists ...
const isExists = XFileTools.isFileExists(path);
if (!isExists) {
//
const msg = "file not found ...";
console.log(XColorTools.applyForegroundColor(msg, XColorTools.COLOR_NAMES.Red));
throw msg;
}
//
const ext = XFileTools.getFileExtension(path);
if (ext !== ".mq5" && ext !== "mq4") {
//
const msg = "invalid file extension ...";
console.log(XColorTools.applyForegroundColor(msg, XColorTools.COLOR_NAMES.Red));
throw msg;
}
//
const cwd = __dirname;
const cmd = "compile.cmd " + path;
//
const result = await XShellTools.execute(cmd, cwd);
return result;
}
/**
* Run Specified Command in workspace ...
*
* @param {string} cmd
* @returns
*/
async function runCommand(cmd = "") {
//
// Validate Args ...
let isValidArgs = cmd.length > 0 &&
XTypeTools.isString(cmd);
//
// Validate Commands ...
if (isValidArgs) {
//
// Check Available Commands ...
isValidArgs =
cmd === "*" ||
cmd === "cleanup" ||
workspacePaths.includes(cmd) ||
workspacePaths.map(x => x.toLowerCase(x)).includes(cmd.toLowerCase());
}
if (!isValidArgs) {
//
// Log ...
console.log(
XColorTools.applyForegroundColor("Invalid Command ...", XColorTools.COLOR_NAMES.Red)
);
}
//
// Compile ...
if (cmd == "*") {
await compileWorkSpace();
} else if (cmd == "cleanup") {
await cleanupWorkSpace();
} else {
//
// Select Workspace to Compile ...
const folder = workspacePaths
.find(x => x.toLowerCase() === cmd.toLowerCase());
isValidArgs =
XTypeTools.isString(folder) &&
folder.length > 0;
if (!isValidArgs) {
//
// Log ...
console.log(
XColorTools.applyForegroundColor("Invalid Command ...", XColorTools.COLOR_NAMES.Red)
);
}
//
// Extract Required to Compile Resources List ...
let compileList = await XFileTools.extractFiles(
folder,
[".mq5", ".mq4"]
);
if (!compileList || compileList.length == 0) {
//
// Log ...
console.log(
XColorTools.applyForegroundColor("Extraction to Compile Failed ...", XColorTools.COLOR_NAMES.Red)
);
//
return;
}
//
// Compile Resources Files ...
for (const f of compileList) {
//
// Log ...
console.log(
XColorTools.applyForegroundColor("try to Compile: ", XColorTools.COLOR_NAMES.Yellow),
XColorTools.applyForegroundColor(f, XColorTools.COLOR_NAMES.Blue)
);
//
await recursiveTriesToCompileFile(f, 0);
}
}
}
/**
* Cleanup Workspace compiled files ...
*/
async function cleanupWorkSpace() {
//
for (const path of workspacePaths) {
//
const fSourcePath = XFileTools.joinPath(".", path);
const filesToRemove = await XFileTools.extractFiles(fSourcePath, [".ex5", ".ex4"]);
for (const f of filesToRemove) {
//
// Log ...
console.log(
XColorTools.applyForegroundColor("try to Remove: ", XColorTools.COLOR_NAMES.Yellow),
XColorTools.applyForegroundColor(f, XColorTools.COLOR_NAMES.Blue)
);
//
let result = await XFileTools.removeFile(f);
if (result) {
//
const msg = "removed successfully ...";
console.log(
XColorTools.applyForegroundColor(msg, XColorTools.COLOR_NAMES.Green)
);
} else {
//
const msg = "removed failed ...";
console.log(XColorTools.applyForegroundColor(msg, XColorTools.COLOR_NAMES.Red));
throw msg;
}
}
}
}
/**
* Compile Workspace ...
*/
async function compileWorkSpace() {
//
for (const path of workspacePaths) {
await runCommand(path);
}
}
//#endregion
//
//#region Module Exports ...
module.exports = {
extractResources,
recursiveTriesToCompileFile,
handleFileCompile,
compileMQLFile,
runCommand,
cleanupWorkSpace,
compileWorkSpace,
prepareProject
}
//#endregion
-219
View File
@@ -1,219 +0,0 @@
/**
* XShell Tools Module ...
* a module for handling shell actions and retrieve OS Info in node js ...
*
* Maintainer
*
* Hadi Khazaee Asl <https://saherelm.ir> (hadi_khazaee_asl@yahoo.com)
*/
//
//#region Imports ...
const os = require('os');
const process = require('process');
const { exec } = require("child_process");
const XFileTools = require('./x-file.tools');
//#endregion
//
//#region Constants ...
//
const OS = {
Aix: 'aix',
Darwin: 'darwin',
FreeBSD: 'freebsd',
Linux: 'linux',
OpenBSD: 'openbsd',
SnOS: 'sunos',
Windows: 'win32'
};
//
const isWindows = process.platform === OS.Windows;
//#endregion
//
//#region Actions ...
//
//#region Pure shell commands ...
/**
* execute a command using NodeJS on shell ...
*
* @param {string} cmd command to execute ...
* @param {string} cwd working directory ...
*
* @returns Promise<any, errr> instance ...
*/
function execute(cmd, cwd) {
return new Promise((resolve, reject) => {
//
if (!cmd || cmd.toString().length === 0 || (cwd && !XFileTools.isDirectoryExists(cwd))) {
reject('invalid args ...');
return;
}
//
exec(cmd, { cwd }, (err, result, stdError) => {
//
if (err) {
reject(err);
return;
}
//
if (stdError) {
//
// reject(stdError);
// return;
}
//
resolve(result);
});
});
};
/**
* determines a command exists on host or not ...
*
* @param {string} name specific command name ...
*
* @returns boolean Promise ...
*/
function checkCommandExists(name) {
return new Promise(resolve => {
//
if (!name) {
resolve(false);
return;
}
//
const cmd = isWindows ? `${name} >nul 2>&1` : `type ${name} >/dev/null 2>&1`;
execute(cmd).then(result => {
resolve(true);
})
.catch(err => {
resolve(false);
});
});
}
//#endregion
//
//#region required commands state ...
/**
* check al required commands exists or not ...
*
* @returns
*/
async function isRequiredCommandsExists() {
//
let result = false;
//
// const isTarExists = await isTarCommandExists();
// const isCatExists = await isCatCommandExists();
// const isGrepExists = await isGrepCommandExists();
// const isSedExists = await isSedCommandExists();
const isNpmExists = await isNpmCommandExists();
const isNgExists = await isNgCommandExists();
const isIonicExists = await isIonicCommandExists();
const isCordovaExists = await isCordovaCommandExists();
//
result = isNpmExists
&& isNgExists
&& isIonicExists
&& isCordovaExists
;
//
return result;
}
/**
* retrieve required commands state object ...
*
* @returns
*/
async function getRequiredCommandsStates() {
//
const result = {};
//
// const isTarExists = await isTarCommandExists();
// const isCatExists = await isCatCommandExists();
// const isGrepExists = await isGrepCommandExists();
// const isSedExists = await isSedCommandExists();
const isNpmExists = await isNpmCommandExists();
const isNgExists = await isNgCommandExists();
const isIonicExists = await isIonicCommandExists();
const isCordovaExists = await isCordovaCommandExists();
//
result['npm'] = isNpmExists;
result['ng'] = isNgExists;
result['ionic'] = isIonicExists;
result['cordova'] = isCordovaExists;
//
return result;
}
//#endregion
//
//#region Commonly used Command Checkers ...
/**
* determines npm command exists or not ...
*
* @returns
*/
function isNpmCommandExists() {
return checkCommandExists('npm');
}
/**
* determines ng command exists or not ...
*
* @returns
*/
function isNgCommandExists() {
return checkCommandExists('ng');
}
/**
* determines ionic command exists or not ...
*
* @returns
*/
function isIonicCommandExists() {
return checkCommandExists('ionic');
}
/**
* determines cordova command exists or not ...
*
* @returns
*/
function isCordovaCommandExists() {
return checkCommandExists('cordova');
}
//#endregion
//#endregion
//
//#region Module Exports ...
module.exports = {
//
execute,
checkCommandExists,
isRequiredCommandsExists,
getRequiredCommandsStates,
//
isNgCommandExists,
isIonicCommandExists,
isCordovaCommandExists,
}
//#endregion
@@ -1,268 +0,0 @@
/**
* DataType Tools Module ...
* a module for manipulate and detect supported data types in node js ...
*
* Maintainer
*
* Hadi Khazaee Asl <https://saherelm.ir> (hadi_khazaee_asl@yahoo.com)
*/
//
//#region Constants ...
/**
* all supported data types ...
*/
const DataTypes = {
Null: 'null',
Date: 'date',
Array: 'array',
Object: 'object',
String: 'string',
Number: 'number',
Unknown: 'unknown',
Boolean: 'boolean',
Function: 'function',
Undefined: 'undefined',
};
//#endregion
//
//#region Actions ...
/**
* detect type of a content ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function getType(value) {
//
const type = typeof value;
//
let result = DataTypes.Unknown;
let dateIdentifier = '[object Date]';
let constructor = value && value.constructor ?
value.constructor.toString() :
'';
//
switch (type) {
//
case 'undefined':
result = DataTypes.Undefined;
break;
//
case 'boolean':
result = DataTypes.Boolean;
break;
//
case 'string':
result = DataTypes.String;
break;
//
case 'number':
result = DataTypes.Number;
break;
//
case 'function':
result = DataTypes.Function;
break;
//
case 'object':
//
// Null ...
if (value === null) {
result = DataTypes.Null;
} else
//
// Array ...
if (Array.isArray(value)) {
result = DataTypes.Array;
} else
//
// Data ...
if (
value instanceof Date ||
isFunction(value.getMonth) ||
constructor.includes(dateIdentifier) ||
Object.prototype.toString.call(value) === dateIdentifier
) {
result = DataTypes.Date;
} else
//
// Object ...
{
result = DataTypes.Object;
}
break;
//
default:
result = DataTypes.Unknown;
break;
}
//
return result;
}
/**
* retrieve an object constructor ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function getConstructor(value) {
//
const result = value && value.constructor ?
value.constructor.toString() :
'';
//
return result;
}
/**
* retrieve an object prototype ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function getPrototype(value) {
//
const result = value ?
Object.prototype.toString.call(value) :
'';
//
return result;
}
/**
* check an object is null or not ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function isNull(value) {
return getType(value) === DataTypes.Null;
}
/**
* check an object is undefined or not ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function isUndefined(value) {
return getType(value) === DataTypes.Undefined;
}
/**
* check an object is null or undefined or not ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function isNullOrUndefined(value) {
return isNull(value) || isUndefined(value);
}
/**
* check an object is a date or not ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function isDate(value) {
return getType(value) === DataTypes.Date;
}
/**
* check an object is number or not ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function isNumber(value) {
return getType(value) === DataTypes.Number;
}
/**
* check an object is string or not ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function isString(value) {
return getType(value) === DataTypes.String;
}
/**
* check an object is boolean or not ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function isBoolean(value) {
return getType(value) === DataTypes.Boolean;
}
/**
* check an object is an Array or not ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function isArray(value) {
return getType(value) === DataTypes.Array;
}
/**
* check an object is and Object or not ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function isObject(value) {
return getType(value) === DataTypes.Object;
}
/**
* check an object is a Function or not ...
*
* @param {any} value the content which going to check ...
* @returns
*/
function isFunction(value) {
return getType(value) === DataTypes.Function;
}
//#endregion
//
//#region Module Exports ...
module.exports = {
//
DataTypes,
//
getType,
getConstructor,
getPrototype,
isNull,
isUndefined,
isNullOrUndefined,
isDate,
isNumber,
isString,
isBoolean,
isArray,
isObject,
isFunction,
}
//#endregion
File diff suppressed because it is too large Load Diff
Binary file not shown.
@@ -0,0 +1,42 @@
-----------------------
Validating:
-----------------------
eaForceHasSwing: true
eaForceOBBarType: false
eaForceFVGBarType: true
eaForceHasFLiquidity: false
eaForceHasRLiquidity: false
eaValidateGapSequence: false
eaValidateBlockEdgeBreakout: false
-----------------------
Filtering:
-----------------------
eaFilterBasedOnKI: true
eaFilterBasedOnPV: false
eaFilterBasedOnSar: false
eaForceSarSwitched: true
eaForceSarOnBothSide: true
eaForceSarHasBreakout: true
eaForceSarHasReversalSide: true
eaFilterBasedOnRSI: false
eaForceHasRSITrending: false
eaForceHasRSIVPattern: false
eaForceHasRSICrossing: true
eaFilterBasedOnADX: false
eaForceHasADXTrending: true
eaForceHasADXCrossing: false
eaFilterBasedOnATR: false
eaForceHasATRTrending: true
eaForceHasATRBreakout: false
eaFilterBasedOnTrend: true
eaForceHasTrendDir: true
eaForceHasTrendPlace: false
eaForceHasTrendChange: true
eaForceHasTrendTrending: true
eaForceHasTrendRejection: false
eaForceHasTrendLineInside: false
eaForceHasTrendDirOnBothSide: false
eaFilterBasedOnDelta: false
eaFilterBasedOnVolume: false
eaFilterBasedOnSignalBar: true
eaFilterBasedOnHKSignalBar: false
@@ -0,0 +1,42 @@
-----------------------
Validating:
-----------------------
eaForceHasSwing: false
eaForceOBBarType: true
eaForceFVGBarType: false
eaForceHasFLiquidity: false
eaForceHasRLiquidity: false
eaValidateGapSequence: false
eaValidateBlockEdgeBreakout: true
-----------------------
Filtering:
-----------------------
eaFilterBasedOnKI: false
eaFilterBasedOnPV: false
eaFilterBasedOnSar: false
eaForceSarSwitched: true
eaForceSarOnBothSide: false
eaForceSarHasBreakout: false
eaForceSarHasReversalSide: true
eaFilterBasedOnRSI: true
eaForceHasRSITrending: true
eaForceHasRSIVPattern: false
eaForceHasRSICrossing: false
eaFilterBasedOnADX: false
eaForceHasADXTrending: true
eaForceHasADXCrossing: false
eaFilterBasedOnATR: true
eaForceHasATRTrending: true
eaForceHasATRBreakout: false
eaFilterBasedOnTrend: true
eaForceHasTrendDir: true
eaForceHasTrendPlace: false
eaForceHasTrendChange: true
eaForceHasTrendTrending: false
eaForceHasTrendRejection: false
eaForceHasTrendLineInside: false
eaForceHasTrendDirOnBothSide: true
eaFilterBasedOnDelta: false
eaFilterBasedOnVolume: false
eaFilterBasedOnSignalBar: false
eaFilterBasedOnHKSignalBar: false
@@ -0,0 +1,42 @@
-----------------------
Validating:
-----------------------
eaForceHasSwing: false
eaForceOBBarType: true
eaForceFVGBarType: true
eaForceHasFLiquidity: false
eaForceHasRLiquidity: false
eaValidateGapSequence: true
eaValidateBlockEdgeBreakout: false
-----------------------
Filtering:
-----------------------
eaFilterBasedOnKI: false
eaFilterBasedOnPV: true
eaFilterBasedOnSar: true
eaForceSarSwitched: false
eaForceSarOnBothSide: true
eaForceSarHasBreakout: false
eaForceSarHasReversalSide: false
eaFilterBasedOnRSI: false
eaForceHasRSITrending: false
eaForceHasRSIVPattern: false
eaForceHasRSICrossing: true
eaFilterBasedOnADX: false
eaForceHasADXTrending: true
eaForceHasADXCrossing: false
eaFilterBasedOnATR: false
eaForceHasATRTrending: false
eaForceHasATRBreakout: false
eaFilterBasedOnTrend: false
eaForceHasTrendDir: true
eaForceHasTrendPlace: true
eaForceHasTrendChange: true
eaForceHasTrendTrending: true
eaForceHasTrendRejection: false
eaForceHasTrendLineInside: true
eaForceHasTrendDirOnBothSide: false
eaFilterBasedOnDelta: false
eaFilterBasedOnVolume: true
eaFilterBasedOnSignalBar: true
eaFilterBasedOnHKSignalBar: false
@@ -0,0 +1,42 @@
-----------------------
Validating:
-----------------------
eaForceHasSwing: true
eaForceOBBarType: false
eaForceFVGBarType: false
eaForceHasFLiquidity: false
eaForceHasRLiquidity: false
eaValidateGapSequence: false
eaValidateBlockEdgeBreakout: false
-----------------------
Filtering:
-----------------------
eaFilterBasedOnKI: true
eaFilterBasedOnPV: false
eaFilterBasedOnSar: false
eaForceSarSwitched: true
eaForceSarOnBothSide: true
eaForceSarHasBreakout: false
eaForceSarHasReversalSide: true
eaFilterBasedOnRSI: false
eaForceHasRSITrending: true
eaForceHasRSIVPattern: false
eaForceHasRSICrossing: true
eaFilterBasedOnADX: false
eaForceHasADXTrending: true
eaForceHasADXCrossing: true
eaFilterBasedOnATR: true
eaForceHasATRTrending: false
eaForceHasATRBreakout: false
eaFilterBasedOnTrend: true
eaForceHasTrendDir: false
eaForceHasTrendPlace: false
eaForceHasTrendChange: false
eaForceHasTrendTrending: true
eaForceHasTrendRejection: true
eaForceHasTrendLineInside: true
eaForceHasTrendDirOnBothSide: true
eaFilterBasedOnDelta: false
eaFilterBasedOnVolume: false
eaFilterBasedOnSignalBar: true
eaFilterBasedOnHKSignalBar: false
@@ -0,0 +1,42 @@
-----------------------
Validating:
-----------------------
eaForceHasSwing: true
eaForceOBBarType: true
eaForceFVGBarType: false
eaForceHasFLiquidity: false
eaForceHasRLiquidity: false
eaValidateGapSequence: true
eaValidateBlockEdgeBreakout: false
-----------------------
Filtering:
-----------------------
eaFilterBasedOnKI: false
eaFilterBasedOnPV: true
eaFilterBasedOnSar: false
eaForceSarSwitched: true
eaForceSarOnBothSide: true
eaForceSarHasBreakout: false
eaForceSarHasReversalSide: true
eaFilterBasedOnRSI: true
eaForceHasRSITrending: false
eaForceHasRSIVPattern: false
eaForceHasRSICrossing: false
eaFilterBasedOnADX: false
eaForceHasADXTrending: false
eaForceHasADXCrossing: false
eaFilterBasedOnATR: true
eaForceHasATRTrending: true
eaForceHasATRBreakout: false
eaFilterBasedOnTrend: true
eaForceHasTrendDir: true
eaForceHasTrendPlace: true
eaForceHasTrendChange: true
eaForceHasTrendTrending: true
eaForceHasTrendRejection: true
eaForceHasTrendLineInside: false
eaForceHasTrendDirOnBothSide: false
eaFilterBasedOnDelta: true
eaFilterBasedOnVolume: true
eaFilterBasedOnSignalBar: true
eaFilterBasedOnHKSignalBar: false
@@ -0,0 +1,42 @@
-----------------------
Validating:
-----------------------
eaForceHasSwing: false
eaForceOBBarType: false
eaForceFVGBarType: false
eaForceHasFLiquidity: false
eaForceHasRLiquidity: false
eaValidateGapSequence: true
eaValidateBlockEdgeBreakout: false
-----------------------
Filtering:
-----------------------
eaFilterBasedOnKI: true
eaFilterBasedOnPV: true
eaFilterBasedOnSar: false
eaForceSarSwitched: false
eaForceSarOnBothSide: false
eaForceSarHasBreakout: true
eaForceSarHasReversalSide: true
eaFilterBasedOnRSI: true
eaForceHasRSITrending: true
eaForceHasRSIVPattern: true
eaForceHasRSICrossing: false
eaFilterBasedOnADX: true
eaForceHasADXTrending: false
eaForceHasADXCrossing: false
eaFilterBasedOnATR: false
eaForceHasATRTrending: false
eaForceHasATRBreakout: false
eaFilterBasedOnTrend: false
eaForceHasTrendDir: false
eaForceHasTrendPlace: false
eaForceHasTrendChange: true
eaForceHasTrendTrending: false
eaForceHasTrendRejection: false
eaForceHasTrendLineInside: true
eaForceHasTrendDirOnBothSide: true
eaFilterBasedOnDelta: true
eaFilterBasedOnVolume: true
eaFilterBasedOnSignalBar: true
eaFilterBasedOnHKSignalBar: true
@@ -0,0 +1,42 @@
-----------------------
Validating:
-----------------------
eaForceHasSwing: true
eaForceOBBarType: false
eaForceFVGBarType: false
eaForceHasFLiquidity: false
eaForceHasRLiquidity: false
eaValidateGapSequence: false
eaValidateBlockEdgeBreakout: true
-----------------------
Filtering:
-----------------------
eaFilterBasedOnKI: true
eaFilterBasedOnPV: false
eaFilterBasedOnSar: false
eaForceSarSwitched: true
eaForceSarOnBothSide: true
eaForceSarHasBreakout: false
eaForceSarHasReversalSide: true
eaFilterBasedOnRSI: false
eaForceHasRSITrending: true
eaForceHasRSIVPattern: false
eaForceHasRSICrossing: false
eaFilterBasedOnADX: false
eaForceHasADXTrending: false
eaForceHasADXCrossing: false
eaFilterBasedOnATR: false
eaForceHasATRTrending: false
eaForceHasATRBreakout: true
eaFilterBasedOnTrend: false
eaForceHasTrendDir: false
eaForceHasTrendPlace: true
eaForceHasTrendChange: true
eaForceHasTrendTrending: true
eaForceHasTrendRejection: false
eaForceHasTrendLineInside: true
eaForceHasTrendDirOnBothSide: false
eaFilterBasedOnDelta: false
eaFilterBasedOnVolume: false
eaFilterBasedOnSignalBar: true
eaFilterBasedOnHKSignalBar: false
@@ -0,0 +1,42 @@
-----------------------
Validating:
-----------------------
eaForceHasSwing: false
eaForceOBBarType: true
eaForceFVGBarType: true
eaForceHasFLiquidity: false
eaForceHasRLiquidity: false
eaValidateGapSequence: true
eaValidateBlockEdgeBreakout: false
-----------------------
Filtering:
-----------------------
eaFilterBasedOnKI: false
eaFilterBasedOnPV: false
eaFilterBasedOnSar: false
eaForceSarSwitched: true
eaForceSarOnBothSide: false
eaForceSarHasBreakout: false
eaForceSarHasReversalSide: true
eaFilterBasedOnRSI: false
eaForceHasRSITrending: false
eaForceHasRSIVPattern: false
eaForceHasRSICrossing: true
eaFilterBasedOnADX: true
eaForceHasADXTrending: true
eaForceHasADXCrossing: true
eaFilterBasedOnATR: false
eaForceHasATRTrending: true
eaForceHasATRBreakout: false
eaFilterBasedOnTrend: false
eaForceHasTrendDir: true
eaForceHasTrendPlace: false
eaForceHasTrendChange: false
eaForceHasTrendTrending: false
eaForceHasTrendRejection: true
eaForceHasTrendLineInside: true
eaForceHasTrendDirOnBothSide: true
eaFilterBasedOnDelta: false
eaFilterBasedOnVolume: false
eaFilterBasedOnSignalBar: false
eaFilterBasedOnHKSignalBar: false
@@ -0,0 +1,42 @@
-----------------------
Validating:
-----------------------
eaForceHasSwing: false
eaForceOBBarType: false
eaForceFVGBarType: true
eaForceHasFLiquidity: false
eaForceHasRLiquidity: false
eaValidateGapSequence: true
eaValidateBlockEdgeBreakout: false
-----------------------
Filtering:
-----------------------
eaFilterBasedOnKI: true
eaFilterBasedOnPV: true
eaFilterBasedOnSar: true
eaForceSarSwitched: false
eaForceSarOnBothSide: true
eaForceSarHasBreakout: false
eaForceSarHasReversalSide: true
eaFilterBasedOnRSI: false
eaForceHasRSITrending: true
eaForceHasRSIVPattern: true
eaForceHasRSICrossing: false
eaFilterBasedOnADX: false
eaForceHasADXTrending: true
eaForceHasADXCrossing: true
eaFilterBasedOnATR: false
eaForceHasATRTrending: true
eaForceHasATRBreakout: false
eaFilterBasedOnTrend: true
eaForceHasTrendDir: true
eaForceHasTrendPlace: true
eaForceHasTrendChange: true
eaForceHasTrendTrending: true
eaForceHasTrendRejection: false
eaForceHasTrendLineInside: false
eaForceHasTrendDirOnBothSide: false
eaFilterBasedOnDelta: false
eaFilterBasedOnVolume: false
eaFilterBasedOnSignalBar: false
eaFilterBasedOnHKSignalBar: false
+86 -26
View File
@@ -725,7 +725,7 @@ ENUM_ORDER_TYPE Opposit(ENUM_ORDER_TYPE value)
*
* @return ( string )
*/
string ToString(ENUM_POSITION_TYPE value)
string ToXString(ENUM_POSITION_TYPE value)
{
//
string result = NULL;
@@ -750,7 +750,7 @@ string ToString(ENUM_POSITION_TYPE value)
*
* @return ( string )
*/
string ToString(ENUM_ORDER_TYPE value)
string ToXString(ENUM_ORDER_TYPE value)
{
//
string result = NULL;
@@ -834,6 +834,12 @@ double GetSpread(
//
return result;
}
double GetXSpread(
string mSymbol = NULL //
)
{
return GetSpread(mSymbol);
}
/**
* Get Point Price ...
@@ -934,6 +940,13 @@ double GetEntry(
//
return result;
}
double GetXEntry(
string mSymbol = NULL,
ENUM_POSITION_TYPE type = POSITION_TYPE_BUY //
)
{
return GetEntry(mSymbol, type);
}
/**
* Get Entry Price ...
@@ -964,6 +977,13 @@ double GetEntry(
//
return result;
}
double GetXEntry(
string mSymbol = NULL,
ENUM_X_DIRECTION type = X_DIRECTION_BULLISH //
)
{
return GetEntry(mSymbol, type);
}
/**
* Get Exit Price ...
@@ -994,6 +1014,13 @@ double GetExit(
//
return result;
}
double GetXExit(
string mSymbol = NULL,
ENUM_POSITION_TYPE type = POSITION_TYPE_BUY //
)
{
return GetExit(mSymbol, type);
}
/**
* Get Exit Price ...
@@ -1024,6 +1051,13 @@ double GetExit(
//
return result;
}
double GetXExit(
string mSymbol = NULL,
ENUM_X_DIRECTION type = X_DIRECTION_BULLISH //
)
{
return GetExit(mSymbol, type);
}
/**
* Retrieve Current Tick ...
@@ -1388,7 +1422,7 @@ string GenerateTag(T &model)
string result = "";
//
string tag = model.ToString();
string tag = model.ToXString();
if (StringLen(tag) == 0)
{
return result;
@@ -1422,7 +1456,7 @@ string ToMD5(T content)
string result = "";
//
string strContent = ToString(content);
string strContent = ToXString(content);
if (StringLen(strContent) == 0)
{
return result;
@@ -1801,6 +1835,15 @@ int FindIndexes(
//
return mResult;
}
int FindXIndexes(
string mQuery,
string mContent,
int &result[],
bool ignoreCase = false //
)
{
return FindXIndexes(mQuery, mContent, result, ignoreCase);
}
/**
* Convert From String ...
@@ -1836,7 +1879,7 @@ T FromString(string value)
* @return ( string )
*/
template <typename T>
string ToString(T value)
string ToXString(T value)
{
return (string)value;
}
@@ -1859,7 +1902,7 @@ string Trim(string value)
//
// Used In Report or Summary Generators ...
string ToString(
string ToXString(
string prefix, // Title
bool value, // Value
bool ignoreFalseConditions = true, // Ignore False Conditions
@@ -1872,7 +1915,7 @@ string ToString(
//
bool canSet =
IsBoolean(ToString(value))
IsBoolean(ToXString(value))
? (bool)value || !ignoreFalseConditions
: true;
@@ -1880,7 +1923,7 @@ string ToString(
result = canSet
? prefix +
prefixSeparator + " " +
ToString(value) +
ToXString(value) +
lineSeparator
: "";
@@ -1890,7 +1933,7 @@ string ToString(
//
template <typename T>
string ToString(
string ToXString(
string prefix, // Title
T value, // Value
string lineSeparator = "\n", // Line Separator
@@ -1903,7 +1946,7 @@ string ToString(
//
result = prefix +
prefixSeparator + " " +
ToString(value) +
ToXString(value) +
lineSeparator;
//
@@ -1944,7 +1987,7 @@ string SetLabel(
//
// Converts a Buffer to String Representation ...
template <typename T>
string ToString(
string ToXString(
const T &buffer[], // Specified Buffer
string separator = ",", // Specified Separator
bool addIndex = false, // Specified Add Items Indexes or Not
@@ -2015,7 +2058,7 @@ bool IsBoolean(string value)
//
string istring = value;
string normalizedValue = ToString(istring);
string normalizedValue = ToXString(istring);
StringToLower(normalizedValue);
normalizedValue = Trim(normalizedValue);
@@ -2726,7 +2769,7 @@ string Surround(
string result = NULL;
//
string strValue = ToString(value);
string strValue = ToXString(value);
if (!IsValid(strValue))
{
return result;
@@ -2762,7 +2805,7 @@ string SurroundArray(
string result = NULL;
//
string valueStr = ToString(value);
string valueStr = ToXString(value);
if (!IsValid(valueStr))
{
return result;
@@ -2908,7 +2951,7 @@ ENUM_TIMEFRAMES ToPeriod(string value)
*
* @return ( string )
*/
string ToString(ENUM_TIMEFRAMES value)
string ToXString(ENUM_TIMEFRAMES value)
{
//
string result = "";
@@ -3758,7 +3801,7 @@ int Add(
return result;
}
template <typename T>
int AddSpecific(
int AddSpecified(
T item, // item want to add
T &buffer[] // Destination buffer
)
@@ -3801,7 +3844,7 @@ bool HasChild(T &buffer[])
return IsValidSize(ArraySize(buffer));
}
template <typename T>
bool SpecificHasChild(T &buffer[])
bool SpecifiedHasChild(T &buffer[])
{
return HasChild(buffer);
}
@@ -3846,7 +3889,7 @@ void Clean(T &buffer[])
ZeroMemory(buffer);
}
template <typename T>
void SpecificClean(T &buffer[])
void SpecifiedClean(T &buffer[])
{
Clean(buffer);
}
@@ -4194,6 +4237,15 @@ int FindIndex(
//
return result;
}
template <typename T>
int FindXIndex(
T item, // What is Search ...
T &buffer[] // Search in ...
)
{
return FindIndex(item, buffer);
}
//
// Find Specific Item Index inside a Collection ...
template <typename T>
@@ -4245,6 +4297,14 @@ int FindIndex(
//
return result;
}
template <typename T>
int FindXIndex(
T &item, // Item to Find
const T &items[] // Items for Search
)
{
return FindIndex(item, items);
}
//
// Check an Array Contains Specified Value ...
@@ -5720,14 +5780,14 @@ string GetTimeString(
}
//
string hour = ToString(tStruct.hour);
string hour = ToXString(tStruct.hour);
hour =
StringLen(hour) == 1
? "0" + hour
: hour;
//
string minute = ToString(tStruct.min);
string minute = ToXString(tStruct.min);
minute =
StringLen(minute) == 1
? "0" + minute
@@ -5768,12 +5828,12 @@ string ToFormatString(
}
//
string year = ToString(timeStruct.year);
string month = ToString(timeStruct.mon);
string day = ToString(timeStruct.day);
string hour = ToString(timeStruct.hour);
string minute = ToString(timeStruct.min);
string second = ToString(timeStruct.sec);
string year = ToXString(timeStruct.year);
string month = ToXString(timeStruct.mon);
string day = ToXString(timeStruct.day);
string hour = ToXString(timeStruct.hour);
string minute = ToXString(timeStruct.min);
string second = ToXString(timeStruct.sec);
//
result =
+4
View File
@@ -342,6 +342,10 @@ bool IsValid(ENUM_X_BOUNDARY_PRICE value)
//
return result;
}
bool IsSpecifiedValid(ENUM_X_BOUNDARY_PRICE value)
{
return IsValid(value);
}
/**
* Converts To String ...
+13 -13
View File
@@ -954,8 +954,8 @@ struct XOHCL
}
//
bool isBullish = IsBullish(forDir);
bool isBearish = IsBearish(forDir);
bool isBullish = IsSpecifiedBullish(forDir);
bool isBearish = IsSpecifiedBearish(forDir);
//
double fiboLevelValue = GetFibonacciLevel(
@@ -1003,13 +1003,13 @@ struct XOHCL
//
bool isBullish =
IsBullish(forDir) &&
IsSpecifiedBullish(forDir) &&
low < price &&
GetDown() > price;
//
bool isBearish =
IsBearish(forDir) &&
IsSpecifiedBearish(forDir) &&
high > price &&
GetUp() < price;
@@ -1064,7 +1064,7 @@ struct XOHCL
result = IsValid() &&
price > 0 &&
HasDirection(forDir) &&
IsValid(boundaryType);
IsSpecifiedValid(boundaryType);
if (!result)
{
return result;
@@ -1078,14 +1078,14 @@ struct XOHCL
IsBullish() &&
low < price &&
high > price &&
IsBullish(forDir);
IsSpecifiedBullish(forDir);
//
bool isBearish =
IsBearish() &&
low < price &&
high > price &&
IsBearish(forDir);
IsSpecifiedBearish(forDir);
//
result = isBullish ||
@@ -1346,10 +1346,10 @@ struct XOHCL
//
result =
(IsValid(prefix)
(IsSpecifiedValid(prefix)
? prefix + "_"
: "") +
"XOHCL_" + symbol + "_" + ToString(period) + "_" + ToFormatString(time);
"XOHCL_" + symbol + "_" + ToXString(period) + "_" + ToFormatString(time);
//
return result;
@@ -1364,7 +1364,7 @@ struct XOHCL
//
result = GetTypeName(this) +
"(O(" + ToString(open) + "),H(" + ToString(high) + "),C(" + ToString(close) + "),L(" + ToString(low) + "))";
"(O(" + ToXString(open) + "),H(" + ToXString(high) + "),C(" + ToXString(close) + "),L(" + ToXString(low) + "))";
//
return result;
@@ -1496,7 +1496,7 @@ struct XBarRemainsTime
if (!ignoreZeroValues || hours > 0)
{
//
string strHour = ToString(hours);
string strHour = ToXString(hours);
if (StringLen(strHour) == 1)
{
strHour = "0" + strHour;
@@ -1511,7 +1511,7 @@ struct XBarRemainsTime
if (!ignoreZeroValues || minutes > 0)
{
//
string strMinute = ToString(minutes);
string strMinute = ToXString(minutes);
if (StringLen(strMinute) == 1)
{
strMinute = "0" + strMinute;
@@ -1526,7 +1526,7 @@ struct XBarRemainsTime
if (!ignoreZeroValues || seconds > 0)
{
//
string strSec = ToString(seconds);
string strSec = ToXString(seconds);
if (StringLen(strSec) == 1)
{
strSec = "0" + strSec;
+20 -20
View File
@@ -93,11 +93,11 @@ struct XBoxZone
upper > 0 &&
lower > 0 &&
from < to &&
IsValid(to) &&
IsSpecifiedValid(to) &&
upper >= lower &&
IsValid(from) &&
IsValid(symbol) &&
IsValid(period)
IsSpecifiedValid(from) &&
IsSpecifiedValid(symbol) &&
IsSpecifiedValid(period)
//
;
@@ -113,7 +113,7 @@ struct XBoxZone
bool IsBullish()
{
return IsValid() &&
IsBullish(dir);
IsSpecifiedBullish(dir);
}
/**
@@ -124,7 +124,7 @@ struct XBoxZone
bool IsBearish()
{
return IsValid() &&
IsBearish(dir);
IsSpecifiedBearish(dir);
}
/**
@@ -209,7 +209,7 @@ struct XBoxZone
}
//
if (!IsValid(forPeriod))
if (!IsSpecifiedValid(forPeriod))
{
forPeriod = period;
}
@@ -379,7 +379,7 @@ struct XBoxZone
}
//
if (!IsValid(forPeriod))
if (!IsSpecifiedValid(forPeriod))
{
forPeriod = period;
}
@@ -450,7 +450,7 @@ struct XBoxZone
}
//
if (!IsValid(forPeriod))
if (!IsSpecifiedValid(forPeriod))
{
forPeriod = period;
}
@@ -515,7 +515,7 @@ struct XBoxZone
double nLower = NormalizeDouble(NormalizePrice(lower, symbol), digits);
//
string typeStr = IsValid(type)
string typeStr = IsSpecifiedValid(type)
? type
: "XBOX";
string result =
@@ -523,9 +523,9 @@ struct XBoxZone
typeStr + "_" +
ToString(dir) + "_" +
symbol + "_" +
ToString(period) + "_" +
ToString(nUpper) + "_" +
ToString(nLower)
ToXString(period) + "_" +
ToXString(nUpper) + "_" +
ToXString(nLower)
//
;
@@ -545,7 +545,7 @@ struct XBoxZone
double nMid = NormalizeDouble(NormalizePrice(GetMid(), symbol), digits);
//
string typeStr = IsValid(type)
string typeStr = IsSpecifiedValid(type)
? type
: "XBOX";
string result =
@@ -554,8 +554,8 @@ struct XBoxZone
"Mid_" +
ToString(dir) + "_" +
symbol + "_" +
ToString(period) + "_" +
ToString(nMid)
ToXString(period) + "_" +
ToXString(nMid)
//
;
@@ -614,11 +614,11 @@ struct XDirectionShift
//
result =
after > 0 &&
IsValid(at) &&
IsValid(type) &&
IsSpecifiedValid(at) &&
IsSpecifiedValid(type) &&
after != before &&
IsValid(symbol) &&
IsValid(period) &&
IsSpecifiedValid(symbol) &&
IsSpecifiedValid(period) &&
HasDirection(shiftTo);
//
+135 -65
View File
@@ -353,7 +353,7 @@ struct XRR
type = X_POSITION_TYPE_NONE;
//
Clean(tps);
SpecifiedClean(tps);
//
ZeroMemory(this);
@@ -376,8 +376,8 @@ struct XRR
result =
_sl > 0 &&
_entry > 0 &&
IsValid(_symbol) &&
IsValid(_period) &&
IsSpecifiedValid(_symbol) &&
IsSpecifiedValid(_period) &&
_type != X_POSITION_TYPE_ALL &&
_type != X_POSITION_TYPE_NONE &&
(_type == X_POSITION_TYPE_LONG
@@ -453,9 +453,9 @@ struct XRR
result =
sl > 0 &&
entry > 0 &&
IsValid(time) &&
IsValid(symbol) &&
IsValid(period) &&
IsSpecifiedValid(time) &&
IsSpecifiedValid(symbol) &&
IsSpecifiedValid(period) &&
IsValidSize(ArraySize(tps)) &&
type != X_POSITION_TYPE_ALL &&
type != X_POSITION_TYPE_NONE &&
@@ -486,7 +486,7 @@ struct XRR
//
result =
GetTypeName(this) + sep + (IsValid(prefix) ? prefix + sep : "") + symbol + sep + ToString(period) + sep + ToFormatString(time) + sep + ToString(type);
GetTypeName(this) + sep + (IsSpecifiedValid(prefix) ? prefix + sep : "") + symbol + sep + ToXString(period) + sep + ToFormatString(time) + sep + ToString(type);
//
return result;
@@ -864,7 +864,7 @@ struct XPosition
//
result =
//
IsValid(symbol) &&
IsSpecifiedValid(symbol) &&
NotEmpty(ticket)
//
;
@@ -887,7 +887,7 @@ struct XPosition
}
//
result = GetEntry(
result = GetXEntry(
symbol,
type
//
@@ -911,7 +911,7 @@ struct XPosition
}
//
result = GetExit(
result = GetXExit(
symbol,
type
//
@@ -935,7 +935,7 @@ struct XPosition
}
//
result = PriceToPoint(GetSpread(symbol));
result = PriceToPoint(GetXSpread(symbol));
//
return result;
@@ -1067,7 +1067,7 @@ struct XPosition
int result = 0;
//
Clean(tps);
SpecifiedClean(tps);
//
bool isValid = IsValid();
@@ -1175,7 +1175,7 @@ struct XPosition
ENUM_TIMEFRAMES mPeriod // Calculate Age based on this period
)
{
return GetAge(this, mPeriod);
return GetXAge(this, mPeriod);
}
//
@@ -1207,11 +1207,11 @@ struct XPosition
//
// Find index in a Collection ...
int FindIndex(
const XPosition &values[] // Collection to Find
XPosition &values[] // Collection to Find
)
{
//
return FindIndex(
return FindXIndex(
this,
values
//
@@ -1358,7 +1358,7 @@ struct XSignal
conditions = NULL;
//
Clean(targets);
SpecifiedClean(targets);
appliedTargetIDX = -1;
ignoreEAVolume = false;
isTargetApplied = false;
@@ -1387,7 +1387,7 @@ struct XSignal
conditions = NULL;
//
Clean(targets);
SpecifiedClean(targets);
appliedTargetIDX = -1;
ignoreEAVolume = false;
isTargetApplied = false;
@@ -1403,8 +1403,8 @@ struct XSignal
//
result =
//
IsValid(period) &&
IsValid(symbol) &&
IsSpecifiedValid(period) &&
IsSpecifiedValid(symbol) &&
NotEmpty(volume) &&
NotEmpty(entry)
//
@@ -1481,7 +1481,7 @@ struct XSignal
}
//
if (IsValid(provider))
if (IsSpecifiedValid(provider))
{
//
// Generate Provider Tag ...
@@ -1489,7 +1489,7 @@ struct XSignal
}
//
if (IsValid(period))
if (IsSpecifiedValid(period))
{
//
// Generate Period Tag ...
@@ -1504,7 +1504,7 @@ struct XSignal
int GetAge()
{
//
return GetAge(
return GetXAge(
this,
this.period //
);
@@ -1579,11 +1579,11 @@ struct XSignal
//
result = "XSignal_" +
symbol + "_" +
ToString(period) + "_" +
ToString(type) + "_" +
ToString(sl) + "_" +
ToString(tp) + "_" +
ToString(entry);
ToXString(period) + "_" +
ToXString(type) + "_" +
ToXString(sl) + "_" +
ToXString(tp) + "_" +
ToXString(entry);
//
return result;
@@ -1599,17 +1599,17 @@ struct XSignal
//
result =
//
ToString("Symbol", symbol) +
ToString("Period", period) +
ToString("Provider", provider) +
ToString("Type", type) +
ToString("Mode", mode) +
ToString("Volume", volume) +
ToString("Entry", entry) +
ToString("TP", tp) +
ToString("SL", sl) +
ToString("Time", time) +
ToString("Comment", comment) +
ToXString("Symbol", symbol) +
ToXString("Period", period) +
ToXString("Provider", provider) +
ToXString("Type", type) +
ToXString("Mode", mode) +
ToXString("Volume", volume) +
ToXString("Entry", entry) +
ToXString("TP", tp) +
ToXString("SL", sl) +
ToXString("Time", time) +
ToXString("Comment", comment) +
//
""
//
@@ -1660,14 +1660,14 @@ struct XSignal
}
//
result = ToString(type) +
result = ToXString(type) +
" Signal" +
(!IsValid(action)
(!IsSpecifiedValid(action)
? ""
: " " + action) +
" by: " + provider +
" on (" + symbol + ")" +
" in: " + ToString(period);
" in: " + ToXString(period);
//
return result;
@@ -1689,8 +1689,8 @@ struct XSignal
result =
//
symbol + "\\" +
ToString(type) + "\\" +
ToString(period) + "_" +
ToXString(type) + "\\" +
ToXString(period) + "_" +
ToFormatString(time)
//
;
@@ -1978,7 +1978,7 @@ struct XOrder
//
result =
//
IsValid(symbol) &&
IsSpecifiedValid(symbol) &&
NotEmpty(ticket) &&
NotEmpty(positionId)
//
@@ -1994,7 +1994,7 @@ struct XOrder
ENUM_TIMEFRAMES mPeriod // Calculate Age based on this period
)
{
return GetAge(this, mPeriod);
return GetXAge(this, mPeriod);
}
//
@@ -2026,11 +2026,11 @@ struct XOrder
//
// Find index in a Collection ...
int FindIndex(
const XOrder &values[] // Collection to Find
XOrder &values[] // Collection to Find
)
{
//
return FindIndex(
return FindXIndex(
this,
values
//
@@ -2338,7 +2338,7 @@ struct XDeal
//
result =
//
IsValid(symbol) &&
IsSpecifiedValid(symbol) &&
NotEmpty(ticket) &&
NotEmpty(positionId)
//
@@ -2354,7 +2354,7 @@ struct XDeal
ENUM_TIMEFRAMES mPeriod // Calculate Age based on this period
)
{
return GetAge(this, mPeriod);
return GetXAge(this, mPeriod);
}
//
@@ -2388,11 +2388,11 @@ struct XDeal
//
// Find index in a Collection ...
int FindIndex(
const XDeal &values[] // Collection to Find
XDeal &values[] // Collection to Find
)
{
//
return FindIndex(
return FindXIndex(
this,
values
//
@@ -2668,7 +2668,7 @@ struct XSymbolPositions
);
//
Clean(positions);
SpecifiedClean(positions);
//
int tmpsCount = ArraySize(_tmp);
@@ -2698,14 +2698,14 @@ struct XSymbolPositions
}
//
Clean(_tmp);
SpecifiedClean(_tmp);
//
Copy(
_positions,
positions //
);
Clean(_positions);
SpecifiedClean(_positions);
//
// Extract Types ...
@@ -2720,7 +2720,7 @@ struct XSymbolPositions
_supports,
supports //
);
Clean(_supports);
SpecifiedClean(_supports);
//
// Extract Types ...
@@ -2779,7 +2779,7 @@ struct XSymbolPositions
);
//
Clean(_allPositions);
SpecifiedClean(_allPositions);
//
result = true;
@@ -2813,9 +2813,9 @@ struct XSymbolPositions
requiredProfitForHedge = 0;
//
Clean(longs);
Clean(shorts);
Clean(positions);
SpecifiedClean(longs);
SpecifiedClean(shorts);
SpecifiedClean(positions);
//
ZeroMemory(this);
@@ -2829,7 +2829,7 @@ struct XSymbolPositions
bool result = false;
//
result = IsValid(symbol);
result = IsSpecifiedValid(symbol);
//
return result;
@@ -2920,7 +2920,7 @@ struct XSymbolPositions
if (isLong)
{
//
result = GetOldest(
result = GetXOldest(
_oldest,
longs //
);
@@ -2928,7 +2928,7 @@ struct XSymbolPositions
else
{
//
result = GetOldest(
result = GetXOldest(
_oldest,
shorts //
);
@@ -2964,7 +2964,7 @@ struct XSymbolPositions
if (isLong)
{
//
result = GetYoungest(
result = GetXYoungest(
_youngest,
longs //
);
@@ -2972,7 +2972,7 @@ struct XSymbolPositions
else
{
//
result = GetYoungest(
result = GetXYoungest(
_youngest,
shorts //
);
@@ -3284,6 +3284,13 @@ int GetAge(
//
return result;
}
int GetXAge(
XSignal &signal, // Selected Signal ...
ENUM_TIMEFRAMES period = NULL // Dest Time Frame ...
)
{
return GetAge(signal, period);
}
//
// Retrieve a Position Age ...
@@ -3310,6 +3317,13 @@ int GetAge(
//
return result;
}
int GetXAge(
XPosition &position, // Selected Position ...
ENUM_TIMEFRAMES period = NULL // Dest Time Frame ...
)
{
return GetAge(position, period);
}
//
// Retrieve an Order Age ...
@@ -3336,6 +3350,13 @@ int GetAge(
//
return result;
}
int GetXAge(
XOrder &order, // Selected Order ...
ENUM_TIMEFRAMES period = NULL // Dest Time Frame ...
)
{
return GetAge(order, period);
}
//
// Retrieve a Deal Age ...
@@ -3362,6 +3383,13 @@ int GetAge(
//
return result;
}
int GetXAge(
XDeal &deal, // Selected Deal ...
ENUM_TIMEFRAMES period = NULL // Dest Time Frame ...
)
{
return GetAge(deal, period);
}
//
// Get Oldest Deal ...
@@ -3410,6 +3438,13 @@ int GetOldest(
//
return result;
}
int GetXOldest(
XDeal &item, // Hold Result ...
XDeal &items[] // Source Array ...
)
{
return GetOldest(item, items);
}
//
// Get Youngest Deal ...
@@ -3458,6 +3493,13 @@ int GetYoungest(
//
return result;
}
int GetXYoungest(
XDeal &item, // Hold Result ...
XDeal &items[] // Source Array ...
)
{
return GetYoungest(item, items);
}
//
// Get Oldest Order ...
@@ -3506,6 +3548,13 @@ int GetOldest(
//
return result;
}
int GetXOldest(
XOrder &item, // Hold Result ...
XOrder &items[] // Source Array ...
)
{
return GetOldest(item, items);
}
//
// Get Youngest Order ...
@@ -3554,6 +3603,13 @@ int GetYoungest(
//
return result;
}
int GetXYoungest(
XOrder &item, // Hold Result ...
XOrder &items[] // Source Array ...
)
{
return GetYoungest(item, items);
}
//
// Get Oldes Position ...
@@ -3602,6 +3658,13 @@ int GetOldest(
//
return result;
}
int GetXOldest(
XPosition &item, // Hold Result ...
XPosition &items[] // Source Array ...
)
{
return GetOldest(item, items);
}
//
// Get Youngest Position ...
@@ -3650,6 +3713,13 @@ int GetYoungest(
//
return result;
}
int GetXYoungest(
XPosition &item, // Hold Result ...
XPosition &items[] // Source Array ...
)
{
return GetYoungest(item, items);
}
//
int FindMaxProfitIndex(
@@ -4481,7 +4551,7 @@ ENUM_ORDER_TYPE ToOrderType(ENUM_X_POSITION_TYPES value)
string GeneratePeriodTag(ENUM_TIMEFRAMES period)
{
//
string strPeriod = ToString(period);
string strPeriod = ToXString(period);
return Surround(
XPeriodToken,
strPeriod