last works applied on XEU5 and pack it ...

also add compile and pack npm script  for XEU5 ...
This commit is contained in:
2024-01-31 17:31:44 -08:00
parent a098550391
commit f973488cdd
8 changed files with 760 additions and 62 deletions
+47
View File
@@ -24,8 +24,15 @@
// START Inputs ...
//
//
input group "Commons";
//
// XCTIMER inputs ...
input bool xEU5ShowCandleTimer = true; // Show Condle Remaining Time
input color xEU5CandleTimerColot = clrYellow; // Candle Timer Color
input ENUM_BASE_CORNER xEU5CandleTimerCorner = CORNER_RIGHT_LOWER; // Where to Show Candle Timer
//
// END Inputs ...
//
@@ -65,6 +72,9 @@ bool isXEU5NewHour;
bool isXEU5NewDay;
bool isXEU5NewWeek;
bool isXEU5NewMonth;
//
int xEU5CTimerHandler = INVALID_HANDLE;
//
// END Global Definitions: Variables, Properties and etc ...
//
@@ -104,6 +114,16 @@ int OnInit()
return INIT_PARAMETERS_INCORRECT;
}
//
// Init XCTimer ...
if (xEU5ShowCandleTimer)
{
if (!XCTimerInit())
{
return INIT_FAILED;
}
}
//
// Init Succeed ...
return INIT_SUCCEEDED;
@@ -135,6 +155,9 @@ void OnDeinit(const int reason)
//
// De Init XDraw Library ...
// OnDeinitDrawLibrary();
//
IndicatorRelease(xEU5CTimerHandler);
}
//
@@ -344,6 +367,30 @@ bool ValidateInputs()
return result;
}
bool XCTimerInit()
{
//
bool result = true;
//
xEU5CTimerHandler = iCustom(
_Symbol,
_Period,
"x-saherelm.xctimer.indicator",
//
// Inputs ...
xEU5CandleTimerColot,
xEU5CandleTimerCorner
);
//
if (xEU5CTimerHandler == INVALID_HANDLE) {
result = false;
}
//
return result;
}
//
// END Functions ...
//
@@ -0,0 +1,206 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 XCTimer Indicator
// ---------------------------------------------
// Name: XCTimer
// Description: Trend Magic Indicator ...
//
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
// Global Properties ...
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir"
#property version "1.00"
#property description "SaherElm XCTimer Indicator"
#property strict
//
// START Constants ...
//
#define ShortName "XCTimer"
//
// END Constants ...
//
//
// START Inputs ...
//
input color clr = clrYellow;
input ENUM_BASE_CORNER corner = CORNER_RIGHT_LOWER;
//
// END Inputs ...
//
//
// START Buffers ...
//
//
// END Buffers ...
//
//
// START Global Definitions: Variables, Properties and etc ...
//
//
// END Global Definitions: Variables, Properties and etc ...
//
//
// START Event Handlers ...
//
//
// Initialization ...
int OnInit()
{
//
// Validate Inputs ...
CreateIndicatorObject();
//
// Set Indicator ShortName ...
SetIndicatorName();
//
// Init Succeed ...
return INIT_SUCCEEDED;
}
//
// DeInitialization ...
void OnDeinit(const int reason)
{
//
// REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function
// REASON_REMOVE 1 Program removed from a chart
// REASON_RECOMPILE 2 Program recompiled
// REASON_CHARTCHANGE 3 A symbol or a chart period is changed
// REASON_CHARTCLOSE 4 Chart closed
// REASON_PARAMETERS 5 Inputs changed by a user
// REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings
// REASON_TEMPLATE 7 Another chart template applied
// REASON_INITFAILED 8 The OnInit() handler returned a non-zero value
// REASON_CLOSE 9 Terminal closed
//
// Delete Object ...
ObjectDelete(0, ShortName);
}
//
// Calculations ...
//
// Calculating what we want ...
int OnCalculate(
//
// total Candles on chart ...
const int rates_total,
//
// total calculated Candles on charts ...
const int prev_calculated,
//
// history of Candles Open Time ...
const datetime &time[],
//
// history of Candles Open Price ...
const double &open[],
//
// history of Candles High Price ...
const double &high[],
//
// history of Candles Low Price ...
const double &low[],
//
// history of Candles Close Price ...
const double &close[],
//
// history of Tick Volumes on Candle ...
const long &tick_volume[],
//
// history of Trade Volumes ...
const long &volume[],
//
// history of Candles Spread Price ...
const int &spread[])
{
//
ArraySetAsSeries(time, true);
//
int m = int(time[0] + PeriodSeconds() - TimeCurrent());
int s = m % 60;
m = (m - s) / 60;
//
long mSpread = SymbolInfoInteger(Symbol(), SYMBOL_SPREAD);
string _sp = "", _m = "", _s = "";
if (mSpread < 10)
_sp = "..";
else if (mSpread < 100)
_sp = ".";
if (m < 10)
_m = "0";
if (s < 10)
_s = "0";
//
string objText = "Spread: " + IntegerToString(mSpread) + _sp + " Next Bar in " + _m + IntegerToString(m) + ":" + _s + IntegerToString(s);
//
ObjectSetInteger(0, ShortName, OBJPROP_COLOR, clr);
ObjectSetString(0, ShortName, OBJPROP_TEXT, objText);
ObjectSetInteger(0, ShortName, OBJPROP_FONTSIZE, 10);
ObjectSetString(0, ShortName, OBJPROP_FONT, "Courier");
//
return rates_total;
}
//
// END Event Handlers ...
//
//
// START Functions ...
//
//
// Set Indicator Short Name and also we can define Buffers Labels ...
void SetIndicatorName()
{
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
}
void CreateIndicatorObject()
{
//
ObjectCreate(0, ShortName, OBJ_LABEL, 0, 0, 0);
ObjectSetInteger(0, ShortName, OBJPROP_CORNER, corner);
ObjectSetInteger(0, ShortName, OBJPROP_XDISTANCE, 10);
ObjectSetInteger(0, ShortName, OBJPROP_YDISTANCE, 2);
ENUM_ANCHOR_POINT Anchor = ANCHOR_LEFT_UPPER;
switch (corner)
{
case CORNER_LEFT_UPPER:
Anchor = ANCHOR_LEFT_UPPER;
break;
case CORNER_RIGHT_UPPER:
Anchor = ANCHOR_RIGHT_UPPER;
break;
case CORNER_LEFT_LOWER:
Anchor = ANCHOR_LEFT_LOWER;
break;
case CORNER_RIGHT_LOWER:
Anchor = ANCHOR_RIGHT_LOWER;
break;
}
//
ObjectSetInteger(0, ShortName, OBJPROP_ANCHOR, Anchor);
}
//
// END Functions ...
//
+47
View File
@@ -24,8 +24,15 @@
// START Inputs ...
//
//
input group "Commons";
//
// XCTIMER inputs ...
input bool xEU5ShowCandleTimer = true; // Show Condle Remaining Time
input color xEU5CandleTimerColot = clrYellow; // Candle Timer Color
input ENUM_BASE_CORNER xEU5CandleTimerCorner = CORNER_RIGHT_LOWER; // Where to Show Candle Timer
//
// END Inputs ...
//
@@ -65,6 +72,9 @@ bool isXEU5NewHour;
bool isXEU5NewDay;
bool isXEU5NewWeek;
bool isXEU5NewMonth;
//
int xEU5CTimerHandler = INVALID_HANDLE;
//
// END Global Definitions: Variables, Properties and etc ...
//
@@ -104,6 +114,16 @@ int OnInit()
return INIT_PARAMETERS_INCORRECT;
}
//
// Init XCTimer ...
if (xEU5ShowCandleTimer)
{
if (!XCTimerInit())
{
return INIT_FAILED;
}
}
//
// Init Succeed ...
return INIT_SUCCEEDED;
@@ -135,6 +155,9 @@ void OnDeinit(const int reason)
//
// De Init XDraw Library ...
// OnDeinitDrawLibrary();
//
IndicatorRelease(xEU5CTimerHandler);
}
//
@@ -344,6 +367,30 @@ bool ValidateInputs()
return result;
}
bool XCTimerInit()
{
//
bool result = true;
//
xEU5CTimerHandler = iCustom(
_Symbol,
_Period,
"x-saherelm.xctimer.indicator",
//
// Inputs ...
xEU5CandleTimerColot,
xEU5CandleTimerCorner
);
//
if (xEU5CTimerHandler == INVALID_HANDLE) {
result = false;
}
//
return result;
}
//
// END Functions ...
//
+206
View File
@@ -0,0 +1,206 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 XCTimer Indicator
// ---------------------------------------------
// Name: XCTimer
// Description: Trend Magic Indicator ...
//
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
// Global Properties ...
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir"
#property version "1.00"
#property description "SaherElm XCTimer Indicator"
#property strict
//
// START Constants ...
//
#define ShortName "XCTimer"
//
// END Constants ...
//
//
// START Inputs ...
//
input color clr = clrYellow;
input ENUM_BASE_CORNER corner = CORNER_RIGHT_LOWER;
//
// END Inputs ...
//
//
// START Buffers ...
//
//
// END Buffers ...
//
//
// START Global Definitions: Variables, Properties and etc ...
//
//
// END Global Definitions: Variables, Properties and etc ...
//
//
// START Event Handlers ...
//
//
// Initialization ...
int OnInit()
{
//
// Validate Inputs ...
CreateIndicatorObject();
//
// Set Indicator ShortName ...
SetIndicatorName();
//
// Init Succeed ...
return INIT_SUCCEEDED;
}
//
// DeInitialization ...
void OnDeinit(const int reason)
{
//
// REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function
// REASON_REMOVE 1 Program removed from a chart
// REASON_RECOMPILE 2 Program recompiled
// REASON_CHARTCHANGE 3 A symbol or a chart period is changed
// REASON_CHARTCLOSE 4 Chart closed
// REASON_PARAMETERS 5 Inputs changed by a user
// REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings
// REASON_TEMPLATE 7 Another chart template applied
// REASON_INITFAILED 8 The OnInit() handler returned a non-zero value
// REASON_CLOSE 9 Terminal closed
//
// Delete Object ...
ObjectDelete(0, ShortName);
}
//
// Calculations ...
//
// Calculating what we want ...
int OnCalculate(
//
// total Candles on chart ...
const int rates_total,
//
// total calculated Candles on charts ...
const int prev_calculated,
//
// history of Candles Open Time ...
const datetime &time[],
//
// history of Candles Open Price ...
const double &open[],
//
// history of Candles High Price ...
const double &high[],
//
// history of Candles Low Price ...
const double &low[],
//
// history of Candles Close Price ...
const double &close[],
//
// history of Tick Volumes on Candle ...
const long &tick_volume[],
//
// history of Trade Volumes ...
const long &volume[],
//
// history of Candles Spread Price ...
const int &spread[])
{
//
ArraySetAsSeries(time, true);
//
int m = int(time[0] + PeriodSeconds() - TimeCurrent());
int s = m % 60;
m = (m - s) / 60;
//
long mSpread = SymbolInfoInteger(Symbol(), SYMBOL_SPREAD);
string _sp = "", _m = "", _s = "";
if (mSpread < 10)
_sp = "..";
else if (mSpread < 100)
_sp = ".";
if (m < 10)
_m = "0";
if (s < 10)
_s = "0";
//
string objText = "Spread: " + IntegerToString(mSpread) + _sp + " Next Bar in " + _m + IntegerToString(m) + ":" + _s + IntegerToString(s);
//
ObjectSetInteger(0, ShortName, OBJPROP_COLOR, clr);
ObjectSetString(0, ShortName, OBJPROP_TEXT, objText);
ObjectSetInteger(0, ShortName, OBJPROP_FONTSIZE, 10);
ObjectSetString(0, ShortName, OBJPROP_FONT, "Courier");
//
return rates_total;
}
//
// END Event Handlers ...
//
//
// START Functions ...
//
//
// Set Indicator Short Name and also we can define Buffers Labels ...
void SetIndicatorName()
{
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
}
void CreateIndicatorObject()
{
//
ObjectCreate(0, ShortName, OBJ_LABEL, 0, 0, 0);
ObjectSetInteger(0, ShortName, OBJPROP_CORNER, corner);
ObjectSetInteger(0, ShortName, OBJPROP_XDISTANCE, 10);
ObjectSetInteger(0, ShortName, OBJPROP_YDISTANCE, 2);
ENUM_ANCHOR_POINT Anchor = ANCHOR_LEFT_UPPER;
switch (corner)
{
case CORNER_LEFT_UPPER:
Anchor = ANCHOR_LEFT_UPPER;
break;
case CORNER_RIGHT_UPPER:
Anchor = ANCHOR_RIGHT_UPPER;
break;
case CORNER_LEFT_LOWER:
Anchor = ANCHOR_LEFT_LOWER;
break;
case CORNER_RIGHT_LOWER:
Anchor = ANCHOR_RIGHT_LOWER;
break;
}
//
ObjectSetInteger(0, ShortName, OBJPROP_ANCHOR, Anchor);
}
//
// END Functions ...
//
@@ -1,62 +0,0 @@
//+------------------------------------------------------------------+
//| CandleTimeStationary|
//| |
//| |
//+------------------------------------------------------------------+
#property indicator_chart_window
#property strict
//---- input parameters
input color Clock_Color = clrDimGray;
input ENUM_BASE_CORNER Corner = CORNER_RIGHT_UPPER;
string objname="Spread&Bar";
double s1[];
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
int OnInit()
{
ObjectCreate(0, objname, OBJ_LABEL,0, 0, 0);
ObjectSetInteger(0, objname, OBJPROP_CORNER, Corner);
ObjectSetInteger(0, objname, OBJPROP_XDISTANCE, 10);
ObjectSetInteger(0, objname, OBJPROP_YDISTANCE, 2);
ENUM_ANCHOR_POINT Anchor = ANCHOR_LEFT_UPPER;
switch (Corner)
{
case CORNER_LEFT_UPPER: Anchor=ANCHOR_LEFT_UPPER; break;
case CORNER_RIGHT_UPPER: Anchor=ANCHOR_RIGHT_UPPER; break;
case CORNER_LEFT_LOWER: Anchor=ANCHOR_LEFT_LOWER; break;
case CORNER_RIGHT_LOWER: Anchor=ANCHOR_RIGHT_LOWER; break;
}
ObjectSetInteger(0, objname, OBJPROP_ANCHOR, Anchor);
return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
void OnDeinit(const int reason) { ObjectDelete(0, objname); }
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total, const int prev_calculated, const datetime& time[], const double& open[], const double& high[], const double& low[], const double& close[], const long& tick_volume[], const long& volume[], const int& spreads[])
{
ArraySetAsSeries(time, true);
int m=int(time[0]+PeriodSeconds()-TimeCurrent());
int s=m%60;
m=(m-s)/60;
long spread=SymbolInfoInteger(Symbol(), SYMBOL_SPREAD);
string _sp="",_m="",_s="";
if (spread<10) _sp="..";
else if (spread<100) _sp=".";
if (m<10) _m="0";
if (s<10) _s="0";
ObjectSetString(0, objname, OBJPROP_TEXT, "Spread: " +IntegerToString(spread)+_sp+" Next Bar in "+_m+IntegerToString(m)+":"+_s+IntegerToString(s));
ObjectSetInteger(0, objname, OBJPROP_FONTSIZE, 10);
ObjectSetInteger(0, objname, OBJPROP_COLOR, Clock_Color);
ObjectSetString(0, objname, OBJPROP_FONT, "Courier");
return(rates_total);
}
@@ -24,8 +24,15 @@
// START Inputs ...
//
//
input group "Commons";
//
// XCTIMER inputs ...
input bool xEU5ShowCandleTimer = true; // Show Condle Remaining Time
input color xEU5CandleTimerColot = clrYellow; // Candle Timer Color
input ENUM_BASE_CORNER xEU5CandleTimerCorner = CORNER_RIGHT_LOWER; // Where to Show Candle Timer
//
// END Inputs ...
//
@@ -65,6 +72,9 @@ bool isXEU5NewHour;
bool isXEU5NewDay;
bool isXEU5NewWeek;
bool isXEU5NewMonth;
//
int xEU5CTimerHandler = INVALID_HANDLE;
//
// END Global Definitions: Variables, Properties and etc ...
//
@@ -104,6 +114,16 @@ int OnInit()
return INIT_PARAMETERS_INCORRECT;
}
//
// Init XCTimer ...
if (xEU5ShowCandleTimer)
{
if (!XCTimerInit())
{
return INIT_FAILED;
}
}
//
// Init Succeed ...
return INIT_SUCCEEDED;
@@ -135,6 +155,9 @@ void OnDeinit(const int reason)
//
// De Init XDraw Library ...
// OnDeinitDrawLibrary();
//
IndicatorRelease(xEU5CTimerHandler);
}
//
@@ -344,6 +367,30 @@ bool ValidateInputs()
return result;
}
bool XCTimerInit()
{
//
bool result = true;
//
xEU5CTimerHandler = iCustom(
_Symbol,
_Period,
"x-saherelm.xctimer.indicator",
//
// Inputs ...
xEU5CandleTimerColot,
xEU5CandleTimerCorner
);
//
if (xEU5CTimerHandler == INVALID_HANDLE) {
result = false;
}
//
return result;
}
//
// END Functions ...
//
@@ -0,0 +1,206 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 XCTimer Indicator
// ---------------------------------------------
// Name: XCTimer
// Description: Trend Magic Indicator ...
//
//
// Maintainer:
// ------------
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
//
//////////////////////////////////////////////////////
//
// Global Properties ...
#property copyright "Copyright 2023, SaherElm IT Center"
#property link "https://saherelm.ir"
#property version "1.00"
#property description "SaherElm XCTimer Indicator"
#property strict
//
// START Constants ...
//
#define ShortName "XCTimer"
//
// END Constants ...
//
//
// START Inputs ...
//
input color clr = clrYellow;
input ENUM_BASE_CORNER corner = CORNER_RIGHT_LOWER;
//
// END Inputs ...
//
//
// START Buffers ...
//
//
// END Buffers ...
//
//
// START Global Definitions: Variables, Properties and etc ...
//
//
// END Global Definitions: Variables, Properties and etc ...
//
//
// START Event Handlers ...
//
//
// Initialization ...
int OnInit()
{
//
// Validate Inputs ...
CreateIndicatorObject();
//
// Set Indicator ShortName ...
SetIndicatorName();
//
// Init Succeed ...
return INIT_SUCCEEDED;
}
//
// DeInitialization ...
void OnDeinit(const int reason)
{
//
// REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function
// REASON_REMOVE 1 Program removed from a chart
// REASON_RECOMPILE 2 Program recompiled
// REASON_CHARTCHANGE 3 A symbol or a chart period is changed
// REASON_CHARTCLOSE 4 Chart closed
// REASON_PARAMETERS 5 Inputs changed by a user
// REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings
// REASON_TEMPLATE 7 Another chart template applied
// REASON_INITFAILED 8 The OnInit() handler returned a non-zero value
// REASON_CLOSE 9 Terminal closed
//
// Delete Object ...
ObjectDelete(0, ShortName);
}
//
// Calculations ...
//
// Calculating what we want ...
int OnCalculate(
//
// total Candles on chart ...
const int rates_total,
//
// total calculated Candles on charts ...
const int prev_calculated,
//
// history of Candles Open Time ...
const datetime &time[],
//
// history of Candles Open Price ...
const double &open[],
//
// history of Candles High Price ...
const double &high[],
//
// history of Candles Low Price ...
const double &low[],
//
// history of Candles Close Price ...
const double &close[],
//
// history of Tick Volumes on Candle ...
const long &tick_volume[],
//
// history of Trade Volumes ...
const long &volume[],
//
// history of Candles Spread Price ...
const int &spread[])
{
//
ArraySetAsSeries(time, true);
//
int m = int(time[0] + PeriodSeconds() - TimeCurrent());
int s = m % 60;
m = (m - s) / 60;
//
long mSpread = SymbolInfoInteger(Symbol(), SYMBOL_SPREAD);
string _sp = "", _m = "", _s = "";
if (mSpread < 10)
_sp = "..";
else if (mSpread < 100)
_sp = ".";
if (m < 10)
_m = "0";
if (s < 10)
_s = "0";
//
string objText = "Spread: " + IntegerToString(mSpread) + _sp + " Next Bar in " + _m + IntegerToString(m) + ":" + _s + IntegerToString(s);
//
ObjectSetInteger(0, ShortName, OBJPROP_COLOR, clr);
ObjectSetString(0, ShortName, OBJPROP_TEXT, objText);
ObjectSetInteger(0, ShortName, OBJPROP_FONTSIZE, 10);
ObjectSetString(0, ShortName, OBJPROP_FONT, "Courier");
//
return rates_total;
}
//
// END Event Handlers ...
//
//
// START Functions ...
//
//
// Set Indicator Short Name and also we can define Buffers Labels ...
void SetIndicatorName()
{
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
}
void CreateIndicatorObject()
{
//
ObjectCreate(0, ShortName, OBJ_LABEL, 0, 0, 0);
ObjectSetInteger(0, ShortName, OBJPROP_CORNER, corner);
ObjectSetInteger(0, ShortName, OBJPROP_XDISTANCE, 10);
ObjectSetInteger(0, ShortName, OBJPROP_YDISTANCE, 2);
ENUM_ANCHOR_POINT Anchor = ANCHOR_LEFT_UPPER;
switch (corner)
{
case CORNER_LEFT_UPPER:
Anchor = ANCHOR_LEFT_UPPER;
break;
case CORNER_RIGHT_UPPER:
Anchor = ANCHOR_RIGHT_UPPER;
break;
case CORNER_LEFT_LOWER:
Anchor = ANCHOR_LEFT_LOWER;
break;
case CORNER_RIGHT_LOWER:
Anchor = ANCHOR_RIGHT_LOWER;
break;
}
//
ObjectSetInteger(0, ShortName, OBJPROP_ANCHOR, Anchor);
}
//
// END Functions ...
//
+1
View File
@@ -46,6 +46,7 @@
"xEU5PrepareWorkspace": "npm run backupWorkspace && npm run cleanupWorkspace && npm run xEU5CpWorkspace",
"xEU5ApplyFromWorkspace": "npm run backupWorkspace && npm run xEU5UpSourceFromWorkspace",
"xEU5Compile": "npm run compile XEU5",
"xEU5CompileAndPack": "npm run compile XEU5 true",
"abd": "|----------|",
"abe": "| /XEU5 |",
"abf": "|----------|",