This commit is contained in:
2024-06-01 08:13:49 +03:30
parent 55dada7f17
commit 2109cc1549
7 changed files with 1746 additions and 9 deletions
+47 -9
View File
@@ -48,15 +48,14 @@
"assignedTo": {
"name": "Hadi Khazaee Asl"
},
"category": "X121 Market Conditions",
"creation_time": "2024-05-30T21:38:04.455Z",
"creation_time": "2024-06-01T00:56:22.059Z",
"description": {
"content": "- [x] Remove all Unused Indicators and Helpers;\n-- [x] XCHLH;\n-- [x] XCHMA;\n-- [x] XFI;\n-- [x] XTS;\n-- [x] XRSI;\n-- [x] XOBD;\n-- [x] XLH;\n- [x] resolve side affects;\n- [x] Cleanup Market Conditions;\n- [] Merge reading Required Data to XMarket Conditions;",
"content": "Indicators:\n- [] XHULL;\n- [] XSSL;\n- [] XAMA;\n- [] XTM;\n\nfor each indicator:\n- [] Buffers;\n- [] Conditions;\n- [] Clean;\n- [] Score;\n- [] Summary;\n",
"mime": "text/markdown"
},
"id": "62",
"id": "71",
"references": [],
"title": "Cleanup all Old Indicator"
"title": "add XHULL/XSSLC/XAMA/XTM Indicators also to X121MarketCycle Calss"
},
{
"assignedTo": {
@@ -75,7 +74,7 @@
"category": "X121 Provider",
"creation_time": "2024-05-30T21:40:26.010Z",
"description": {
"content": "implement a Signaller Struct to Describe a Signaller state;\nuse it in X121ProviderDescriptor;\ninside X121Provider use this Struct to Handle Signaller's State;",
"content": "- [x] implement a Signaller Struct to Describe a Signaller state;\n- [] use it in X121ProviderDescriptor;\n- [] inside X121Provider use this Struct to Handle Signaller's State;",
"mime": "text/markdown"
},
"id": "63",
@@ -89,7 +88,7 @@
"category": "XMQL",
"creation_time": "2024-05-30T22:34:15.388Z",
"description": {
"content": "in this way all class can Has his own Alerts ...",
"content": "- [x] in this way all class can Has his own Alerts ...\n- [] preare Alert Prefix for Each Separated Once ...",
"mime": "text/markdown"
},
"id": "69",
@@ -103,15 +102,54 @@
"category": "X121 Provider",
"creation_time": "2024-05-30T21:41:50.930Z",
"description": {
"content": "Each Market must have their own Pivot Points;",
"content": "Each Market must have their own Pivot Points;\n\n- [] Remove Current Support and Resistance;\n- [] add Support and Resistance and also Score Generating in each Market;\n- [] create a General Common Function to Access Support and Resistances;",
"mime": "text/markdown"
},
"id": "64",
"references": [],
"title": "Move Support and Resistance Pivots Finders inside X121Market Class"
},
{
"assignedTo": {
"name": "Hadi Khazaee Asl"
},
"category": "XMQL",
"creation_time": "2024-06-01T00:57:10.458Z",
"description": {
"content": "do r&d about Volume Profiling and Implement it inside X121 Market Cycle;",
"mime": "text/markdown"
},
"id": "72",
"references": [],
"title": "R&D about Volume Profiling"
},
{
"assignedTo": {
"name": "Hadi Khazaee Asl"
},
"category": "XMQL",
"creation_time": "2024-06-01T00:58:06.730Z",
"id": "73",
"references": [],
"title": "R&D about indicator Class implementation ..."
}
],
"testing": [
{
"assignedTo": {
"name": "Hadi Khazaee Asl"
},
"category": "X121 Market Conditions",
"creation_time": "2024-05-30T21:38:04.455Z",
"description": {
"content": "- [x] Remove all Unused Indicators and Helpers;\n-- [x] XCHLH;\n-- [x] XCHMA;\n-- [x] XFI;\n-- [x] XTS;\n-- [x] XRSI;\n-- [x] XOBD;\n-- [x] XLH;\n- [x] resolve side affects;\n- [x] Cleanup Market Conditions;\n- [x] Merge reading Required Data to XMarket Conditions;",
"mime": "text/markdown"
},
"id": "62",
"references": [],
"title": "Cleanup all Old Indicator"
}
],
"testing": [],
"done": [
{
"assignedTo": {
+154
View File
@@ -0,0 +1,154 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Class Library
// ----------------------------------------------
// Name: XSCBaseInd
// Description: provides Indicator implementation
// 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 <Indicators/Indicator.mqh>
//
// XSCMid Indicator Buffers ...
enum ENUM_XSCMID_BUFFERS
{
XSCMID_MAIN_LINE = 0, // Main Buffer ...
XSCMID_STATE_LINE = 1, // State Buffer ...
};
//
string GetTitle(ENUM_XSCMID_BUFFERS bufferLine)
{
//
string result = NULL;
//
switch (bufferLine)
{
//
case XSCMID_MAIN_LINE:
result = "XMID";
break;
//
case XSCMID_STATE_LINE:
result = "XSTATE";
break;
}
//
return result;
}
//
// XSCMid Indicator Inputs ...
struct XSCMidInputs
{
//
// Props ...
string version;
//
// Constructor ...
XSCMidInputs()
{
Clean();
}
//
// Tools ...
//
// Initial Inputs ...
bool Init()
{
//
bool result = false;
//
result = IsValid();
//
return result;
}
//
// Cleanup ...
void Clean()
{
}
//
// Default ...
void Default()
{
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
true
//
;
//
return result;
}
//
// Retrieve Max Length ...
int Max()
{
//
int result = 0;
//
result = 0;
//
return result;
}
};
//
// a Simple Indicator ...
class XSCMid : public CIndicator
{
//
// Protected ...
protected:
//
// Private ...
private:
//
// Props ...
//
// Inputs ...
XSCMidInputs mInputs;
};
+683
View File
@@ -0,0 +1,683 @@
///////////////////////////////////////////////////////
//
// SaherElm IT Center MQL5 Class Library
// ----------------------------------------------
// Name: XSCBaseInd
// Description: provides all Indicator 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.base.class.mq5"
#include "../Libraries/x-saherelm.draw.lib.mq5"
#include "../Classes/x-saherelm.xalert.class.mq5"
//
// Definitions ...
//
struct XBuffer
{
//
string title; // Buffer Title
string symbol; // Buffer Symbol
double values[]; // Buffer Values
ENUM_TIMEFRAMES period; // Buffer Period
datetime times[]; // Buffer Values Time
//
// Constructor ...
XBuffer()
{
Clean();
}
//
// Tools ...
bool Init(
string mTitle // Title
)
{
//
bool result = false;
//
result = IsValid(mTitle);
if (!result)
{
return result;
}
//
Clean();
//
result = StringToLower(mTitle);
if (!result)
{
return result;
}
//
title = mTitle;
// ArraySetAsSeries(values, false);
//
result = IsValid();
//
return result;
}
//
// Cleanup ...
void Clean()
{
//
Clean(values);
Clean(times);
//
title = NULL;
symbol = NULL;
period = NULL;
}
//
// Validate ...
bool IsValid()
{
//
bool result = false;
//
result =
//
IsValid(title) &&
IsValid(period) &&
IsValid(symbol)
//
;
//
return result;
}
//
// Check Owwn ...
bool IsOwn(
string mTitle // Checking Title
)
{
//
bool result = false;
//
result = IsValid(mTitle);
if (!result)
{
return result;
}
//
result = StringToLower(mTitle);
if (!result)
{
return result;
}
//
result = this.title == mTitle;
//
return result;
}
//
// Count Size ...
int Count()
{
return ArraySize(values);
}
//
// Add Value to Buffer ...
int Add(double value)
{
//
int result = -1;
//
if (!IsValid())
{
return result;
}
//
datetime time = GetPeriodStartTime(
this.symbol,
this.period);
//
// Check Date Exists before ...
int timeIDX = FindIndex(
time,
times //
);
if (timeIDX >= 0)
{
//
// Item Exists ...
// Update it ...
//
values[timeIDX] = value;
}
else
{
//
// New Item ...
// Add It ...
//
int count = Count();
ArrayResize(
values,
count + 1 //
);
ArrayResize(
times,
count + 1 //
);
//
times[count] = time;
values[count] = value;
}
//
result = Count();
//
return result;
}
//
// Get Specified Index Value ...
double Get(
int index // Specified Index
)
{
//
double result = EMPTY_VALUE;
//
NormalizeIndex(
index,
values //
);
//
result = values[index];
//
return result;
}
//
// Remove Specified Index Value ...
bool Remove(int index)
{
//
bool result = false;
//
int count = Count();
result = IsValidSize(count);
if (!result)
{
return result;
}
//
result = index > 0 && index < count - 1;
if (!result)
{
return result;
}
//
result = ArrayRemove(
values,
index,
1 //
);
//
return result;
}
//
double Get(
datetime time = NULL //
)
{
//
double result = EMPTY_VALUE;
//
NormalizeTime(time);
//
datetime iTime = GetPeriodStartTime(
this.symbol,
this.period,
time //
);
//
int timeIDX = FindIndex(
iTime,
this.times //
);
if (timeIDX < 0)
{
return result;
}
//
result = Get(timeIDX);
//
return result;
}
//
bool Remove(
datetime time = NULL //
)
{
//
bool result = false;
//
NormalizeTime(time);
//
datetime iTime = GetPeriodStartTime(
this.symbol,
this.period,
time //
);
//
int timeIDX = FindIndex(
iTime,
this.times //
);
if (timeIDX < 0)
{
return result;
}
//
result = Remove(timeIDX);
//
return result;
}
};
//
// Base Indicator Class ...
class XSCBaseInd : public XSCBaseAlert
{
//
// Public ...
public:
//
// Props ...
//
// Indicators Buffers ...
XBuffer mBuffers[];
//
// Constructor(s) ...
void XSCBaseInd(
string symbol, // Trading Symbol
ENUM_TIMEFRAMES period // Trading TimeFrame
) : XSCBaseAlert()
{
//
mSymbol = symbol;
mPeriod = period;
//
mCalculatedBars = 0;
}
//
// Deconstructor ...
void ~XSCBaseInd() {}
//
// Property Getter(s) / Setter(s) ...
//
string GetSymbol()
{
return mSymbol;
}
//
ENUM_TIMEFRAMES GetPeriod()
{
return mPeriod;
}
//
// Overrides ...
//
virtual string GetTag();
//
virtual string GetToken();
//
virtual void DeInit(int reason); // Indicator DeInitialization
//
// Validate Inputs ...
virtual bool IsValidInputs()
{
return false;
}
//
// Calculate ...
virtual void Calculate() {}
//
// Tools ...
//
// Retrieve Calculate Bars ...
int GetCalculatedBars()
{
return mCalculatedBars;
}
//
// Count available Bars ...
int CountBars()
{
//
return iBars(
mSymbol,
mPeriod //
);
}
//
// Validate Indicator States ...
bool IsValid()
{
//
bool result = false;
//
result = IsValidInputs();
if (!result)
{
return result;
}
//
result =
//
IsSpecifiedValid(mSymbol) &&
IsSpecifiedValid(mPeriod)
//
;
//
return result;
}
//
// Buffer Registrations ...
//
// Count Registered Buffers ...
int CountBuffers()
{
return ArraySize(mBuffers);
}
//
// Retrieve Specified Buffer Index ...
int GetBufferIndex(
string title // Specified Buffer Title
)
{
//
int result = -1;
//
if (!IsSpecifiedValid(title))
{
return result;
}
//
int buffersCount = CountBuffers();
if (!IsValidSize(buffersCount))
{
return result;
}
//
for (int i = 0; i < buffersCount; i++)
{
//
XBuffer iBuffer = mBuffers[i];
//
bool isOwn = iBuffer.IsOwn(title);
if (isOwn)
{
//
result = i;
break;
}
}
//
return result;
}
//
// Check Contains Specific Buffer or not ...
bool HasBuffer(
string title // Specified Buffer Title
)
{
//
bool result = false;
//
int bufferIndex = GetBufferIndex(title);
result = bufferIndex >= 0;
//
return result;
}
//
// Retrieve Specified Buffer ...
bool GetBuffer(
string title, // Specified Buffer Title
XBuffer &buffer // Hold Result
)
{
//
bool result = false;
//
int idx = GetBufferIndex(title);
result = idx >= 0;
if (!result)
{
return result;
}
//
buffer = mBuffers[idx];
//
result = buffer.IsValid();
//
return result;
}
//
// Register Specified Buffer ...
bool SetBuffer(
XBuffer &buffer // Specified Buffer for Registration
)
{
//
bool result = false;
//
// Validate buffer ...
result = buffer.IsValid();
if (!result)
{
return result;
}
//
// Check Buffer Doesn't Exists before ...
int idx = GetBufferIndex(buffer.title);
result = idx == -1;
if (!result)
{
return result;
}
//
AddRef(
buffer,
mBuffers //
);
//
return result;
}
//
double GetBufferValue(
string mTitle, // Required Buffer Title
int index // Bar Index
)
{
//
double result = EMPTY_VALUE;
//
// Validate State ...
if (!IsValid())
{
return result;
}
//
int bufferIDX = GetBufferIndex(mTitle);
if (bufferIDX < 0)
{
return result;
}
//
Calculate();
//
result = mBuffers[bufferIDX].Get(index);
//
return result;
}
//
double GetBufferValue(
string mTitle, // Required Buffer Title
datetime time = NULL // Time
)
{
//
NormalizeTime(time);
double result = EMPTY_VALUE;
//
// Validate State ...
if (!IsValid())
{
return result;
}
//
int bufferIDX = GetBufferIndex(mTitle);
if (bufferIDX < 0)
{
return result;
}
//
Calculate();
//
result = mBuffers[bufferIDX].Get(time);
//
return result;
}
//
// Protected ...
protected:
//
// Props ...
//
string mSymbol; // Trading Symbol
ENUM_TIMEFRAMES mPeriod; // Trading TimeFrame
//
int mCalculatedBars; // Calculated Bars
//
// Tools ...
//
// Private ...
private:
//
// Props ...
};
+194
View File
@@ -0,0 +1,194 @@
//+------------------------------------------------------------------+
//| Custom.mqh |
//| Copyright 2000-2024, MetaQuotes Ltd. |
//| https://www.mql5.com |
//+------------------------------------------------------------------+
#include "Indicator.mqh"
//+------------------------------------------------------------------+
//| Class CiCustom. |
//| Purpose: Class of custom indicators. |
//| Derives from class CIndicator. |
//+------------------------------------------------------------------+
class CiCustom : public CIndicator
{
protected:
int m_num_params; // number of creation parameters
MqlParam m_params[]; // creation parameters
public:
CiCustom(void);
~CiCustom(void);
//--- methods of access to protected data
bool NumBuffers(const int buffers);
int NumParams(void) const { return(m_num_params); }
ENUM_DATATYPE ParamType(const int ind) const;
long ParamLong(const int ind) const;
double ParamDouble(const int ind) const;
string ParamString(const int ind) const;
//--- method of identifying
virtual int Type(void) const { return(IND_CUSTOM); }
protected:
//--- methods of tuning
virtual bool Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam &params[]);
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CiCustom::CiCustom(void) : m_num_params(0)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CiCustom::~CiCustom(void)
{
}
//+------------------------------------------------------------------+
//| Set number of buffers of indicator |
//+------------------------------------------------------------------+
bool CiCustom::NumBuffers(const int buffers)
{
bool result=true;
//---
if(m_buffers_total==0)
{
m_buffers_total=buffers;
return(true);
}
if(m_buffers_total!=buffers)
{
Shutdown();
result=CreateBuffers(m_symbol,m_period,buffers);
if(result)
{
//--- create buffers
for(int i=0;i<m_buffers_total;i++)
((CIndicatorBuffer*)At(i)).Name("LINE "+IntegerToString(i));
}
}
//---
return(result);
}
//+------------------------------------------------------------------+
//| Get type of specified parameter of creation |
//+------------------------------------------------------------------+
ENUM_DATATYPE CiCustom::ParamType(const int ind) const
{
if(ind>=m_num_params)
return(WRONG_VALUE);
//---
return(m_params[ind].type);
}
//+------------------------------------------------------------------+
//| Get specified parameter of creatiob as a long value |
//+------------------------------------------------------------------+
long CiCustom::ParamLong(const int ind) const
{
if(ind>=m_num_params)
return(0);
switch(m_params[ind].type)
{
case TYPE_DOUBLE:
case TYPE_FLOAT:
case TYPE_STRING:
return(0);
}
//---
return(m_params[ind].integer_value);
}
//+------------------------------------------------------------------+
//| Get specified parameter of creation as a double value |
//+------------------------------------------------------------------+
double CiCustom::ParamDouble(const int ind) const
{
if(ind>=m_num_params)
return(EMPTY_VALUE);
switch(m_params[ind].type)
{
case TYPE_DOUBLE:
case TYPE_FLOAT:
break;
default:
return(EMPTY_VALUE);
}
//---
return(m_params[ind].double_value);
}
//+------------------------------------------------------------------+
//| Get specified parameter of creation as a string value |
//+------------------------------------------------------------------+
string CiCustom::ParamString(const int ind) const
{
if(ind>=m_num_params || m_params[ind].type!=TYPE_STRING)
return("");
//---
return(m_params[ind].string_value);
}
//+------------------------------------------------------------------+
//| Initialize the indicator with universal parameters |
//+------------------------------------------------------------------+
bool CiCustom::Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam &params[])
{
int i;
//--- tune
if(m_buffers_total==0)
m_buffers_total=256;
if(CreateBuffers(symbol,period,m_buffers_total))
{
//--- string of status of drawing
m_name ="Custom "+params[0].string_value;
m_status="("+symbol+","+PeriodDescription();
for(i=1;i<num_params;i++)
{
switch(params[i].type)
{
case TYPE_BOOL:
m_status=m_status+","+((params[i].integer_value)?"true":"false");
break;
case TYPE_CHAR:
case TYPE_UCHAR:
case TYPE_SHORT:
case TYPE_USHORT:
case TYPE_INT:
case TYPE_UINT:
case TYPE_LONG:
case TYPE_ULONG:
m_status=m_status+","+IntegerToString(params[i].integer_value);
break;
case TYPE_COLOR:
m_status=m_status+","+ColorToString((color)params[i].integer_value);
break;
case TYPE_DATETIME:
m_status=m_status+","+TimeToString(params[i].integer_value);
break;
case TYPE_FLOAT:
case TYPE_DOUBLE:
m_status=m_status+","+DoubleToString(params[i].double_value);
break;
case TYPE_STRING:
m_status=m_status+",'"+params[i].string_value+"'";
break;
}
}
m_status=m_status+") H="+IntegerToString(m_handle);
//--- save settings
ArrayResize(m_params,num_params);
for(i=0;i<num_params;i++)
{
m_params[i].type =params[i].type;
m_params[i].integer_value=params[i].integer_value;
m_params[i].double_value =params[i].double_value;
m_params[i].string_value =params[i].string_value;
}
m_num_params=num_params;
//--- create buffers
for(i=0;i<m_buffers_total;i++)
((CIndicatorBuffer*)At(i)).Name("LINE "+IntegerToString(i));
//--- ok
return(true);
}
//--- error
return(false);
}
//+------------------------------------------------------------------+
+175
View File
@@ -0,0 +1,175 @@
//+------------------------------------------------------------------+
//| Class CiIchimoku. |
//| Purpose: Class of the "Ichimoku Kinko Hyo" indicator. |
//| Derives from class CIndicator. |
//+------------------------------------------------------------------+
class CiIchimoku : public CIndicator
{
protected:
int m_tenkan_sen;
int m_kijun_sen;
int m_senkou_span_b;
public:
CiIchimoku(void);
~CiIchimoku(void);
//--- methods of access to protected data
int TenkanSenPeriod(void) const { return (m_tenkan_sen); }
int KijunSenPeriod(void) const { return (m_kijun_sen); }
int SenkouSpanBPeriod(void) const { return (m_senkou_span_b); }
//--- method of creation
bool Create(const string symbol, const ENUM_TIMEFRAMES period,
const int tenkan_sen, const int kijun_sen, const int senkou_span_b);
//--- methods of access to indicator data
double TenkanSen(const int index) const;
double KijunSen(const int index) const;
double SenkouSpanA(const int index) const;
double SenkouSpanB(const int index) const;
double ChinkouSpan(const int index) const;
//--- method of identifying
virtual int Type(void) const { return (IND_ICHIMOKU); }
protected:
//--- methods of tuning
virtual bool Initialize(const string symbol, const ENUM_TIMEFRAMES period, const int num_params, const MqlParam &params[]);
bool Initialize(const string symbol, const ENUM_TIMEFRAMES period,
const int tenkan_sen, const int kijun_sen, const int senkou_span_b);
};
//+------------------------------------------------------------------+
//| Constructor |
//+------------------------------------------------------------------+
CiIchimoku::CiIchimoku(void) : m_tenkan_sen(-1),
m_kijun_sen(-1),
m_senkou_span_b(-1)
{
}
//+------------------------------------------------------------------+
//| Destructor |
//+------------------------------------------------------------------+
CiIchimoku::~CiIchimoku(void)
{
}
//+------------------------------------------------------------------+
//| Create indicator "Ichimoku Kinko Hyo" |
//+------------------------------------------------------------------+
bool CiIchimoku::Create(const string symbol, const ENUM_TIMEFRAMES period,
const int tenkan_sen, const int kijun_sen, const int senkou_span_b)
{
//--- check history
if (!SetSymbolPeriod(symbol, period))
return (false);
//--- create
m_handle = iIchimoku(symbol, period, tenkan_sen, kijun_sen, senkou_span_b);
//--- check result
if (m_handle == INVALID_HANDLE)
return (false);
//--- indicator successfully created
if (!Initialize(symbol, period, tenkan_sen, kijun_sen, senkou_span_b))
{
//--- initialization failed
IndicatorRelease(m_handle);
m_handle = INVALID_HANDLE;
return (false);
}
//--- ok
return (true);
}
//+------------------------------------------------------------------+
//| Initialize the indicator with universal parameters |
//+------------------------------------------------------------------+
bool CiIchimoku::Initialize(const string symbol, const ENUM_TIMEFRAMES period, const int num_params, const MqlParam &params[])
{
return (Initialize(symbol, period, (int)params[0].integer_value, (int)params[1].integer_value, (int)params[2].integer_value));
}
//+------------------------------------------------------------------+
//| Initialize indicator with the special parameters |
//+------------------------------------------------------------------+
bool CiIchimoku::Initialize(const string symbol, const ENUM_TIMEFRAMES period,
const int tenkan_sen, const int kijun_sen, const int senkou_span_b)
{
if (CreateBuffers(symbol, period, 5))
{
//--- string of status of drawing
m_name = "Ichimoku";
m_status = "(" + symbol + "," + PeriodDescription() + "," +
IntegerToString(tenkan_sen) + "," + IntegerToString(kijun_sen) + "," +
IntegerToString(senkou_span_b) + ") H=" + IntegerToString(m_handle);
//--- save settings
m_tenkan_sen = tenkan_sen;
m_kijun_sen = kijun_sen;
m_senkou_span_b = senkou_span_b;
//--- create buffers
((CIndicatorBuffer *)At(0)).Name("TENKANSEN_LINE");
((CIndicatorBuffer *)At(1)).Name("KIJUNSEN_LINE");
((CIndicatorBuffer *)At(2)).Name("SENKOUSPANA_LINE");
((CIndicatorBuffer *)At(2)).Offset(kijun_sen);
((CIndicatorBuffer *)At(3)).Name("SENKOUSPANB_LINE");
((CIndicatorBuffer *)At(3)).Offset(kijun_sen);
((CIndicatorBuffer *)At(4)).Name("CHIKOUSPAN_LINE");
((CIndicatorBuffer *)At(4)).Offset(-kijun_sen);
//--- ok
return (true);
}
//--- error
return (false);
}
//+------------------------------------------------------------------+
//| Access to TenkanSen buffer of "Ichimoku Kinko Hyo" |
//+------------------------------------------------------------------+
double CiIchimoku::TenkanSen(const int index) const
{
CIndicatorBuffer *buffer = At(0);
//--- check
if (buffer == NULL)
return (EMPTY_VALUE);
//---
return (buffer.At(index));
}
//+------------------------------------------------------------------+
//| Access to KijunSen buffer of "Ichimoku Kinko Hyo" |
//+------------------------------------------------------------------+
double CiIchimoku::KijunSen(const int index) const
{
CIndicatorBuffer *buffer = At(1);
//--- check
if (buffer == NULL)
return (EMPTY_VALUE);
//---
return (buffer.At(index));
}
//+------------------------------------------------------------------+
//| Access to SenkouSpanA buffer of "Ichimoku Kinko Hyo" |
//+------------------------------------------------------------------+
double CiIchimoku::SenkouSpanA(const int index) const
{
CIndicatorBuffer *buffer = At(2);
//--- check
if (buffer == NULL)
return (EMPTY_VALUE);
//---
return (buffer.At(index));
}
//+------------------------------------------------------------------+
//| Access to SenkouSpanB buffer of "Ichimoku Kinko Hyo" |
//+------------------------------------------------------------------+
double CiIchimoku::SenkouSpanB(const int index) const
{
CIndicatorBuffer *buffer = At(3);
//--- check
if (buffer == NULL)
return (EMPTY_VALUE);
//---
return (buffer.At(index));
}
//+------------------------------------------------------------------+
//| Access to ChikouSpan buffer of "Ichimoku Kinko Hyo" |
//+------------------------------------------------------------------+
double CiIchimoku::ChinkouSpan(const int index) const
{
CIndicatorBuffer *buffer = At(4);
//--- check
if (buffer == NULL)
return (EMPTY_VALUE);
//---
return (buffer.At(index));
}
+252
View File
@@ -0,0 +1,252 @@
///////////////////////////////////////////////////////
// SaherElm IT Center MQL5 Indicator
// -------------------------------------------
// Name: XMidTest
// Description: DONCHAIN Channel ...
//
// 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 XMidTest Indicator"
#property strict
//
// Imports ...
#include "../Classes/Indicators/x-saherelm.mid.class.mq5"
//
#define ShortName "XMidTest"
//
#property indicator_chart_window
//
#property indicator_buffers 1
#property indicator_plots 1
//
// Variables ...
XSCMid *mMid;
//
#property indicator_type1 DRAW_LINE
double mainBuffer[];
double mainColorBuffer[];
//
// Initialization ...
int OnInit()
{
//
// Initialize Indicator Class ...
bool isInited = InitIndicatorClass();
if (!isInited)
{
return INIT_PARAMETERS_INCORRECT;
}
//
// Define Index Buffers ...
DefineBuffers();
//
// 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
//
mMid.DeInit(reason);
delete mMid;
}
//
// Calculating what we want ...
int OnCalculate(
const int rates_total, // Total Bars on Chart ...
const int prev_calculated, // Total Calculated Bars on Charts ...
const datetime &time[], // History of Open Time ...
const double &open[], // History of Open Price ...
const double &high[], // History of High Price ...
const double &low[], // History of Low Price ...
const double &close[], // History of Close Price ...
const long &tick_volume[], // History of Tick Volumes on Bar ...
const long &volume[], // History of Trade Volumes ...
const int &spread[] // History of Spread Price ...
)
{
//
// this counts Available Bars ...
int limit;
//
// because in some cases we may have more than one input for
// calculation and we must prevent any calculation
// untill we pass the biggest input length, here we get max Input length
// and then wait until pass it ...
int maxLength = mMid.GetInputs().Max();
//
int midCalculatedBars = mMid.GetCalculatedBars();
if (midCalculatedBars < 0)
{
return prev_calculated;
}
//
limit = (prev_calculated > rates_total || prev_calculated <= 0) ? rates_total : (rates_total - prev_calculated) + 1;
// //
// int midMainCopiedItems = mMid.CopyBufferValueByLine(
// XSCMID_MAIN_LINE,
// mainBuffer,
// 0,
// limit //
// );
// if (midMainCopiedItems <= 0)
// {
// return prev_calculated;
// }
//
// Main Loop ...
for (int i = limit - 1; i >= 0 && !IsStopped(); i--)
{
CalculateBuffers(i);
}
//
return rates_total;
}
//
// CUSTOM Functions ...
//
// Validate Input Args for Initialization ...
bool InitIndicatorClass()
{
//
bool result = false;
//
// Initialize and Prepare
// Inputs of Indicator ...
XSCMidInputs inputs;
result = inputs.Init();
if (!result)
{
return result;
}
//
// Instantiate Class ...
mMid = new XSCMid(
_Symbol,
_Period //
);
//
// Now Initialize Indicator Class using Given Inputs ...
result = mMid.Init(
inputs //
);
//
return result;
}
//
// Define Indexes and Styles ...
void DefineBuffers()
{
//
// Start Styling and Indexing Buffers ...
//
string bufferLabel = GetTitle(XSCMID_MAIN_LINE);
int mainIDX = mMid.GetBufferIndexByLine(XSCMID_MAIN_LINE);
XBuffer mainBufferStruct;
mMid.GetBufferByLine(
XSCMID_MAIN_LINE,
mainBufferStruct //
);
//
int bufferIndex = 0;
//
int max = mMid.GetInputs().Max();
//
ArraySetAsSeries(mainBuffer, true);
//
XBufferPlotStyle mainBufferStyle;
mainBufferStyle.clr = clrAqua;
mainBufferStyle.type = DRAW_LINE;
//
SetIndexBuffer(
bufferIndex,
mainBuffer,
mainBufferStyle,
mainColorBuffer,
bufferLabel,
true,
0,
max //
);
}
//
// Set Indicator Short Name and also we can define Buffers Labels ...
void SetIndicatorName()
{
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
}
//
void CalculateBuffers(int barIndex)
{
//
double iValue = mMid.GetBufferValueByLine(
XSCMID_MAIN_LINE,
barIndex //
);
//
// double iValue = iClose(
// _Symbol,
// _Period,
// barIndex //
// );
mainBuffer[barIndex] = iValue;
}
+241
View File
@@ -2930,6 +2930,247 @@ struct XMarketCycle
}
};
//
// Styling Buffers ...
//
struct XBufferPlotStyle
{
//
int width; // Width
color clr; // Color
uchar arrow; // Arrow Code
ENUM_DRAW_TYPE type; // Type
ENUM_LINE_STYLE style; // Style
//
// Constructor ...
XBufferPlotStyle()
{
Default();
}
//
// Tools ...
//
// Default ...
void Default()
{
//
width = 1;
arrow = 0;
clr = CLR_NONE;
type = DRAW_NONE;
style = STYLE_SOLID;
}
};
//
// Register a Buffer as Indexed Buffer ...
void SetIndexBuffer(
int &index, // the Index refrence for Buffer
double &buffer[], // Buffer to Set
XBufferPlotStyle &style, // Style to Apply to Buffer
double &colorBuffer[], // Color Buffer
string label = NULL, // Buffer Label
bool showData = true, // Show Data on Data Window
double empty = -1, // Set 0 or EMPTY_VALUE used for setting Empty Value
int drawBegin = -1 // if Set More Than -1 applied
)
{
//
// Set Buffer Index ...
SetIndexBuffer(index, buffer, INDICATOR_DATA);
//
// Show Date ...
PlotIndexSetInteger(index, PLOT_SHOW_DATA, showData);
//
// Set Buffer Label ...
if (IsValid(label))
{
PlotIndexSetString(index, PLOT_LABEL, label);
}
//
if (empty == 0 || empty == EMPTY_VALUE)
{
PlotIndexSetDouble(index, PLOT_EMPTY_VALUE, empty);
}
//
if (drawBegin > -1)
{
PlotIndexSetInteger(index, PLOT_DRAW_BEGIN, drawBegin);
}
//
if (style.type == DRAW_ARROW)
{
PlotIndexSetInteger(index, PLOT_ARROW, style.arrow);
}
//
PlotIndexSetInteger(index, PLOT_LINE_STYLE, style.style);
PlotIndexSetInteger(index, PLOT_LINE_WIDTH, style.width);
//
string drawTypeStr = EnumToString(style.type);
bool hasColorBuffer = Contains("COLOR", drawTypeStr);
//
if (!hasColorBuffer)
{
PlotIndexSetInteger(index, PLOT_LINE_COLOR, style.clr);
}
else
{
//
// Since Color Buffers must add as next Index of it's own Buffer
// here before applied Color Buffer increase index ...
index++;
//
SetIndexBuffer(index, colorBuffer, INDICATOR_COLOR_INDEX);
}
//
// Increase Index for Next Buffer ...
index++;
}
//
void SetIndexCandleBuffers(
int &index, // the Index refrence for Buffer
string openLabel, // Open Label
double &open[], // Open Buffer
string highLabel, // High Label
double &high[], // High Buffer
string lowLabel, // Low Label
double &low[], // Low Buffer
string closeLabel, // Close Label
double &close[], // Close Buffer
bool showData = true, // Show Data on Data Window
double empty = -1, // Set 0 or EMPTY_VALUE used for setting Empty Value
int drawBegin = -1 // if Set More Than -1 applied
)
{
//
bool hasLabel =
//
IsValid(openLabel) &&
IsValid(highLabel) &&
IsValid(lowLabel) &&
IsValid(closeLabel)
//
;
//
string label =
!hasLabel
? NULL
: openLabel + ";" + highLabel + ";" + lowLabel + ";" + closeLabel;
//
// Set Buffer Index ...
SetIndexBuffer(index, open, INDICATOR_DATA);
//
// Set Draw Candles Type ...
PlotIndexSetInteger(index, PLOT_LINE_STYLE, DRAW_CANDLES);
//
// Show Date ...
PlotIndexSetInteger(index, PLOT_SHOW_DATA, showData);
//
// Set Buffer Label ...
if (IsValid(label))
{
PlotIndexSetString(index, PLOT_LABEL, label);
}
//
if (empty == 0 || empty == EMPTY_VALUE)
{
PlotIndexSetDouble(index, PLOT_EMPTY_VALUE, empty);
}
//
if (drawBegin > -1)
{
PlotIndexSetInteger(index, PLOT_DRAW_BEGIN, drawBegin);
}
//
index++;
//
// Set Buffer Index ...
SetIndexBuffer(index, high, INDICATOR_DATA);
index++;
//
// Set Buffer Index ...
SetIndexBuffer(index, low, INDICATOR_DATA);
index++;
//
// Set Buffer Index ...
SetIndexBuffer(index, close, INDICATOR_DATA);
index++;
}
//
void SetIndexCandleBuffers(
int &index, // the Index refrence for Buffer
string openLabel, // Open Label
double &open[], // Open Buffer
string highLabel, // High Label
double &high[], // High Buffer
string lowLabel, // Low Label
double &low[], // Low Buffer
string closeLabel, // Close Label
double &close[], // Close Buffer
double &colorBuffer[], // Candle Color Buffer
bool showData = true, // Show Data on Data Window
double empty = -1, // Set 0 or EMPTY_VALUE used for setting Empty Value
int drawBegin = -1 // if Set More Than -1 applied
)
{
//
SetIndexCandleBuffers(
index,
openLabel,
open,
highLabel,
high,
lowLabel,
low,
closeLabel,
close,
showData,
empty,
drawBegin //
);
//
int mFirstIndex = index - 4;
//
// Set Draw Candles Type ...
PlotIndexSetInteger(mFirstIndex, PLOT_LINE_STYLE, DRAW_COLOR_CANDLES);
//
// Set Color Buffer ...
SetIndexBuffer(index, colorBuffer, INDICATOR_COLOR_INDEX);
//
index++;
}
//
// Functions ...