prepare workspace by eu5, add some scripts and node modules on Documents folder, extends compile script and also node module to automate usefull most commonly used compilation tasks and also create required npm scripts and vscode debug lunch tasks based on them ...
This commit is contained in:
@@ -0,0 +1,261 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Logger Library
|
||||
// ---------------------------------------
|
||||
// Name: XLogger
|
||||
// Description: provides Logging abilities ...
|
||||
//
|
||||
//
|
||||
// Maintainer:
|
||||
// ------------
|
||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||
//
|
||||
//////////////////////////////////////////////////////
|
||||
//
|
||||
// Global Properties ...
|
||||
#property library
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://www.saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// START Inputs ...
|
||||
//
|
||||
input group "Logging";
|
||||
input bool enableLogging = true; // Enable Logging
|
||||
//
|
||||
// END Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
// Including Models ...
|
||||
#include "x-saherelm.models.lib.mq5"
|
||||
|
||||
//
|
||||
// START Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
string logTag = "X-Logger"; // LogTag
|
||||
//
|
||||
// END Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Provided Functions ...
|
||||
//
|
||||
//
|
||||
// Logging a Message ...
|
||||
void LogMessage(string message)
|
||||
{
|
||||
//
|
||||
if (!enableLogging)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
Print(logTag, " > ", message);
|
||||
}
|
||||
void LogMessage(string tag, string message)
|
||||
{
|
||||
//
|
||||
if (!enableLogging)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
Print(tag, " > ", message);
|
||||
}
|
||||
|
||||
//
|
||||
// Logging an Array ...
|
||||
void LogArray(int &array[])
|
||||
{
|
||||
//
|
||||
if (!enableLogging)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
Print(logTag, ">");
|
||||
ArrayPrint(array);
|
||||
}
|
||||
void LogArray(double &array[])
|
||||
{
|
||||
//
|
||||
if (!enableLogging)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
Print(logTag, ">");
|
||||
ArrayPrint(array);
|
||||
}
|
||||
void LogArray(string &array[])
|
||||
{
|
||||
//
|
||||
if (!enableLogging)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
Print(logTag, ">");
|
||||
ArrayPrint(array);
|
||||
}
|
||||
|
||||
//
|
||||
// Convert a Signal to String Message ...
|
||||
string SignalToString(const XSignal &signal)
|
||||
{
|
||||
//
|
||||
string result = "\n";
|
||||
|
||||
//
|
||||
result += "Signal: " + "\n";
|
||||
result += "id: " + (string)signal.id + "\n";
|
||||
result += "symbol: " + signal.symbol + "\n";
|
||||
result += "type: " + EnumToString(signal.type) + "\n";
|
||||
result += "magicNumber: " + (string)signal.magicNumber + "\n";
|
||||
result += "ticket: " + (string)signal.ticket + "\n";
|
||||
result += "entry: " + (string)signal.entry + "\n";
|
||||
result += "tp: " + (string)signal.tp + "\n";
|
||||
result += "sl: " + (string)signal.sl + "\n";
|
||||
result += "riskFreeStep: " + (string)signal.riskFreeStep + "\n";
|
||||
result += "riskFreeRate: " + (string)signal.riskFreeRate + "\n";
|
||||
result += "profit: " + (string)signal.profit + "\n";
|
||||
result += "time: " + (string)signal.time + "\n";
|
||||
result += "volume: " + (string)signal.volume + "\n";
|
||||
result += "comment: " + signal.comment + "\n";
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Convert an Executed Signal to String Message ...
|
||||
string ExecutedSignalToString(const XSignal &signal)
|
||||
{
|
||||
//
|
||||
string result = "";
|
||||
|
||||
//
|
||||
result += (signal.type == X_SIGNAL_LONG ? "Buy" : "Sell") + " Signal Executed provided on (" + signal.symbol + " _ " + EnumToString(_Period) + ") by this comment: " + signal.comment;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Logging Signal ...
|
||||
void LogSignal(const XSignal &signal)
|
||||
{
|
||||
//
|
||||
string message = SignalToString(signal);
|
||||
|
||||
//
|
||||
LogMessage(message);
|
||||
}
|
||||
|
||||
//
|
||||
// Log Signal Execution ...
|
||||
void LogExecutedSignal(const XSignal &signal)
|
||||
{
|
||||
//
|
||||
string message = ExecutedSignalToString(signal);
|
||||
|
||||
//
|
||||
LogMessage(message);
|
||||
}
|
||||
|
||||
//
|
||||
// Convert a Deal to String ...
|
||||
string DealToString(const XDeal &deal)
|
||||
{
|
||||
//
|
||||
string result = "\n";
|
||||
|
||||
//
|
||||
result += "Deal:" + "\n";
|
||||
result += " " + "\n";
|
||||
result += "time: " + (string)deal.time + "\n";
|
||||
result += "ticket: " + (string)deal.ticket + "\n";
|
||||
result += "order: " + (string)deal.order + "\n";
|
||||
result += "positionId: " + (string)deal.positionId + "\n";
|
||||
result += "type: " + EnumToString(deal.type) + "\n";
|
||||
result += "entry: " + EnumToString(deal.entry) + "\n";
|
||||
result += "reason: " + EnumToString(deal.reason) + "\n";
|
||||
result += "symbol: " + deal.symbol + "\n";
|
||||
result += "price: " + (string)deal.price + "\n";
|
||||
result += "profit: " + (string)deal.profit + "\n";
|
||||
result += "swap: " + (string)deal.swap + "\n";
|
||||
result += "commission: " + (string)deal.commission + "\n";
|
||||
result += "volume: " + (string)deal.volume + "\n";
|
||||
result += "comment: " + deal.comment + "\n";
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Log Specific Deal ...
|
||||
void LogDeal(const XDeal &deal)
|
||||
{
|
||||
//
|
||||
string message = DealToString(deal);
|
||||
|
||||
//
|
||||
LogMessage(message);
|
||||
}
|
||||
|
||||
//
|
||||
// Convert an Order to String ...
|
||||
string OrderToString(const XOrder &order)
|
||||
{
|
||||
//
|
||||
string result = "\n";
|
||||
|
||||
//
|
||||
result += "Order: " + "\n";
|
||||
result += "magic: " + (string)order.magic + "\n";
|
||||
result += "positionId: " + (string)order.positionId + "\n";
|
||||
result += "symbol: " + (string)order.symbol + "\n";
|
||||
result += "ticket: " + (string)order.ticket + "\n";
|
||||
result += "timeSetup: " + (string)order.timeSetup + "\n";
|
||||
result += "timeDone: " + (string)order.timeDone + "\n";
|
||||
result += "timeExpiration: " + (string)order.timeExpiration + "\n";
|
||||
result += "priceOpen: " + (string)order.priceOpen + "\n";
|
||||
result += "priceCurrent: " + (string)order.priceCurrent + "\n";
|
||||
result += "priceStopLimit: " + (string)order.priceStopLimit + "\n";
|
||||
result += "stopLoss: " + (string)order.stopLoss + "\n";
|
||||
result += "takeProfit: " + (string)order.takeProfit + "\n";
|
||||
result += "volumeInitial: " + (string)order.volumeInitial + "\n";
|
||||
result += "volumeCurrent: " + (string)order.volumeCurrent + "\n";
|
||||
result += "comment: " + order.comment + "\n";
|
||||
result += "type: " + EnumToString(order.type) + "\n";
|
||||
result += "state: " + EnumToString(order.state) + "\n";
|
||||
result += "typeFilling: " + EnumToString(order.typeFilling) + "\n";
|
||||
result += "typeTime: " + EnumToString(order.typeTime) + "\n";
|
||||
result += "reason: " + EnumToString(order.reason) + "\n";
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Log Specific Order ...
|
||||
void LogOrder(const XOrder &order)
|
||||
{
|
||||
//
|
||||
string message = OrderToString(order);
|
||||
|
||||
//
|
||||
LogMessage(message);
|
||||
}
|
||||
|
||||
//
|
||||
// END Provided Functions ...
|
||||
//
|
||||
Reference in New Issue
Block a user