This commit is contained in:
2025-04-09 14:00:39 +03:30
parent 031c5f3462
commit 55ac840a38
6 changed files with 1327 additions and 15 deletions
+68
View File
@@ -0,0 +1,68 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center XTest MQL5 Expert Advisor
// -------------------------------------------------
// Name: XSTRCCIEA
// Description: an Exper Advisor which used Panels
//
// 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 XSTRCCIEA"
#property strict
//
// Imports ...
#include "../Classes/x-saherelm.x-alert.class.mq5"
#include "../Classes/x-saherelm.x-trade.class.mq5"
//
// Setup Requirements ...
#include "../Helpers/x-saherelm.x121.xstr.helper.mq5"
//
#define ShortName "XSTRCCIEA"
//
// Inputs ...
//
// Common ...
input group "Common";
input long eaMagicNumber = 78692110; // Magic Number
input int eaSlippage = 10; // Slippgae
input string eaLogSuffix = ""; // Log Suffix
//
// Alert ...
// Here we Provider All Requirements for
// Configuring Alert Provider ...
input group "Alert";
input bool eaEnableAlerts = true; // Enable Alerts
input bool eaLogAlerts = true; // Log Alerts
input bool eaMailAlerts = false; // Mail Alerts
input bool eaPushAlerts = false; // Push Alerts
input bool eaTerminalAlerts = false; // Terminal Alerts
//
// Time Report ...
input group "Reports";
input bool eaReportNewMonths = false; // Report New Month
input bool eaReportNewWeeks = false; // Report New Weeks
input bool eaReportNewDays = true; // Report New Days
input bool eaReportNewHours = false; // Report New Hours
//
// Variables, Instances ...
XCAlert *eaAlert;
XCTrade *eaTrade;
//
XCX121XSTRHelper *strHelper;
+9
View File
@@ -355,6 +355,7 @@ struct X121Conditions
//
double strBuffer[];
double vidyaBuffer[];
double strUpBuffer[];
double strMidBuffer[];
double strDownBuffer[];
@@ -777,6 +778,7 @@ struct X121Conditions
//
Clean(strBuffer);
Clean(vidyaBuffer);
Clean(strUpBuffer);
Clean(strMidBuffer);
Clean(strDownBuffer);
@@ -791,6 +793,7 @@ struct X121Conditions
//
ArraySetAsSeries(strBuffer, true);
ArraySetAsSeries(vidyaBuffer, true);
ArraySetAsSeries(strUpBuffer, true);
ArraySetAsSeries(strMidBuffer, true);
ArraySetAsSeries(strDownBuffer, true);
@@ -2777,6 +2780,12 @@ class XCX121Helper : public XCBase
//
// Buffers ...
//
Copy(
xstrConditions.vidyaBuffer,
conditions.vidyaBuffer //
);
//
Copy(
xstrConditions.strBuffer,
+59
View File
@@ -0,0 +1,59 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Helper Class Library
// ----------------------------------------------
// Name: XCX121XOCSHelper
// Description: provides all Indicator
// Helper requirements ...
//
//
// 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
//
// Imports ...
#include "../Classes/x-saherelm.x-helper.class.mq5"
//
// Buffers ...
enum ENUM_X121_XOSCS_BUFFERS
{
//
// https://www.mql5.com/en/articles/11467 ...
X121_XOSCS_XAC_LINE = 0,
// https://www.mql5.com/en/articles/10993 ...
X121_XOSCS_XAD_LINE = 1,
// https://www.mql5.com/en/articles/10715 ...
X121_XOSCS_XADX_LINE = 2,
X121_XOSCS_XADX_P_LINE = 3,
X121_XOSCS_XADX_N_LINE = 4,
// https://www.mql5.com/en/articles/10748 ...
X121_XOSCS_XATR_LINE = 5,
// https://www.mql5.com/en/articles/10592 ...
X121_XOSCS_XCCI_LINE = 6,
// https://www.mql5.com/en/articles/10528 ...
X121_XOSCS_XRSI_LINE = 7,
// https://www.mql5.com/en/articles/11037 ...
X121_XOSCS_XMFI_LINE = 8,
// https://www.mql5.com/en/articles/11425 ...
X121_XOSCS_XRVI_LINE = 9,
X121_XOSCS_XRVI_S_LINE = 10,
// https://www.mql5.com/en/articles/10674 ...
X121_XOSCS_XMACD_LINE = 11,
X121_XOSCS_XMACD_S_LINE = 12,
// https://www.mql5.com/en/articles/10547 ...
X121_XOSCS_XMOMENTUM_LINE = 13,
// https://www.mql5.com/en/articles/10692 ..
X121_XOSCS_XSTOCHASTIC_LINE = 14,
X121_XOSCS_XSTOCHASTIC_S_LINE = 15,
}
+103 -8
View File
@@ -33,15 +33,17 @@ enum ENUM_X121_XSTR_BUFFERS
{
//
X121_XSTR_LINE = 0,
X121_XSTR_COLOR_LINE = 1,
X121_XSTR_UP_LINE = 2,
X121_XSTR_DOWN_LINE = 3,
X121_XSTR_HSM_LINE = 4,
X121_XSTR_LSM_LINE = 5,
X121_XSTR_MID_LINE = 6,
X121_XSTR_MID_STATE_LINE = 7,
X121_XSTR_ATR_LINE = 8,
X121_XSTR_PRICE_LINE = 9,
X121_XSTR_STATE_LINE = 10,
X121_XSTR_XVIDYA_LINE = 8,
X121_XSTR_ATR_LINE = 9,
X121_XSTR_PRICE_LINE = 10,
X121_XSTR_STATE_LINE = 11,
};
//
@@ -51,13 +53,16 @@ struct X121XSTRInputs
//
// Props ...
int strLength; // Length
double strMultiplier; // Multiplier
ENUM_MA_METHOD strBoundaryMode; // Boundary Mode
ENUM_APPLIED_PRICE strAppliedTo; // Applied To
int strLength; // Length
double strMultiplier; // Multiplier
int vidyaLength; // Smothing Length
ENUM_MA_METHOD strBoundaryMode; // Boundary Mode
ENUM_APPLIED_PRICE strAppliedTo; // Applied To
ENUM_APPLIED_PRICE vidyaAppliedTo; // Smoothing Applied To
//
bool showStr; // Show Str
bool showVidya; // Show Vidya
bool showStrMid; // Show Str Mid
bool showStrUpper; // Show Str Upper
bool showStrLower; // Show Str Lower
@@ -82,11 +87,14 @@ struct X121XSTRInputs
//
strLength = 0;
strMultiplier = 0.0;
vidyaLength = 0;
strBoundaryMode = MODE_SMA;
strAppliedTo = PRICE_MEDIAN;
vidyaAppliedTo = PRICE_CLOSE;
//
showStr = false;
showVidya = false;
showStrMid = false;
showStrUpper = false;
showStrLower = false;
@@ -103,12 +111,15 @@ struct X121XSTRInputs
{
//
strLength = 14;
vidyaLength = 14;
strMultiplier = 3.0;
strBoundaryMode = MODE_SMA;
strAppliedTo = PRICE_CLOSE;
vidyaAppliedTo = PRICE_CLOSE;
//
showStr = true;
showVidya = true;
showStrMid = true;
showStrUpper = true;
showStrLower = true;
@@ -143,7 +154,7 @@ struct X121XSTRInputs
int result = 0;
//
result = MathMax(1, strLength);
result = MathMax(strLength, vidyaLength);
//
return result;
@@ -164,6 +175,7 @@ struct X121XSTRConditions
// Buffers ...
double strBuffer[];
double atrBuffer[];
double vidyaBuffer[];
double strUpBuffer[];
double strMidBuffer[];
double strDownBuffer[];
@@ -214,6 +226,7 @@ struct X121XSTRConditions
//
Clean(strBuffer);
Clean(atrBuffer);
Clean(vidyaBuffer);
Clean(strUpBuffer);
Clean(strMidBuffer);
Clean(strDownBuffer);
@@ -226,6 +239,7 @@ struct X121XSTRConditions
//
ArraySetAsSeries(strBuffer, true);
ArraySetAsSeries(atrBuffer, true);
ArraySetAsSeries(vidyaBuffer, true);
ArraySetAsSeries(strUpBuffer, true);
ArraySetAsSeries(strMidBuffer, true);
ArraySetAsSeries(strDownBuffer, true);
@@ -447,6 +461,7 @@ class XCX121XSTRHelper : public XCBaseHelper
//
ArraySetAsSeries(strBuffer, true);
ArraySetAsSeries(atrBuffer, true);
ArraySetAsSeries(vidyaBuffer, true);
ArraySetAsSeries(strUpBuffer, true);
ArraySetAsSeries(strMidBuffer, true);
ArraySetAsSeries(strDownBuffer, true);
@@ -471,12 +486,15 @@ class XCX121XSTRHelper : public XCBaseHelper
"",
mInputs.strLength,
mInputs.strMultiplier,
mInputs.vidyaLength,
mInputs.strBoundaryMode,
mInputs.strAppliedTo,
mInputs.vidyaAppliedTo,
//
// Presentation ...
"",
mInputs.showStr,
mInputs.showVidya,
mInputs.showStrMid,
mInputs.showStrUpper,
mInputs.showStrLower,
@@ -520,6 +538,58 @@ class XCX121XSTRHelper : public XCBaseHelper
//
// Readers ...
//
// Vidya ...
//
double GetVidya(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate(barIndex);
//
int count = ArraySize(vidyaBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return vidyaBuffer[barIndex];
}
//
int CopyVidya(
int start, // Start
int count, // Number of Items for read
double &buffer[], // Dest Buffer
bool forceClean = true // Force To Clean buffer
)
{
//
// Update Calculations ...
Calculate(start);
//
// Copy Items ...
return Copy(
0,
count,
vidyaBuffer,
buffer,
forceClean
//
);
}
//
// ATR ...
@@ -1141,6 +1211,13 @@ class XCX121XSTRHelper : public XCBaseHelper
//
// Buffers ...
//
CopyVidya(
zIndex,
loopback,
conditions.vidyaBuffer //
);
//
CopyATR(
zIndex,
@@ -1264,6 +1341,7 @@ class XCX121XSTRHelper : public XCBaseHelper
// Buffers ...
double strBuffer[];
double atrBuffer[];
double vidyaBuffer[];
double strUpBuffer[];
double strMidBuffer[];
double strDownBuffer[];
@@ -1286,6 +1364,17 @@ class XCX121XSTRHelper : public XCBaseHelper
barIndex = 0;
}
//
// VIDYA ...
CopyBuffer(
mHandler,
X121_XSTR_XVIDYA_LINE,
barIndex,
maxRequiredBars,
vidyaBuffer
//
);
//
// STR ...
CopyBuffer(
@@ -1400,6 +1489,12 @@ class XCX121XSTRHelper : public XCBaseHelper
int maxAllowed = 100 //
)
{
//
CleanupArray(
vidyaBuffer,
maxAllowed //
);
//
CleanupArray(
strBuffer,
File diff suppressed because it is too large Load Diff
+62 -7
View File
@@ -35,14 +35,17 @@
//
// Market ...
input group "Market";
input int strLength = 14; // Length
input double strMultiplier = 3; // Multiplier
input ENUM_MA_METHOD strBoundaryMode = MODE_SMA; // Boundary Mode
input ENUM_APPLIED_PRICE strAppliedTo = PRICE_MEDIAN; // Applied To
input int strLength = 14; // Length
input double strMultiplier = 3; // Multiplier
input int vidyaLength = 14; // Smothing Length
input ENUM_MA_METHOD strBoundaryMode = MODE_SMA; // Boundary Mode
input ENUM_APPLIED_PRICE strAppliedTo = PRICE_MEDIAN; // Applied To
input ENUM_APPLIED_PRICE vidyaAppliedTo = PRICE_CLOSE; // Smoothing Applied To
//
input group "Presentation";
input bool showStr = true; // Show Str
input bool showVidya = true; // Show Vidya
input bool showStrMid = true; // Show Str Mid
input bool showStrUpper = true; // Show Str Upper
input bool showStrLower = true; // Show Str Lower
@@ -65,8 +68,8 @@ input bool showStrHighMa = true; // Show High Smoothed Buffer
#property indicator_chart_window
//
#property indicator_buffers 11
#property indicator_plots 6
#property indicator_buffers 12
#property indicator_plots 7
//
// STR ...
@@ -152,11 +155,24 @@ double strMidColorBuffer[];
#property indicator_style6 STYLE_SOLID
#property indicator_width6 1
//
// VIDYA ...
#define vidyaBufferIndex 8
double vidyaBuffer[];
//
#define vidyaPlotBufferIndex 6
#property indicator_label7 "X121 VIDYA"
#property indicator_type7 DRAW_LINE
#property indicator_color7 clrYellow
#property indicator_style7 STYLE_SOLID
#property indicator_width7 1
//
// Data Buffers ...
//
int mLastBufferIndex = 7;
int mLastBufferIndex = 8;
//
// STR ...
@@ -194,6 +210,7 @@ int atrHandler = INVALID_HANDLE;
// MA Handler ...
int lowMaHandler = INVALID_HANDLE;
int highMaHandler = INVALID_HANDLE;
int vidyaHandler = INVALID_HANDLE;
//
bool isStrTrendChanged;
@@ -270,6 +287,22 @@ int OnInit()
return INIT_FAILED;
}
//
// Vidya ...
vidyaHandler = iVIDyA(
_Symbol,
_Period,
strLength,
vidyaLength,
0, // Shift ...
vidyaAppliedTo //
);
isInited = vidyaHandler != INVALID_HANDLE;
if (!isInited)
{
return INIT_FAILED;
}
//
// because in some cases we may have more than one input for
// calculation and we must prevent any calculation
@@ -311,6 +344,7 @@ void OnDeinit(const int reason)
//
IndicatorRelease(atrHandler);
IndicatorRelease(vidyaHandler);
IndicatorRelease(lowMaHandler);
IndicatorRelease(highMaHandler);
}
@@ -354,6 +388,10 @@ int OnCalculate(
// ATR ...
int atrCalculatedBars = BarsCalculated(atrHandler);
//
// VIDYA ...
int vidyaCalculatedBars = BarsCalculated(vidyaHandler);
//
// Low Ma ...
int lowMaCalculatedBars = BarsCalculated(lowMaHandler);
@@ -368,6 +406,9 @@ int OnCalculate(
// ATR ...
atrCalculatedBars >= 0 &&
//
// VIDYA ...
vidyaCalculatedBars >= 0 &&
//
// Low Ma ...
lowMaCalculatedBars >= 0 &&
//
@@ -395,6 +436,10 @@ int OnCalculate(
// ATR ...
int copiedAtrs = CopyBuffer(atrHandler, 0, 0, rates_total, atrBuffer);
//
// VYDIA ...
int copiedVidyas = CopyBuffer(vidyaHandler, 0, 0, rates_total, vidyaBuffer);
//
// Low Ma ...
int copiedLowMas = CopyBuffer(lowMaHandler, 0, 0, rates_total, strLowMaBuffer);
@@ -410,6 +455,9 @@ int OnCalculate(
// ATR ...
copiedAtrs >= 0 &&
//
// VIDYA ...
copiedVidyas >= 0 &&
//
// Low Ma ...
copiedLowMas >= 0 &&
//
@@ -522,6 +570,13 @@ void DefineBuffers()
PlotIndexSetInteger(strHighMaPlotBufferIndex, PLOT_SHOW_DATA, showStrHighMa);
PlotIndexSetInteger(strHighMaPlotBufferIndex, PLOT_DRAW_TYPE, strHighMaDrawType);
//
ENUM_DRAW_TYPE vidyaDrawType = showVidya ? DRAW_LINE : DRAW_NONE;
SetIndexBuffer(vidyaBufferIndex, vidyaBuffer, INDICATOR_DATA);
PlotIndexSetDouble(vidyaPlotBufferIndex, PLOT_EMPTY_VALUE, emptyValue);
PlotIndexSetInteger(vidyaPlotBufferIndex, PLOT_SHOW_DATA, showVidya);
PlotIndexSetInteger(vidyaPlotBufferIndex, PLOT_DRAW_TYPE, vidyaDrawType);
//
ENUM_DRAW_TYPE strMidDrawType = showStrMid ? DRAW_COLOR_LINE : DRAW_NONE;
SetIndexBuffer(strMidBufferIndex, strMidBuffer, INDICATOR_DATA);