last ...
This commit is contained in:
Binary file not shown.
@@ -0,0 +1,88 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// --------------------------------------
|
||||
// Name: XBaseClass
|
||||
// Description: provides all based classes for use ...
|
||||
//
|
||||
//
|
||||
// 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
|
||||
|
||||
//
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||
|
||||
//
|
||||
// XBase Class ...
|
||||
class XSCBase
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Protected ...
|
||||
|
||||
//
|
||||
// Represent Basic Unique Tag ...
|
||||
virtual string GetTag();
|
||||
|
||||
//
|
||||
// Retrieve Class Token ...
|
||||
virtual string GetToken()
|
||||
{
|
||||
//
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
string mType = GetTypeName(this);
|
||||
|
||||
//
|
||||
result = mType;
|
||||
|
||||
//
|
||||
string parts[];
|
||||
int partsCount = SplitContent(
|
||||
parts,
|
||||
result,
|
||||
" "
|
||||
//
|
||||
);
|
||||
if (partsCount <= 0)
|
||||
{
|
||||
//
|
||||
result = mType;
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool hasLastPart = GetLastItem(
|
||||
result,
|
||||
parts
|
||||
//
|
||||
);
|
||||
if (!hasLastPart)
|
||||
{
|
||||
//
|
||||
result = mType;
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
};
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,308 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCX5EA
|
||||
// Description: provides all X5 EA requirements ...
|
||||
// - X5 Provider;
|
||||
//
|
||||
//
|
||||
// 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.xea.class.mq5"
|
||||
#include "../Classes/x-saherelm.x5.provider.class.mq5"
|
||||
|
||||
//
|
||||
// Define On Signal Event Handler Type Specified for X5 ...
|
||||
typedef void (*TX5OnSignal)(X5ProviderDescriptor &descriptor);
|
||||
|
||||
//
|
||||
// Class Definition ...
|
||||
|
||||
class XSCX5EA : public XSCBaseEA
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XSCX5EA(
|
||||
//
|
||||
// XTrade Class Requirements ...
|
||||
int slippage, // Specify Slippage
|
||||
ulong magicNumber, // Specify Magic Number
|
||||
int manageInterval, // Manager Check Intervals Seconds
|
||||
double maxAllowedSpread, // Max Allowed Spred for Opening Trades
|
||||
int maxAllowedPositions, // Max Allowed Positions
|
||||
double maxAllowedDrawdownFactor, // Max Allowed Drawdown Factor
|
||||
double staticVolume, // Static Volume for Positions
|
||||
//
|
||||
// Position Management ...
|
||||
bool allowLong = true, // Allow Long Trades
|
||||
bool allowShort = true, // Allow Short Trades
|
||||
double minProfitPerTrade = 0, // Min Profit Per Trade based On Volume Factor (Hedge)
|
||||
double minProfitPerVolumeFactor = 0, // Min Volume Factor for Calculating Profit (Hedge)
|
||||
//
|
||||
// Event Handlers ...
|
||||
TOnStopLoss onStopLossTriggered = NULL, // On StopLoass Triggered Event Handler
|
||||
TOnTakeProfit onTakeProfitTriggered = NULL, // On TakeProfit Triggered Event Handler
|
||||
TOnDealsChanged onDealsChangedHandler = NULL, // On Deals Changed Event Handler
|
||||
TOnOrdersChanged onOrdersChangedHandler = NULL, // On Orders Changed Event Handler
|
||||
TOnPositionsChanged onPositionsChangedHandler = NULL, // On Positions Changed Event Handler
|
||||
TOnTradeStateChanged onTradeStateChangedHandler = NULL, // On Trade State Changed Event Handler
|
||||
//
|
||||
TOnSignal onSignalHandler = NULL, // On Signal Event Handler
|
||||
//
|
||||
// Log Handler ...
|
||||
bool enableAlerts = true, // Enable Alerts
|
||||
bool logAlerts = true, // Log Alerts
|
||||
bool terminalAlerts = false, // Terminal Alerts
|
||||
bool mailAlerts = false, // Mail Alerts
|
||||
bool pushAlerts = false // Push Alerts
|
||||
) : XSCBaseEA(slippage,
|
||||
magicNumber,
|
||||
manageInterval,
|
||||
maxAllowedSpread,
|
||||
maxAllowedPositions,
|
||||
maxAllowedDrawdownFactor,
|
||||
allowLong,
|
||||
allowShort,
|
||||
minProfitPerTrade,
|
||||
minProfitPerVolumeFactor,
|
||||
staticVolume,
|
||||
onStopLossTriggered,
|
||||
onTakeProfitTriggered,
|
||||
onDealsChangedHandler,
|
||||
onOrdersChangedHandler,
|
||||
onPositionsChangedHandler,
|
||||
onTradeStateChangedHandler,
|
||||
enableAlerts,
|
||||
logAlerts,
|
||||
terminalAlerts,
|
||||
mailAlerts,
|
||||
pushAlerts //
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XSCX5EA() {}
|
||||
|
||||
//
|
||||
// Properties Getter(s) / Setter(s) ...
|
||||
|
||||
//
|
||||
// Add X5 Specified Signal Event Handler ...
|
||||
void AddOnSignalEventHandler(TX5OnSignal listener)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
listener,
|
||||
mX5OnSignalEventHandlers
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Add Specified X5 Provider ...
|
||||
bool AddProvider(X5ProviderDescriptor &descriptor)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Validate Inputs ...
|
||||
result = descriptor.Init();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
AddRef(
|
||||
descriptor,
|
||||
mDescriptors //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Overrides ...
|
||||
|
||||
//
|
||||
// Customize Token ...
|
||||
string GetToken() override
|
||||
{
|
||||
return GetSpecificToken(this);
|
||||
}
|
||||
|
||||
//
|
||||
string GetTag() override
|
||||
{
|
||||
return this.GetToken();
|
||||
}
|
||||
|
||||
//
|
||||
// Check Provider for any Guards ...
|
||||
bool CheckForGuard(XGuard &guards[]) override
|
||||
{
|
||||
//
|
||||
// TODO: Implement this ...
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Request Provider to Collect all
|
||||
// Potentially Signals and then
|
||||
// filters theme here and passed them
|
||||
// for Executing ...
|
||||
int RequestForSignal(
|
||||
XSignal &signals[] // Holds Signals ...
|
||||
) override
|
||||
{
|
||||
//
|
||||
bool result = 0;
|
||||
|
||||
//
|
||||
Clean(signals);
|
||||
|
||||
//
|
||||
int descriptorsCount = CountDescriptors();
|
||||
if (descriptorsCount <= 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < descriptorsCount; i++)
|
||||
{
|
||||
//
|
||||
X5ProviderDescriptor iDescriptor = mDescriptors[i];
|
||||
|
||||
//
|
||||
bool iHasSignal = iDescriptor.HasSignal();
|
||||
if (iHasSignal)
|
||||
{
|
||||
//
|
||||
// Here we Can double check Signals by Conditions
|
||||
// for Score Base Filtering ...
|
||||
|
||||
//
|
||||
AddRef(
|
||||
iDescriptor.signal,
|
||||
signals
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
NotifyX5OnSignalEventHandlers(iDescriptor);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
result = ArraySize(signals);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Handl Management Actions ...
|
||||
// if returns true, it is going to prevent for processing forward ...
|
||||
bool HandleStateManagement(XSignal &signals[]) override
|
||||
{
|
||||
//
|
||||
// TODO: Implement this ...
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Request for Support Signals using Guard ...
|
||||
bool RequestForSupport(
|
||||
XSignal &support, // Holds Support Signal, if Provided
|
||||
string provider, // Positions Provided by Specific Provider
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_POSITION_TYPE type, // Trading Type
|
||||
ENUM_TIMEFRAMES period // Specified Time Frame
|
||||
) override
|
||||
{
|
||||
//
|
||||
// TODO: Implement this ...
|
||||
return false;
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
void NotifyX5OnSignalEventHandlers(X5ProviderDescriptor &descriptor)
|
||||
{
|
||||
//
|
||||
int listenersCount = ArraySize(mX5OnSignalEventHandlers);
|
||||
if (listenersCount <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < listenersCount; i++)
|
||||
{
|
||||
//
|
||||
TX5OnSignal iListener = mX5OnSignalEventHandlers[i];
|
||||
|
||||
//
|
||||
iListener(descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Collection of Signal Event Listeners ...
|
||||
TX5OnSignal mX5OnSignalEventHandlers[];
|
||||
|
||||
//
|
||||
// a Collection of X5 Provider Descriptors ...
|
||||
X5ProviderDescriptor mDescriptors[];
|
||||
|
||||
//
|
||||
int CountDescriptors()
|
||||
{
|
||||
return ArraySize(mDescriptors);
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
Binary file not shown.
@@ -0,0 +1,398 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCAccount
|
||||
// Description: provides all Account 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
|
||||
|
||||
//
|
||||
// START Definitions ...
|
||||
//
|
||||
|
||||
//
|
||||
// END Definitions ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Import and Inclused requirements ...
|
||||
//
|
||||
|
||||
//
|
||||
// Includes ...
|
||||
#include <Trade/AccountInfo.mqh>
|
||||
#include "../Classes/x-saherelm.base.class.mq5"
|
||||
|
||||
//
|
||||
// END Import and Inclused requirements ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Overrides ...
|
||||
//
|
||||
|
||||
//
|
||||
// END Overrides ...
|
||||
//
|
||||
|
||||
//
|
||||
// a Class for Manage Account ...
|
||||
class XSCAccount : public XSCBase
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Constructor ...
|
||||
void XSCAccount()
|
||||
{
|
||||
//
|
||||
mAccountInfo = new CAccountInfo();
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
void ~XSCAccount()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// START Provided Functions ...
|
||||
//
|
||||
|
||||
//
|
||||
// User Account ...
|
||||
long GetUserAccount()
|
||||
{
|
||||
return mAccountInfo.Login();
|
||||
}
|
||||
|
||||
//
|
||||
// Account Leverage ...
|
||||
long GetLeverage()
|
||||
{
|
||||
return mAccountInfo.Leverage();
|
||||
}
|
||||
|
||||
//
|
||||
// Get Trade Expert State ...
|
||||
bool CanExpertTrade()
|
||||
{
|
||||
return mAccountInfo.TradeExpert();
|
||||
}
|
||||
|
||||
//
|
||||
// User Account Trade Mopde (ENUM_ACCOUNT_TRADE_MODE) ...
|
||||
// --------------------------
|
||||
// ACCOUNT_TRADE_MODE_DEMO
|
||||
// ACCOUNT_TRADE_MODE_CONTEST
|
||||
// ACCOUNT_TRADE_MODE_REAL
|
||||
ENUM_ACCOUNT_TRADE_MODE GetTradeMode()
|
||||
{
|
||||
return mAccountInfo.TradeMode();
|
||||
}
|
||||
|
||||
//
|
||||
// Get Account Balance ...
|
||||
double GetBalance()
|
||||
{
|
||||
return mAccountInfo.Balance();
|
||||
}
|
||||
|
||||
//
|
||||
// Get the amount of give Credit ...
|
||||
double GetCredit()
|
||||
{
|
||||
return mAccountInfo.Credit();
|
||||
}
|
||||
|
||||
//
|
||||
// Get the amount of current Profit on account ...
|
||||
double GetProfit()
|
||||
{
|
||||
return mAccountInfo.Profit();
|
||||
}
|
||||
|
||||
//
|
||||
// Get the amount of current Equity on account ...
|
||||
double GetEquity()
|
||||
{
|
||||
return mAccountInfo.Equity();
|
||||
}
|
||||
|
||||
//
|
||||
// Get the amount of reserved Margin ...
|
||||
double GetMargin()
|
||||
{
|
||||
return mAccountInfo.Margin();
|
||||
}
|
||||
|
||||
//
|
||||
// Get the amount of free Margin ...
|
||||
double GetFreeMargin()
|
||||
{
|
||||
return mAccountInfo.FreeMargin();
|
||||
}
|
||||
|
||||
//
|
||||
// Get the Level of Margin ...
|
||||
double GetMarginLevel()
|
||||
{
|
||||
return mAccountInfo.MarginLevel();
|
||||
}
|
||||
|
||||
//
|
||||
// Get the Level Of Margin for a Deposit ...
|
||||
double GetMarginCall()
|
||||
{
|
||||
return mAccountInfo.MarginCall();
|
||||
}
|
||||
|
||||
//
|
||||
// Get the Level of Margin for Stop out ...
|
||||
double GetMarginStopOut()
|
||||
{
|
||||
return mAccountInfo.MarginStopOut();
|
||||
}
|
||||
|
||||
//
|
||||
// Get the Client Name ...
|
||||
string GetName()
|
||||
{
|
||||
return mAccountInfo.Name();
|
||||
}
|
||||
|
||||
//
|
||||
// Get the Trade Server Name ...
|
||||
string GetServerName()
|
||||
{
|
||||
return mAccountInfo.Server();
|
||||
}
|
||||
|
||||
//
|
||||
// Get deposit Currency Name ...
|
||||
string GetCurrency()
|
||||
{
|
||||
return mAccountInfo.Currency();
|
||||
}
|
||||
|
||||
//
|
||||
// Get the Company Name that serves an Account ...
|
||||
string GetCompany()
|
||||
{
|
||||
return mAccountInfo.Company();
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate Profits for the current account based on passed parameters ...
|
||||
double CalculateTradeProfit(
|
||||
const string symbol, // trading symbol
|
||||
ENUM_ORDER_TYPE type, // order type
|
||||
double volume, // volume
|
||||
double entry, // open price
|
||||
double exit // close price
|
||||
)
|
||||
{
|
||||
//
|
||||
double result = mAccountInfo.OrderProfitCheck(
|
||||
symbol,
|
||||
type,
|
||||
volume,
|
||||
entry,
|
||||
exit);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate amount of margin which required for trade operation ...
|
||||
double CalculateMarging(
|
||||
const string symbol, // trading symbol
|
||||
ENUM_ORDER_TYPE type, // order type
|
||||
double volume, // volume
|
||||
double entry // open price
|
||||
)
|
||||
{
|
||||
//
|
||||
double result = mAccountInfo.MarginCheck(
|
||||
symbol,
|
||||
type,
|
||||
volume,
|
||||
entry);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate amount of free margin left after trade operation ...
|
||||
double CalculateFreeMarging(
|
||||
const string symbol, // trading symbol
|
||||
ENUM_ORDER_TYPE type, // order type
|
||||
double volume, // volume
|
||||
double entry // open price
|
||||
)
|
||||
{
|
||||
//
|
||||
double result = mAccountInfo.FreeMarginCheck(
|
||||
symbol,
|
||||
type,
|
||||
volume,
|
||||
entry);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate the Maximum possible volume of trade operation ...
|
||||
double CalculateMaxVolume(
|
||||
const string symbol, // trading symbol
|
||||
ENUM_ORDER_TYPE type, // order type
|
||||
double entry, // open price
|
||||
double percent = 100 // percent of available margin
|
||||
)
|
||||
{
|
||||
//
|
||||
double result = mAccountInfo.MaxLotCheck(
|
||||
symbol,
|
||||
type,
|
||||
entry,
|
||||
percent);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate Point Value for Given Symbol based on Account ...
|
||||
double GetPointValue(
|
||||
string symbol // trading symbol
|
||||
)
|
||||
{
|
||||
//
|
||||
double result = 0;
|
||||
|
||||
//
|
||||
double tickSize = SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_SIZE);
|
||||
double tickValue = SymbolInfoDouble(symbol, SYMBOL_TRADE_TICK_VALUE);
|
||||
double point = SymbolInfoDouble(symbol, SYMBOL_POINT);
|
||||
|
||||
//
|
||||
double ticksPerPoint = tickSize / point;
|
||||
|
||||
//
|
||||
result = tickValue / ticksPerPoint;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate Risk Amount based on account Currency by Providing:
|
||||
// Points and Volume ...
|
||||
double CalculateRiskAmount(
|
||||
string symbol, // trading symbol
|
||||
double points, // amount of Risk Points
|
||||
double volume // position Volume
|
||||
)
|
||||
{
|
||||
//
|
||||
double result = 0;
|
||||
|
||||
//
|
||||
double pointValue = GetPointValue(symbol);
|
||||
|
||||
//
|
||||
result = pointValue * volume * points;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate Risk Points based on account Currency by Providing:
|
||||
// Volume and Amount ...
|
||||
double CalculateRiskPoints(
|
||||
string symbol, // trading symbol
|
||||
double volume, // position Volume
|
||||
double amount // amount of Risk based on Account Currency
|
||||
)
|
||||
{
|
||||
//
|
||||
double result = 0;
|
||||
|
||||
//
|
||||
double pointValue = GetPointValue(symbol);
|
||||
|
||||
//
|
||||
result = amount / (pointValue * volume);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate Volume based on account Currency by Providing:
|
||||
// Amount and Risk Points ...
|
||||
double CalculateVolume(
|
||||
string symbol, // trading symbol
|
||||
double amount, // amount of Risk based on Account Currency
|
||||
double points // amount of Risk Points
|
||||
)
|
||||
{
|
||||
//
|
||||
double result = 0;
|
||||
|
||||
//
|
||||
points =
|
||||
points <= 0
|
||||
? 10
|
||||
: points;
|
||||
|
||||
//
|
||||
double pointValue = GetPointValue(symbol);
|
||||
|
||||
//
|
||||
result = amount / (pointValue * points);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// END Provided Functions ...
|
||||
//
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Account Info ...
|
||||
CAccountInfo mAccountInfo;
|
||||
};
|
||||
|
||||
//
|
||||
// START Usefull Functions ...
|
||||
//
|
||||
|
||||
//
|
||||
// END Usefull Functions ...
|
||||
//
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,481 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCDataCollector
|
||||
// Description: provides Data Collection 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"
|
||||
|
||||
//
|
||||
template <typename T>
|
||||
class XSCDataCollector : public XSCBase
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
void XSCDataCollector(
|
||||
string path = NULL, // Base Folder for Data Store
|
||||
string fileName = NULL // File Name for Data Store
|
||||
)
|
||||
{
|
||||
//
|
||||
if (!IsValid(path))
|
||||
{
|
||||
path = GetType();
|
||||
}
|
||||
|
||||
//
|
||||
if (!IsValid(fileName))
|
||||
{
|
||||
fileName = GetType() + ".txt";
|
||||
}
|
||||
|
||||
//
|
||||
Path(path);
|
||||
FileName(fileName);
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
void ~XSCDataCollector() {}
|
||||
|
||||
//
|
||||
// Properties ...
|
||||
|
||||
//
|
||||
bool Path(string value)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid(value);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = value != mPath;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mPath = value;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string Path()
|
||||
{
|
||||
return mPath;
|
||||
}
|
||||
|
||||
//
|
||||
bool FileName(string value)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid(value);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
result = value != mFileName;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mFileName = value;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string FileName()
|
||||
{
|
||||
return mFileName;
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Clear Exists Collected Data ...
|
||||
void Clear()
|
||||
{
|
||||
//
|
||||
ResetLastError();
|
||||
|
||||
//
|
||||
string dataStorePath = GetStorePath();
|
||||
|
||||
//
|
||||
// Check Data Store Exists or not ...
|
||||
bool isExists = FileIsExist(dataStorePath);
|
||||
if (!isExists)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
FileDelete(dataStorePath);
|
||||
}
|
||||
|
||||
//
|
||||
// Collect All Stored Items ...
|
||||
int Collect(
|
||||
T &items[] // Hold Result
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
Clean(items);
|
||||
|
||||
//
|
||||
// Reading Store Whole Content ...
|
||||
|
||||
//
|
||||
string storePath = GetStorePath();
|
||||
int mFileHandler = FileOpen(
|
||||
storePath,
|
||||
FILE_READ | FILE_TXT);
|
||||
result = mFileHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Parse Store Content and Read Data ...
|
||||
while (!FileIsEnding(mFileHandler))
|
||||
{
|
||||
//
|
||||
// Each Line Represent One Model ...
|
||||
string content = FileReadString(mFileHandler);
|
||||
|
||||
//
|
||||
T iItem;
|
||||
bool isValid = iItem.ParseModel(content);
|
||||
if (isValid)
|
||||
{
|
||||
//
|
||||
AddRef(
|
||||
iItem,
|
||||
items
|
||||
//
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Close File ...
|
||||
FileClose(mFileHandler);
|
||||
|
||||
//
|
||||
result = ArraySize(items);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Add Item ...
|
||||
bool Add(
|
||||
T &item // Item to Store
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = item.IsModelValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string content = item.ToModelString();
|
||||
result = IsValid(content);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string storePath = GetStorePath();
|
||||
int mFileHandler = FileOpen(
|
||||
storePath,
|
||||
FILE_READ | FILE_WRITE | FILE_TXT);
|
||||
result = mFileHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
FileSeek(mFileHandler, 0, SEEK_END);
|
||||
FileWrite(mFileHandler, content);
|
||||
FileFlush(mFileHandler);
|
||||
FileClose(mFileHandler);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Add Item ...
|
||||
bool Add(
|
||||
string content // Content
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = IsValid(content);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string storePath = GetStorePath();
|
||||
int mFileHandler = FileOpen(
|
||||
storePath,
|
||||
FILE_READ | FILE_WRITE | FILE_TXT);
|
||||
result = mFileHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
FileSeek(mFileHandler, 0, SEEK_END);
|
||||
FileWrite(mFileHandler, content);
|
||||
FileFlush(mFileHandler);
|
||||
FileClose(mFileHandler);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Add Items ...
|
||||
int Add(
|
||||
T &items[] // Items to Add ...
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
int itemsCount = ArraySize(items);
|
||||
if (itemsCount <= 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
for (int i = 0; i < itemsCount; i++)
|
||||
{
|
||||
//
|
||||
T iItem = items[i];
|
||||
|
||||
//
|
||||
if (!iItem.IsModelValid())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
bool isAdded = Add(iItem);
|
||||
if (isAdded)
|
||||
{
|
||||
result++;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Remove Item ...
|
||||
bool Remove(
|
||||
T &item // Item to Remove
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = item.IsModelValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
T items[];
|
||||
int itemsCount = Collect(items);
|
||||
if (itemsCount <= 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int itemIndex = item.FindIndex(items);
|
||||
result = ArrayRemove(
|
||||
items,
|
||||
itemIndex,
|
||||
1);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
Clear();
|
||||
|
||||
//
|
||||
int itemsAdded = Add(items);
|
||||
|
||||
//
|
||||
result = itemsAdded == ArraySize(items);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Retrieve Type of Class as String ...
|
||||
string GetType()
|
||||
{
|
||||
//
|
||||
string mType = (string) typename(T);
|
||||
|
||||
//
|
||||
string result = mType;
|
||||
|
||||
//
|
||||
string parts[];
|
||||
int partsCount = SplitContent(
|
||||
parts,
|
||||
result,
|
||||
" "
|
||||
//
|
||||
);
|
||||
if (partsCount <= 0)
|
||||
{
|
||||
//
|
||||
result = mType;
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool hasLastPart = GetLastItem(
|
||||
result,
|
||||
parts
|
||||
//
|
||||
);
|
||||
if (!hasLastPart)
|
||||
{
|
||||
//
|
||||
result = mType;
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Pricate ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
string mPath; // Path
|
||||
string mFileName; // Data Store File Name
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Generate Full File Path ...
|
||||
string GetFilePath(string fileName)
|
||||
{
|
||||
//
|
||||
string result = "";
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
Path() + "\\" + fileName
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Data Store File Address ...
|
||||
string GetStorePath()
|
||||
{
|
||||
//
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
result = GetFilePath(mFileName);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,148 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCBaseHelper
|
||||
// Description: provides all Base 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
|
||||
|
||||
//
|
||||
// Includes ...
|
||||
#include "../Classes/x-saherelm.base.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
// a Class for Handle base requirements ...
|
||||
// for indicators ...
|
||||
class XSCBaseHelper : public XSCBase
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Constructor ...
|
||||
void XSCBaseHelper(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period // Trading Time Frame
|
||||
)
|
||||
{
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
void ~XSCBaseHelper()
|
||||
{
|
||||
//
|
||||
IndicatorRelease(mHandler);
|
||||
}
|
||||
|
||||
//
|
||||
// Setter(s) / Getter(s) ...
|
||||
|
||||
//
|
||||
// Symbol ...
|
||||
string GetSymbol()
|
||||
{
|
||||
return mSymbol;
|
||||
}
|
||||
|
||||
//
|
||||
// Period ...
|
||||
ENUM_TIMEFRAMES GetPeriod()
|
||||
{
|
||||
return mPeriod;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Bars ...
|
||||
int CountBars()
|
||||
{
|
||||
//
|
||||
int result =
|
||||
Bars(
|
||||
mSymbol,
|
||||
mPeriod
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve Indicator Calculated Bars ...
|
||||
int CountCalculatedBars()
|
||||
{
|
||||
return BarsCalculated(mHandler);
|
||||
}
|
||||
|
||||
//
|
||||
// Generate Tag ...
|
||||
virtual string GetTag()
|
||||
{
|
||||
//
|
||||
string result = NULL;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
GetToken() +
|
||||
"[" +
|
||||
GetSymbol() + "|" +
|
||||
ToString(GetPeriod()) +
|
||||
"]"
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Functions ...
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Symbol ...
|
||||
string mSymbol;
|
||||
|
||||
//
|
||||
// Period ...
|
||||
ENUM_TIMEFRAMES mPeriod;
|
||||
|
||||
//
|
||||
// Indicator Handler ...
|
||||
int mHandler;
|
||||
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ....
|
||||
Binary file not shown.
@@ -0,0 +1,373 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCHttp
|
||||
// Description: provides all HTTP 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
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
enum X_HTTP_METHOD
|
||||
{
|
||||
X_HTTP_GET,
|
||||
X_HTTP_POST
|
||||
};
|
||||
|
||||
//
|
||||
// Imports ...
|
||||
|
||||
//
|
||||
// Includes ...
|
||||
#include "../Classes/x-saherelm.base.class.mq5"
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||
|
||||
//
|
||||
// a Class for Manage Account ...
|
||||
class XSCHttp : public XSCBase
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Constructor ...
|
||||
void XSCHttp()
|
||||
{
|
||||
XSCHttp("", 10000);
|
||||
}
|
||||
void XSCHttp(
|
||||
string path, // Base Folder to Store Data
|
||||
int timeout // base timeout for Requests
|
||||
)
|
||||
{
|
||||
//
|
||||
Path(path);
|
||||
Timeout(timeout);
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
void ~XSCHttp()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Properties Getter(s) / Setter(s) ...
|
||||
|
||||
//
|
||||
// Path ...
|
||||
void Path(string value)
|
||||
{
|
||||
//
|
||||
mPath = value;
|
||||
|
||||
//
|
||||
if (!IsValid(mPath))
|
||||
{
|
||||
mPath = GetTag();
|
||||
}
|
||||
}
|
||||
|
||||
string Path()
|
||||
{
|
||||
return mPath;
|
||||
}
|
||||
|
||||
//
|
||||
// Timeout ...
|
||||
void Timeout(int value)
|
||||
{
|
||||
mTimeout = value;
|
||||
}
|
||||
|
||||
//
|
||||
int Timeout()
|
||||
{
|
||||
return mTimeout;
|
||||
}
|
||||
|
||||
//
|
||||
// Error ...
|
||||
int Error()
|
||||
{
|
||||
return mError;
|
||||
}
|
||||
|
||||
//
|
||||
// Response ...
|
||||
string Response()
|
||||
{
|
||||
return mResponse;
|
||||
}
|
||||
|
||||
//
|
||||
// Overrides ...
|
||||
string GetTag() override
|
||||
{
|
||||
return GetSpecificToken(this);
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Send Global Request ...
|
||||
int SendRequest(
|
||||
X_HTTP_METHOD method, // Httm Request Method
|
||||
const string url, // Server Address
|
||||
const string headers, // Headers providing
|
||||
const char &payload[], // the Data which needs to Send
|
||||
char &response[], // Response of request
|
||||
string responseHeaders, // Response Headers
|
||||
int timeout = 500 // Timeout for response default is 500
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = -1;
|
||||
|
||||
//
|
||||
string strMethod = ToString(method);
|
||||
if (StringLen(strMethod) == 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Reset State ...
|
||||
ResetState();
|
||||
|
||||
//
|
||||
result = WebRequest(
|
||||
strMethod,
|
||||
url,
|
||||
headers,
|
||||
timeout,
|
||||
payload,
|
||||
response,
|
||||
responseHeaders);
|
||||
|
||||
//
|
||||
if (result < 0)
|
||||
{
|
||||
mError = GetLastError();
|
||||
}
|
||||
else
|
||||
{
|
||||
mResponse = CharArrayToString(response);
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Get Request ...
|
||||
int GetRequest(
|
||||
const string url, // Server Address
|
||||
const string headers, // Headers providing
|
||||
const char &payload[], // the Data which needs to Send
|
||||
char &response[], // Response of request
|
||||
string responseHeaders, // Response Headers
|
||||
int timeout = 500 // Timeout for response default is 500
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = SendRequest(
|
||||
X_HTTP_GET,
|
||||
url,
|
||||
headers,
|
||||
payload,
|
||||
response,
|
||||
responseHeaders,
|
||||
timeout);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Post Request ...
|
||||
int PostRequest(
|
||||
const string url, // Server Address
|
||||
const string headers, // Headers providing
|
||||
const char &payload[], // the Data which needs to Send
|
||||
char &response[], // Response of request
|
||||
string responseHeaders, // Response Headers
|
||||
int timeout = 500 // Timeout for response default is 500
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = SendRequest(
|
||||
X_HTTP_POST,
|
||||
url,
|
||||
headers,
|
||||
payload,
|
||||
response,
|
||||
responseHeaders,
|
||||
timeout);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Handle Download Specific URL Content to Specific Path and File Name ...
|
||||
bool Download(
|
||||
string url, // the URL address which going to download
|
||||
string fileName // Specify Destination file name to Store Response
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
string filePath = GetFilePath(fileName);
|
||||
string cookie = NULL;
|
||||
string referer = NULL;
|
||||
int timeout = Timeout();
|
||||
|
||||
//
|
||||
char payload[];
|
||||
string headers;
|
||||
char response[];
|
||||
string responseHeaders;
|
||||
|
||||
//
|
||||
// Send Request ...
|
||||
int requestResult = GetRequest(
|
||||
url,
|
||||
headers,
|
||||
payload,
|
||||
response,
|
||||
responseHeaders,
|
||||
timeout);
|
||||
|
||||
//
|
||||
// Define File Handler ...
|
||||
int mFileHandler = FileOpen(
|
||||
filePath,
|
||||
FILE_WRITE | FILE_BIN);
|
||||
if (mFileHandler == INVALID_HANDLE)
|
||||
{
|
||||
//
|
||||
mError = GetLastError();
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Write Response to File ...
|
||||
uint writed = FileWriteArray(
|
||||
mFileHandler,
|
||||
response,
|
||||
0,
|
||||
ArraySize(response));
|
||||
FileFlush(mFileHandler);
|
||||
FileClose(mFileHandler);
|
||||
|
||||
//
|
||||
result = writed > 0;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// END Provided Functions ...
|
||||
//
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Destintion Folder Path ...
|
||||
string mPath;
|
||||
|
||||
//
|
||||
// WEB Request Timeout Value ...
|
||||
int mTimeout;
|
||||
|
||||
//
|
||||
// WEB Request's Response ...
|
||||
string mResponse;
|
||||
|
||||
//
|
||||
// Error Value ...
|
||||
int mError;
|
||||
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Reset Errors State ...
|
||||
void ResetState()
|
||||
{
|
||||
//
|
||||
// Reset Errors ...
|
||||
mError = -1;
|
||||
mResponse = "";
|
||||
ResetLastError();
|
||||
}
|
||||
|
||||
//
|
||||
// Generate Full File Path ...
|
||||
string GetFilePath(string fileName)
|
||||
{
|
||||
//
|
||||
string result = "";
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
Path() + "\\" + fileName
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Convert enum to String ...
|
||||
string ToString(X_HTTP_METHOD method)
|
||||
{
|
||||
//
|
||||
string result = "";
|
||||
|
||||
//
|
||||
switch (method)
|
||||
{
|
||||
//
|
||||
case X_HTTP_GET:
|
||||
result = "GET";
|
||||
break;
|
||||
|
||||
//
|
||||
case X_HTTP_POST:
|
||||
result = "POST";
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
Binary file not shown.
@@ -0,0 +1,441 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCMD5
|
||||
// Description: Provides MD5 Hashing 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
|
||||
|
||||
//
|
||||
// START Definitions ...
|
||||
//
|
||||
|
||||
//
|
||||
static uchar _md5_PADDING[64] =
|
||||
{
|
||||
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
//
|
||||
#define _md5_F(x, y, z) (((x) & (y)) | ((~x) & (z)))
|
||||
#define _md5_G(x, y, z) (((x) & (z)) | ((y) & (~z)))
|
||||
#define _md5_H(x, y, z) ((x) ^ (y) ^ (z))
|
||||
#define _md5_I(x, y, z) ((y) ^ ((x) | (~z)))
|
||||
#define _md5_ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
|
||||
|
||||
//
|
||||
#define _md5_FF(a, b, c, d, x, s, ac) \
|
||||
{ \
|
||||
(a) += _md5_F((b), (c), (d)) + (x) + (uint)(ac); \
|
||||
(a) = _md5_ROTATE_LEFT((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
|
||||
//
|
||||
#define _md5_GG(a, b, c, d, x, s, ac) \
|
||||
{ \
|
||||
(a) += _md5_G((b), (c), (d)) + (x) + (uint)(ac); \
|
||||
(a) = _md5_ROTATE_LEFT((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
|
||||
//
|
||||
#define _md5_HH(a, b, c, d, x, s, ac) \
|
||||
{ \
|
||||
(a) += _md5_H((b), (c), (d)) + (x) + (uint)(ac); \
|
||||
(a) = _md5_ROTATE_LEFT((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
|
||||
//
|
||||
#define _md5_II(a, b, c, d, x, s, ac) \
|
||||
{ \
|
||||
(a) += _md5_I((b), (c), (d)) + (x) + (uint)(ac); \
|
||||
(a) = _md5_ROTATE_LEFT((a), (s)); \
|
||||
(a) += (b); \
|
||||
}
|
||||
|
||||
//
|
||||
#define _md5_INIT_STATE_0 0x67452301
|
||||
#define _md5_INIT_STATE_1 0xefcdab89
|
||||
#define _md5_INIT_STATE_2 0x98badcfe
|
||||
#define _md5_INIT_STATE_3 0x10325476
|
||||
|
||||
//
|
||||
#define _md5_S11 7
|
||||
#define _md5_S12 12
|
||||
#define _md5_S13 17
|
||||
#define _md5_S14 22
|
||||
|
||||
//
|
||||
#define _md5_S21 5
|
||||
#define _md5_S22 9
|
||||
#define _md5_S23 14
|
||||
#define _md5_S24 20
|
||||
|
||||
//
|
||||
#define _md5_S31 4
|
||||
#define _md5_S32 11
|
||||
#define _md5_S33 16
|
||||
#define _md5_S34 23
|
||||
|
||||
//
|
||||
#define _md5_S41 6
|
||||
#define _md5_S42 10
|
||||
#define _md5_S43 15
|
||||
#define _md5_S44 21
|
||||
|
||||
//
|
||||
// END Definitions ...
|
||||
//
|
||||
|
||||
//
|
||||
// XCMD5 a library for Hashing ...
|
||||
class XSCMD5
|
||||
{
|
||||
//
|
||||
// Public Provides ...
|
||||
public:
|
||||
//
|
||||
// Protected Provides ...
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
XSCMD5(void) {}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XSCMD5(void) {}
|
||||
|
||||
//
|
||||
// Hash Specified Char Array ...
|
||||
string Hash(
|
||||
uchar &mSource[], // Specify Char Array to Hash
|
||||
int mLength = 0 // Specify Length of Char Array which required to hash
|
||||
)
|
||||
{
|
||||
//
|
||||
string result = "";
|
||||
|
||||
//
|
||||
int sourceCount = ArraySize(mSource);
|
||||
|
||||
//
|
||||
// Validate Args ...
|
||||
if (
|
||||
sourceCount <= 0 ||
|
||||
(sourceCount > 0 && mLength > sourceCount))
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Normalize Args ...
|
||||
if (mLength == 0)
|
||||
{
|
||||
mLength = sourceCount;
|
||||
}
|
||||
|
||||
//
|
||||
// Init MD5 ...
|
||||
MD5Init();
|
||||
|
||||
//
|
||||
// Update Buffer ...
|
||||
MD5Update(mSource, mLength);
|
||||
|
||||
//
|
||||
// Calculate Result ...
|
||||
result = MD5Final();
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Hash Specified String ...
|
||||
string Hash(
|
||||
string mSource // Specified String
|
||||
)
|
||||
{
|
||||
//
|
||||
string result = "";
|
||||
|
||||
//
|
||||
// Converts String to Char Array ...
|
||||
uchar bytes[];
|
||||
StringToCharArray(
|
||||
mSource,
|
||||
bytes,
|
||||
0,
|
||||
StringLen(mSource));
|
||||
|
||||
//
|
||||
result = Hash(
|
||||
bytes,
|
||||
ArraySize(bytes));
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
protected:
|
||||
//
|
||||
// Private Provides ...
|
||||
private:
|
||||
//
|
||||
uint m_lMD5[4];
|
||||
uint m_nCount[2];
|
||||
uchar m_lpszBuffer[64];
|
||||
|
||||
//
|
||||
// Convert Byte to DWord ...
|
||||
void ByteToDWord(int &out[], uint &in[], uint len)
|
||||
{
|
||||
//
|
||||
uint i = 0;
|
||||
uint j = 0;
|
||||
|
||||
//
|
||||
for (; j < len; i++, j += 4)
|
||||
{
|
||||
out[i] = (int)in[j] | (int)in[j + 1] << 8 | (int)in[j + 2] << 16 | (int)in[j + 3] << 24;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Convert DWord to Byte ...
|
||||
void DWordToByte(uchar &out[], int &in[], uint len)
|
||||
{
|
||||
//
|
||||
uint i = 0;
|
||||
uint j = 0;
|
||||
|
||||
//
|
||||
for (; j < len; i++, j += 4)
|
||||
{
|
||||
//
|
||||
out[j] = (uchar)(in[i] & 0xff);
|
||||
out[j + 1] = (uchar)((in[i] >> 8) & 0xff);
|
||||
out[j + 2] = (uchar)((in[i] >> 16) & 0xff);
|
||||
out[j + 3] = (uchar)((in[i] >> 24) & 0xff);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Init MD5 Array ...
|
||||
void MD5Init()
|
||||
{
|
||||
//
|
||||
ArrayInitialize(m_lpszBuffer, 64);
|
||||
|
||||
//
|
||||
m_nCount[0] = m_nCount[1] = 0;
|
||||
m_lMD5[0] = _md5_INIT_STATE_0;
|
||||
m_lMD5[1] = _md5_INIT_STATE_1;
|
||||
m_lMD5[2] = _md5_INIT_STATE_2;
|
||||
m_lMD5[3] = _md5_INIT_STATE_3;
|
||||
}
|
||||
|
||||
//
|
||||
// Update MD5 ...
|
||||
void MD5Update(uchar &inBuf[], uint inLen)
|
||||
{
|
||||
//
|
||||
int i, ii;
|
||||
int mdi;
|
||||
|
||||
//
|
||||
uint in[16];
|
||||
int i0 = 0;
|
||||
|
||||
//
|
||||
mdi = (int)((m_nCount[0] >> 3) & 0x3F);
|
||||
|
||||
//
|
||||
if ((m_nCount[0] + ((uint)inLen << 3)) < m_nCount[0])
|
||||
{
|
||||
m_nCount[1]++;
|
||||
}
|
||||
|
||||
//
|
||||
m_nCount[0] += ((uint)inLen << 3);
|
||||
m_nCount[1] += ((uint)inLen >> 29);
|
||||
|
||||
//
|
||||
while ((inLen--) > 0)
|
||||
{
|
||||
//
|
||||
m_lpszBuffer[mdi++] = inBuf[i0++];
|
||||
if (mdi == 0x40)
|
||||
{
|
||||
//
|
||||
for (i = 0, ii = 0; i < 16; i++, ii += 4)
|
||||
{
|
||||
in[i] = (((uint)m_lpszBuffer[ii + 3]) << 24) | (((uint)m_lpszBuffer[ii + 2]) << 16) | (((uint)m_lpszBuffer[ii + 1]) << 8) | ((uint)m_lpszBuffer[ii]);
|
||||
}
|
||||
|
||||
//
|
||||
Transform(m_lMD5, in);
|
||||
|
||||
//
|
||||
mdi = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Finalize an MD5 Expression ...
|
||||
string MD5Final()
|
||||
{
|
||||
//
|
||||
uchar bits[8];
|
||||
int nIndex;
|
||||
uint nPadLen;
|
||||
const int nMD5Size = 16;
|
||||
uchar lpszMD5[16];
|
||||
string temp;
|
||||
string out = "";
|
||||
int i;
|
||||
|
||||
//
|
||||
DWordToByte(bits, m_nCount, 8);
|
||||
nIndex = (int)((m_nCount[0] >> 3) & 0x3f);
|
||||
nPadLen = (nIndex < 56) ? (56 - nIndex) : (120 - nIndex);
|
||||
MD5Update(_md5_PADDING, nPadLen);
|
||||
MD5Update(bits, 8);
|
||||
DWordToByte(lpszMD5, m_lMD5, nMD5Size);
|
||||
|
||||
//
|
||||
for (i = 0; i < nMD5Size; i++)
|
||||
{
|
||||
//
|
||||
if (lpszMD5[i] == 0)
|
||||
{
|
||||
temp = "00";
|
||||
}
|
||||
else if (lpszMD5[i] <= 15)
|
||||
{
|
||||
temp = StringFormat("0%x", lpszMD5[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
temp = StringFormat("%x", lpszMD5[i]);
|
||||
}
|
||||
|
||||
//
|
||||
out += temp;
|
||||
}
|
||||
|
||||
//
|
||||
lpszMD5[0] = '\0';
|
||||
|
||||
//
|
||||
return (out);
|
||||
}
|
||||
|
||||
//
|
||||
// Transform Buffers ...
|
||||
void Transform(uint &buf[], uint &in[])
|
||||
{
|
||||
//
|
||||
uint a = buf[0], b = buf[1], c = buf[2], d = buf[3];
|
||||
|
||||
//
|
||||
_md5_FF(a, b, c, d, in[0], _md5_S11, 0xD76AA478);
|
||||
_md5_FF(d, a, b, c, in[1], _md5_S12, 0xE8C7B756);
|
||||
_md5_FF(c, d, a, b, in[2], _md5_S13, 0x242070DB);
|
||||
_md5_FF(b, c, d, a, in[3], _md5_S14, 0xC1BDCEEE);
|
||||
_md5_FF(a, b, c, d, in[4], _md5_S11, 0xF57C0FAF);
|
||||
_md5_FF(d, a, b, c, in[5], _md5_S12, 0x4787C62A);
|
||||
_md5_FF(c, d, a, b, in[6], _md5_S13, 0xA8304613);
|
||||
_md5_FF(b, c, d, a, in[7], _md5_S14, 0xFD469501);
|
||||
_md5_FF(a, b, c, d, in[8], _md5_S11, 0x698098D8);
|
||||
_md5_FF(d, a, b, c, in[9], _md5_S12, 0x8B44F7AF);
|
||||
_md5_FF(c, d, a, b, in[10], _md5_S13, 0xFFFF5BB1);
|
||||
_md5_FF(b, c, d, a, in[11], _md5_S14, 0x895CD7BE);
|
||||
_md5_FF(a, b, c, d, in[12], _md5_S11, 0x6B901122);
|
||||
_md5_FF(d, a, b, c, in[13], _md5_S12, 0xFD987193);
|
||||
_md5_FF(c, d, a, b, in[14], _md5_S13, 0xA679438E);
|
||||
_md5_FF(b, c, d, a, in[15], _md5_S14, 0x49B40821);
|
||||
|
||||
//
|
||||
_md5_GG(a, b, c, d, in[1], _md5_S21, 0xF61E2562);
|
||||
_md5_GG(d, a, b, c, in[6], _md5_S22, 0xC040B340);
|
||||
_md5_GG(c, d, a, b, in[11], _md5_S23, 0x265E5A51);
|
||||
_md5_GG(b, c, d, a, in[0], _md5_S24, 0xE9B6C7AA);
|
||||
_md5_GG(a, b, c, d, in[5], _md5_S21, 0xD62F105D);
|
||||
_md5_GG(d, a, b, c, in[10], _md5_S22, 0x02441453);
|
||||
_md5_GG(c, d, a, b, in[15], _md5_S23, 0xD8A1E681);
|
||||
_md5_GG(b, c, d, a, in[4], _md5_S24, 0xE7D3FBC8);
|
||||
_md5_GG(a, b, c, d, in[9], _md5_S21, 0x21E1CDE6);
|
||||
_md5_GG(d, a, b, c, in[14], _md5_S22, 0xC33707D6);
|
||||
_md5_GG(c, d, a, b, in[3], _md5_S23, 0xF4D50D87);
|
||||
_md5_GG(b, c, d, a, in[8], _md5_S24, 0x455A14ED);
|
||||
_md5_GG(a, b, c, d, in[13], _md5_S21, 0xA9E3E905);
|
||||
_md5_GG(d, a, b, c, in[2], _md5_S22, 0xFCEFA3F8);
|
||||
_md5_GG(c, d, a, b, in[7], _md5_S23, 0x676F02D9);
|
||||
_md5_GG(b, c, d, a, in[12], _md5_S24, 0x8D2A4C8A);
|
||||
|
||||
//
|
||||
_md5_HH(a, b, c, d, in[5], _md5_S31, 0xFFFA3942);
|
||||
_md5_HH(d, a, b, c, in[8], _md5_S32, 0x8771F681);
|
||||
_md5_HH(c, d, a, b, in[11], _md5_S33, 0x6D9D6122);
|
||||
_md5_HH(b, c, d, a, in[14], _md5_S34, 0xFDE5380C);
|
||||
_md5_HH(a, b, c, d, in[1], _md5_S31, 0xA4BEEA44);
|
||||
_md5_HH(d, a, b, c, in[4], _md5_S32, 0x4BDECFA9);
|
||||
_md5_HH(c, d, a, b, in[7], _md5_S33, 0xF6BB4B60);
|
||||
_md5_HH(b, c, d, a, in[10], _md5_S34, 0xBEBFBC70);
|
||||
_md5_HH(a, b, c, d, in[13], _md5_S31, 0x289B7EC6);
|
||||
_md5_HH(d, a, b, c, in[0], _md5_S32, 0xEAA127FA);
|
||||
_md5_HH(c, d, a, b, in[3], _md5_S33, 0xD4EF3085);
|
||||
_md5_HH(b, c, d, a, in[6], _md5_S34, 0x04881D05);
|
||||
_md5_HH(a, b, c, d, in[9], _md5_S31, 0xD9D4D039);
|
||||
_md5_HH(d, a, b, c, in[12], _md5_S32, 0xE6DB99E5);
|
||||
_md5_HH(c, d, a, b, in[15], _md5_S33, 0x1FA27CF8);
|
||||
_md5_HH(b, c, d, a, in[2], _md5_S34, 0xC4AC5665);
|
||||
|
||||
//
|
||||
_md5_II(a, b, c, d, in[0], _md5_S41, 0xF4292244);
|
||||
_md5_II(d, a, b, c, in[7], _md5_S42, 0x432AFF97);
|
||||
_md5_II(c, d, a, b, in[14], _md5_S43, 0xAB9423A7);
|
||||
_md5_II(b, c, d, a, in[5], _md5_S44, 0xFC93A039);
|
||||
_md5_II(a, b, c, d, in[12], _md5_S41, 0x655B59C3);
|
||||
_md5_II(d, a, b, c, in[3], _md5_S42, 0x8F0CCC92);
|
||||
_md5_II(c, d, a, b, in[10], _md5_S43, 0xFFEFF47D);
|
||||
_md5_II(b, c, d, a, in[1], _md5_S44, 0x85845DD1);
|
||||
_md5_II(a, b, c, d, in[8], _md5_S41, 0x6FA87E4F);
|
||||
_md5_II(d, a, b, c, in[15], _md5_S42, 0xFE2CE6E0);
|
||||
_md5_II(c, d, a, b, in[6], _md5_S43, 0xA3014314);
|
||||
_md5_II(b, c, d, a, in[13], _md5_S44, 0x4E0811A1);
|
||||
_md5_II(a, b, c, d, in[4], _md5_S41, 0xF7537E82);
|
||||
_md5_II(d, a, b, c, in[11], _md5_S42, 0xBD3AF235);
|
||||
_md5_II(c, d, a, b, in[2], _md5_S43, 0x2AD7D2BB);
|
||||
_md5_II(b, c, d, a, in[9], _md5_S44, 0xEB86D391);
|
||||
|
||||
//
|
||||
buf[0] += a;
|
||||
buf[1] += b;
|
||||
buf[2] += c;
|
||||
buf[3] += d;
|
||||
}
|
||||
};
|
||||
Binary file not shown.
@@ -0,0 +1,267 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCBaseProvider
|
||||
// Description: provides all Base Provider
|
||||
// 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
|
||||
|
||||
//
|
||||
// Includes ...
|
||||
#include "../Classes/x-saherelm.base.class.mq5"
|
||||
#include "../Libraries/x-saherelm.xtrade.lib.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
// Base Provider Inputs ...
|
||||
class XSCBaseProviderInpts : public XSCBase
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Validate Input ...
|
||||
virtual bool IsValid();
|
||||
|
||||
//
|
||||
// Cleanup ...
|
||||
virtual void Clean();
|
||||
|
||||
//
|
||||
// Default ...
|
||||
virtual void Default();
|
||||
|
||||
//
|
||||
// Max ...
|
||||
virtual int Max();
|
||||
};
|
||||
|
||||
//
|
||||
// Base Market Conditions Class ...
|
||||
class XSCBaseProviderMarketConditions : public XSCBase
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
string symbol; // Symbol
|
||||
ENUM_TIMEFRAMES period; // Period
|
||||
datetime time; // Time
|
||||
|
||||
//
|
||||
XOHCL bars[]; // Number of Bars ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
// Conditions ...
|
||||
|
||||
//
|
||||
// Generate Score ...
|
||||
virtual void GenerateScore(
|
||||
double &bullishScore, // Bullish Score
|
||||
double &bearishScore, // Bearish Score
|
||||
double multiplier = 1 // Score Multiplier
|
||||
);
|
||||
|
||||
//
|
||||
// Generate Summary ...
|
||||
virtual string GenerateSummary(
|
||||
const bool onlySummary = false, // Only Generate Conditions Summary
|
||||
double multiplier = 1, // Score Multiplier
|
||||
const string separator = "\n", // Separator
|
||||
const bool ignoreFalseConditions = true // Ignore False Conditions
|
||||
);
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
|
||||
//
|
||||
// Base Provider Class ...
|
||||
class XSCBaseProvider : public XSCBase
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
XSCBaseProvider(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
double staticVolume // Static Volume for Positions
|
||||
)
|
||||
{
|
||||
//
|
||||
// Initialize Cycle ...
|
||||
mCycle.Init(
|
||||
symbol,
|
||||
period,
|
||||
X_MARKET_CYCLE_SHORT,
|
||||
X_PERIOD_MANUALLY,
|
||||
period,
|
||||
"HOST Period"
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
mStaticVolume = staticVolume;
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XSCBaseProvider()
|
||||
{
|
||||
DeInit();
|
||||
}
|
||||
|
||||
//
|
||||
// Properties Gettr(s) / Setter(s) ...
|
||||
|
||||
//
|
||||
// Inheritance ...
|
||||
|
||||
//
|
||||
// Init all Requirements ...
|
||||
virtual bool Init(XSCBaseProviderInpts &inputs);
|
||||
|
||||
//
|
||||
// Get Inputs ...
|
||||
virtual void GetInputs(XSCBaseProviderInpts &inputs);
|
||||
|
||||
//
|
||||
// Set Inputs and Reinitial ...
|
||||
virtual bool setInputs(XSCBaseProviderInpts &inputs);
|
||||
|
||||
//
|
||||
// DeInit all Requirements ...
|
||||
virtual void DeInit();
|
||||
|
||||
//
|
||||
virtual void GetMarketConditions(
|
||||
XSCBaseProviderMarketConditions &conditions, // Market Conditions Result
|
||||
int barIndex = 0 // Specified Bar Index
|
||||
);
|
||||
|
||||
//
|
||||
// Check Market For Signal ...
|
||||
virtual bool HasSignal(
|
||||
int barIndex,
|
||||
XSignal &signal, // Hold's Signal if Exists ...
|
||||
XSCBaseProviderMarketConditions &conditions // Hold's Market Conditions ...
|
||||
);
|
||||
|
||||
//
|
||||
// Functions ...
|
||||
|
||||
//
|
||||
string GetSymbol()
|
||||
{
|
||||
return mCycle.symbol;
|
||||
}
|
||||
|
||||
//
|
||||
ENUM_TIMEFRAMES GetPeriod()
|
||||
{
|
||||
return mCycle.hostPeriod;
|
||||
}
|
||||
|
||||
//
|
||||
double GetStaticVolume()
|
||||
{
|
||||
return mStaticVolume;
|
||||
}
|
||||
|
||||
//
|
||||
// Count Bars ...
|
||||
int CountBars()
|
||||
{
|
||||
//
|
||||
return mCycle
|
||||
.CountBars();
|
||||
}
|
||||
|
||||
//
|
||||
// Check New Bar ...
|
||||
bool IsNewBar()
|
||||
{
|
||||
//
|
||||
return mCycle
|
||||
.IsNewBar();
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
double mStaticVolume; // Static Volume for Positions
|
||||
|
||||
//
|
||||
XMarketCycle mCycle;
|
||||
|
||||
//
|
||||
bool mWaitsUntilNewBar;
|
||||
|
||||
//
|
||||
// Can Ignore Process ...
|
||||
bool CanIgnoreProcess()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
IsRunningOnTestMode()
|
||||
? !IsNewBar()
|
||||
: !IsNewBar() && mWaitsUntilNewBar
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Toggle Waititng Until New Candle ...
|
||||
void ToggleWaitingUntilNewBar()
|
||||
{
|
||||
mWaitsUntilNewBar = !mWaitsUntilNewBar;
|
||||
}
|
||||
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,953 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center X121EA MQL5 Expert Advisor
|
||||
// -------------------------------------------------
|
||||
// Name: X121EA
|
||||
// Description: an Exper Advisor which used RSI and MA
|
||||
// to Analyse Market ...
|
||||
//
|
||||
// Maintainer:
|
||||
// ------------
|
||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||
//
|
||||
//////////////////////////////////////////////////////x
|
||||
//
|
||||
// Global Properties ...
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property description "SaherElm X121EA"
|
||||
#property strict
|
||||
|
||||
//
|
||||
#define ShortName "X121EA"
|
||||
|
||||
//
|
||||
#include "../Classes/x-saherelm.x121.xea.class.mq5"
|
||||
|
||||
//
|
||||
// "EURUSDb,USDCHFb,USDJPYb,XAUUSDb"
|
||||
// "EURUSDb,USDCHFb,USDJPYb,GBPUSDb,XAUUSDb,AUDUSDb,USDCADb,NZDUSDb"
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
long x121EAMagicNumber = 78692110; // Magic Number
|
||||
int x121EASlippage = 10; // Slippgae
|
||||
string x121EASymbols = "EURUSDb,USDCHFb,USDJPYb,GBPUSDb"; // Symbols
|
||||
//
|
||||
bool x121EAAllowLong = true; // Allow Long Trades
|
||||
bool x121EAAllowShort = true; // Allow Short Trades
|
||||
int x121EAManageInterval = 0; // Manager Check Intervals Seconds
|
||||
int x121EAMaxAllowedPositions = 5; // Max Allowed Positions
|
||||
double x121EAMaxAllowedSpread = 0; // Max Allowed Spred for Opening Trades
|
||||
double x121EAMinProfitPerTrade = 3; // Min Profit Per Trade based On Volume Factor (Hedge)
|
||||
double x121EAMinProfitPerVolumeFactor = 0.01; // Min Volume Factor for Calculating Profit (Hedge)
|
||||
double x121EAMaxAllowedDrawdownFactor = 0.002; // Max Allowed Drawdown Factor
|
||||
//
|
||||
double x121EAVolume = 0.01;
|
||||
|
||||
//
|
||||
// Vars ...
|
||||
string x121EASymbol;
|
||||
ENUM_TIMEFRAMES x121EAPeriod;
|
||||
|
||||
//
|
||||
MqlTick x121EATick;
|
||||
|
||||
//
|
||||
// X121EA ...
|
||||
XSCX121EA *mX121EA;
|
||||
|
||||
//
|
||||
// Event Handlers ...
|
||||
|
||||
//
|
||||
// Initialization ...
|
||||
int OnInit()
|
||||
{
|
||||
//
|
||||
if (x121EASymbol == NULL || StringLen(x121EASymbol) <= 0)
|
||||
{
|
||||
x121EASymbol = _Symbol;
|
||||
}
|
||||
|
||||
//
|
||||
if (x121EAPeriod == NULL)
|
||||
{
|
||||
x121EAPeriod = _Period;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Inputs ...
|
||||
if (!X121EAValidateInputs())
|
||||
{
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
// Initial EA ...
|
||||
if (!InitialEA())
|
||||
{
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
// TesterHideIndicators(true);
|
||||
|
||||
//
|
||||
// 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
|
||||
|
||||
//
|
||||
// De Initialize X121EA Providers ...
|
||||
}
|
||||
|
||||
//
|
||||
// On Tick Handler ...
|
||||
void OnTick()
|
||||
{
|
||||
//
|
||||
// Reading Tick ...
|
||||
if (!SymbolInfoTick(x121EASymbol, x121EATick))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
mX121EA.OnTick();
|
||||
}
|
||||
|
||||
//
|
||||
// Custom Functions ...
|
||||
|
||||
//
|
||||
// Validate Variables nd Inputs ...
|
||||
bool X121EAValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
x121EASlippage > 0 &&
|
||||
x121EAMagicNumber > 0
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize Specific Providers ...
|
||||
bool InitialEA()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Here We Have to Initial 4 instance of X5Provider ...
|
||||
// - EURUSD/M5;
|
||||
// - USDCHF/M5;
|
||||
// - USDJPY/M5;
|
||||
// - XAUUSD/M5;
|
||||
|
||||
//
|
||||
result = IsValid(x121EASymbols);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string symbols[];
|
||||
int symbolsCount = SplitContent(
|
||||
symbols,
|
||||
x121EASymbols);
|
||||
result = symbolsCount > 0;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Signallers ...
|
||||
ENUM_X121_SIGNAL_PROVIDERS signallers[];
|
||||
Add(X786, signallers);
|
||||
Add(X110, signallers);
|
||||
Add(X121, signallers);
|
||||
Add(X128, signallers);
|
||||
Add(X92, signallers);
|
||||
// GetAllX121SignalProviders(signallers);
|
||||
|
||||
//
|
||||
// Instantiate X121EA Class ...
|
||||
mX121EA = new XSCX121EA(
|
||||
x121EASlippage, // Slippgae
|
||||
x121EAMagicNumber, // Magic Number
|
||||
x121EAManageInterval, // Manager Check Intervals Seconds
|
||||
x121EAMaxAllowedSpread, // Max Allowed Spred for Opening Trades
|
||||
x121EAMaxAllowedPositions, // Max Allowed Positions
|
||||
x121EAMaxAllowedDrawdownFactor, // Max Allowed Drawdown Factor
|
||||
x121EAVolume, // Static Volume for Positions
|
||||
x121EAAllowLong, // Allow Long Trades
|
||||
x121EAAllowShort, // Allow Short Trades
|
||||
x121EAMinProfitPerTrade, // Min Profit Per Trade based On Volume Factor (Hedge)
|
||||
x121EAMinProfitPerVolumeFactor // Min Volume Factor for Calculating Profit (Hedge)
|
||||
);
|
||||
|
||||
//
|
||||
// Prepare Providers and Add them into mX121EA class ...
|
||||
for (int i = 0; i < symbolsCount; i++)
|
||||
{
|
||||
//
|
||||
// Requirements ...
|
||||
string iSymbol = symbols[i];
|
||||
ENUM_TIMEFRAMES iPeriod = PERIOD_M5;
|
||||
|
||||
//
|
||||
// Define Structure ...
|
||||
X121ProviderDescriptor iDescriptor;
|
||||
|
||||
//
|
||||
iDescriptor.symbol = iSymbol;
|
||||
iDescriptor.period = iPeriod;
|
||||
iDescriptor.staticVolume = x121EAVolume;
|
||||
iDescriptor.allowLong = x121EAAllowLong;
|
||||
iDescriptor.allowShort = x121EAAllowShort;
|
||||
Copy(
|
||||
signallers,
|
||||
iDescriptor.signallers);
|
||||
|
||||
//
|
||||
// Set Inputs to Default ...
|
||||
iDescriptor.inputs.Default();
|
||||
|
||||
//
|
||||
// Prepare Input Requirements ...
|
||||
|
||||
//
|
||||
iDescriptor.inputs.symbol = iSymbol;
|
||||
iDescriptor.inputs.period = iPeriod;
|
||||
|
||||
//
|
||||
ConfigureDescriptor(iDescriptor);
|
||||
|
||||
//
|
||||
// Init Inputs ...
|
||||
result = iDescriptor.inputs.Init();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Inputs ...
|
||||
bool isInputsValid = iDescriptor.inputs.IsValid();
|
||||
if (!isInputsValid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
result = mX121EA.AddProvider(iDescriptor);
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Configurators ...
|
||||
|
||||
//
|
||||
// Configuring Descriptors ...
|
||||
void ConfigureDescriptor(
|
||||
X121ProviderDescriptor &iDescriptor //
|
||||
)
|
||||
{
|
||||
//
|
||||
// XHK ...
|
||||
iDescriptor.inputs.hkInputs.drawHikenAshi = false;
|
||||
iDescriptor.inputs.hkInputs.drawSmoothedHikenAshi = false;
|
||||
|
||||
//
|
||||
// XMC ...
|
||||
iDescriptor.inputs.mcInputs.showFastMa = false;
|
||||
iDescriptor.inputs.mcInputs.showSlowMa = false;
|
||||
iDescriptor.inputs.mcInputs.showVerifierMa = false;
|
||||
|
||||
//
|
||||
// XICH ...
|
||||
iDescriptor.inputs.ichInputs.showKumo = false;
|
||||
iDescriptor.inputs.ichInputs.showKijunSen = false;
|
||||
iDescriptor.inputs.ichInputs.showTenkanSen = false;
|
||||
iDescriptor.inputs.ichInputs.showChikouSpan = false;
|
||||
iDescriptor.inputs.ichInputs.showSenkouSpanA = false;
|
||||
iDescriptor.inputs.ichInputs.showSenkouSpanB = false;
|
||||
iDescriptor.inputs.ichInputs.showKijunSenPlus = false;
|
||||
iDescriptor.inputs.ichInputs.showKijunSenNegative = false;
|
||||
|
||||
//
|
||||
// XCHE ...
|
||||
iDescriptor.inputs.cheInputs.showLongExit1Line = false;
|
||||
iDescriptor.inputs.cheInputs.showShortExit1Line = false;
|
||||
iDescriptor.inputs.cheInputs.showLongExit2Line = false;
|
||||
iDescriptor.inputs.cheInputs.showShortExit2Line = false;
|
||||
|
||||
//
|
||||
// XPV ...
|
||||
iDescriptor.inputs.pvInputs.showPeaksAndVales = true;
|
||||
iDescriptor.inputs.pvInputs.showLevels = false;
|
||||
iDescriptor.inputs.pvInputs.showConsolidations = false;
|
||||
iDescriptor.inputs.pvInputs.showFibo1Levels = false;
|
||||
iDescriptor.inputs.pvInputs.showFibo2Levels = false;
|
||||
iDescriptor.inputs.pvInputs.showFibo3Levels = false;
|
||||
iDescriptor.inputs.pvInputs.showFibo4Levels = false;
|
||||
iDescriptor.inputs.pvInputs.showFibo5Levels = false;
|
||||
|
||||
//
|
||||
// XZG ...
|
||||
iDescriptor.inputs.zgInputs.showZigZag = true;
|
||||
iDescriptor.inputs.zgInputs.showPeaksAndVales = true;
|
||||
|
||||
//
|
||||
// XDON ...
|
||||
iDescriptor.inputs.donInputs.showOpen = false;
|
||||
iDescriptor.inputs.donInputs.showHigh = false;
|
||||
iDescriptor.inputs.donInputs.showClose = false;
|
||||
iDescriptor.inputs.donInputs.showLow = false;
|
||||
|
||||
//
|
||||
// XSTR ...
|
||||
iDescriptor.inputs.strInputs.showTrends = false;
|
||||
iDescriptor.inputs.strInputs.fillTrends = false;
|
||||
|
||||
//
|
||||
// Short MArket ...
|
||||
iDescriptor.inputs.sMarketPeriod = NULL;
|
||||
iDescriptor.inputs.sMarketMethod = X_PERIOD_AUTO;
|
||||
|
||||
//
|
||||
// Medium Market ...
|
||||
iDescriptor.inputs.mMarketPeriod = NULL;
|
||||
iDescriptor.inputs.mMarketMethod = X_PERIOD_AUTO;
|
||||
|
||||
//
|
||||
// Long Market ...
|
||||
iDescriptor.inputs.lMarketPeriod = NULL;
|
||||
iDescriptor.inputs.lMarketMethod = X_PERIOD_AUTO;
|
||||
|
||||
//
|
||||
int fontSize = 12;
|
||||
double fontAngel = 90;
|
||||
string fontName = "Arial";
|
||||
ENUM_ANCHOR_POINT fontAnchor = ANCHOR_LEFT_UPPER;
|
||||
|
||||
//
|
||||
// Current Market ...
|
||||
ConfigureCurrentMarketDrawSpecs(
|
||||
//
|
||||
iDescriptor,
|
||||
//
|
||||
"Current",
|
||||
//
|
||||
false, // Draw Labels ...
|
||||
false, // Draw C Bar ...
|
||||
false, // Draw P Bar ...
|
||||
false, // Draw C Bar Mid Line ...
|
||||
false, // Draw P Bar Mid Line ...
|
||||
//
|
||||
fontSize,
|
||||
fontAngel,
|
||||
fontName,
|
||||
fontAnchor // ,
|
||||
//
|
||||
// cBarPrefix
|
||||
// pBarPrefix
|
||||
// openLabel
|
||||
// closeLabel
|
||||
// highLabel
|
||||
// lowLabel
|
||||
// midLineLabel
|
||||
);
|
||||
|
||||
//
|
||||
// Short Market ...
|
||||
ConfigureShortMarketDrawSpecs(
|
||||
//
|
||||
iDescriptor,
|
||||
//
|
||||
iDescriptor.inputs.sMarketPeriod,
|
||||
iDescriptor.inputs.sMarketMethod,
|
||||
//
|
||||
"Short",
|
||||
//
|
||||
false, // Draw Labels ...
|
||||
false, // Draw C Bar ...
|
||||
false, // Draw P Bar ...
|
||||
false, // Draw C Bar Mid Line ...
|
||||
false, // Draw P Bar Mid Line ...
|
||||
//
|
||||
fontSize,
|
||||
fontAngel,
|
||||
fontName,
|
||||
fontAnchor // ,
|
||||
//
|
||||
// cBarPrefix
|
||||
// pBarPrefix
|
||||
// openLabel
|
||||
// closeLabel
|
||||
// highLabel
|
||||
// lowLabel
|
||||
// midLineLabel
|
||||
);
|
||||
|
||||
//
|
||||
// Medium Market ...
|
||||
ConfigureMediumMarketDrawSpecs(
|
||||
//
|
||||
iDescriptor,
|
||||
//
|
||||
iDescriptor.inputs.mMarketPeriod,
|
||||
iDescriptor.inputs.mMarketMethod,
|
||||
//
|
||||
"Medium",
|
||||
//
|
||||
false, // Draw Labels ...
|
||||
false, // Draw C Bar ...
|
||||
false, // Draw P Bar ...
|
||||
false, // Draw C Bar Mid Line ...
|
||||
false, // Draw P Bar Mid Line ...
|
||||
//
|
||||
fontSize,
|
||||
fontAngel,
|
||||
fontName,
|
||||
fontAnchor // ,
|
||||
//
|
||||
// cBarPrefix
|
||||
// pBarPrefix
|
||||
// openLabel
|
||||
// closeLabel
|
||||
// highLabel
|
||||
// lowLabel
|
||||
// midLineLabel
|
||||
);
|
||||
|
||||
//
|
||||
// Long Market ...
|
||||
ConfigureLongMarketDrawSpecs(
|
||||
//
|
||||
iDescriptor,
|
||||
//
|
||||
iDescriptor.inputs.lMarketPeriod,
|
||||
iDescriptor.inputs.lMarketMethod,
|
||||
//
|
||||
"Long",
|
||||
//
|
||||
false, // Draw Labels ...
|
||||
false, // Draw C Bar ...
|
||||
false, // Draw P Bar ...
|
||||
false, // Draw C Bar Mid Line ...
|
||||
false, // Draw P Bar Mid Line ...
|
||||
//
|
||||
fontSize,
|
||||
fontAngel,
|
||||
fontName,
|
||||
fontAnchor // ,
|
||||
//
|
||||
// cBarPrefix
|
||||
// pBarPrefix
|
||||
// openLabel
|
||||
// closeLabel
|
||||
// highLabel
|
||||
// lowLabel
|
||||
// midLineLabel
|
||||
);
|
||||
|
||||
//
|
||||
// Hind Market ...
|
||||
ConfigureHindMarketDrawSpecs(
|
||||
//
|
||||
iDescriptor,
|
||||
//
|
||||
iDescriptor.inputs.hMarketPeriod,
|
||||
iDescriptor.inputs.hMarketMethod,
|
||||
//
|
||||
"Hind",
|
||||
//
|
||||
false, // Draw Labels ...
|
||||
false, // Draw C Bar ...
|
||||
false, // Draw P Bar ...
|
||||
false, // Draw C Bar Mid Line ...
|
||||
false, // Draw P Bar Mid Line ...
|
||||
//
|
||||
fontSize,
|
||||
fontAngel,
|
||||
fontName,
|
||||
fontAnchor // ,
|
||||
//
|
||||
// cBarPrefix
|
||||
// pBarPrefix
|
||||
// openLabel
|
||||
// closeLabel
|
||||
// highLabel
|
||||
// lowLabel
|
||||
// midLineLabel
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Current ...
|
||||
void ConfigureCurrentMarketDrawSpecs(
|
||||
X121ProviderDescriptor &iDescriptor,
|
||||
string prefix = "Current",
|
||||
bool drawLabels = false,
|
||||
bool drawCBar = false,
|
||||
bool drawPBar = false,
|
||||
bool drawCBarMid = false,
|
||||
bool drawPBarMid = false,
|
||||
int fontSize = 12,
|
||||
double fontAngel = 90,
|
||||
string fontName = "Arial",
|
||||
ENUM_ANCHOR_POINT fontAnchor = ANCHOR_LEFT_UPPER,
|
||||
string cBarPrefix = "C",
|
||||
string pBarPrefix = "P",
|
||||
string openLabel = "O",
|
||||
string closeLabel = "C",
|
||||
string highLabel = "H",
|
||||
string lowLabel = "L",
|
||||
string midLineLabel = "Mid" //
|
||||
)
|
||||
{
|
||||
//
|
||||
ConfigureMarketDrawSpecs(
|
||||
iDescriptor.inputs.cMarketInputs,
|
||||
//
|
||||
drawLabels,
|
||||
drawCBar,
|
||||
drawPBar,
|
||||
drawCBarMid,
|
||||
drawPBarMid,
|
||||
fontSize,
|
||||
fontAngel,
|
||||
fontName,
|
||||
fontAnchor,
|
||||
prefix,
|
||||
cBarPrefix,
|
||||
pBarPrefix,
|
||||
openLabel,
|
||||
closeLabel,
|
||||
highLabel,
|
||||
lowLabel,
|
||||
midLineLabel //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Short ...
|
||||
void ConfigureShortMarketDrawSpecs(
|
||||
X121ProviderDescriptor &iDescriptor,
|
||||
ENUM_TIMEFRAMES period = NULL,
|
||||
ENUM_X_PERIOD_METHOD method = X_PERIOD_AUTO,
|
||||
string prefix = "Short",
|
||||
bool drawLabels = false,
|
||||
bool drawCBar = false,
|
||||
bool drawPBar = false,
|
||||
bool drawCBarMid = false,
|
||||
bool drawPBarMid = false,
|
||||
int fontSize = 12,
|
||||
double fontAngel = 90,
|
||||
string fontName = "Arial",
|
||||
ENUM_ANCHOR_POINT fontAnchor = ANCHOR_LEFT_UPPER,
|
||||
string cBarPrefix = "C",
|
||||
string pBarPrefix = "P",
|
||||
string openLabel = "O",
|
||||
string closeLabel = "C",
|
||||
string highLabel = "H",
|
||||
string lowLabel = "L",
|
||||
string midLineLabel = "Mid" //
|
||||
)
|
||||
{
|
||||
//
|
||||
// Short Market ...
|
||||
iDescriptor.inputs.sMarketPeriod = period;
|
||||
iDescriptor.inputs.sMarketMethod = method;
|
||||
|
||||
//
|
||||
ConfigureMarketDrawSpecs(
|
||||
iDescriptor.inputs.sMarketInputs,
|
||||
//
|
||||
drawLabels,
|
||||
drawCBar,
|
||||
drawPBar,
|
||||
drawCBarMid,
|
||||
drawPBarMid,
|
||||
fontSize,
|
||||
fontAngel,
|
||||
fontName,
|
||||
fontAnchor,
|
||||
prefix,
|
||||
cBarPrefix,
|
||||
pBarPrefix,
|
||||
openLabel,
|
||||
closeLabel,
|
||||
highLabel,
|
||||
lowLabel,
|
||||
midLineLabel //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Medium ...
|
||||
void ConfigureMediumMarketDrawSpecs(
|
||||
X121ProviderDescriptor &iDescriptor,
|
||||
ENUM_TIMEFRAMES period = NULL,
|
||||
ENUM_X_PERIOD_METHOD method = X_PERIOD_AUTO,
|
||||
string prefix = "Medium",
|
||||
bool drawLabels = false,
|
||||
bool drawCBar = false,
|
||||
bool drawPBar = false,
|
||||
bool drawCBarMid = false,
|
||||
bool drawPBarMid = false,
|
||||
int fontSize = 12,
|
||||
double fontAngel = 90,
|
||||
string fontName = "Arial",
|
||||
ENUM_ANCHOR_POINT fontAnchor = ANCHOR_LEFT_UPPER,
|
||||
string cBarPrefix = "C",
|
||||
string pBarPrefix = "P",
|
||||
string openLabel = "O",
|
||||
string closeLabel = "C",
|
||||
string highLabel = "H",
|
||||
string lowLabel = "L",
|
||||
string midLineLabel = "Mid" //
|
||||
)
|
||||
{
|
||||
//
|
||||
// Medium Market ...
|
||||
iDescriptor.inputs.mMarketPeriod = period;
|
||||
iDescriptor.inputs.mMarketMethod = method;
|
||||
|
||||
//
|
||||
ConfigureMarketDrawSpecs(
|
||||
iDescriptor.inputs.mMarketInputs,
|
||||
//
|
||||
drawLabels,
|
||||
drawCBar,
|
||||
drawPBar,
|
||||
drawCBarMid,
|
||||
drawPBarMid,
|
||||
fontSize,
|
||||
fontAngel,
|
||||
fontName,
|
||||
fontAnchor,
|
||||
prefix,
|
||||
cBarPrefix,
|
||||
pBarPrefix,
|
||||
openLabel,
|
||||
closeLabel,
|
||||
highLabel,
|
||||
lowLabel,
|
||||
midLineLabel //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Long ...
|
||||
void ConfigureLongMarketDrawSpecs(
|
||||
X121ProviderDescriptor &iDescriptor,
|
||||
ENUM_TIMEFRAMES period = NULL,
|
||||
ENUM_X_PERIOD_METHOD method = X_PERIOD_AUTO,
|
||||
string prefix = "Long",
|
||||
bool drawLabels = false,
|
||||
bool drawCBar = false,
|
||||
bool drawPBar = false,
|
||||
bool drawCBarMid = false,
|
||||
bool drawPBarMid = false,
|
||||
int fontSize = 12,
|
||||
double fontAngel = 90,
|
||||
string fontName = "Arial",
|
||||
ENUM_ANCHOR_POINT fontAnchor = ANCHOR_LEFT_UPPER,
|
||||
string cBarPrefix = "C",
|
||||
string pBarPrefix = "P",
|
||||
string openLabel = "O",
|
||||
string closeLabel = "C",
|
||||
string highLabel = "H",
|
||||
string lowLabel = "L",
|
||||
string midLineLabel = "Mid" //
|
||||
)
|
||||
{
|
||||
//
|
||||
// Long Market ...
|
||||
iDescriptor.inputs.lMarketPeriod = period;
|
||||
iDescriptor.inputs.lMarketMethod = method;
|
||||
|
||||
//
|
||||
ConfigureMarketDrawSpecs(
|
||||
iDescriptor.inputs.lMarketInputs,
|
||||
//
|
||||
drawLabels,
|
||||
drawCBar,
|
||||
drawPBar,
|
||||
drawCBarMid,
|
||||
drawPBarMid,
|
||||
fontSize,
|
||||
fontAngel,
|
||||
fontName,
|
||||
fontAnchor,
|
||||
prefix,
|
||||
cBarPrefix,
|
||||
pBarPrefix,
|
||||
openLabel,
|
||||
closeLabel,
|
||||
highLabel,
|
||||
lowLabel,
|
||||
midLineLabel //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Hind ...
|
||||
void ConfigureHindMarketDrawSpecs(
|
||||
X121ProviderDescriptor &iDescriptor,
|
||||
ENUM_TIMEFRAMES period = NULL,
|
||||
ENUM_X_PERIOD_METHOD method = X_PERIOD_AUTO,
|
||||
string prefix = "Hind",
|
||||
bool drawLabels = false,
|
||||
bool drawCBar = false,
|
||||
bool drawPBar = false,
|
||||
bool drawCBarMid = false,
|
||||
bool drawPBarMid = false,
|
||||
int fontSize = 12,
|
||||
double fontAngel = 90,
|
||||
string fontName = "Arial",
|
||||
ENUM_ANCHOR_POINT fontAnchor = ANCHOR_LEFT_UPPER,
|
||||
string cBarPrefix = "C",
|
||||
string pBarPrefix = "P",
|
||||
string openLabel = "O",
|
||||
string closeLabel = "C",
|
||||
string highLabel = "H",
|
||||
string lowLabel = "L",
|
||||
string midLineLabel = "Mid" //
|
||||
)
|
||||
{
|
||||
//
|
||||
// Hind Market ...
|
||||
iDescriptor.inputs.hMarketPeriod = period;
|
||||
iDescriptor.inputs.hMarketMethod = method;
|
||||
|
||||
//
|
||||
ConfigureMarketDrawSpecs(
|
||||
iDescriptor.inputs.hMarketInputs,
|
||||
//
|
||||
drawLabels,
|
||||
drawCBar,
|
||||
drawPBar,
|
||||
drawCBarMid,
|
||||
drawPBarMid,
|
||||
fontSize,
|
||||
fontAngel,
|
||||
fontName,
|
||||
fontAnchor,
|
||||
prefix,
|
||||
cBarPrefix,
|
||||
pBarPrefix,
|
||||
openLabel,
|
||||
closeLabel,
|
||||
highLabel,
|
||||
lowLabel,
|
||||
midLineLabel //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Configure Market ...
|
||||
void ConfigureMarketDrawSpecs(
|
||||
X121MCycleInputs &inputs,
|
||||
bool drawLabels = false,
|
||||
bool drawCBar = false,
|
||||
bool drawPBar = false,
|
||||
bool drawCBarMid = false,
|
||||
bool drawPBarMid = false,
|
||||
int fontSize = 12,
|
||||
double fontAngel = 90,
|
||||
string fontName = "Arial",
|
||||
ENUM_ANCHOR_POINT fontAnchor = ANCHOR_LEFT_UPPER,
|
||||
string prefix = "",
|
||||
string cBarPrefix = "C",
|
||||
string pBarPrefix = "P",
|
||||
string openLabel = "O",
|
||||
string closeLabel = "C",
|
||||
string highLabel = "H",
|
||||
string lowLabel = "L",
|
||||
string midLineLabel = "Mid" //
|
||||
)
|
||||
{
|
||||
inputs.drawLabels = drawLabels;
|
||||
inputs.drawCBar = drawCBar;
|
||||
inputs.drawPBar = drawPBar;
|
||||
inputs.drawCBarMid = drawCBarMid;
|
||||
inputs.drawPBarMid = drawPBarMid;
|
||||
inputs.cBarDrawSpecs.Default();
|
||||
inputs.pBarDrawSpecs.Default();
|
||||
|
||||
//
|
||||
if (drawCBarMid)
|
||||
{
|
||||
inputs.cBarMidDrawSpecs.clr = clrYellow;
|
||||
}
|
||||
|
||||
//
|
||||
if (drawPBarMid)
|
||||
{
|
||||
inputs.pBarMidDrawSpecs.clr = clrYellow;
|
||||
}
|
||||
|
||||
//
|
||||
if (drawLabels)
|
||||
{
|
||||
//
|
||||
string cBarStr = prefix + " " + cBarPrefix + " ";
|
||||
string pBarStr = prefix + " " + pBarPrefix + " ";
|
||||
|
||||
//
|
||||
if (drawCBar)
|
||||
{
|
||||
//
|
||||
inputs.cBarDrawSpecs.openStyle.Label(
|
||||
cBarStr + openLabel,
|
||||
inputs.cBarDrawSpecs.openStyle.clr,
|
||||
fontName,
|
||||
fontSize,
|
||||
fontAnchor,
|
||||
fontAngel //
|
||||
);
|
||||
|
||||
//
|
||||
inputs.cBarDrawSpecs.highStyle.Label(
|
||||
cBarStr + highLabel,
|
||||
inputs.cBarDrawSpecs.highStyle.clr,
|
||||
fontName,
|
||||
fontSize,
|
||||
fontAnchor,
|
||||
fontAngel //
|
||||
);
|
||||
|
||||
//
|
||||
inputs.cBarDrawSpecs.closeStyle.Label(
|
||||
cBarStr + closeLabel,
|
||||
inputs.cBarDrawSpecs.closeStyle.clr,
|
||||
fontName,
|
||||
fontSize,
|
||||
fontAnchor,
|
||||
fontAngel //
|
||||
);
|
||||
|
||||
//
|
||||
inputs.cBarDrawSpecs.lowStyle.Label(
|
||||
cBarStr + lowLabel,
|
||||
inputs.cBarDrawSpecs.lowStyle.clr,
|
||||
fontName,
|
||||
fontSize,
|
||||
fontAnchor,
|
||||
fontAngel //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
if (drawPBar)
|
||||
{
|
||||
//
|
||||
inputs.pBarDrawSpecs.openStyle.Label(
|
||||
pBarStr + openLabel,
|
||||
inputs.pBarDrawSpecs.openStyle.clr,
|
||||
fontName,
|
||||
fontSize,
|
||||
fontAnchor,
|
||||
fontAngel //
|
||||
);
|
||||
|
||||
//
|
||||
inputs.pBarDrawSpecs.highStyle.Label(
|
||||
pBarStr + highLabel,
|
||||
inputs.pBarDrawSpecs.highStyle.clr,
|
||||
fontName,
|
||||
fontSize,
|
||||
fontAnchor,
|
||||
fontAngel //
|
||||
);
|
||||
|
||||
//
|
||||
inputs.pBarDrawSpecs.closeStyle.Label(
|
||||
pBarStr + closeLabel,
|
||||
inputs.pBarDrawSpecs.closeStyle.clr,
|
||||
fontName,
|
||||
fontSize,
|
||||
fontAnchor,
|
||||
fontAngel //
|
||||
);
|
||||
|
||||
//
|
||||
inputs.pBarDrawSpecs.lowStyle.Label(
|
||||
pBarStr + lowLabel,
|
||||
inputs.pBarDrawSpecs.lowStyle.clr,
|
||||
fontName,
|
||||
fontSize,
|
||||
fontAnchor,
|
||||
fontAngel //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
if (drawCBarMid)
|
||||
{
|
||||
//
|
||||
inputs.cBarMidDrawSpecs.Label(
|
||||
cBarStr + midLineLabel,
|
||||
clrYellow,
|
||||
fontName,
|
||||
fontSize,
|
||||
fontAnchor,
|
||||
fontAngel //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
if (drawPBarMid)
|
||||
{
|
||||
//
|
||||
inputs.pBarMidDrawSpecs.Label(
|
||||
pBarStr + midLineLabel,
|
||||
clrYellow,
|
||||
fontName,
|
||||
fontSize,
|
||||
fontAnchor,
|
||||
fontAngel //
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,252 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center X5EA MQL5 Expert Advisor
|
||||
// -------------------------------------------------
|
||||
// Name: X5EA
|
||||
// Description: an Exper Advisor which used RSI and MA
|
||||
// to Analyse Market ...
|
||||
//
|
||||
// Maintainer:
|
||||
// ------------
|
||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||
//
|
||||
//////////////////////////////////////////////////////x
|
||||
//
|
||||
// Global Properties ...
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property description "SaherElm X5EA"
|
||||
#property strict
|
||||
|
||||
//
|
||||
#define ShortName "X5EA"
|
||||
|
||||
//
|
||||
#include "../Classes/x-saherelm.x5.xea.class.mq5"
|
||||
|
||||
//
|
||||
// "EURUSDb,USDCHFb,USDJPYb,XAUUSDb"
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
long x5EAMagicNumber = 78692110; // Magic Number
|
||||
int x5EASlippage = 10; // Slippgae
|
||||
string x5EASymbols = "EURUSDb,USDCHFb,USDJPYb,XAUUSDb"; // Symbols
|
||||
//
|
||||
bool x5EAAllowLong = true; // Allow Long Trades
|
||||
bool x5EAAllowShort = true; // Allow Short Trades
|
||||
int x5EAManageInterval = 5; // Manager Check Intervals Seconds
|
||||
int x5EAMaxAllowedPositions = 15; // Max Allowed Positions
|
||||
double x5EAMaxAllowedSpread = 0; // Max Allowed Spred for Opening Trades
|
||||
double x5EAMinProfitPerTrade = 0; // Min Profit Per Trade based On Volume Factor (Hedge)
|
||||
double x5EAMinProfitPerVolumeFactor = 0; // Min Volume Factor for Calculating Profit (Hedge)
|
||||
double x5EAMaxAllowedDrawdownFactor = 0; // Max Allowed Drawdown Factor
|
||||
//
|
||||
double x5EAVolume = 0.01;
|
||||
|
||||
//
|
||||
// Vars ...
|
||||
string x5EASymbol;
|
||||
ENUM_TIMEFRAMES x5EAPeriod;
|
||||
|
||||
//
|
||||
MqlTick x5EATick;
|
||||
|
||||
//
|
||||
// X5EA ...
|
||||
XSCX5EA *mX5EA;
|
||||
|
||||
//
|
||||
// Event Handlers ...
|
||||
|
||||
//
|
||||
// Initialization ...
|
||||
int OnInit()
|
||||
{
|
||||
//
|
||||
if (x5EASymbol == NULL || StringLen(x5EASymbol) <= 0)
|
||||
{
|
||||
x5EASymbol = _Symbol;
|
||||
}
|
||||
|
||||
//
|
||||
if (x5EAPeriod == NULL)
|
||||
{
|
||||
x5EAPeriod = _Period;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate Inputs ...
|
||||
if (!X5EAValidateInputs())
|
||||
{
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
// Initial EA ...
|
||||
if (!InitialEA())
|
||||
{
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
TesterHideIndicators(true);
|
||||
|
||||
//
|
||||
// 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
|
||||
|
||||
//
|
||||
// De Initialize X5EA Providers ...
|
||||
}
|
||||
|
||||
//
|
||||
// On Tick Handler ...
|
||||
void OnTick()
|
||||
{
|
||||
//
|
||||
// Reading Tick ...
|
||||
if (!SymbolInfoTick(x5EASymbol, x5EATick))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
mX5EA.OnTick();
|
||||
}
|
||||
|
||||
//
|
||||
// Custom Functions ...
|
||||
|
||||
//
|
||||
// Validate Variables nd Inputs ...
|
||||
bool X5EAValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
x5EASlippage > 0 &&
|
||||
x5EAMagicNumber > 0
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Initialize Specific Providers ...
|
||||
bool InitialEA()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Here We Have to Initial 4 instance of X5Provider ...
|
||||
// - EURUSD/M5;
|
||||
// - USDCHF/M5;
|
||||
// - USDJPY/M5;
|
||||
// - XAUUSD/M5;
|
||||
|
||||
//
|
||||
result = IsValid(x5EASymbols);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
string symbols[];
|
||||
int symbolsCount = SplitContent(
|
||||
symbols,
|
||||
x5EASymbols);
|
||||
result = symbolsCount > 0;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Signallers ...
|
||||
ENUM_X5_SIGNAL_PROVIDERS signallers[];
|
||||
GetAllX5SignalProviders(signallers);
|
||||
|
||||
//
|
||||
// Instantiate X5EA Class ...
|
||||
mX5EA = new XSCX5EA(
|
||||
x5EASlippage, // Slippgae
|
||||
x5EAMagicNumber, // Magic Number
|
||||
x5EAManageInterval, // Manager Check Intervals Seconds
|
||||
x5EAMaxAllowedSpread, // Max Allowed Spred for Opening Trades
|
||||
x5EAMaxAllowedPositions, // Max Allowed Positions
|
||||
x5EAMaxAllowedDrawdownFactor, // Max Allowed Drawdown Factor
|
||||
x5EAAllowLong, // Allow Long Trades
|
||||
x5EAAllowShort, // Allow Short Trades
|
||||
x5EAMinProfitPerTrade, // Min Profit Per Trade based On Volume Factor (Hedge)
|
||||
x5EAMinProfitPerVolumeFactor // Min Volume Factor for Calculating Profit (Hedge)
|
||||
);
|
||||
|
||||
//
|
||||
// Prepare Providers and Add them into mX5EA class ...
|
||||
for (int i = 0; i < symbolsCount; i++)
|
||||
{
|
||||
//
|
||||
// Define Structure ...
|
||||
X5ProviderDescriptor iDescriptor;
|
||||
|
||||
//
|
||||
iDescriptor.symbol = symbols[i];
|
||||
iDescriptor.period = PERIOD_M5;
|
||||
iDescriptor.staticVolume = x5EAVolume;
|
||||
iDescriptor.allowLong = x5EAAllowLong;
|
||||
iDescriptor.allowShort = x5EAAllowShort;
|
||||
Copy(
|
||||
signallers,
|
||||
iDescriptor.signallers);
|
||||
|
||||
//
|
||||
// Set Inputs to Default ...
|
||||
iDescriptor.inputs.Default();
|
||||
|
||||
//
|
||||
// Validate Inputs ...
|
||||
bool isInputsValid = iDescriptor.inputs.IsValid();
|
||||
if (!isInputsValid)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//
|
||||
result = mX5EA.AddProvider(iDescriptor);
|
||||
if (!result)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
Binary file not shown.
@@ -0,0 +1,317 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Helper Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCXAMAHelper
|
||||
// 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.xhelper.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
enum ENUM_XAMA_BUFFERS
|
||||
{
|
||||
XAMA_MAIN_LINE = 0
|
||||
};
|
||||
|
||||
//
|
||||
// Input Models ...
|
||||
struct XAMAInputs
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
//
|
||||
// Market ...
|
||||
int length; // Period
|
||||
int fastEMA; // Fast EMA Period
|
||||
int slowEMA; // Slow EMA Period
|
||||
int maShift; // Shift
|
||||
ENUM_APPLIED_PRICE appliedTo; // Applied To
|
||||
//
|
||||
// Presentation ...
|
||||
bool showLine; // Show Line
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
XAMAInputs()
|
||||
{
|
||||
//
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Clean ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
length = 0;
|
||||
fastEMA = 0;
|
||||
slowEMA = 0;
|
||||
maShift = 0;
|
||||
showLine = false;
|
||||
appliedTo = PRICE_CLOSE;
|
||||
}
|
||||
|
||||
//
|
||||
// Default ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
length = 18;
|
||||
fastEMA = 2;
|
||||
slowEMA = 30;
|
||||
maShift = 0;
|
||||
showLine = true;
|
||||
appliedTo = PRICE_CLOSE;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
length > 0 &&
|
||||
fastEMA > 0 &&
|
||||
slowEMA > 0 &&
|
||||
slowEMA > fastEMA
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve MAx Length ...
|
||||
int Max()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = MathMax(length, length);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
class XSCXAMAHelper : public XSCBaseHelper
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XSCXAMAHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XSCXAMAHelper() {}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
XAMAInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
ArraySetAsSeries(mainBuffer, true);
|
||||
mHandler = iCustom(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
"x-saherelm.xama",
|
||||
//
|
||||
// Inputs ...
|
||||
//
|
||||
// Market ...
|
||||
"",
|
||||
mInputs.length, // Period
|
||||
mInputs.fastEMA, // Fast EMA Period
|
||||
mInputs.slowEMA, // Slow EMA Period
|
||||
mInputs.maShift, // Shift
|
||||
mInputs.appliedTo, // Applied To
|
||||
//
|
||||
// Presentation ...
|
||||
"",
|
||||
mInputs.showLine // Show Line
|
||||
//
|
||||
);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
XAMAInputs GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(
|
||||
XAMAInputs &inputs // Configs
|
||||
)
|
||||
{
|
||||
//
|
||||
return Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
inputs
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
double GetMain(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(mainBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return mainBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyMain(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
mainBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
XAMAInputs mInputs; // Inputs ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
double mainBuffer[];
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Calculate Values Until Now ...
|
||||
void Calculate()
|
||||
{
|
||||
//
|
||||
int totalBars = CountBars();
|
||||
|
||||
//
|
||||
// Main Buffer ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XAMA_MAIN_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
mainBuffer
|
||||
//
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
Binary file not shown.
@@ -0,0 +1,245 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Helper Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCXCCHelper
|
||||
// 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.xhelper.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
// Input Models ...
|
||||
struct XCCInputs
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Chart Style ...
|
||||
ENUM_CHART_MODE mode; // Mode
|
||||
color upColor; // Up Color
|
||||
color downColor; // Down Color
|
||||
color lineColor; // Line mode and Doji candlestick Color
|
||||
color bearishColor; // Bullish Color
|
||||
color bullishColor; // Bearish Color
|
||||
color volumesColor; // Volumes Color
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
bool showCandles; // Show Candles
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
XCCInputs()
|
||||
{
|
||||
//
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Clean ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
mode = CHART_CANDLES;
|
||||
|
||||
//
|
||||
upColor = CLR_NONE;
|
||||
downColor = CLR_NONE;
|
||||
lineColor = CLR_NONE;
|
||||
bearishColor = CLR_NONE;
|
||||
bullishColor = CLR_NONE;
|
||||
volumesColor = CLR_NONE;
|
||||
|
||||
//
|
||||
showCandles = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Default ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
mode = CHART_CANDLES;
|
||||
|
||||
//
|
||||
upColor = clrLime;
|
||||
downColor = clrRed;
|
||||
lineColor = clrLime;
|
||||
bearishColor = clrRed;
|
||||
bullishColor = clrLime;
|
||||
volumesColor = clrGreen;
|
||||
//
|
||||
showCandles = true;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
true
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve MAx Length ...
|
||||
int Max()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = MathMax(0, 0);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
class XSCXCCHelper : public XSCBaseHelper
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XSCXCCHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XSCXCCHelper() {}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
XCCInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
mHandler = iCustom(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
"x-saherelm.xcc",
|
||||
//
|
||||
// Inputs ...
|
||||
//
|
||||
// Chart Style ...
|
||||
"",
|
||||
mInputs.mode, // Mode
|
||||
mInputs.upColor, // Up Color
|
||||
mInputs.downColor, // Down Color
|
||||
mInputs.lineColor, // Line mode and Doji candlestick Color
|
||||
mInputs.bearishColor, // Bullish Color
|
||||
mInputs.bullishColor, // Bearish Color
|
||||
mInputs.volumesColor, // Volumes Color
|
||||
//
|
||||
// Presentation ...
|
||||
"",
|
||||
mInputs.showCandles // Show Candles
|
||||
//
|
||||
);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
XCCInputs GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(
|
||||
XCCInputs &inputs // Configs
|
||||
)
|
||||
{
|
||||
//
|
||||
return Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
inputs
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
XCCInputs mInputs; // Inputs ...
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
Binary file not shown.
@@ -0,0 +1,514 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Helper Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCXCHEHelper
|
||||
// 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
|
||||
|
||||
//
|
||||
#include "../Classes/x-saherelm.xhelper.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
enum ENUM_XCHE_BUFFERS
|
||||
{
|
||||
X_CHE_LONG_EXIT_1_LINE = 0,
|
||||
X_CHE_SHORT_EXIT_1_LINE = 1,
|
||||
X_CHE_LONG_EXIT_2_LINE = 2,
|
||||
X_CHE_SHORT_EXIT_2_LINE = 3,
|
||||
};
|
||||
|
||||
//
|
||||
// Input Models ...
|
||||
struct XCHEInputs
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Market ...
|
||||
int length; // Length
|
||||
int loopback; // Loopback
|
||||
double multiplier1; // 1st Multiplier
|
||||
double multiplier2; // 2nd Multiplier
|
||||
|
||||
//
|
||||
// Calculation ...
|
||||
ENUM_APPLIED_PRICE upAppliedTo; // Up Zone Applied To
|
||||
ENUM_APPLIED_PRICE downAppliedTo; // Down Zone Applied To
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
bool showLongExit1Line; // Show 1st Long Exit
|
||||
bool showShortExit1Line; // Show 1st Short Exit
|
||||
bool showLongExit2Line; // Show 2st Long Exit
|
||||
bool showShortExit2Line; // Show 2st Short Exit
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
XCHEInputs()
|
||||
{
|
||||
//
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Clean ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
length = 0;
|
||||
loopback = 0;
|
||||
multiplier1 = 0;
|
||||
multiplier2 = 0;
|
||||
|
||||
//
|
||||
upAppliedTo = PRICE_HIGH;
|
||||
downAppliedTo = PRICE_LOW;
|
||||
|
||||
//
|
||||
showLongExit1Line = false;
|
||||
showShortExit1Line = false;
|
||||
showLongExit2Line = false;
|
||||
showShortExit2Line = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Default ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
length = 35;
|
||||
loopback = 26;
|
||||
multiplier1 = 3.0;
|
||||
multiplier2 = 3.5;
|
||||
|
||||
//
|
||||
upAppliedTo = PRICE_HIGH;
|
||||
downAppliedTo = PRICE_LOW;
|
||||
|
||||
//
|
||||
showLongExit1Line = true;
|
||||
showShortExit1Line = true;
|
||||
showLongExit2Line = true;
|
||||
showShortExit2Line = true;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
length > 0 &&
|
||||
loopback < length &&
|
||||
multiplier1 > 0 &&
|
||||
multiplier2 > multiplier1
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve MAx Length ...
|
||||
int Max()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = MathMax(length, loopback);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
class XSCXCHEHelper : public XSCBaseHelper
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XSCXCHEHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XSCXCHEHelper() {}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
XCHEInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
ArraySetAsSeries(longExit1Buffer, true);
|
||||
ArraySetAsSeries(longExit2Buffer, true);
|
||||
ArraySetAsSeries(shortExit1Buffer, true);
|
||||
ArraySetAsSeries(shortExit2Buffer, true);
|
||||
|
||||
//
|
||||
mHandler = iCustom(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
"x-saherelm.xche",
|
||||
//
|
||||
// Inputs ...
|
||||
//
|
||||
// Market ...
|
||||
"",
|
||||
mInputs.length,
|
||||
mInputs.loopback,
|
||||
mInputs.multiplier1,
|
||||
mInputs.multiplier2,
|
||||
//
|
||||
// Calculations ...
|
||||
"",
|
||||
mInputs.upAppliedTo,
|
||||
mInputs.downAppliedTo,
|
||||
//
|
||||
// Presentation ...
|
||||
"",
|
||||
mInputs.showLongExit1Line, // Show 1st Long Exit,
|
||||
mInputs.showShortExit1Line, // Show 1st Short Exit,
|
||||
mInputs.showLongExit2Line, // Show 2st Long Exit,
|
||||
mInputs.showShortExit2Line // Show 2st Short Exit
|
||||
//
|
||||
);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
XCHEInputs GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(
|
||||
XCHEInputs &inputs // Configs
|
||||
)
|
||||
{
|
||||
//
|
||||
return Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
inputs);
|
||||
}
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
double GetLongExit1(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
return longExit1Buffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Long Exits 1 ...
|
||||
int CopyLongExit1(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
longExit1Buffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetLongExit2(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
return longExit2Buffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Long Exits 2 ...
|
||||
int CopyLongExit2(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
longExit2Buffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetShortExit1(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
return shortExit1Buffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Short Exits 1 ...
|
||||
int CopyShortExit1(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
shortExit1Buffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetShortExit2(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
return shortExit2Buffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Short Exits 2 ...
|
||||
int CopyShortExit2(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
shortExit2Buffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
XCHEInputs mInputs; // Inputs ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
//
|
||||
double longExit1Buffer[];
|
||||
double longExit2Buffer[];
|
||||
double shortExit1Buffer[];
|
||||
double shortExit2Buffer[];
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Calculate Values Until Now ...
|
||||
void Calculate()
|
||||
{
|
||||
//
|
||||
int totalBars = CountBars();
|
||||
int calculatedBars = CountCalculatedBars();
|
||||
|
||||
//
|
||||
// Long Exit 1 ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X_CHE_LONG_EXIT_1_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
longExit1Buffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Long Exit 2 ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X_CHE_LONG_EXIT_2_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
longExit2Buffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Short Exit 1 ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X_CHE_SHORT_EXIT_1_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
shortExit1Buffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Short Exit 2 ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X_CHE_SHORT_EXIT_2_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
shortExit2Buffer
|
||||
//
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
Binary file not shown.
@@ -0,0 +1,967 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Helper Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCXCHLHHelper
|
||||
// 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.xhelper.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
enum ENUM_XCHLH_BUFFERS
|
||||
{
|
||||
//
|
||||
// LC ...
|
||||
XCHLH_LC_HH_LINE = 0,
|
||||
XCHLH_LC_LL_LINE = 1,
|
||||
//
|
||||
// MC ...
|
||||
XCHLH_MC_HH_LINE = 2,
|
||||
XCHLH_MC_LL_LINE = 3,
|
||||
//
|
||||
// SC ...
|
||||
XCHLH_SC_HH_LINE = 4,
|
||||
XCHLH_SC_LL_LINE = 5,
|
||||
//
|
||||
// Hot State ...
|
||||
XCHLH_HOT_STATE_LINE = 6
|
||||
};
|
||||
|
||||
//
|
||||
// Input Models ...
|
||||
struct XCHLHInputs
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Hot Areas ...
|
||||
bool drawHotAreas; // Draw Hot Areas Symbol
|
||||
uchar hotHHArrowCode; // Hot HH Arrow Code
|
||||
color hotHHArrowColor; // Hot HH Arrow Color
|
||||
uchar hotLLArrowCode; // Hot LL Arrow Code
|
||||
color hotLLArrowColor; // Hot LL Arrow Color
|
||||
|
||||
//
|
||||
// Long Cycle ...
|
||||
// LC Market ...
|
||||
int lcLength; // Length
|
||||
double lcThresholdInPips; // Threshold In Pips
|
||||
ENUM_SERIESMODE lcHHMode; // Highest High Calculation Method
|
||||
ENUM_SERIESMODE lcLLMode; // Lowest Low Calculation Method
|
||||
//
|
||||
// LC Style ...
|
||||
int lcDrawWidth; // Draw Width
|
||||
ENUM_DRAW_TYPE lcDrawType; // Draw Type
|
||||
ENUM_LINE_STYLE lcDrawStyle; // Draw Style
|
||||
color lcHHColor; // Highest High Color
|
||||
color lcLLColor; // Lowest Low Color
|
||||
// LC Drawings ...
|
||||
bool lcDrawHH; // Draw Highest High
|
||||
bool lcDrawLL; // Draw Lowest Low
|
||||
|
||||
//
|
||||
// Medium Cycle ...
|
||||
// MC Market ...
|
||||
int mcLength; // Length
|
||||
double mcThresholdInPips; // Threshold In Pips
|
||||
ENUM_SERIESMODE mcHHMode; // Highest High Calculation Method
|
||||
ENUM_SERIESMODE mcLLMode; // Lowest Low Calculation Method
|
||||
// MC Style ...
|
||||
int mcDrawWidth; // Draw Width
|
||||
ENUM_DRAW_TYPE mcDrawType; // Draw Type
|
||||
ENUM_LINE_STYLE mcDrawStyle; // Draw Style
|
||||
color mcHHColor; // Highest High Color
|
||||
color mcLLColor; // Lowest Low Color
|
||||
// MC Drawings ...
|
||||
bool mcDrawHH; // Draw Highest High
|
||||
bool mcDrawLL; // Draw Lowest Low
|
||||
|
||||
//
|
||||
// Short Cycle ...
|
||||
// SC Market ...
|
||||
int scLength; // Length
|
||||
double scThresholdInPips; // Threshold In Pips
|
||||
ENUM_SERIESMODE scHHMode; // Highest High Calculation Method
|
||||
ENUM_SERIESMODE scLLMode; // Lowest Low Calculation Method
|
||||
// SC Style ...
|
||||
int scDrawWidth; // Draw Width
|
||||
ENUM_DRAW_TYPE scDrawType; // Draw Type
|
||||
ENUM_LINE_STYLE scDrawStyle; // Draw Style
|
||||
color scHHColor; // Highest High Color
|
||||
color scLLColor; // Lowest Low Color
|
||||
// SC Drawings ...
|
||||
bool scDrawHH; // Draw Highest High
|
||||
bool scDrawLL; // Draw Lowest Low
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
XCHLHInputs()
|
||||
{
|
||||
//
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Clean ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
// Hot Areas ...
|
||||
drawHotAreas = false;
|
||||
hotHHArrowCode = 234;
|
||||
hotHHArrowColor = CLR_NONE;
|
||||
hotLLArrowCode = 233;
|
||||
hotLLArrowColor = CLR_NONE;
|
||||
|
||||
//
|
||||
// Long Cycle ...
|
||||
// LC Market ...
|
||||
lcLength = 0;
|
||||
lcThresholdInPips = 0;
|
||||
lcHHMode = MODE_HIGH;
|
||||
lcLLMode = MODE_LOW;
|
||||
//
|
||||
// LC Style ...
|
||||
lcDrawWidth = 1;
|
||||
lcDrawType = DRAW_NONE;
|
||||
lcDrawStyle = STYLE_DOT;
|
||||
lcHHColor = CLR_NONE;
|
||||
lcLLColor = CLR_NONE;
|
||||
// LC Drawings ...
|
||||
lcDrawHH = false;
|
||||
lcDrawLL = false;
|
||||
|
||||
//
|
||||
// Medium Cycle ...
|
||||
// MC Market ...
|
||||
mcLength = 0;
|
||||
mcThresholdInPips = 0;
|
||||
mcHHMode = MODE_HIGH;
|
||||
mcLLMode = MODE_LOW;
|
||||
// MC Style ...
|
||||
mcDrawWidth = 1;
|
||||
mcDrawType = DRAW_NONE;
|
||||
mcDrawStyle = STYLE_DOT;
|
||||
mcHHColor = CLR_NONE;
|
||||
mcLLColor = CLR_NONE;
|
||||
// MC Drawings ...
|
||||
mcDrawHH = false;
|
||||
mcDrawLL = false;
|
||||
|
||||
//
|
||||
// Short Cycle ...
|
||||
// SC Market ...
|
||||
scLength = 0;
|
||||
scThresholdInPips = 0;
|
||||
scHHMode = MODE_HIGH;
|
||||
scLLMode = MODE_LOW;
|
||||
// SC Style ...
|
||||
scDrawWidth = 1;
|
||||
scDrawType = DRAW_NONE;
|
||||
scDrawStyle = STYLE_DOT;
|
||||
scHHColor = CLR_NONE;
|
||||
scLLColor = CLR_NONE;
|
||||
// SC Drawings ...
|
||||
scDrawHH = false;
|
||||
scDrawLL = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Default ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
// Hot Areas ...
|
||||
drawHotAreas = false;
|
||||
hotHHArrowCode = 234;
|
||||
hotHHArrowColor = CLR_NONE;
|
||||
hotLLArrowCode = 233;
|
||||
hotLLArrowColor = CLR_NONE;
|
||||
|
||||
//
|
||||
// Long Cycle ...
|
||||
// LC Market ...
|
||||
lcLength = 28;
|
||||
lcThresholdInPips = 0.3;
|
||||
lcHHMode = MODE_HIGH;
|
||||
lcLLMode = MODE_LOW;
|
||||
//
|
||||
// LC Style ...
|
||||
lcDrawWidth = 1;
|
||||
lcDrawType = DRAW_LINE;
|
||||
lcDrawStyle = STYLE_DOT;
|
||||
lcHHColor = clrAqua;
|
||||
lcLLColor = clrFuchsia;
|
||||
// LC Drawings ...
|
||||
lcDrawHH = false;
|
||||
lcDrawLL = false;
|
||||
|
||||
//
|
||||
// Medium Cycle ...
|
||||
// MC Market ...
|
||||
mcLength = 14;
|
||||
mcThresholdInPips = 0.3;
|
||||
mcHHMode = MODE_HIGH;
|
||||
mcLLMode = MODE_LOW;
|
||||
// MC Style ...
|
||||
mcDrawWidth = 1;
|
||||
mcDrawType = DRAW_LINE;
|
||||
mcDrawStyle = STYLE_DOT;
|
||||
mcHHColor = clrLime;
|
||||
mcLLColor = clrRed;
|
||||
// MC Drawings ...
|
||||
mcDrawHH = false;
|
||||
mcDrawLL = false;
|
||||
|
||||
//
|
||||
// Short Cycle ...
|
||||
// SC Market ...
|
||||
scLength = 7;
|
||||
scThresholdInPips = 0.3;
|
||||
scHHMode = MODE_HIGH;
|
||||
scLLMode = MODE_LOW;
|
||||
// SC Style ...
|
||||
scDrawWidth = 1;
|
||||
scDrawType = DRAW_LINE;
|
||||
scDrawStyle = STYLE_DOT;
|
||||
scHHColor = clrLightBlue;
|
||||
scLLColor = clrLightSalmon;
|
||||
// SC Drawings ...
|
||||
scDrawHH = false;
|
||||
scDrawLL = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
// LC ...
|
||||
(lcLength >= 4 &&
|
||||
lcLength > mcLength &&
|
||||
lcLength > scLength)
|
||||
//
|
||||
&&
|
||||
//
|
||||
// MC ...
|
||||
(mcLength >= 4 &&
|
||||
mcLength > scLength &&
|
||||
mcLength < lcLength)
|
||||
//
|
||||
&&
|
||||
//
|
||||
// SC ...
|
||||
(scLength >= 4 &&
|
||||
scLength < mcLength &&
|
||||
scLength < lcLength)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve MAx Length ...
|
||||
int Max()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = MathMax(lcLength, mcLength);
|
||||
result = MathMax(result, scLength);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
class XSCXCHLHHelper : public XSCBaseHelper
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XSCXCHLHHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XSCXCHLHHelper() {}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
XCHLHInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
ArraySetAsSeries(scHHBuffer, true);
|
||||
ArraySetAsSeries(scLLBuffer, true);
|
||||
ArraySetAsSeries(mcHHBuffer, true);
|
||||
ArraySetAsSeries(mcLLBuffer, true);
|
||||
ArraySetAsSeries(lcHHBuffer, true);
|
||||
ArraySetAsSeries(lcLLBuffer, true);
|
||||
ArraySetAsSeries(hotStateBuffer, true);
|
||||
|
||||
//
|
||||
mHandler = iCustom(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
"x-saherelm.xchlh",
|
||||
//
|
||||
// Inputs ...
|
||||
//
|
||||
// Hot Areas ...
|
||||
"",
|
||||
//
|
||||
mInputs.drawHotAreas, // Draw Hot Areas Symbol
|
||||
mInputs.hotHHArrowCode, // Hot HH Arrow Code
|
||||
mInputs.hotHHArrowColor, // Hot HH Arrow Color
|
||||
mInputs.hotLLArrowCode, // Hot LL Arrow Code
|
||||
mInputs.hotLLArrowColor, // Hot LL Arrow Color
|
||||
//
|
||||
// Long Cycle ...
|
||||
"",
|
||||
// LC Market ...
|
||||
"",
|
||||
//
|
||||
mInputs.lcLength, // Length
|
||||
mInputs.lcThresholdInPips, // Threshold In Pips
|
||||
mInputs.lcHHMode, // Highest High Calculation Method
|
||||
mInputs.lcLLMode, // Lowest Low Calculation Method
|
||||
//
|
||||
// LC Style ...
|
||||
"",
|
||||
//
|
||||
mInputs.lcDrawWidth, // Draw Width
|
||||
mInputs.lcDrawType, // Draw Type
|
||||
mInputs.lcDrawStyle, // Draw Style
|
||||
mInputs.lcHHColor, // Highest High Color
|
||||
mInputs.lcLLColor, // Lowest Low Color
|
||||
//
|
||||
// LC Drawings ...
|
||||
"",
|
||||
mInputs.lcDrawHH, // Draw Highest High
|
||||
mInputs.lcDrawLL, // Draw Lowest Low
|
||||
//
|
||||
// Medium Cycle ...
|
||||
"",
|
||||
// MC Market ...
|
||||
"",
|
||||
//
|
||||
mInputs.mcLength, // Length
|
||||
mInputs.mcThresholdInPips, // Threshold In Pips
|
||||
mInputs.mcHHMode, // Highest High Calculation Method
|
||||
mInputs.mcLLMode, // Lowest Low Calculation Method
|
||||
//
|
||||
// MC Style ...
|
||||
"",
|
||||
//
|
||||
mInputs.mcDrawWidth, // Draw Width
|
||||
mInputs.mcDrawType, // Draw Type
|
||||
mInputs.mcDrawStyle, // Draw Style
|
||||
mInputs.mcHHColor, // Highest High Color
|
||||
mInputs.mcLLColor, // Lowest Low Color
|
||||
//
|
||||
// MC Drawings ...
|
||||
"",
|
||||
mInputs.mcDrawHH, // Draw Highest High
|
||||
mInputs.mcDrawLL, // Draw Lowest Low
|
||||
//
|
||||
// Short Cycle ...
|
||||
"",
|
||||
// SC Market ...
|
||||
"",
|
||||
//
|
||||
mInputs.scLength, // Length
|
||||
mInputs.scThresholdInPips, // Threshold In Pips
|
||||
mInputs.scHHMode, // Highest High Calculation Method
|
||||
mInputs.scLLMode, // Lowest Low Calculation Method
|
||||
//
|
||||
// SC Style ...
|
||||
"",
|
||||
//
|
||||
mInputs.scDrawWidth, // Draw Width
|
||||
mInputs.scDrawType, // Draw Type
|
||||
mInputs.scDrawStyle, // Draw Style
|
||||
mInputs.scHHColor, // Highest High Color
|
||||
mInputs.scLLColor, // Lowest Low Color
|
||||
//
|
||||
// SC Drawings ...
|
||||
"",
|
||||
mInputs.scDrawHH, // Draw Highest High
|
||||
mInputs.scDrawLL // Draw Lowest Low
|
||||
//
|
||||
);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
XCHLHInputs GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(
|
||||
XCHLHInputs &inputs // Configs
|
||||
)
|
||||
{
|
||||
//
|
||||
return Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
inputs
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
// Short ...
|
||||
|
||||
//
|
||||
double GetSCHH(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(scHHBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return scHHBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopySCHH(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
scHHBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetSCLL(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(scLLBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return scLLBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopySCLL(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
scLLBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Medium ...
|
||||
|
||||
//
|
||||
double GetMCHH(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(mcHHBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return mcHHBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyMCHH(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
mcHHBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetMCLL(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(mcLLBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return mcLLBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyMCLL(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
mcLLBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Long ...
|
||||
|
||||
//
|
||||
double GetLCHH(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(lcHHBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return lcHHBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyLCHH(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
lcHHBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetLCLL(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(lcLLBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return lcLLBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyLCLL(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
lcLLBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetHotState(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(hotStateBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return hotStateBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyHotState(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
hotStateBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
XCHLHInputs mInputs; // Inputs ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
double scHHBuffer[];
|
||||
double scLLBuffer[];
|
||||
double mcHHBuffer[];
|
||||
double mcLLBuffer[];
|
||||
double lcHHBuffer[];
|
||||
double lcLLBuffer[];
|
||||
double hotStateBuffer[];
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Calculate Values Until Now ...
|
||||
void Calculate()
|
||||
{
|
||||
//
|
||||
int totalBars = CountBars();
|
||||
|
||||
//
|
||||
// Short Cycle ...
|
||||
|
||||
//
|
||||
// HH ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XCHLH_SC_HH_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
scHHBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// LL ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XCHLH_SC_LL_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
scLLBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Medium Cycle ...
|
||||
|
||||
//
|
||||
// HH ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XCHLH_MC_HH_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
mcHHBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// LL ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XCHLH_MC_LL_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
mcLLBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Long Cycle ...
|
||||
|
||||
//
|
||||
// HH ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XCHLH_LC_HH_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
lcHHBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// LL ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XCHLH_LC_LL_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
lcLLBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Hot State ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XCHLH_HOT_STATE_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
hotStateBuffer
|
||||
//
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
Binary file not shown.
@@ -0,0 +1,960 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Helper Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCXCHMAHelper
|
||||
// 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.xhelper.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
enum ENUM_XCHMA_BUFFERS
|
||||
{
|
||||
//
|
||||
// LC ...
|
||||
XCHMA_LC_FAST_LINE = 0,
|
||||
XCHMA_LC_SLOW_LINE = 1,
|
||||
//
|
||||
// MC ...
|
||||
XCHMA_MC_FAST_LINE = 2,
|
||||
XCHMA_MC_SLOW_LINE = 3,
|
||||
//
|
||||
// SC ...
|
||||
XCHMA_SC_FAST_LINE = 4,
|
||||
XCHMA_SC_SLOW_LINE = 5,
|
||||
//
|
||||
XCHMA_HOT_STATE_LINE = 6,
|
||||
};
|
||||
|
||||
//
|
||||
// Input Models ...
|
||||
struct XCHMAInputs
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
//
|
||||
// Hot Areas ...
|
||||
bool drawHotAreas; // Draw Hot Areas Symbol
|
||||
uchar hotBullishArrowCode; // Hot Bullish Arrow Code
|
||||
color hotBullishArrowColor; // Hot Bullish Arrow Color
|
||||
uchar hotBearishArrowCode; // Hot Bearish Arrow Code
|
||||
color hotBearishArrowColor; // Hot Bearish Arrow Color
|
||||
|
||||
//
|
||||
// Long Cycle ...
|
||||
// LC Market ...
|
||||
int lcFastLength; // Fast Length
|
||||
int lcSlowLength; // Slow Length
|
||||
ENUM_MA_METHOD lcMethod; // Calculation Method
|
||||
ENUM_APPLIED_PRICE lcAppliedTo; // Applied To
|
||||
// LC Style ...
|
||||
int lcDrawWidth; // Draw Width
|
||||
ENUM_DRAW_TYPE lcDrawType; // Draw Type
|
||||
ENUM_LINE_STYLE lcDrawStyle; // Draw Style
|
||||
color lcFastColor; // Fast Color
|
||||
color lcSlowColor; // Slow Color
|
||||
// LC Drawings ...
|
||||
bool lcDrawFast; // Draw Fast
|
||||
bool lcDrawSlow; // Draw Slow
|
||||
bool lcDrawCrosses; // Draw Cross Lines
|
||||
|
||||
//
|
||||
// Medium Cycle ...
|
||||
// MC Market ...
|
||||
int mcFastLength; // Fast Length
|
||||
int mcSlowLength; // Slow Length
|
||||
ENUM_MA_METHOD mcMethod; // Calculation Method
|
||||
ENUM_APPLIED_PRICE mcAppliedTo; // Applied To
|
||||
// MC Style ...
|
||||
int mcDrawWidth; // Draw Width
|
||||
ENUM_DRAW_TYPE mcDrawType; // Draw Type
|
||||
ENUM_LINE_STYLE mcDrawStyle; // Draw Style
|
||||
color mcFastColor; // Fast Color
|
||||
color mcSlowColor; // Slow Color
|
||||
// MC Drawings ...
|
||||
bool mcDrawFast; // Draw Fast
|
||||
bool mcDrawSlow; // Draw Slow
|
||||
bool mcDrawCrosses; // Draw Cross Lines
|
||||
|
||||
//
|
||||
// Short Cycle ...
|
||||
// SC Market ...
|
||||
int scFastLength; // Fast Length
|
||||
int scSlowLength; // Slow Length
|
||||
ENUM_MA_METHOD scMethod; // Calculation Method
|
||||
ENUM_APPLIED_PRICE scAppliedTo; // Applied To
|
||||
// SC Style ...
|
||||
int scDrawWidth; // Draw Width
|
||||
ENUM_DRAW_TYPE scDrawType; // Draw Type
|
||||
ENUM_LINE_STYLE scDrawStyle; // Draw Style
|
||||
color scFastColor; // Fast Color
|
||||
color scSlowColor; // Slow Color
|
||||
// SC Drawings ...
|
||||
bool scDrawFast; // Draw Fast
|
||||
bool scDrawSlow; // Draw Slow
|
||||
bool scDrawCrosses; // Draw Cross Lines
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
XCHMAInputs()
|
||||
{
|
||||
//
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Clean ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
// Hot Areas ...
|
||||
drawHotAreas = false;
|
||||
hotBullishArrowCode = 228;
|
||||
hotBullishArrowColor = CLR_NONE;
|
||||
hotBearishArrowCode = 230;
|
||||
hotBearishArrowColor = CLR_NONE;
|
||||
|
||||
//
|
||||
// Long Cycle ...
|
||||
// LC Market ...
|
||||
lcFastLength = 20;
|
||||
lcSlowLength = 50;
|
||||
lcMethod = MODE_EMA;
|
||||
lcAppliedTo = PRICE_CLOSE;
|
||||
// LC Style ...
|
||||
lcDrawWidth = 1;
|
||||
lcDrawType = DRAW_NONE;
|
||||
lcDrawStyle = STYLE_DOT;
|
||||
lcFastColor = CLR_NONE;
|
||||
lcSlowColor = CLR_NONE;
|
||||
// LC Drawings ...
|
||||
lcDrawFast = false;
|
||||
lcDrawSlow = false;
|
||||
lcDrawCrosses = false;
|
||||
|
||||
//
|
||||
// Medium Cycle ...
|
||||
// MC Market ...
|
||||
mcFastLength = 10;
|
||||
mcSlowLength = 30;
|
||||
mcMethod = MODE_EMA;
|
||||
mcAppliedTo = PRICE_CLOSE;
|
||||
// MC Style ...
|
||||
mcDrawWidth = 1;
|
||||
mcDrawType = DRAW_NONE;
|
||||
mcDrawStyle = STYLE_DOT;
|
||||
mcFastColor = CLR_NONE;
|
||||
mcSlowColor = CLR_NONE;
|
||||
// MC Drawings ...
|
||||
mcDrawFast = false;
|
||||
mcDrawSlow = false;
|
||||
mcDrawCrosses = false;
|
||||
|
||||
//
|
||||
// Short Cycle ...
|
||||
// SC Market ...
|
||||
scFastLength = 7;
|
||||
scSlowLength = 14;
|
||||
scMethod = MODE_EMA;
|
||||
scAppliedTo = PRICE_CLOSE;
|
||||
// SC Style ...
|
||||
scDrawWidth = 1;
|
||||
scDrawType = DRAW_NONE;
|
||||
scDrawStyle = STYLE_SOLID;
|
||||
scFastColor = CLR_NONE;
|
||||
scSlowColor = CLR_NONE;
|
||||
// SC Drawings ...
|
||||
scDrawFast = false;
|
||||
scDrawSlow = false;
|
||||
scDrawCrosses = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Default ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
// Hot Areas ...
|
||||
drawHotAreas = false;
|
||||
hotBullishArrowCode = 228;
|
||||
hotBullishArrowColor = CLR_NONE;
|
||||
hotBearishArrowCode = 230;
|
||||
hotBearishArrowColor = CLR_NONE;
|
||||
|
||||
//
|
||||
// Long Cycle ...
|
||||
// LC Market ...
|
||||
lcFastLength = 20;
|
||||
lcSlowLength = 50;
|
||||
lcMethod = MODE_EMA;
|
||||
lcAppliedTo = PRICE_CLOSE;
|
||||
// LC Style ...
|
||||
lcDrawWidth = 1;
|
||||
lcDrawType = DRAW_LINE;
|
||||
lcDrawStyle = STYLE_DOT;
|
||||
lcFastColor = clrAqua;
|
||||
lcSlowColor = clrFuchsia;
|
||||
// LC Drawings ...
|
||||
lcDrawFast = false;
|
||||
lcDrawSlow = false;
|
||||
lcDrawCrosses = false;
|
||||
|
||||
//
|
||||
// Medium Cycle ...
|
||||
// MC Market ...
|
||||
mcFastLength = 10;
|
||||
mcSlowLength = 30;
|
||||
mcMethod = MODE_EMA;
|
||||
mcAppliedTo = PRICE_CLOSE;
|
||||
// MC Style ...
|
||||
mcDrawWidth = 1;
|
||||
mcDrawType = DRAW_LINE;
|
||||
mcDrawStyle = STYLE_DOT;
|
||||
mcFastColor = clrLime;
|
||||
mcSlowColor = clrRed;
|
||||
// MC Drawings ...
|
||||
mcDrawFast = false;
|
||||
mcDrawSlow = false;
|
||||
mcDrawCrosses = false;
|
||||
|
||||
//
|
||||
// Short Cycle ...
|
||||
// SC Market ...
|
||||
scFastLength = 7;
|
||||
scSlowLength = 14;
|
||||
scMethod = MODE_EMA;
|
||||
scAppliedTo = PRICE_CLOSE;
|
||||
// SC Style ...
|
||||
scDrawWidth = 1;
|
||||
scDrawType = DRAW_LINE;
|
||||
scDrawStyle = STYLE_SOLID;
|
||||
scFastColor = clrLightBlue;
|
||||
scSlowColor = clrLightSalmon;
|
||||
// SC Drawings ...
|
||||
scDrawFast = false;
|
||||
scDrawSlow = false;
|
||||
scDrawCrosses = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
(lcFastLength >= 4 && lcSlowLength > lcFastLength) &&
|
||||
(mcFastLength >= 4 && mcSlowLength > mcFastLength) &&
|
||||
(scFastLength >= 4 && scSlowLength > scFastLength) &&
|
||||
(lcFastLength > mcFastLength &&
|
||||
mcFastLength > scFastLength)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve MAx Length ...
|
||||
int Max()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = MathMax(scFastLength, scSlowLength);
|
||||
result = MathMax(result, lcFastLength);
|
||||
result = MathMax(result, lcSlowLength);
|
||||
result = MathMax(result, mcFastLength);
|
||||
result = MathMax(result, mcSlowLength);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
class XSCXCHMAHelper : public XSCBaseHelper
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XSCXCHMAHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XSCXCHMAHelper() {}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
XCHMAInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
ArraySetAsSeries(scFastBuffer, true);
|
||||
ArraySetAsSeries(scSlowBuffer, true);
|
||||
ArraySetAsSeries(mcFastBuffer, true);
|
||||
ArraySetAsSeries(mcSlowBuffer, true);
|
||||
ArraySetAsSeries(lcFastBuffer, true);
|
||||
ArraySetAsSeries(lcSlowBuffer, true);
|
||||
ArraySetAsSeries(hotStateBuffer, true);
|
||||
|
||||
//
|
||||
mHandler = iCustom(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
"x-saherelm.xchma",
|
||||
//
|
||||
// Inputs ...
|
||||
//
|
||||
// Hot Areas ...
|
||||
"",
|
||||
mInputs.drawHotAreas, // Draw Hot Areas Symbol
|
||||
mInputs.hotBullishArrowCode, // Hot Bullish Arrow Code
|
||||
mInputs.hotBullishArrowColor, // Hot Bullish Arrow Color
|
||||
mInputs.hotBearishArrowCode, // Hot Bearish Arrow Code
|
||||
mInputs.hotBearishArrowColor, // Hot Bearish Arrow Color
|
||||
//
|
||||
// Long Cycle ...
|
||||
"",
|
||||
//
|
||||
// LC Market ...
|
||||
"",
|
||||
mInputs.lcFastLength, // Fast Length
|
||||
mInputs.lcSlowLength, // Slow Length
|
||||
mInputs.lcMethod, // Calculation Method
|
||||
mInputs.lcAppliedTo, // Applied To
|
||||
//
|
||||
// LC Style ...
|
||||
"",
|
||||
mInputs.lcDrawWidth, // Draw Width
|
||||
mInputs.lcDrawType, // Draw Type
|
||||
mInputs.lcDrawStyle, // Draw Style
|
||||
mInputs.lcFastColor, // Fast Color
|
||||
mInputs.lcSlowColor, // Slow Color
|
||||
//
|
||||
// LC Drawings ...
|
||||
"",
|
||||
mInputs.lcDrawFast, // Draw Fast
|
||||
mInputs.lcDrawSlow, // Draw Slow
|
||||
mInputs.lcDrawCrosses, // Draw Cross Lines
|
||||
//
|
||||
// Medium Cycle ...
|
||||
"",
|
||||
//
|
||||
// MC Market ...
|
||||
"",
|
||||
mInputs.mcFastLength, // Fast Length
|
||||
mInputs.mcSlowLength, // Slow Length
|
||||
mInputs.mcMethod, // Calculation Method
|
||||
mInputs.mcAppliedTo, // Applied To
|
||||
//
|
||||
// MC Style ...
|
||||
"",
|
||||
mInputs.mcDrawWidth, // Draw Width
|
||||
mInputs.mcDrawType, // Draw Type
|
||||
mInputs.mcDrawStyle, // Draw Style
|
||||
mInputs.mcFastColor, // Fast Color
|
||||
mInputs.mcSlowColor, // Slow Color
|
||||
//
|
||||
// MC Drawings ...
|
||||
"",
|
||||
mInputs.mcDrawFast, // Draw Fast
|
||||
mInputs.mcDrawSlow, // Draw Slow
|
||||
mInputs.mcDrawCrosses, // Draw Cross Lines
|
||||
//
|
||||
// Short Cycle ...
|
||||
"",
|
||||
//
|
||||
// SC Market ...
|
||||
"",
|
||||
mInputs.scFastLength, // Fast Length
|
||||
mInputs.scSlowLength, // Slow Length
|
||||
mInputs.scMethod, // Calculation Method
|
||||
mInputs.scAppliedTo, // Applied To
|
||||
//
|
||||
// SC Style ...
|
||||
"",
|
||||
mInputs.scDrawWidth, // Draw Width
|
||||
mInputs.scDrawType, // Draw Type
|
||||
mInputs.scDrawStyle, // Draw Style
|
||||
mInputs.scFastColor, // Fast Color
|
||||
mInputs.scSlowColor, // Slow Color
|
||||
//
|
||||
// SC Drawings ...
|
||||
"",
|
||||
mInputs.scDrawFast, // Draw Fast
|
||||
mInputs.scDrawSlow, // Draw Slow
|
||||
mInputs.scDrawCrosses // Draw Cross Lines
|
||||
//
|
||||
);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
XCHMAInputs GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(
|
||||
XCHMAInputs &inputs // Configs
|
||||
)
|
||||
{
|
||||
//
|
||||
return Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
inputs
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
// Short ...
|
||||
|
||||
//
|
||||
double GetSCFast(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(scFastBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return scFastBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopySCFast(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
scFastBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetSCSlow(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(scSlowBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return scSlowBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopySCSlow(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
scSlowBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Medium ...
|
||||
|
||||
//
|
||||
double GetMCFast(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(mcFastBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return mcFastBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyMCFast(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
mcFastBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetMCSlow(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(mcSlowBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return mcSlowBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyMCSlow(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
mcSlowBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Long ...
|
||||
|
||||
//
|
||||
double GetLCFast(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(lcFastBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return lcFastBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyLCFast(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
lcFastBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetLCSlow(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(lcSlowBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return lcSlowBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyLCSlow(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
lcSlowBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetHotState(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(hotStateBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return hotStateBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyHotState(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
hotStateBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
XCHMAInputs mInputs; // Inputs ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
double scFastBuffer[];
|
||||
double scSlowBuffer[];
|
||||
double mcFastBuffer[];
|
||||
double mcSlowBuffer[];
|
||||
double lcFastBuffer[];
|
||||
double lcSlowBuffer[];
|
||||
double hotStateBuffer[];
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Calculate Values Until Now ...
|
||||
void Calculate()
|
||||
{
|
||||
//
|
||||
int totalBars = CountBars();
|
||||
|
||||
//
|
||||
// Short Cycle ...
|
||||
|
||||
//
|
||||
// Fast ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XCHMA_SC_FAST_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
scFastBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Slow ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XCHMA_SC_SLOW_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
scSlowBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Medium Cycle ...
|
||||
|
||||
//
|
||||
// Fast ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XCHMA_MC_FAST_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
mcFastBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Slow ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XCHMA_MC_SLOW_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
mcSlowBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Long Cycle ...
|
||||
|
||||
//
|
||||
// Fast ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XCHMA_LC_FAST_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
lcFastBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Slow ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XCHMA_LC_SLOW_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
lcSlowBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Hot State ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XCHMA_HOT_STATE_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
hotStateBuffer
|
||||
//
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
Binary file not shown.
@@ -0,0 +1,220 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Helper Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCXCTHelper
|
||||
// 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.xhelper.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
// Input Models ...
|
||||
struct XCTInputs
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
color clr; // Text Color
|
||||
ENUM_BASE_CORNER corner; // Text Position
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
bool showCandleTime; // Show Candle Time
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
XCTInputs()
|
||||
{
|
||||
//
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Clean ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
clr = CLR_NONE;
|
||||
corner = CORNER_RIGHT_LOWER;
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
showCandleTime = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Default ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
clr = clrYellow;
|
||||
corner = CORNER_RIGHT_LOWER;
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
showCandleTime = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
true
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve MAx Length ...
|
||||
int Max()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = MathMax(0, 0);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
class XSCXCTHelper : public XSCBaseHelper
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XSCXCTHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XSCXCTHelper() {}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
XCTInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
mHandler = iCustom(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
"x-saherelm.xct",
|
||||
//
|
||||
// Inputs ...
|
||||
mInputs.clr, // Text Color
|
||||
mInputs.corner, // Text Position
|
||||
//
|
||||
// Presentation ...
|
||||
"",
|
||||
mInputs.showCandleTime // Show Candle Time
|
||||
//
|
||||
);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
XCTInputs GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(
|
||||
XCTInputs &inputs // Configs
|
||||
)
|
||||
{
|
||||
//
|
||||
return Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
inputs
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
XCTInputs mInputs; // Inputs ...
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,292 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Helper Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCXFIHelper
|
||||
// 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.xhelper.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
enum ENUM_XFI_BUFFERS
|
||||
{
|
||||
XFI_MAIN_LINE = 0
|
||||
};
|
||||
|
||||
//
|
||||
// Input Models ...
|
||||
struct XFIInputs
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
int length; // Length
|
||||
ENUM_MA_METHOD method; // MA Method
|
||||
ENUM_APPLIED_VOLUME appliedTo; // Applied To
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
XFIInputs()
|
||||
{
|
||||
//
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Clean ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
length = 0;
|
||||
method = MODE_SMA;
|
||||
appliedTo = VOLUME_TICK;
|
||||
}
|
||||
|
||||
//
|
||||
// Default ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
length = 18;
|
||||
method = MODE_SMA;
|
||||
appliedTo = VOLUME_TICK;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
length >= 2
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve MAx Length ...
|
||||
int Max()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = MathMax(result, length);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
class XSCXFIHelper : public XSCBaseHelper
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XSCXFIHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XSCXFIHelper() {}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
XFIInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
ArraySetAsSeries(mainBuffer, true);
|
||||
mHandler = iCustom(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
"x-saherelm.xfi",
|
||||
//
|
||||
// Inputs ...
|
||||
mInputs.length, // Length
|
||||
mInputs.method, // MA Method
|
||||
mInputs.appliedTo // Applied To
|
||||
//
|
||||
);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
XFIInputs GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(
|
||||
XFIInputs &inputs // Configs
|
||||
)
|
||||
{
|
||||
//
|
||||
return Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
inputs
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
double GetMain(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(mainBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return mainBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyMain(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
mainBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
XFIInputs mInputs; // Inputs ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
double mainBuffer[];
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Calculate Values Until Now ...
|
||||
void Calculate()
|
||||
{
|
||||
//
|
||||
int totalBars = CountBars();
|
||||
|
||||
//
|
||||
// Short Exit 2 ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XFI_MAIN_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
mainBuffer
|
||||
//
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,399 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Helper Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCXHULLHelper
|
||||
// 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.xhelper.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
enum ENUM_XHULLC_BUFFERS
|
||||
{
|
||||
XHULLC_UP_LINE = 0,
|
||||
XHULLC_DOWN_LINE = 2,
|
||||
};
|
||||
|
||||
//
|
||||
// Input Models ...
|
||||
struct XHULLInputs
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
//
|
||||
// Market ...
|
||||
int length; // Length
|
||||
double divisor; // Divisor (Speed)
|
||||
|
||||
//
|
||||
// Calculation ...
|
||||
ENUM_APPLIED_PRICE upAppliedTo; // Up Zone Applied to
|
||||
ENUM_APPLIED_PRICE downAppliedTo; // Down Zone Applied to
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
bool showUpZone; // Show Up Zone
|
||||
bool showDownZone; // Show Down Zone
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
XHULLInputs()
|
||||
{
|
||||
//
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Clean ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
// Market ...
|
||||
length = 0;
|
||||
divisor = 0;
|
||||
|
||||
//
|
||||
// Calculation ...
|
||||
upAppliedTo = PRICE_HIGH;
|
||||
downAppliedTo = PRICE_LOW;
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
showUpZone = false;
|
||||
showDownZone = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Default ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
// Market ...
|
||||
length = 72;
|
||||
divisor = 2.0;
|
||||
|
||||
//
|
||||
// Calculation ...
|
||||
upAppliedTo = PRICE_HIGH;
|
||||
downAppliedTo = PRICE_LOW;
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
showUpZone = true;
|
||||
showDownZone = true;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
length >= 9 &&
|
||||
divisor >= 0.5
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve MAx Length ...
|
||||
int Max()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = MathMax(0, length);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
class XSCXHULLHelper : public XSCBaseHelper
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XSCXHULLHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XSCXHULLHelper() {}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
XHULLInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
// ArraySetAsSeries(mainBuffer, true);
|
||||
mHandler = iCustom(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
"x-saherelm.xhull",
|
||||
//
|
||||
// Inputs ...
|
||||
//
|
||||
// Market ...
|
||||
"",
|
||||
mInputs.length, // Length
|
||||
mInputs.divisor, // Divisor (Speed)
|
||||
//
|
||||
// Calculation ...
|
||||
"",
|
||||
mInputs.upAppliedTo, // Up Zone Applied to
|
||||
mInputs.downAppliedTo, // Down Zone Applied to
|
||||
//
|
||||
// Presentation ...
|
||||
"",
|
||||
mInputs.showUpZone, // Show Up Zone
|
||||
mInputs.showDownZone // Show Down Zone
|
||||
//
|
||||
);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
XHULLInputs GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(
|
||||
XHULLInputs &inputs // Configs
|
||||
)
|
||||
{
|
||||
//
|
||||
return Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
inputs
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
double GetUp(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(upBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return upBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyUp(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
upBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetDown(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(downBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return downBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyDown(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
downBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
XHULLInputs mInputs; // Inputs ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
double upBuffer[];
|
||||
double downBuffer[];
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Calculate Values Until Now ...
|
||||
void Calculate()
|
||||
{
|
||||
//
|
||||
int totalBars = CountBars();
|
||||
|
||||
//
|
||||
// Up Buffer ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XHULLC_UP_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
upBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Down Buffer ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XHULLC_DOWN_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
downBuffer
|
||||
//
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
Binary file not shown.
@@ -0,0 +1,827 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Helper Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCXICHHelper
|
||||
// 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
|
||||
|
||||
//
|
||||
#include "../Classes/x-saherelm.xhelper.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
//
|
||||
// Ichimoku Lines Calculator Mode ...
|
||||
enum ENUM_XICH_CALCULATION_MODE
|
||||
{
|
||||
//
|
||||
X_XICH_HH_LL_MODE = 1, // Highest High and Lowest Low
|
||||
X_XICH_HO_LC_MODE = 2, // Highest Open and Lowest Close
|
||||
};
|
||||
|
||||
//
|
||||
enum ENUM_XICH_BUFFERS
|
||||
{
|
||||
X_ICH_TEANKANSEN_LINE = 0,
|
||||
X_ICH_KIJUNSEN_LINE = 1,
|
||||
X_ICH_CHIKOUSPAN_LINE = 4,
|
||||
X_ICH_SENKOUSPANA_LINE = 5,
|
||||
X_ICH_SENKOUSPANB_LINE = 6,
|
||||
};
|
||||
|
||||
//
|
||||
// Input Models ...
|
||||
struct XICHInputs
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Market ...
|
||||
//
|
||||
// Tenkan Sen ...
|
||||
int tenkanSenLength; // Length
|
||||
ENUM_XICH_CALCULATION_MODE tenkanSenMode; // Calculation Mode
|
||||
|
||||
//
|
||||
// Kijun Sen ...
|
||||
int kijunSenLength; // Length
|
||||
ENUM_XICH_CALCULATION_MODE kijunSenMode; // Calculation Mode
|
||||
|
||||
//
|
||||
// Senkou Span B ...
|
||||
int senkouSpanBLength; // Length
|
||||
ENUM_XICH_CALCULATION_MODE senkouSpanBMode; // Calculation Mode
|
||||
|
||||
//
|
||||
// Chikou Span ...
|
||||
ENUM_APPLIED_PRICE chikuoSpanAppliedTo; // Price Type
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
bool showTenkanSen; // Show Tenkan Sen
|
||||
bool showKijunSen; // Show Kijun Sen
|
||||
bool showKijunSenPlus; // Show Kijun Sen +
|
||||
bool showKijunSenNegative; // Show Kijun Sen -
|
||||
bool showChikouSpan; // Show Chikou Span
|
||||
bool showSenkouSpanA; // Show Senkou Span A
|
||||
bool showSenkouSpanB; // Show Senkou Span B
|
||||
bool showKumo; // Show Kumo
|
||||
bool shiftKumo; // Shift Kumo to Future
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
XICHInputs()
|
||||
{
|
||||
//
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Clean ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
kijunSenLength = 0;
|
||||
tenkanSenLength = 0;
|
||||
senkouSpanBLength = 0;
|
||||
|
||||
//
|
||||
kijunSenMode = X_XICH_HH_LL_MODE;
|
||||
tenkanSenMode = X_XICH_HH_LL_MODE;
|
||||
senkouSpanBMode = X_XICH_HH_LL_MODE;
|
||||
|
||||
//
|
||||
chikuoSpanAppliedTo = PRICE_CLOSE;
|
||||
|
||||
//
|
||||
showTenkanSen = false;
|
||||
showKijunSen = false;
|
||||
showKijunSenPlus = false;
|
||||
showKijunSenNegative = false;
|
||||
showChikouSpan = false;
|
||||
showSenkouSpanA = false;
|
||||
showSenkouSpanB = false;
|
||||
showKumo = false;
|
||||
shiftKumo = true;
|
||||
}
|
||||
|
||||
//
|
||||
// Default ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
kijunSenLength = 26;
|
||||
tenkanSenLength = 9;
|
||||
senkouSpanBLength = 52;
|
||||
|
||||
//
|
||||
kijunSenMode = X_XICH_HH_LL_MODE;
|
||||
tenkanSenMode = X_XICH_HH_LL_MODE;
|
||||
senkouSpanBMode = X_XICH_HH_LL_MODE;
|
||||
|
||||
//
|
||||
chikuoSpanAppliedTo = PRICE_CLOSE;
|
||||
|
||||
//
|
||||
showTenkanSen = true;
|
||||
showKijunSen = true;
|
||||
showKijunSenPlus = false;
|
||||
showKijunSenNegative = false;
|
||||
showChikouSpan = true;
|
||||
showSenkouSpanA = true;
|
||||
showSenkouSpanB = true;
|
||||
showKumo = true;
|
||||
shiftKumo = true;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
tenkanSenLength > 2 &&
|
||||
kijunSenLength > tenkanSenLength &&
|
||||
senkouSpanBLength > kijunSenLength
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve MAx Length ...
|
||||
int Max()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = MathMax(result, tenkanSenLength);
|
||||
result = MathMax(result, kijunSenLength);
|
||||
result = MathMax(result, senkouSpanBLength);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
class XSCXICHHelper : public XSCBaseHelper
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XSCXICHHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XSCXICHHelper() {}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
XICHInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
ArraySetAsSeries(tenkanSenBuffer, true);
|
||||
ArraySetAsSeries(kijunSenBuffer, true);
|
||||
ArraySetAsSeries(chikouSpanBuffer, true);
|
||||
ArraySetAsSeries(senkouSpanABuffer, true);
|
||||
ArraySetAsSeries(senkouSpanBBuffer, true);
|
||||
|
||||
//
|
||||
mHandler = iCustom(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
"x-saherelm.xich",
|
||||
//
|
||||
// Inputs ...
|
||||
//
|
||||
// TenkanSen ...
|
||||
"",
|
||||
mInputs.tenkanSenLength,
|
||||
mInputs.tenkanSenMode,
|
||||
//
|
||||
// KijunSen ...
|
||||
"",
|
||||
mInputs.kijunSenLength,
|
||||
mInputs.kijunSenMode,
|
||||
//
|
||||
// SenkouSpan B ...
|
||||
"",
|
||||
mInputs.senkouSpanBLength,
|
||||
mInputs.senkouSpanBMode,
|
||||
//
|
||||
// ChikouSpan ...
|
||||
"",
|
||||
mInputs.chikuoSpanAppliedTo,
|
||||
//
|
||||
// Presentation ...
|
||||
"",
|
||||
mInputs.showTenkanSen, // Show Tenkan Sen
|
||||
mInputs.showKijunSen, // Show Kijun Sen
|
||||
mInputs.showKijunSenPlus, // Show Kijun Sen +
|
||||
mInputs.showKijunSenNegative, // Show Kijun Sen -
|
||||
mInputs.showChikouSpan, // Show Chikou Span
|
||||
mInputs.showSenkouSpanA, // Show Senkou Span A
|
||||
mInputs.showSenkouSpanB, // Show Senkou Span B
|
||||
mInputs.showKumo, // Show Kumo
|
||||
mInputs.shiftKumo // Shift Kumo to Future
|
||||
//
|
||||
);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
XICHInputs GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(
|
||||
XICHInputs &inputs // Configs
|
||||
)
|
||||
{
|
||||
//
|
||||
return Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
inputs);
|
||||
}
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
// TenkanSen ...
|
||||
|
||||
//
|
||||
double GetTenkanSen(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
return tenkanSenBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyTenkanSen(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
tenkanSenBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
bool IsSameTenkanSen(
|
||||
int barIndex, // Start Bar Index
|
||||
int verifier = 71 // Number of Verifiers
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
return IsSame(
|
||||
tenkanSenBuffer,
|
||||
verifier,
|
||||
barIndex //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// KijunSen ...
|
||||
|
||||
//
|
||||
double GetKijunSen(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
return kijunSenBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyKijunSen(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
kijunSenBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
bool IsSameKijunSen(
|
||||
int barIndex, // Start Bar Index
|
||||
int verifier = 71 // Number of Verifiers
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
return IsSame(
|
||||
kijunSenBuffer,
|
||||
verifier,
|
||||
barIndex //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// ChikouSpan ...
|
||||
|
||||
//
|
||||
double GetChikouSpan(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
barIndex -= mInputs.kijunSenLength;
|
||||
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
if (barIndex > ArraySize(chikouSpanBuffer))
|
||||
{
|
||||
barIndex = ArraySize(chikouSpanBuffer) - 1;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
return chikouSpanBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyChikouSpan(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start - mInputs.kijunSenLength,
|
||||
count,
|
||||
chikouSpanBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// SenkouSpanA ...
|
||||
|
||||
//
|
||||
double GetSenkouSpanA(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
barIndex += mInputs.kijunSenLength;
|
||||
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
if (barIndex > ArraySize(senkouSpanABuffer))
|
||||
{
|
||||
barIndex = ArraySize(senkouSpanABuffer) - 1;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
return senkouSpanABuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopySenkouSpanA(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start + mInputs.kijunSenLength,
|
||||
count,
|
||||
senkouSpanABuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
bool IsSameSenkouSpanA(
|
||||
int barIndex, // Start Bar Index
|
||||
int verifier = 71 // Number of Verifiers
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
return IsSame(
|
||||
senkouSpanABuffer,
|
||||
verifier,
|
||||
barIndex //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// SenkouSpanB ...
|
||||
|
||||
//
|
||||
double GetSenkouSpanB(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
barIndex += mInputs.kijunSenLength;
|
||||
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
if (barIndex > ArraySize(senkouSpanBBuffer))
|
||||
{
|
||||
barIndex = ArraySize(senkouSpanBBuffer) - 1;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
return senkouSpanBBuffer[barIndex + mInputs.kijunSenLength];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopySenkouSpanB(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start + mInputs.kijunSenLength,
|
||||
count,
|
||||
senkouSpanBBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
bool IsSameSenkouSpanB(
|
||||
int barIndex, // Start Bar Index
|
||||
int verifier = 71 // Number of Verifiers
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
return IsSame(
|
||||
senkouSpanBBuffer,
|
||||
verifier,
|
||||
barIndex //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Future SenkouSpanA ...
|
||||
|
||||
//
|
||||
double GetFutureSenkouSpanA(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
return senkouSpanABuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyFutureSenkouSpanA(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
senkouSpanABuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// SenkouSpanB ...
|
||||
|
||||
//
|
||||
double GetFutureSenkouSpanB(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
return senkouSpanBBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyFutureSenkouSpanB(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
senkouSpanBBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
XICHInputs mInputs; // Inputs ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
double tenkanSenBuffer[];
|
||||
double kijunSenBuffer[];
|
||||
double chikouSpanBuffer[];
|
||||
double senkouSpanABuffer[];
|
||||
double senkouSpanBBuffer[];
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Calculate Values Until Now ...
|
||||
void Calculate()
|
||||
{
|
||||
//
|
||||
int totalBars = CountBars();
|
||||
int calculatedBars = CountCalculatedBars();
|
||||
|
||||
//
|
||||
// TenkanSen ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X_ICH_TEANKANSEN_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
tenkanSenBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// KijunSen ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X_ICH_KIJUNSEN_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
kijunSenBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// ChikouSpan ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X_ICH_CHIKOUSPAN_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
chikouSpanBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// SenkouSpan A ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X_ICH_SENKOUSPANA_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
senkouSpanABuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// SenkouSpan B ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X_ICH_SENKOUSPANB_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
senkouSpanBBuffer
|
||||
//
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
Binary file not shown.
@@ -0,0 +1,422 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Helper Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCXLHHelper
|
||||
// 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.xhelper.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
enum ENUM_XLH_BUFFERS
|
||||
{
|
||||
XLH_HH_LINE = 0,
|
||||
XLH_LL_LINE = 1,
|
||||
XLH_SIGNAL_LINE = 2,
|
||||
};
|
||||
|
||||
//
|
||||
// Input Models ...
|
||||
struct XLHInputs
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
int length; // Length
|
||||
ENUM_SERIESMODE hhMode; // Highest High Calculation Method
|
||||
ENUM_SERIESMODE llMode; // Lowest Low Calculation Method
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
XLHInputs()
|
||||
{
|
||||
//
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Clean ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
length = 0;
|
||||
hhMode = MODE_HIGH;
|
||||
llMode = MODE_LOW;
|
||||
}
|
||||
|
||||
//
|
||||
// Default ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
length = 14;
|
||||
hhMode = MODE_HIGH;
|
||||
llMode = MODE_LOW;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
length >= 2
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve MAx Length ...
|
||||
int Max()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = MathMax(result, length);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
class XSCXLHHelper : public XSCBaseHelper
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XSCXLHHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XSCXLHHelper() {}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
XLHInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
ArraySetAsSeries(hhBuffer, true);
|
||||
ArraySetAsSeries(llBuffer, true);
|
||||
ArraySetAsSeries(signalBuffer, true);
|
||||
|
||||
//
|
||||
mHandler = iCustom(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
"x-saherelm.xlh",
|
||||
//
|
||||
// Inputs ...
|
||||
mInputs.length, // Length
|
||||
mInputs.hhMode, // Highest High Calculation Method
|
||||
mInputs.llMode // Lowest Low Calculation Method
|
||||
//
|
||||
);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
XLHInputs GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(
|
||||
XLHInputs &inputs // Configs
|
||||
)
|
||||
{
|
||||
//
|
||||
return Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
inputs
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
double GetHH(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(hhBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return hhBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyHH(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
hhBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetLL(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(llBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return llBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyLL(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
llBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetSignal(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(signalBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return signalBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopySignal(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
signalBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
XLHInputs mInputs; // Inputs ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
double hhBuffer[];
|
||||
double llBuffer[];
|
||||
double signalBuffer[];
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Calculate Values Until Now ...
|
||||
void Calculate()
|
||||
{
|
||||
//
|
||||
int totalBars = CountBars();
|
||||
|
||||
//
|
||||
// HH ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XLH_HH_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
hhBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// LL ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XLH_LL_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
llBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Signal ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XLH_SIGNAL_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
signalBuffer
|
||||
//
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
Binary file not shown.
@@ -0,0 +1,497 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Helper Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCXMCHelper
|
||||
// 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
|
||||
|
||||
//
|
||||
#include "../Classes/x-saherelm.xhelper.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
enum ENUM_XMC_BUFFERS
|
||||
{
|
||||
X_MC_FAST_LINE = 0,
|
||||
X_MC_SLOW_LINE = 1,
|
||||
X_MC_VERIFIER_LINE = 2,
|
||||
};
|
||||
|
||||
//
|
||||
// Input Models ...
|
||||
struct XMCInputs
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Market ...
|
||||
|
||||
//
|
||||
// Fast ...
|
||||
int fastLength; // Length
|
||||
int fastShift; // Shift
|
||||
ENUM_MA_METHOD fastMethod; // Method
|
||||
ENUM_APPLIED_PRICE fastAppliedTo; // Applied To
|
||||
|
||||
//
|
||||
// Slow ...
|
||||
int slowLength; // Length
|
||||
int slowShift; // Shift
|
||||
ENUM_MA_METHOD slowMethod; // Method
|
||||
ENUM_APPLIED_PRICE slowAppliedTo; // Applied To
|
||||
|
||||
//
|
||||
// Verifier ...
|
||||
int verifierLength; // Length
|
||||
int verifierShift; // Shift
|
||||
ENUM_MA_METHOD verifierMethod; // Method
|
||||
ENUM_APPLIED_PRICE verifierAppliedTo; // Applied To
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
bool showFastMa; // Show Fast
|
||||
bool showSlowMa; // Show Slow
|
||||
bool showVerifierMa; // Show Verifier
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
XMCInputs()
|
||||
{
|
||||
//
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Clean ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
fastLength = 0;
|
||||
fastShift = 0;
|
||||
fastMethod = 0;
|
||||
fastAppliedTo = PRICE_CLOSE;
|
||||
|
||||
//
|
||||
slowLength = 0;
|
||||
slowShift = 0;
|
||||
slowMethod = 0;
|
||||
slowAppliedTo = PRICE_CLOSE;
|
||||
|
||||
//
|
||||
verifierLength = 0;
|
||||
verifierShift = 0;
|
||||
verifierMethod = 0;
|
||||
verifierAppliedTo = PRICE_CLOSE;
|
||||
|
||||
//
|
||||
showFastMa = false;
|
||||
showSlowMa = false;
|
||||
showVerifierMa = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Default ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
fastLength = 9;
|
||||
fastShift = 0;
|
||||
fastMethod = MODE_EMA;
|
||||
fastAppliedTo = PRICE_CLOSE;
|
||||
|
||||
//
|
||||
slowLength = 18;
|
||||
slowShift = 0;
|
||||
slowMethod = MODE_EMA;
|
||||
slowAppliedTo = PRICE_CLOSE;
|
||||
|
||||
//
|
||||
verifierLength = 200;
|
||||
verifierShift = 0;
|
||||
verifierMethod = MODE_EMA;
|
||||
verifierAppliedTo = PRICE_CLOSE;
|
||||
|
||||
//
|
||||
showFastMa = true;
|
||||
showSlowMa = true;
|
||||
showVerifierMa = true;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
fastLength > 1 &&
|
||||
slowLength > fastLength &&
|
||||
verifierLength > slowLength
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve MAx Length ...
|
||||
int Max()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = MathMax(fastLength, slowLength);
|
||||
result = MathMax(result, verifierLength);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
class XSCXMCHelper : public XSCBaseHelper
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XSCXMCHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XSCXMCHelper() {}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
XMCInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
ArraySetAsSeries(fastBuffer, true);
|
||||
ArraySetAsSeries(slowBuffer, true);
|
||||
ArraySetAsSeries(verifierBuffer, true);
|
||||
mHandler = iCustom(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
"x-saherelm.xmc",
|
||||
//
|
||||
// Inputs ...
|
||||
//
|
||||
// Fast ...
|
||||
"",
|
||||
mInputs.fastLength,
|
||||
mInputs.fastShift,
|
||||
mInputs.fastMethod,
|
||||
mInputs.fastAppliedTo,
|
||||
//
|
||||
// Slow ...
|
||||
"",
|
||||
mInputs.slowLength,
|
||||
mInputs.slowShift,
|
||||
mInputs.slowMethod,
|
||||
mInputs.slowAppliedTo,
|
||||
//
|
||||
// Verifier ...
|
||||
"",
|
||||
mInputs.verifierLength,
|
||||
mInputs.verifierShift,
|
||||
mInputs.verifierMethod,
|
||||
mInputs.verifierAppliedTo,
|
||||
//
|
||||
// Presentation ...
|
||||
"",
|
||||
mInputs.showFastMa, // Show Fast,
|
||||
mInputs.showSlowMa, // Show Slow,
|
||||
mInputs.showVerifierMa // Show Verifier
|
||||
//
|
||||
);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
XMCInputs GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(
|
||||
XMCInputs &inputs // Configs
|
||||
)
|
||||
{
|
||||
//
|
||||
return Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
inputs);
|
||||
}
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
// Fast ...
|
||||
|
||||
//
|
||||
double GetFast(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
return fastBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Buffer ...
|
||||
int CopyFast(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
fastBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Slow ...
|
||||
|
||||
//
|
||||
double GetSlow(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
return slowBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Buffer ...
|
||||
int CopySlow(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
slowBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Verifier ...
|
||||
|
||||
//
|
||||
double GetVerifier(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
return verifierBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Buffer ...
|
||||
int CopyVerifier(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
verifierBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
XMCInputs mInputs; // Inputs ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
//
|
||||
double fastBuffer[];
|
||||
double slowBuffer[];
|
||||
double verifierBuffer[];
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Calculate Values Until Now ...
|
||||
void Calculate()
|
||||
{
|
||||
//
|
||||
int totalBars = CountBars();
|
||||
int calculatedBars = CountCalculatedBars();
|
||||
|
||||
//
|
||||
// Fast ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X_MC_FAST_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
fastBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Slow ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X_MC_SLOW_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
slowBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Verifier ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X_MC_VERIFIER_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
verifierBuffer
|
||||
//
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,306 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Helper Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCXOBDHelper
|
||||
// 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.xhelper.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
enum ENUM_XOBD_BUFFERS
|
||||
{
|
||||
XOBD_MAIN_LINE = 0
|
||||
};
|
||||
|
||||
//
|
||||
// Input Models ...
|
||||
struct XOBDInputs
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
int length; // Swing Length
|
||||
|
||||
//
|
||||
uchar swingHighArrowCode; // Swing High Arrow Code
|
||||
color swingHighArrowColor; // Swing High Arrow Color
|
||||
|
||||
//
|
||||
uchar swingLowArrowCode; // Swing Low Arrow Code
|
||||
color swingLowArrowColor; // Swing Low Arrow Color
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
XOBDInputs()
|
||||
{
|
||||
//
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Clean ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
length = 0;
|
||||
swingHighArrowCode = 0;
|
||||
swingHighArrowColor = CLR_NONE;
|
||||
swingLowArrowCode = 0;
|
||||
swingLowArrowColor = CLR_NONE;
|
||||
}
|
||||
|
||||
//
|
||||
// Default ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
length = 5;
|
||||
swingHighArrowCode = 0;
|
||||
swingHighArrowColor = CLR_NONE;
|
||||
swingLowArrowCode = 0;
|
||||
swingLowArrowColor = CLR_NONE;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
length >= 3
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve MAx Length ...
|
||||
int Max()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = MathMax(result, length);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
class XSCXOBDHelper : public XSCBaseHelper
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XSCXOBDHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XSCXOBDHelper() {}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
XOBDInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
ArraySetAsSeries(mainBuffer, true);
|
||||
mHandler = iCustom(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
"x-saherelm.xobd",
|
||||
//
|
||||
// Inputs ...
|
||||
mInputs.length, // Swing Length
|
||||
mInputs.swingHighArrowCode, // Swing High Arrow Code
|
||||
mInputs.swingHighArrowColor, // Swing High Arrow Color
|
||||
mInputs.swingLowArrowCode, // Swing Low Arrow Code
|
||||
mInputs.swingLowArrowColor // Swing Low Arrow Color
|
||||
//
|
||||
);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
XOBDInputs GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(
|
||||
XOBDInputs &inputs // Configs
|
||||
)
|
||||
{
|
||||
//
|
||||
return Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
inputs
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
double GetMain(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(mainBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return mainBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyMain(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
mainBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
XOBDInputs mInputs; // Inputs ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
double mainBuffer[];
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Calculate Values Until Now ...
|
||||
void Calculate()
|
||||
{
|
||||
//
|
||||
int totalBars = CountBars();
|
||||
|
||||
//
|
||||
// Main ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XOBD_MAIN_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
mainBuffer
|
||||
//
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,392 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Helper Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCXRSIHelper
|
||||
// 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.xhelper.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
enum ENUM_XRSI_BUFFERS
|
||||
{
|
||||
XRSI_MAIN_LINE = 0
|
||||
};
|
||||
|
||||
//
|
||||
// Input Models ...
|
||||
struct XRSIInputs
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Market ...
|
||||
int length; // Market Length
|
||||
ENUM_APPLIED_PRICE appliedTo; // Applied To
|
||||
|
||||
//
|
||||
// Short Entry ...
|
||||
double shortEntryValue; // Short Entry Level
|
||||
color shortEntryColor; // Short Entry Level Color
|
||||
ENUM_LINE_STYLE shortEntryLineStyle; // Short Entry Style
|
||||
|
||||
//
|
||||
// Short Exit ...
|
||||
double shortExitValue; // Short Exit Level
|
||||
color shortExitColor; // Short Exit Level Color
|
||||
ENUM_LINE_STYLE shortExitLineStyle; // Short Exit Style
|
||||
|
||||
//
|
||||
// Long Entry ...
|
||||
double longEntryValue; // Long Entry Level
|
||||
color longEntryColor; // Long Entry Level Color
|
||||
ENUM_LINE_STYLE longEntryLineStyle; // Long Entry Style
|
||||
|
||||
//
|
||||
// Long Exit ...
|
||||
double longExitValue; // Long Exit Level
|
||||
color longExitColor; // Long Exit Level Color
|
||||
ENUM_LINE_STYLE longExitLineStyle; // Long Exit Style
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
XRSIInputs()
|
||||
{
|
||||
//
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Clean ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
// Market ...
|
||||
length = 0;
|
||||
appliedTo = PRICE_CLOSE;
|
||||
|
||||
//
|
||||
// Short Entry ...
|
||||
shortEntryValue = 0;
|
||||
shortEntryColor = CLR_NONE;
|
||||
shortEntryLineStyle = STYLE_DOT;
|
||||
|
||||
//
|
||||
// Short Exit ...
|
||||
shortExitValue = 0;
|
||||
shortExitColor = CLR_NONE;
|
||||
shortExitLineStyle = STYLE_DOT;
|
||||
|
||||
//
|
||||
// Long Entry ...
|
||||
longEntryValue = 0;
|
||||
longEntryColor = CLR_NONE;
|
||||
longEntryLineStyle = STYLE_DOT;
|
||||
|
||||
//
|
||||
// Long Exit ...
|
||||
longExitValue = 0;
|
||||
longExitColor = CLR_NONE;
|
||||
longExitLineStyle = STYLE_DOT;
|
||||
}
|
||||
|
||||
//
|
||||
// Default ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
// Market ...
|
||||
length = 14;
|
||||
appliedTo = PRICE_CLOSE;
|
||||
|
||||
//
|
||||
// Short Entry ...
|
||||
shortEntryValue = 70;
|
||||
shortEntryColor = CLR_NONE;
|
||||
shortEntryLineStyle = STYLE_DOT;
|
||||
|
||||
//
|
||||
// Short Exit ...
|
||||
shortExitValue = 40;
|
||||
shortExitColor = CLR_NONE;
|
||||
shortExitLineStyle = STYLE_DOT;
|
||||
|
||||
//
|
||||
// Long Entry ...
|
||||
longEntryValue = 30;
|
||||
longEntryColor = CLR_NONE;
|
||||
longEntryLineStyle = STYLE_DOT;
|
||||
|
||||
//
|
||||
// Long Exit ...
|
||||
longExitValue = 60;
|
||||
longExitColor = CLR_NONE;
|
||||
longExitLineStyle = STYLE_DOT;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
length >= 2
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve MAx Length ...
|
||||
int Max()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = MathMax(result, length);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
class XSCXRSIHelper : public XSCBaseHelper
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XSCXRSIHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XSCXRSIHelper() {}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
XRSIInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
ArraySetAsSeries(mainBuffer, true);
|
||||
mHandler = iCustom(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
"x-saherelm.xrsi",
|
||||
//
|
||||
// Inputs ...
|
||||
//
|
||||
// Market ...
|
||||
"",
|
||||
mInputs.length, // Market Length
|
||||
mInputs.appliedTo, // Applied To
|
||||
//
|
||||
// Short Entry ...
|
||||
"",
|
||||
mInputs.shortEntryValue, // Short Entry Level
|
||||
mInputs.shortEntryColor, // Short Entry Level Color
|
||||
mInputs.shortEntryLineStyle, // Short Entry Style
|
||||
//
|
||||
// Short Exit ...
|
||||
"",
|
||||
mInputs.shortExitValue, // Short Exit Level
|
||||
mInputs.shortExitColor, // Short Exit Level Color
|
||||
mInputs.shortExitLineStyle, // Short Exit Style
|
||||
//
|
||||
// Long Entry ...
|
||||
"",
|
||||
mInputs.longEntryValue, // Long Entry Level
|
||||
mInputs.longEntryColor, // Long Entry Level Color
|
||||
mInputs.longEntryLineStyle, // Long Entry Style
|
||||
//
|
||||
// Long Exit ...
|
||||
"",
|
||||
mInputs.longExitValue, // Long Exit Level
|
||||
mInputs.longExitColor, // Long Exit Level Color
|
||||
mInputs.longExitLineStyle // Long Exit Style
|
||||
//
|
||||
);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
XRSIInputs GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(
|
||||
XRSIInputs &inputs // Configs
|
||||
)
|
||||
{
|
||||
//
|
||||
return Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
inputs
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
double GetMain(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(mainBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return mainBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyMain(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
mainBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
XRSIInputs mInputs; // Inputs ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
double mainBuffer[];
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Calculate Values Until Now ...
|
||||
void Calculate()
|
||||
{
|
||||
//
|
||||
int totalBars = CountBars();
|
||||
|
||||
//
|
||||
// Main ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XRSI_MAIN_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
mainBuffer
|
||||
//
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
Binary file not shown.
@@ -0,0 +1,408 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Helper Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCXSSLCHelper
|
||||
// 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.xhelper.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
enum ENUM_XSSLC_BUFFERS
|
||||
{
|
||||
XSSLC_UP_LINE = 0,
|
||||
XSSLC_DOWN_LINE = 1,
|
||||
};
|
||||
|
||||
//
|
||||
// Input Models ...
|
||||
struct XSSLCInputs
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Market ...
|
||||
int length; // Length
|
||||
|
||||
//
|
||||
// Calculation ...
|
||||
ENUM_MA_METHOD method; // Method
|
||||
ENUM_APPLIED_PRICE upAppliedTo; // Up Applied To
|
||||
ENUM_APPLIED_PRICE downAppliedTo; // Down Applied To
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
bool showUp; // Show Up
|
||||
bool showDown; // Show Down
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
XSSLCInputs()
|
||||
{
|
||||
//
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Clean ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
// Market ...
|
||||
length = 0;
|
||||
|
||||
//
|
||||
// Calculation ...
|
||||
method = MODE_SMA;
|
||||
upAppliedTo = PRICE_HIGH;
|
||||
downAppliedTo = PRICE_LOW;
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
showUp = false;
|
||||
showDown = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Default ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
// Market ...
|
||||
length = 36;
|
||||
|
||||
//
|
||||
// Calculation ...
|
||||
method = MODE_SMA;
|
||||
upAppliedTo = PRICE_HIGH;
|
||||
downAppliedTo = PRICE_LOW;
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
showUp = true;
|
||||
showDown = true;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
false
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve MAx Length ...
|
||||
int Max()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = MathMax(0, 0);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
class XSCXSSLCHelper : public XSCBaseHelper
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XSCXSSLCHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XSCXSSLCHelper() {}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
XSSLCInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
ArraySetAsSeries(upBuffer, true);
|
||||
ArraySetAsSeries(downBuffer, true);
|
||||
|
||||
//
|
||||
mHandler = iCustom(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
"x-saherelm.xsslc",
|
||||
//
|
||||
// Inputs ...
|
||||
//
|
||||
// Market ...
|
||||
"",
|
||||
mInputs.length, // Length
|
||||
//
|
||||
// Calculation ...
|
||||
"",
|
||||
mInputs.method, // Method
|
||||
mInputs.upAppliedTo, // Up Applied To
|
||||
mInputs.downAppliedTo, // Down Applied To
|
||||
//
|
||||
// Presentation ...
|
||||
"",
|
||||
mInputs.showUp, // Show Up
|
||||
mInputs.showDown // Show Down
|
||||
//
|
||||
);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
XSSLCInputs GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(
|
||||
XSSLCInputs &inputs // Configs
|
||||
)
|
||||
{
|
||||
//
|
||||
return Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
inputs
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
// Up ...
|
||||
|
||||
//
|
||||
double GetUp(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(upBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return upBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyUp(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
upBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Down ...
|
||||
|
||||
//
|
||||
double GetDown(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(downBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return downBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyDown(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
downBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
XSSLCInputs mInputs; // Inputs ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
double upBuffer[];
|
||||
double downBuffer[];
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Calculate Values Until Now ...
|
||||
void Calculate()
|
||||
{
|
||||
//
|
||||
int totalBars = CountBars();
|
||||
|
||||
//
|
||||
// Up ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XSSLC_UP_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
upBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Down ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XSSLC_DOWN_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
downBuffer
|
||||
//
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
Binary file not shown.
@@ -0,0 +1,421 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Helper Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCXSTRHelper
|
||||
// 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
|
||||
|
||||
//
|
||||
#include "../Classes/x-saherelm.xhelper.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
enum ENUM_XSTR_BUFFERS
|
||||
{
|
||||
X_STR_TREND_LINE = 0,
|
||||
X_STR_STATE_LINE = 5,
|
||||
};
|
||||
|
||||
//
|
||||
enum ENUM_XSTR_TREND_STATES
|
||||
{
|
||||
X_STR_BULLISH = 1, // Bullish
|
||||
X_STR_BEARISH = -1, // Bearish
|
||||
};
|
||||
|
||||
//
|
||||
// Input Models ...
|
||||
struct XSTRInputs
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Market ...
|
||||
int length; // Length
|
||||
double multiplier; // Multiplier
|
||||
ENUM_APPLIED_PRICE appliedTo; // Applied To
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
bool showTrends; // Show Trends
|
||||
bool fillTrends; // Fill Trends
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
XSTRInputs()
|
||||
{
|
||||
//
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Clean ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
length = 0;
|
||||
multiplier = 0;
|
||||
appliedTo = PRICE_CLOSE;
|
||||
//
|
||||
showTrends = false;
|
||||
fillTrends = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Default ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
length = 14;
|
||||
multiplier = 3.5;
|
||||
appliedTo = PRICE_MEDIAN;
|
||||
//
|
||||
showTrends = true;
|
||||
fillTrends = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
length > 0 &&
|
||||
multiplier > 0
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve MAx Length ...
|
||||
int Max()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = length;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
class XSCXSTRHelper : public XSCBaseHelper
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XSCXSTRHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XSCXSTRHelper() {}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
XSTRInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
ArraySetAsSeries(trendBuffer, true);
|
||||
ArraySetAsSeries(stateBuffer, true);
|
||||
|
||||
//
|
||||
mHandler = iCustom(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
"x-saherelm.xstr",
|
||||
//
|
||||
// Inputs ...
|
||||
//
|
||||
// ATR ...
|
||||
"",
|
||||
mInputs.length, // Length
|
||||
mInputs.multiplier, // Multiplier
|
||||
mInputs.appliedTo, // Applied To
|
||||
//
|
||||
// Presentation ...
|
||||
"",
|
||||
mInputs.showTrends, // Show Trends
|
||||
mInputs.fillTrends // Fill Trends
|
||||
//
|
||||
);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
XSTRInputs GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(
|
||||
XSTRInputs &inputs // Configs
|
||||
)
|
||||
{
|
||||
//
|
||||
return Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
inputs);
|
||||
}
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
// Trend ...
|
||||
|
||||
//
|
||||
double GetTrend(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
return trendBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Buffer ...
|
||||
int CopyTrend(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
trendBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// State ...
|
||||
|
||||
//
|
||||
ENUM_XSTR_TREND_STATES GetState(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
return (ENUM_XSTR_TREND_STATES)((int)stateBuffer[barIndex]);
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Buffer ...
|
||||
int CopyState(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
stateBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
ENUM_XSTR_TREND_STATES ToState(double state)
|
||||
{
|
||||
return (ENUM_XSTR_TREND_STATES)((int)state);
|
||||
}
|
||||
|
||||
//
|
||||
bool IsBullish(double state)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
ToState(state) == X_STR_BULLISH;
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
bool IsBearish(double state)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
ToState(state) == X_STR_BEARISH;
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
XSTRInputs mInputs; // Inputs ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
double trendBuffer[];
|
||||
double stateBuffer[];
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Calculate Values Until Now ...
|
||||
void Calculate()
|
||||
{
|
||||
//
|
||||
int totalBars = CountBars();
|
||||
int calculatedBars = CountCalculatedBars();
|
||||
|
||||
//
|
||||
// Trend ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X_STR_TREND_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
trendBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// State ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
X_STR_STATE_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
stateBuffer
|
||||
//
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
Binary file not shown.
@@ -0,0 +1,458 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Helper Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCXTDHelper
|
||||
// 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.xhelper.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
enum ENUM_XTD_BUFFERS
|
||||
{
|
||||
XTD_BULLISH_LINE = 0,
|
||||
XTD_BEARISH_LINE = 1,
|
||||
XTD_SIGNAL_LINE = 2,
|
||||
};
|
||||
|
||||
//
|
||||
// Input Models ...
|
||||
struct XTDInputs
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
//
|
||||
int length; // Market Length
|
||||
bool drawCrosses; // Draw Cross Arrows
|
||||
|
||||
//
|
||||
// Bullish ...
|
||||
uchar bullishArrowCode; // Cross Over Arrow Code
|
||||
color bullishArrowColor; // Cross Over Arrow Color
|
||||
|
||||
//
|
||||
// Bearish ...
|
||||
uchar bearishArrowCode; // Cross Under Arrow Code
|
||||
color bearishArrowColor; // Cross Under Arrow Color
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
XTDInputs()
|
||||
{
|
||||
//
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Clean ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
length = 0;
|
||||
drawCrosses = false;
|
||||
|
||||
//
|
||||
// Bullish ...
|
||||
bullishArrowCode = 228;
|
||||
bullishArrowColor = CLR_NONE;
|
||||
|
||||
//
|
||||
// Bearish ...
|
||||
bearishArrowCode = 230;
|
||||
bearishArrowColor = CLR_NONE;
|
||||
}
|
||||
|
||||
//
|
||||
// Default ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
length = 14;
|
||||
drawCrosses = false;
|
||||
|
||||
//
|
||||
// Bullish ...
|
||||
bullishArrowCode = 228;
|
||||
bullishArrowColor = CLR_NONE;
|
||||
|
||||
//
|
||||
// Bearish ...
|
||||
bearishArrowCode = 230;
|
||||
bearishArrowColor = CLR_NONE;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
length >= 2
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve MAx Length ...
|
||||
int Max()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = MathMax(result, length);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
class XSCXTDHelper : public XSCBaseHelper
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XSCXTDHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XSCXTDHelper() {}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
XTDInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
ArraySetAsSeries(bullishBuffer, true);
|
||||
ArraySetAsSeries(bearishBuffer, true);
|
||||
ArraySetAsSeries(signalBuffer, true);
|
||||
|
||||
//
|
||||
mHandler = iCustom(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
"x-saherelm.xtd",
|
||||
//
|
||||
// Inputs ...
|
||||
//
|
||||
mInputs.length, // Market Length
|
||||
mInputs.drawCrosses, // Draw Cross Arrows
|
||||
//
|
||||
// Bullish ...
|
||||
mInputs.bullishArrowCode, // Cross Over Arrow Code
|
||||
mInputs.bullishArrowColor, // Cross Over Arrow Color
|
||||
//
|
||||
// Bearish ...
|
||||
mInputs.bearishArrowCode, // Cross Under Arrow Code
|
||||
mInputs.bearishArrowColor // Cross Under Arrow Color
|
||||
//
|
||||
);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
XTDInputs GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(
|
||||
XTDInputs &inputs // Configs
|
||||
)
|
||||
{
|
||||
//
|
||||
return Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
inputs
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
double GetBullish(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(bullishBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return bullishBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyBullish(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
bullishBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetBearish(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(bearishBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return bearishBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyBearish(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
bearishBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetSignal(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(signalBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return signalBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopySignal(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
signalBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
XTDInputs mInputs; // Inputs ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
double bullishBuffer[];
|
||||
double bearishBuffer[];
|
||||
double signalBuffer[];
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Calculate Values Until Now ...
|
||||
void Calculate()
|
||||
{
|
||||
//
|
||||
int totalBars = CountBars();
|
||||
|
||||
//
|
||||
// Bullish ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XTD_BULLISH_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
bullishBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Bearish ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XTD_BEARISH_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
bearishBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Signal ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XTD_SIGNAL_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
signalBuffer
|
||||
//
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
Binary file not shown.
@@ -0,0 +1,310 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Helper Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCXTMHelper
|
||||
// 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.xhelper.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
enum ENUM_XTM_BUFFERS
|
||||
{
|
||||
XTM_MAIN_LINE = 0
|
||||
};
|
||||
|
||||
//
|
||||
// Input Models ...
|
||||
struct XTMInputs
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
//
|
||||
// Market ...
|
||||
int maPeriod; // Period
|
||||
int maShift; // Shift
|
||||
ENUM_MA_METHOD maMethod; // Method
|
||||
ENUM_APPLIED_PRICE maAppliedTo; // Applied To
|
||||
//
|
||||
// Presentation ...
|
||||
bool showLine; // Show Line
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
XTMInputs()
|
||||
{
|
||||
//
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Clean ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
maShift = 0;
|
||||
maPeriod = 0;
|
||||
showLine = false;
|
||||
maMethod = MODE_SMA;
|
||||
maAppliedTo = PRICE_CLOSE;
|
||||
}
|
||||
|
||||
//
|
||||
// Default ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
maShift = 0;
|
||||
maPeriod = 14;
|
||||
showLine = true;
|
||||
maMethod = MODE_SMA;
|
||||
maAppliedTo = PRICE_CLOSE;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
maPeriod >= 2
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve MAx Length ...
|
||||
int Max()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = MathMax(result, maPeriod);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
class XSCXTMHelper : public XSCBaseHelper
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XSCXTMHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XSCXTMHelper() {}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
XTMInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
ArraySetAsSeries(mainBuffer, true);
|
||||
mHandler = iCustom(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
"x-saherelm.xtm",
|
||||
//
|
||||
// Inputs ...
|
||||
//
|
||||
// Market ...
|
||||
"",
|
||||
mInputs.maPeriod, // Period
|
||||
mInputs.maShift, // Shift
|
||||
mInputs.maMethod, // Method
|
||||
mInputs.maAppliedTo, // Applied To
|
||||
//
|
||||
// Presentation ...
|
||||
"",
|
||||
mInputs.showLine // Show Line
|
||||
//
|
||||
);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
XTMInputs GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(
|
||||
XTMInputs &inputs // Configs
|
||||
)
|
||||
{
|
||||
//
|
||||
return Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
inputs
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
double GetMain(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(mainBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return mainBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyMain(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
mainBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
XTMInputs mInputs; // Inputs ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
double mainBuffer[];
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Calculate Values Until Now ...
|
||||
void Calculate()
|
||||
{
|
||||
//
|
||||
int totalBars = CountBars();
|
||||
|
||||
//
|
||||
// Main Buffer ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XTM_MAIN_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
mainBuffer
|
||||
//
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
Binary file not shown.
@@ -0,0 +1,550 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Helper Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCXTSHelper
|
||||
// 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.xhelper.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
enum ENUM_XTS_BUFFERS
|
||||
{
|
||||
XTS_CURRENT_LINE = 0,
|
||||
XTS_NEAREST_LINE = 1,
|
||||
XTS_MEDIEST_LINE = 2,
|
||||
XTS_FAREST_LINE = 3,
|
||||
};
|
||||
|
||||
//
|
||||
// Input Models ...
|
||||
struct XTSInputs
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
//
|
||||
// Current Period ...
|
||||
ENUM_APPLIED_PRICE currentAppliedTo; // Current Applied To
|
||||
//
|
||||
// Nearest Period ...
|
||||
ENUM_X_PERIOD_METHOD nearestMethod; // How to Find Nearest Period
|
||||
ENUM_TIMEFRAMES nearestPeriod; // Nearest Time Frame
|
||||
ENUM_APPLIED_PRICE nearestAppliedTo; // Nearest Applied To
|
||||
//
|
||||
// Mediest Period ...
|
||||
ENUM_X_PERIOD_METHOD mediestMethod; // How to Find Mediest Period
|
||||
ENUM_TIMEFRAMES mediestPeriod; // Mediest Time Frame
|
||||
ENUM_APPLIED_PRICE mediestAppliedTo; // Mediest Applied To
|
||||
//
|
||||
// Farest Period ...
|
||||
ENUM_X_PERIOD_METHOD farestMethod; // How to Find Farest Period
|
||||
ENUM_TIMEFRAMES farestPeriod; // Farest Time Frame
|
||||
ENUM_APPLIED_PRICE farestAppliedTo; // Farest Applied To
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
XTSInputs()
|
||||
{
|
||||
//
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Clean ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
// Current Period ...
|
||||
currentAppliedTo = PRICE_CLOSE;
|
||||
//
|
||||
// Nearest Period ...
|
||||
nearestMethod = X_PERIOD_NOTHING;
|
||||
nearestPeriod = NULL;
|
||||
nearestAppliedTo = PRICE_CLOSE;
|
||||
//
|
||||
// Mediest Period ...
|
||||
mediestMethod = X_PERIOD_NOTHING;
|
||||
mediestPeriod = NULL;
|
||||
mediestAppliedTo = PRICE_CLOSE;
|
||||
//
|
||||
// Farest Period ...
|
||||
farestMethod = X_PERIOD_NOTHING;
|
||||
farestPeriod = NULL;
|
||||
farestAppliedTo = PRICE_CLOSE;
|
||||
}
|
||||
|
||||
//
|
||||
// Default ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
// Current Period ...
|
||||
currentAppliedTo = PRICE_CLOSE;
|
||||
//
|
||||
// Nearest Period ...
|
||||
nearestMethod = X_PERIOD_AUTO;
|
||||
nearestPeriod = NULL;
|
||||
nearestAppliedTo = PRICE_CLOSE;
|
||||
//
|
||||
// Mediest Period ...
|
||||
mediestMethod = X_PERIOD_AUTO;
|
||||
mediestPeriod = NULL;
|
||||
mediestAppliedTo = PRICE_CLOSE;
|
||||
//
|
||||
// Farest Period ...
|
||||
farestMethod = X_PERIOD_AUTO;
|
||||
farestPeriod = NULL;
|
||||
farestAppliedTo = PRICE_CLOSE;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
IsValid(nearestMethod, nearestPeriod) &&
|
||||
IsValid(mediestMethod, mediestPeriod) &&
|
||||
IsValid(farestMethod, farestPeriod)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve MAx Length ...
|
||||
int Max()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = MathMax(result, 0);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
class XSCXTSHelper : public XSCBaseHelper
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XSCXTSHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XSCXTSHelper() {}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
XTSInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
ArraySetAsSeries(currentBuffer, true);
|
||||
ArraySetAsSeries(nearestBuffer, true);
|
||||
ArraySetAsSeries(mediestBuffer, true);
|
||||
ArraySetAsSeries(farestBuffer, true);
|
||||
|
||||
//
|
||||
mHandler = iCustom(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
"x-saherelm.xts",
|
||||
//
|
||||
// Inputs ...
|
||||
//
|
||||
// Current Period ...
|
||||
"",
|
||||
mInputs.currentAppliedTo, // Current Applied To
|
||||
//
|
||||
// Nearest Period ...
|
||||
"",
|
||||
mInputs.nearestMethod, // How to Find Nearest Period
|
||||
mInputs.nearestPeriod, // Nearest Time Frame
|
||||
mInputs.nearestAppliedTo, // Nearest Applied To
|
||||
//
|
||||
// Mediest Period ...
|
||||
"",
|
||||
mInputs.mediestMethod, // How to Find Mediest Period
|
||||
mInputs.mediestPeriod, // Mediest Time Frame
|
||||
mInputs.mediestAppliedTo, // Mediest Applied To
|
||||
//
|
||||
// Farest Period ...
|
||||
"",
|
||||
mInputs.farestMethod, // How to Find Farest Period
|
||||
mInputs.farestPeriod, // Farest Time Frame
|
||||
mInputs.farestAppliedTo // Farest Applied To
|
||||
//
|
||||
);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
XTSInputs GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(
|
||||
XTSInputs &inputs // Configs
|
||||
)
|
||||
{
|
||||
//
|
||||
return Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
inputs
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
double GetCurrent(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(currentBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return currentBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyCurrent(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
currentBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetNearest(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(nearestBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return nearestBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyNearest(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
nearestBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetMediest(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(mediestBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return mediestBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyMediest(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
mediestBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetFarest(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(farestBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return farestBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyFarest(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
farestBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
XTSInputs mInputs; // Inputs ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
double currentBuffer[];
|
||||
double nearestBuffer[];
|
||||
double mediestBuffer[];
|
||||
double farestBuffer[];
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Calculate Values Until Now ...
|
||||
void Calculate()
|
||||
{
|
||||
//
|
||||
int totalBars = CountBars();
|
||||
|
||||
//
|
||||
// Current ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XTS_CURRENT_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
currentBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Nearest ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XTS_NEAREST_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
nearestBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Mediest ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XTS_MEDIEST_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
mediestBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Farest ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XTS_FAREST_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
farestBuffer
|
||||
//
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
Binary file not shown.
@@ -0,0 +1,527 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Helper Class Library
|
||||
// ----------------------------------------------
|
||||
// Name: XSCXZGHelper
|
||||
// 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.xhelper.class.mq5"
|
||||
|
||||
//
|
||||
// Definitions ...
|
||||
|
||||
//
|
||||
// How to Calculate Up and Down Price ...
|
||||
enum ENUM_X_ZG_PRICE_MODE
|
||||
{
|
||||
//
|
||||
X_ZG_PRICE_HIGH_LOW_MODE = 1,
|
||||
X_ZG_PRICE_OPEN_CLOSE_MODE = 2,
|
||||
};
|
||||
|
||||
//
|
||||
enum ENUM_XZG_BUFFERS
|
||||
{
|
||||
//
|
||||
XZG_MAIN_LINE = 0,
|
||||
XZG_PEAKSANDVALES_LINE = 2,
|
||||
XZG_HIGHS_LINE = 4,
|
||||
XZG_LOWS_LINE = 5,
|
||||
};
|
||||
|
||||
//
|
||||
// Input Models ...
|
||||
struct XZGInputs
|
||||
{
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Market ...
|
||||
int depth; // Depth
|
||||
int deviation; // Deviation
|
||||
int backStep; // Back Step
|
||||
ENUM_X_ZG_PRICE_MODE mode; // Mode
|
||||
//
|
||||
// Presentation ...
|
||||
bool showZigZag; // Show ZigZag
|
||||
bool showPeaksAndVales; // Show Peaks and Vales
|
||||
|
||||
//
|
||||
// Constructor(s) ...
|
||||
XZGInputs()
|
||||
{
|
||||
//
|
||||
Clean();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Clean ...
|
||||
void Clean()
|
||||
{
|
||||
//
|
||||
// Market ...
|
||||
depth = 0;
|
||||
deviation = 0;
|
||||
backStep = 0;
|
||||
mode = X_ZG_PRICE_HIGH_LOW_MODE;
|
||||
//
|
||||
// Presentation ...
|
||||
showZigZag = false;
|
||||
showPeaksAndVales = false;
|
||||
}
|
||||
|
||||
//
|
||||
// Default ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
// Market ...
|
||||
depth = 12;
|
||||
deviation = 5;
|
||||
backStep = 3;
|
||||
mode = X_ZG_PRICE_HIGH_LOW_MODE;
|
||||
//
|
||||
// Presentation ...
|
||||
showZigZag = true;
|
||||
showPeaksAndVales = true;
|
||||
}
|
||||
|
||||
//
|
||||
// Validate ...
|
||||
bool IsValid()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result =
|
||||
//
|
||||
depth > 0 &&
|
||||
deviation > 0 &&
|
||||
backStep > 0
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve MAx Length ...
|
||||
int Max()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = MathMax(backStep, depth);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Class ...
|
||||
class XSCXZGHelper : public XSCBaseHelper
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
|
||||
//
|
||||
// Constructors ...
|
||||
XSCXZGHelper() : XSCBaseHelper(_Symbol, _Period)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Deconstructor ...
|
||||
~XSCXZGHelper() {}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
bool Init(
|
||||
string symbol, // Trading Symbol
|
||||
ENUM_TIMEFRAMES period, // Trading Period
|
||||
XZGInputs &inputs // Inputs
|
||||
)
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
mSymbol = symbol;
|
||||
mPeriod = period;
|
||||
|
||||
//
|
||||
result = inputs.IsValid();
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
mInputs = inputs;
|
||||
|
||||
//
|
||||
ArraySetAsSeries(mainBuffer, true);
|
||||
ArraySetAsSeries(PeaksAndValesBuffer, true);
|
||||
ArraySetAsSeries(highsBuffer, true);
|
||||
ArraySetAsSeries(lowsBuffer, true);
|
||||
|
||||
//
|
||||
mHandler = iCustom(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
"x-saherelm.xzg",
|
||||
//
|
||||
// Inputs ...
|
||||
//
|
||||
// Market ...
|
||||
"",
|
||||
mInputs.depth, // Depth
|
||||
mInputs.deviation, // Deviation
|
||||
mInputs.backStep, // Back Step
|
||||
mInputs.mode, // Mode
|
||||
//
|
||||
// Presentation ...
|
||||
"",
|
||||
mInputs.showZigZag, // Show ZigZag
|
||||
mInputs.showPeaksAndVales // Show Peaks and Vales
|
||||
//
|
||||
);
|
||||
result = mHandler != INVALID_HANDLE;
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
XZGInputs GetInputs()
|
||||
{
|
||||
return mInputs;
|
||||
}
|
||||
|
||||
//
|
||||
bool SetInputs(
|
||||
XZGInputs &inputs // Configs
|
||||
)
|
||||
{
|
||||
//
|
||||
return Init(
|
||||
mSymbol,
|
||||
mPeriod,
|
||||
inputs
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
|
||||
//
|
||||
double GetMain(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(mainBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return mainBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyMain(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
mainBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetPeaksAndVales(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(PeaksAndValesBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return PeaksAndValesBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyPeaksAndVales(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
PeaksAndValesBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetHigh(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(highsBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return highsBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyHigh(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
highsBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
double GetLow(
|
||||
int barIndex // Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
if (barIndex < 0)
|
||||
{
|
||||
barIndex = 0;
|
||||
}
|
||||
|
||||
//
|
||||
Calculate();
|
||||
|
||||
//
|
||||
int count = ArraySize(lowsBuffer);
|
||||
if (barIndex >= count)
|
||||
{
|
||||
barIndex = count - 1;
|
||||
}
|
||||
|
||||
//
|
||||
return lowsBuffer[barIndex];
|
||||
}
|
||||
|
||||
//
|
||||
// Copy Required Items ...
|
||||
int CopyLow(
|
||||
int start, // Start
|
||||
int count, // Number of Items for read
|
||||
double &buffer[], // Dest Buffer
|
||||
bool forceClean = true // Force To Clean buffer
|
||||
)
|
||||
{
|
||||
//
|
||||
// Update Calculations ...
|
||||
Calculate();
|
||||
|
||||
//
|
||||
// Copy Items ...
|
||||
return Copy(
|
||||
start,
|
||||
count,
|
||||
lowsBuffer,
|
||||
buffer,
|
||||
forceClean
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Protected ...
|
||||
protected:
|
||||
//
|
||||
// Private ...
|
||||
private:
|
||||
//
|
||||
// Props ...
|
||||
XZGInputs mInputs; // Inputs ...
|
||||
|
||||
//
|
||||
// Buffers ...
|
||||
double mainBuffer[];
|
||||
double PeaksAndValesBuffer[];
|
||||
double highsBuffer[];
|
||||
double lowsBuffer[];
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Calculate Values Until Now ...
|
||||
void Calculate()
|
||||
{
|
||||
//
|
||||
int totalBars = CountBars();
|
||||
|
||||
//
|
||||
// Main Buffer ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XZG_MAIN_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
mainBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Peaks and Vales Buffer ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XZG_PEAKSANDVALES_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
PeaksAndValesBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Highs Buffer ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XZG_HIGHS_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
highsBuffer
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Lows Buffer ...
|
||||
CopyBuffer(
|
||||
mHandler,
|
||||
XZG_LOWS_LINE,
|
||||
0,
|
||||
totalBars,
|
||||
lowsBuffer
|
||||
//
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
Binary file not shown.
@@ -0,0 +1,348 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 XAMA Indicator
|
||||
// ---------------------------------------------
|
||||
// Name: XAMA
|
||||
// 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 XAMA Indicator"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// Constants ...
|
||||
|
||||
#define ShortName "XAMA"
|
||||
|
||||
//
|
||||
// Indicator States ...
|
||||
enum ENUM_X_XAMA_STATES
|
||||
{
|
||||
X_XAMA_BULLISH = 1,
|
||||
X_XAMA_BEARISH = -1,
|
||||
X_XAMA_NEUTURAL = 0,
|
||||
};
|
||||
|
||||
//
|
||||
// Inputs ...
|
||||
|
||||
//
|
||||
// Market ...
|
||||
input group "Market";
|
||||
input int length = 18; // Period
|
||||
input int fastEMA = 2; // Fast EMA Period
|
||||
input int slowEMA = 30; // Slow EMA Period
|
||||
input int maShift = 0; // Shift
|
||||
input ENUM_APPLIED_PRICE appliedTo = PRICE_CLOSE; // Applied To
|
||||
|
||||
//
|
||||
// Presentation ...
|
||||
input group "Presentation";
|
||||
input bool showLine = true; // Show Line
|
||||
|
||||
//
|
||||
// Includes Common Library ...
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||
|
||||
//
|
||||
// START Buffers ...
|
||||
//
|
||||
#property indicator_chart_window
|
||||
|
||||
//
|
||||
#property indicator_buffers 3
|
||||
#property indicator_plots 1
|
||||
|
||||
//
|
||||
// maBuffer ...
|
||||
#define maBufferIndex 0
|
||||
#define maColorBufferIndex 1
|
||||
#define stateBufferIndex 2
|
||||
|
||||
double maBuffer[];
|
||||
double maColorBuffer[];
|
||||
double stateBuffer[];
|
||||
|
||||
#property indicator_label1 "XAMA"
|
||||
#property indicator_type1 DRAW_COLOR_LINE
|
||||
#property indicator_color1 clrLime, clrGray, clrRed, CLR_NONE
|
||||
#property indicator_style1 STYLE_SOLID
|
||||
#property indicator_width1 1
|
||||
//
|
||||
// END Buffers ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
int maHandler = INVALID_HANDLE;
|
||||
//
|
||||
// END Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Event Handlers ...
|
||||
//
|
||||
//
|
||||
// Initialization ...
|
||||
int OnInit()
|
||||
{
|
||||
//
|
||||
// Validate Inputs ...
|
||||
if (!ValidateInputs())
|
||||
{
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
// Initializing MA Handler ...
|
||||
maHandler = iAMA(
|
||||
_Symbol,
|
||||
_Period,
|
||||
length,
|
||||
fastEMA,
|
||||
slowEMA,
|
||||
maShift,
|
||||
appliedTo);
|
||||
if (maHandler == INVALID_HANDLE)
|
||||
{
|
||||
//
|
||||
return INIT_FAILED;
|
||||
}
|
||||
|
||||
//
|
||||
// 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
|
||||
|
||||
//
|
||||
// Here we can handle De Initialization Reasons ...
|
||||
IndicatorRelease(maHandler);
|
||||
}
|
||||
|
||||
//
|
||||
// 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[])
|
||||
{
|
||||
//
|
||||
// Prepare Buffers ...
|
||||
ArraySetAsSeries(time, true);
|
||||
ArraySetAsSeries(open, true);
|
||||
ArraySetAsSeries(high, true);
|
||||
ArraySetAsSeries(low, true);
|
||||
ArraySetAsSeries(close, true);
|
||||
ArraySetAsSeries(tick_volume, true);
|
||||
ArraySetAsSeries(volume, true);
|
||||
ArraySetAsSeries(spread, true);
|
||||
|
||||
//
|
||||
// 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 = MathMax(fastEMA, slowEMA);
|
||||
maxLength = MathMax(maxLength, length);
|
||||
|
||||
//
|
||||
// Check Calculated Bars ...
|
||||
int maCalculatedBars = BarsCalculated(maHandler);
|
||||
if (maCalculatedBars < maxLength)
|
||||
{
|
||||
return prev_calculated;
|
||||
}
|
||||
|
||||
//
|
||||
limit = (prev_calculated > rates_total || prev_calculated <= 0) ? rates_total : (rates_total - prev_calculated) + 1;
|
||||
|
||||
//
|
||||
// Buffers Copy ...
|
||||
int copiedMas = CopyBuffer(maHandler, 0, 0, limit, maBuffer);
|
||||
if (copiedMas <= 0)
|
||||
{
|
||||
return prev_calculated;
|
||||
}
|
||||
|
||||
//
|
||||
// Main Loop ...
|
||||
for (int i = limit - 1; i >= 0 && !IsStopped(); i--)
|
||||
{
|
||||
//
|
||||
// Do Buffers Calculation ...
|
||||
CalculateBuffers(i);
|
||||
}
|
||||
|
||||
//
|
||||
return rates_total;
|
||||
}
|
||||
//
|
||||
// END Event Handlers ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Functions ...
|
||||
//
|
||||
//
|
||||
// Validate Input Args for Initialization ...
|
||||
bool ValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Validate Args ...
|
||||
if (length >= 2)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Indexes and Styles ...
|
||||
void DefineBuffers()
|
||||
{
|
||||
//
|
||||
string maBufferLabel = "XAMA " + "(" + (string)length + ")";
|
||||
|
||||
//
|
||||
// Ma Buffer ...
|
||||
ArraySetAsSeries(maBuffer, true);
|
||||
SetIndexBuffer(maBufferIndex, maBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetString(maBufferIndex, PLOT_LABEL, maBufferLabel);
|
||||
|
||||
//
|
||||
// Ma Color Buffer ...
|
||||
ArraySetAsSeries(maColorBuffer, true);
|
||||
SetIndexBuffer(maColorBufferIndex, maColorBuffer, INDICATOR_COLOR_INDEX);
|
||||
|
||||
//
|
||||
// State Buffer ...
|
||||
ArraySetAsSeries(stateBuffer, true);
|
||||
SetIndexBuffer(stateBufferIndex, stateBuffer, INDICATOR_CALCULATIONS);
|
||||
}
|
||||
|
||||
//
|
||||
// Set Indicator Short Name and also we can define Buffers Labels ...
|
||||
void SetIndicatorName()
|
||||
{
|
||||
//
|
||||
string indicatorShortName = "";
|
||||
StringConcatenate(indicatorShortName, ShortName, " ", "(", length, ")");
|
||||
|
||||
//
|
||||
IndicatorSetString(INDICATOR_SHORTNAME, indicatorShortName);
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate Buffers ...
|
||||
void CalculateBuffers(int bar_index)
|
||||
{
|
||||
//
|
||||
// Requirements ...
|
||||
XOHCL candle;
|
||||
candle.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
bar_index);
|
||||
|
||||
//
|
||||
double maValue = maBuffer[bar_index];
|
||||
|
||||
//
|
||||
double lineColorIndex =
|
||||
maValue < candle.low ? 0 : maValue > candle.high ? 2
|
||||
: 1;
|
||||
|
||||
//
|
||||
// Define State Value ...
|
||||
// lineColorIndex == 0 => Bullish => 1;
|
||||
// lineColorIndex == 1 => Neutural => 0;
|
||||
// lineColorIndex == 2 => Bearish => -1;
|
||||
double stateValue =
|
||||
lineColorIndex == 0 ? X_XAMA_BULLISH : lineColorIndex == 2 ? X_XAMA_BEARISH
|
||||
: X_XAMA_NEUTURAL;
|
||||
|
||||
//
|
||||
// Set Ma Buffer Color Index ...
|
||||
maColorBuffer[bar_index] = showLine ? lineColorIndex : 3;
|
||||
|
||||
//
|
||||
// Set State Buffer Value ...
|
||||
stateBuffer[bar_index] = stateValue;
|
||||
}
|
||||
|
||||
//
|
||||
// END Functions ...
|
||||
//
|
||||
Binary file not shown.
@@ -0,0 +1,458 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Candle Styles
|
||||
// ---------------------------------------------------
|
||||
// Name: XCC
|
||||
// Description: Candle Styles ...
|
||||
//
|
||||
//
|
||||
// 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 XCC Indicator"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// START Constants ...
|
||||
//
|
||||
|
||||
//
|
||||
// Indicator Short Name ...
|
||||
#define ShortName "XCC"
|
||||
|
||||
//
|
||||
// Holds an SnapShot of Charts Configuration ...
|
||||
struct XChartStyle
|
||||
{
|
||||
//
|
||||
// chart's ID ...
|
||||
long chartId;
|
||||
//
|
||||
// chart's mode ...
|
||||
ENUM_CHART_MODE mode;
|
||||
//
|
||||
// show bid line ...
|
||||
bool showBidLine;
|
||||
//
|
||||
// show ask line ...
|
||||
bool showAskLine;
|
||||
//
|
||||
// show grids on chart ...
|
||||
bool showGrid;
|
||||
//
|
||||
// show volumes ...
|
||||
bool showVolumes;
|
||||
//
|
||||
// Displaying trade levels in the chart (levels of open positions, Stop Loss, Take Profit and pending orders) ...
|
||||
bool showTradeLevels;
|
||||
//
|
||||
// chart autoscroll ...
|
||||
bool autoScroll;
|
||||
//
|
||||
// chart quick navigation state ...
|
||||
bool quickNavigation;
|
||||
//
|
||||
// chart's foreground color ...
|
||||
color foreGroundColor;
|
||||
//
|
||||
// chart's background color ...
|
||||
color backGroundColor;
|
||||
//
|
||||
// Up Color ...
|
||||
color upColor;
|
||||
//
|
||||
// Down Color ...
|
||||
color downColor;
|
||||
//
|
||||
// Bullish color ...
|
||||
color bullishColor;
|
||||
//
|
||||
// Bearish color ...
|
||||
color bearishColor;
|
||||
//
|
||||
// grid color ...
|
||||
color gridColor;
|
||||
//
|
||||
// bid line color ...
|
||||
color bidLineColor;
|
||||
//
|
||||
// ask line color ...
|
||||
color askLineColor;
|
||||
//
|
||||
// line mode and doji candlestick color ...
|
||||
color lineColor;
|
||||
//
|
||||
// Color of stop order levels (Stop Loss and Take Profit) ...
|
||||
color stopColor;
|
||||
//
|
||||
// volumes color ...
|
||||
color volumesColor;
|
||||
};
|
||||
|
||||
//
|
||||
// END Constants ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
input group "Chart Style";
|
||||
input ENUM_CHART_MODE mode = CHART_CANDLES; // Mode
|
||||
input color upColor = clrLime; // Up Color
|
||||
input color downColor = clrRed; // Down Color
|
||||
input color lineColor = clrLime; // Line mode and Doji candlestick Color
|
||||
input color bearishColor = clrRed; // Bullish Color
|
||||
input color bullishColor = clrLime; // Bearish Color
|
||||
input color volumesColor = clrGreen; // Volumes Color
|
||||
|
||||
//
|
||||
input group "Presentation";
|
||||
input bool showCandles = true; // Show Candles
|
||||
|
||||
//
|
||||
// END Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Includes and Imports ...
|
||||
//
|
||||
|
||||
//
|
||||
// Includes Draw Library ...
|
||||
#include "../Libraries/x-saherelm.draw.lib.mq5"
|
||||
|
||||
//
|
||||
// Includes Common Library ...
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||
|
||||
//
|
||||
// END Includes and Imports ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Buffers ...
|
||||
//
|
||||
|
||||
//
|
||||
#property indicator_chart_window
|
||||
|
||||
//
|
||||
#property indicator_buffers 0
|
||||
#property indicator_plots 0
|
||||
|
||||
//
|
||||
// END Buffers ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
|
||||
//
|
||||
int maxLength;
|
||||
|
||||
//
|
||||
XChartStyle chartStyle;
|
||||
XChartStyle clearStyle;
|
||||
|
||||
//
|
||||
// END Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Event Handlers ...
|
||||
//
|
||||
|
||||
//
|
||||
// Initialization ...
|
||||
int OnInit()
|
||||
{
|
||||
//
|
||||
// Validate Inputs ...
|
||||
if (!ValidateInputs())
|
||||
{
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
drawPrefix = ShortName;
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
maxLength = ExtractMaxLengthOfInputs();
|
||||
|
||||
//
|
||||
// Define Index Buffers ...
|
||||
DefineBuffers();
|
||||
|
||||
//
|
||||
// Set Indicator ShortName ...
|
||||
SetIndicatorName();
|
||||
|
||||
//
|
||||
// Apply Chart Style ...
|
||||
ApplyCustomChartStyle();
|
||||
|
||||
//
|
||||
// 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
|
||||
}
|
||||
|
||||
//
|
||||
// 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[]
|
||||
//
|
||||
)
|
||||
{
|
||||
//
|
||||
// Prepare Buffers ...
|
||||
ArraySetAsSeries(time, true);
|
||||
ArraySetAsSeries(open, true);
|
||||
ArraySetAsSeries(high, true);
|
||||
ArraySetAsSeries(low, true);
|
||||
ArraySetAsSeries(close, true);
|
||||
ArraySetAsSeries(tick_volume, true);
|
||||
ArraySetAsSeries(volume, true);
|
||||
ArraySetAsSeries(spread, true);
|
||||
|
||||
//
|
||||
// this counts Available Bars ...
|
||||
int limit;
|
||||
|
||||
//
|
||||
limit = (prev_calculated > rates_total || prev_calculated <= 0) ? rates_total : (rates_total - prev_calculated) + 1;
|
||||
|
||||
//
|
||||
// Main Loop ...
|
||||
for (int i = limit - 1; i >= 0 && !IsStopped(); i--)
|
||||
{
|
||||
CalculateBuffers(i);
|
||||
}
|
||||
|
||||
//
|
||||
return rates_total;
|
||||
}
|
||||
|
||||
//
|
||||
// END Event Handlers ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Functions ...
|
||||
//
|
||||
|
||||
//
|
||||
// Validate Input Args for Initialization ...
|
||||
bool ValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = true;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve all Exists Input Max Length ...
|
||||
// use for Start Of Drawing ...
|
||||
int ExtractMaxLengthOfInputs()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Indexes and Styles ...
|
||||
void DefineBuffers()
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Set Indicator Short Name and also we can define Buffers Labels ...
|
||||
void SetIndicatorName()
|
||||
{
|
||||
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate Buffers ...
|
||||
void CalculateBuffers(
|
||||
int bar_index // Selected Bar Index
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
//
|
||||
// Apply Custom Chart Style ...
|
||||
void ApplyCustomChartStyle()
|
||||
{
|
||||
//
|
||||
// Read Current Chart Config and Store it ...
|
||||
ReadChartStyle();
|
||||
|
||||
//
|
||||
// After Reading Current Chart Style ...
|
||||
// we have to Save Configs and Change Styles ...
|
||||
clearStyle = chartStyle;
|
||||
|
||||
//
|
||||
clearStyle.upColor = CLR_NONE;
|
||||
clearStyle.downColor = CLR_NONE;
|
||||
clearStyle.lineColor = CLR_NONE;
|
||||
clearStyle.bullishColor = CLR_NONE;
|
||||
clearStyle.bearishColor = CLR_NONE;
|
||||
|
||||
//
|
||||
// Decide to Show or not Candles based on User Input ...
|
||||
if (showCandles)
|
||||
{
|
||||
SetChartStyle(chartStyle);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetChartStyle(clearStyle);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Read Previous Chart Style ...
|
||||
void ReadChartStyle()
|
||||
{
|
||||
//
|
||||
// Retrieve Current Chart ID ...
|
||||
long chartId = ChartID();
|
||||
chartStyle.chartId = chartId;
|
||||
|
||||
//
|
||||
// Retrieve Chart Mode ...
|
||||
chartStyle.mode = (ENUM_CHART_MODE)ChartGetInteger(chartId, CHART_MODE);
|
||||
|
||||
//
|
||||
chartStyle.showBidLine = (bool)ChartGetInteger(chartId, CHART_SHOW_BID_LINE);
|
||||
chartStyle.showAskLine = (bool)ChartGetInteger(chartId, CHART_SHOW_ASK_LINE);
|
||||
chartStyle.showGrid = (bool)ChartGetInteger(chartId, CHART_SHOW_GRID);
|
||||
chartStyle.showVolumes = (bool)ChartGetInteger(chartId, CHART_SHOW_VOLUMES);
|
||||
chartStyle.showTradeLevels = (bool)ChartGetInteger(chartId, CHART_SHOW_TRADE_LEVELS);
|
||||
chartStyle.autoScroll = (bool)ChartGetInteger(chartId, CHART_AUTOSCROLL);
|
||||
chartStyle.quickNavigation = (bool)ChartGetInteger(chartId, CHART_QUICK_NAVIGATION);
|
||||
|
||||
//
|
||||
chartStyle.foreGroundColor = (color)ChartGetInteger(chartId, CHART_COLOR_FOREGROUND);
|
||||
chartStyle.backGroundColor = (color)ChartGetInteger(chartId, CHART_COLOR_BACKGROUND);
|
||||
chartStyle.upColor = (color)ChartGetInteger(chartId, CHART_COLOR_CHART_UP);
|
||||
chartStyle.downColor = (color)ChartGetInteger(chartId, CHART_COLOR_CHART_DOWN);
|
||||
chartStyle.bullishColor = (color)ChartGetInteger(chartId, CHART_COLOR_CANDLE_BULL);
|
||||
chartStyle.bearishColor = (color)ChartGetInteger(chartId, CHART_COLOR_CANDLE_BEAR);
|
||||
chartStyle.gridColor = (color)ChartGetInteger(chartId, CHART_COLOR_GRID);
|
||||
chartStyle.bidLineColor = (color)ChartGetInteger(chartId, CHART_COLOR_BID);
|
||||
chartStyle.askLineColor = (color)ChartGetInteger(chartId, CHART_COLOR_ASK);
|
||||
chartStyle.stopColor = (color)ChartGetInteger(chartId, CHART_COLOR_STOP_LEVEL);
|
||||
chartStyle.lineColor = (color)ChartGetInteger(chartId, CHART_COLOR_CHART_LINE);
|
||||
chartStyle.volumesColor = (color)ChartGetInteger(chartId, CHART_COLOR_VOLUME);
|
||||
|
||||
//
|
||||
chartStyle.mode = mode;
|
||||
chartStyle.upColor = upColor;
|
||||
chartStyle.downColor = downColor;
|
||||
chartStyle.lineColor = lineColor;
|
||||
chartStyle.bearishColor = bearishColor;
|
||||
chartStyle.bullishColor = bullishColor;
|
||||
chartStyle.volumesColor = volumesColor;
|
||||
}
|
||||
|
||||
//
|
||||
// Set Chart Style ...
|
||||
void SetChartStyle(
|
||||
XChartStyle &mChartStyle // Chart Style to Apply
|
||||
)
|
||||
{
|
||||
//
|
||||
ApplyChartStyle(
|
||||
mChartStyle.chartId,
|
||||
mChartStyle.mode,
|
||||
mChartStyle.showBidLine,
|
||||
mChartStyle.showAskLine,
|
||||
mChartStyle.showGrid,
|
||||
mChartStyle.showVolumes,
|
||||
mChartStyle.showTradeLevels,
|
||||
mChartStyle.autoScroll,
|
||||
mChartStyle.quickNavigation,
|
||||
mChartStyle.foreGroundColor,
|
||||
mChartStyle.backGroundColor,
|
||||
mChartStyle.upColor,
|
||||
mChartStyle.downColor,
|
||||
mChartStyle.bullishColor,
|
||||
mChartStyle.bearishColor,
|
||||
mChartStyle.gridColor,
|
||||
mChartStyle.bidLineColor,
|
||||
mChartStyle.askLineColor,
|
||||
mChartStyle.lineColor,
|
||||
mChartStyle.stopColor,
|
||||
mChartStyle.volumesColor);
|
||||
}
|
||||
|
||||
//
|
||||
// END Functions ...
|
||||
//
|
||||
Binary file not shown.
@@ -0,0 +1,631 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Indicator
|
||||
// ---------------------------------------------
|
||||
// Name: XCHE
|
||||
// Description: Chandelier Exit 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 XCHE Indicator"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// START Constants ...
|
||||
//
|
||||
|
||||
//
|
||||
#define ShortName "XCHE"
|
||||
|
||||
//
|
||||
// END Constants ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
input group "Market";
|
||||
input int length = 35; // Length
|
||||
input int loopback = 26; // Loopback
|
||||
input double multiplier1 = 3.0; // 1st Multiplier
|
||||
input double multiplier2 = 3.5; // 2nd Multiplier
|
||||
|
||||
//
|
||||
input group "Calculation";
|
||||
input ENUM_APPLIED_PRICE upAppliedTo = PRICE_HIGH; // Up Zone Applied to
|
||||
input ENUM_APPLIED_PRICE downAppliedTo = PRICE_LOW; // Down Zone Applied to
|
||||
|
||||
//
|
||||
input group "Presentation";
|
||||
input bool showLongExit1Line = true; // Show 1st Long Exit
|
||||
input bool showShortExit1Line = true; // Show 1st Short Exit
|
||||
input bool showLongExit2Line = true; // Show 2st Long Exit
|
||||
input bool showShortExit2Line = true; // Show 2st Short Exit
|
||||
|
||||
//
|
||||
// END Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Includes and Imports ...
|
||||
//
|
||||
|
||||
//
|
||||
// Includes Common Library ...
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||
|
||||
//
|
||||
// END Includes and Imports ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Buffers ...
|
||||
//
|
||||
|
||||
//
|
||||
#property indicator_chart_window
|
||||
|
||||
//
|
||||
#property indicator_buffers 8
|
||||
#property indicator_plots 8
|
||||
|
||||
//
|
||||
// Long Exit 1 ...
|
||||
#define longExit1BufferIndex 0
|
||||
double longExit1Buffer[];
|
||||
|
||||
//
|
||||
#property indicator_label1 "XCHE LE 1"
|
||||
#property indicator_type1 DRAW_LINE
|
||||
#property indicator_color1 clrLime
|
||||
#property indicator_style1 STYLE_DOT
|
||||
|
||||
//
|
||||
// Short Exit 1 ...
|
||||
#define shortExit1BufferIndex 1
|
||||
double shortExit1Buffer[];
|
||||
|
||||
//
|
||||
#property indicator_label2 "XCHE SE 1"
|
||||
#property indicator_type2 DRAW_LINE
|
||||
#property indicator_style2 STYLE_DOT
|
||||
#property indicator_color2 clrRed
|
||||
|
||||
//
|
||||
// Long Exit 2 ...
|
||||
#define longExit2BufferIndex 2
|
||||
double longExit2Buffer[];
|
||||
|
||||
//
|
||||
#property indicator_label3 "XCHE LE 2"
|
||||
#property indicator_type3 DRAW_LINE
|
||||
#property indicator_style2 STYLE_DOT
|
||||
#property indicator_color3 clrAqua
|
||||
|
||||
//
|
||||
// Short Exit 2 ...
|
||||
#define shortExit2BufferIndex 3
|
||||
double shortExit2Buffer[];
|
||||
|
||||
//
|
||||
#property indicator_label4 "XCHE SE 2"
|
||||
#property indicator_type4 DRAW_LINE
|
||||
#property indicator_style2 STYLE_DOT
|
||||
#property indicator_color4 clrMagenta
|
||||
|
||||
//
|
||||
// START Arrows ...
|
||||
|
||||
//
|
||||
// Long Exit 1 Start ...
|
||||
#define longExit1StartBufferIndex 4
|
||||
double longExit1StartBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label5 "XCHE LES 1"
|
||||
#property indicator_type5 DRAW_ARROW
|
||||
#property indicator_color5 clrLime
|
||||
|
||||
//
|
||||
// Short Exit 1 Start ...
|
||||
#define shortExit1StartBufferIndex 5
|
||||
double shortExit1StartBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label6 "XCHE SES 1"
|
||||
#property indicator_type6 DRAW_ARROW
|
||||
#property indicator_color6 clrRed
|
||||
|
||||
//
|
||||
// Long Exit 2 Start ...
|
||||
#define longExit2StartBufferIndex 6
|
||||
double longExit2StartBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label7 "XCHE LES 2"
|
||||
#property indicator_type7 DRAW_ARROW
|
||||
#property indicator_color7 clrAqua
|
||||
|
||||
//
|
||||
// Short Exit 2 Start ...
|
||||
#define shortExit2StartBufferIndex 7
|
||||
double shortExit2StartBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label8 "XCHE SES 2"
|
||||
#property indicator_type8 DRAW_ARROW
|
||||
#property indicator_color8 clrMagenta
|
||||
|
||||
//
|
||||
// END Buffers ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
|
||||
//
|
||||
int maxLength;
|
||||
|
||||
//
|
||||
// Working Array ...
|
||||
double work[][6];
|
||||
#define hi1Idx 0
|
||||
#define lo1Idx 1
|
||||
#define hi2Idx 2
|
||||
#define lo2Idx 3
|
||||
#define trend1Idx 4
|
||||
#define trend2Idx 5
|
||||
|
||||
//
|
||||
// END Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Event Handlers ...
|
||||
//
|
||||
|
||||
//
|
||||
// Initialization ...
|
||||
int OnInit()
|
||||
{
|
||||
//
|
||||
// Validate Inputs ...
|
||||
if (!ValidateInputs())
|
||||
{
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
maxLength = ExtractMaxLengthOfInputs();
|
||||
|
||||
//
|
||||
// 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 mPeriod 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
|
||||
}
|
||||
|
||||
//
|
||||
// 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[])
|
||||
{
|
||||
//
|
||||
if (Bars(_Symbol, _Period) < rates_total)
|
||||
{
|
||||
return (prev_calculated);
|
||||
}
|
||||
|
||||
//
|
||||
if (ArrayRange(work, 0) != rates_total)
|
||||
{
|
||||
ArrayResize(work, rates_total);
|
||||
}
|
||||
|
||||
//
|
||||
// this counts Available Bars ...
|
||||
int limit;
|
||||
|
||||
//
|
||||
limit = prev_calculated - 1;
|
||||
if (limit < 0)
|
||||
{
|
||||
limit = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// Main Loop ...
|
||||
for (int i = limit; i < rates_total && !IsStopped(); i++)
|
||||
{
|
||||
CalculateBuffers(
|
||||
i,
|
||||
prev_calculated,
|
||||
rates_total,
|
||||
//
|
||||
open,
|
||||
high,
|
||||
low,
|
||||
close);
|
||||
}
|
||||
|
||||
//
|
||||
return rates_total;
|
||||
}
|
||||
//
|
||||
// END Event Handlers ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Functions ...
|
||||
//
|
||||
|
||||
//
|
||||
// Validate Input Args for Initialization ...
|
||||
bool ValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = true;
|
||||
|
||||
//
|
||||
result =
|
||||
length >= 9 &&
|
||||
loopback >= 0;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Retrieve all Exists Input Max Length ...
|
||||
// use for Start Of Drawing ...
|
||||
int ExtractMaxLengthOfInputs()
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
result = MathMax(length, loopback);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Set Indicator Short Name and also we can define Buffers Labels ...
|
||||
void SetIndicatorName()
|
||||
{
|
||||
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
|
||||
}
|
||||
|
||||
//
|
||||
// Define Indexes and Styles ...
|
||||
void DefineBuffers()
|
||||
{
|
||||
//
|
||||
uint arrowCode = 159;
|
||||
|
||||
//
|
||||
// LEVEL 1 ...
|
||||
|
||||
//
|
||||
// Long Exit 1 ...
|
||||
|
||||
//
|
||||
// Draw Type ...
|
||||
ENUM_DRAW_TYPE longExit1DrawType = showLongExit1Line ? DRAW_LINE : DRAW_NONE;
|
||||
ENUM_DRAW_TYPE longExit1StartDrawType = showLongExit1Line ? DRAW_ARROW : DRAW_NONE;
|
||||
|
||||
//
|
||||
// Buffer ...
|
||||
SetIndexBuffer(longExit1BufferIndex, longExit1Buffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(longExit1BufferIndex, PLOT_SHOW_DATA, showLongExit1Line);
|
||||
PlotIndexSetInteger(longExit1BufferIndex, PLOT_DRAW_TYPE, longExit1DrawType);
|
||||
|
||||
//
|
||||
// Start Buffer ...
|
||||
SetIndexBuffer(longExit1StartBufferIndex, longExit1StartBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(longExit1StartBufferIndex, PLOT_ARROW, arrowCode);
|
||||
PlotIndexSetInteger(longExit1StartBufferIndex, PLOT_SHOW_DATA, false);
|
||||
PlotIndexSetInteger(longExit1StartBufferIndex, PLOT_DRAW_TYPE, longExit1StartDrawType);
|
||||
|
||||
//
|
||||
// Short Exit 1 ...
|
||||
|
||||
//
|
||||
// Draw Type ...
|
||||
ENUM_DRAW_TYPE shortExit1DrawType = showShortExit1Line ? DRAW_LINE : DRAW_NONE;
|
||||
ENUM_DRAW_TYPE shortExit1StartDrawType = showShortExit1Line ? DRAW_ARROW : DRAW_NONE;
|
||||
|
||||
//
|
||||
// Buffer ...
|
||||
SetIndexBuffer(shortExit1BufferIndex, shortExit1Buffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(shortExit1BufferIndex, PLOT_SHOW_DATA, showShortExit1Line);
|
||||
PlotIndexSetInteger(shortExit1BufferIndex, PLOT_DRAW_TYPE, shortExit1DrawType);
|
||||
|
||||
//
|
||||
// Start Buffer ...
|
||||
SetIndexBuffer(shortExit1StartBufferIndex, shortExit1StartBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(shortExit1StartBufferIndex, PLOT_ARROW, arrowCode);
|
||||
PlotIndexSetInteger(shortExit1StartBufferIndex, PLOT_SHOW_DATA, false);
|
||||
PlotIndexSetInteger(shortExit1StartBufferIndex, PLOT_DRAW_TYPE, shortExit1StartDrawType);
|
||||
|
||||
//
|
||||
// LEVEL 2 ...
|
||||
|
||||
//
|
||||
// Long Exit 2 ...
|
||||
|
||||
//
|
||||
// Draw Type ...
|
||||
ENUM_DRAW_TYPE longExit2DrawType = showLongExit2Line ? DRAW_LINE : DRAW_NONE;
|
||||
ENUM_DRAW_TYPE longExit2StartDrawType = showLongExit2Line ? DRAW_ARROW : DRAW_NONE;
|
||||
|
||||
//
|
||||
// Buffer ...
|
||||
SetIndexBuffer(longExit2BufferIndex, longExit2Buffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(longExit2BufferIndex, PLOT_SHOW_DATA, showLongExit2Line);
|
||||
PlotIndexSetInteger(longExit2BufferIndex, PLOT_DRAW_TYPE, longExit2DrawType);
|
||||
|
||||
//
|
||||
// Start Buffer ...
|
||||
SetIndexBuffer(longExit2StartBufferIndex, longExit2StartBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(longExit2StartBufferIndex, PLOT_ARROW, arrowCode);
|
||||
PlotIndexSetInteger(longExit2StartBufferIndex, PLOT_SHOW_DATA, false);
|
||||
PlotIndexSetInteger(longExit2StartBufferIndex, PLOT_DRAW_TYPE, longExit2StartDrawType);
|
||||
|
||||
//
|
||||
// Short Exit 2 ...
|
||||
|
||||
//
|
||||
// Draw Type ...
|
||||
ENUM_DRAW_TYPE shortExit2DrawType = showShortExit2Line ? DRAW_LINE : DRAW_NONE;
|
||||
ENUM_DRAW_TYPE shortExit2StartDrawType = showShortExit2Line ? DRAW_ARROW : DRAW_NONE;
|
||||
|
||||
//
|
||||
// Buffer ...
|
||||
SetIndexBuffer(shortExit2BufferIndex, shortExit2Buffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(shortExit2BufferIndex, PLOT_SHOW_DATA, showShortExit2Line);
|
||||
PlotIndexSetInteger(shortExit2BufferIndex, PLOT_DRAW_TYPE, shortExit2DrawType);
|
||||
|
||||
//
|
||||
// Start Buffer ...
|
||||
SetIndexBuffer(shortExit2StartBufferIndex, shortExit2StartBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(shortExit2StartBufferIndex, PLOT_ARROW, arrowCode);
|
||||
PlotIndexSetInteger(shortExit2StartBufferIndex, PLOT_SHOW_DATA, false);
|
||||
PlotIndexSetInteger(shortExit2StartBufferIndex, PLOT_DRAW_TYPE, shortExit2StartDrawType);
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate Buffers ...
|
||||
void CalculateBuffers(
|
||||
int bar_index, // Selected Bar Index
|
||||
int prevCalculated, // Previous Calculated
|
||||
int ratesTotal, // Total Rates
|
||||
const double &open[], // Rates Open ...
|
||||
const double &high[], // Rates High ...
|
||||
const double &low[], // Rates Low ...
|
||||
const double &close[] // Rates Close ...
|
||||
)
|
||||
{
|
||||
//
|
||||
// Cleanup Buffers ...
|
||||
longExit1Buffer[bar_index] = longExit1StartBuffer[bar_index] = shortExit1Buffer[bar_index] = shortExit1StartBuffer[bar_index] = EMPTY_VALUE;
|
||||
longExit2Buffer[bar_index] = longExit2StartBuffer[bar_index] = shortExit2Buffer[bar_index] = shortExit2StartBuffer[bar_index] = EMPTY_VALUE;
|
||||
|
||||
//
|
||||
int start = MathMax(bar_index - loopback, 0);
|
||||
|
||||
//
|
||||
// Calculate ATR Value ...
|
||||
double atrValue = 0;
|
||||
for (int k = 1; k <= length && (bar_index - k - 1) >= 0; k++)
|
||||
{
|
||||
//
|
||||
atrValue += MathMax(high[bar_index - k], close[MathMax(bar_index - k - 1, 0)]) -
|
||||
MathMin(low[bar_index - k], close[MathMax(bar_index - k - 1, 0)]);
|
||||
}
|
||||
atrValue /= (double)length;
|
||||
|
||||
//
|
||||
// Retrieve Highest High and Lowest Lows ...
|
||||
double loopbackMax = high[ArrayMaximum(high, start, loopback)];
|
||||
double loopbackMin = low[ArrayMinimum(low, start, loopback)];
|
||||
|
||||
//
|
||||
// Fill Multi Dimesional Working Array ...
|
||||
work[bar_index][hi1Idx] = loopbackMax - multiplier1 * atrValue;
|
||||
work[bar_index][lo1Idx] = loopbackMin + multiplier1 * atrValue;
|
||||
work[bar_index][hi2Idx] = loopbackMax - multiplier2 * atrValue;
|
||||
work[bar_index][lo2Idx] = loopbackMin + multiplier2 * atrValue;
|
||||
work[bar_index][trend1Idx] = (bar_index > 0) ? work[bar_index - 1][trend1Idx] : 0;
|
||||
work[bar_index][trend2Idx] = (bar_index > 0) ? work[bar_index - 1][trend2Idx] : 0;
|
||||
|
||||
//
|
||||
if (bar_index > 0)
|
||||
{
|
||||
//
|
||||
// Calculate Trends ...
|
||||
if (close[bar_index] > work[bar_index - 1][lo1Idx])
|
||||
{
|
||||
work[bar_index][trend1Idx] = 1;
|
||||
}
|
||||
|
||||
//
|
||||
if (close[bar_index] < work[bar_index - 1][hi1Idx])
|
||||
{
|
||||
work[bar_index][trend1Idx] = -1;
|
||||
}
|
||||
|
||||
//
|
||||
if (close[bar_index] > work[bar_index - 1][lo2Idx])
|
||||
{
|
||||
work[bar_index][trend2Idx] = 1;
|
||||
}
|
||||
|
||||
//
|
||||
if (close[bar_index] < work[bar_index - 1][hi2Idx])
|
||||
{
|
||||
work[bar_index][trend2Idx] = -1;
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate Exit Values ...
|
||||
|
||||
//
|
||||
// Exit 1 ...
|
||||
|
||||
//
|
||||
// Long ...
|
||||
if (multiplier1 > 0 && work[bar_index][trend1Idx] == 1)
|
||||
{
|
||||
//
|
||||
if (work[bar_index][hi1Idx] < work[bar_index - 1][hi1Idx])
|
||||
{
|
||||
work[bar_index][hi1Idx] = work[bar_index - 1][hi1Idx];
|
||||
}
|
||||
|
||||
//
|
||||
longExit1Buffer[bar_index] = work[bar_index][hi1Idx];
|
||||
|
||||
//
|
||||
if (longExit1Buffer[bar_index - 1] == EMPTY_VALUE)
|
||||
{
|
||||
longExit1StartBuffer[bar_index] = longExit1Buffer[bar_index];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Short ...
|
||||
if (multiplier1 > 0 && work[bar_index][trend1Idx] == -1)
|
||||
{
|
||||
//
|
||||
if (work[bar_index][lo1Idx] > work[bar_index - 1][lo1Idx])
|
||||
{
|
||||
work[bar_index][lo1Idx] = work[bar_index - 1][lo1Idx];
|
||||
}
|
||||
|
||||
//
|
||||
shortExit1Buffer[bar_index] = work[bar_index][lo1Idx];
|
||||
|
||||
//
|
||||
if (shortExit1Buffer[bar_index - 1] == EMPTY_VALUE)
|
||||
{
|
||||
shortExit1StartBuffer[bar_index] = shortExit1Buffer[bar_index];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Exit 2 ...
|
||||
|
||||
//
|
||||
// Long ...
|
||||
if (multiplier2 > 0 && work[bar_index][trend2Idx] == 1)
|
||||
{
|
||||
if (work[bar_index][hi2Idx] < work[bar_index - 1][hi2Idx])
|
||||
{
|
||||
work[bar_index][hi2Idx] = work[bar_index - 1][hi2Idx];
|
||||
}
|
||||
|
||||
//
|
||||
longExit2Buffer[bar_index] = work[bar_index][hi2Idx];
|
||||
|
||||
//
|
||||
if (longExit2Buffer[bar_index - 1] == EMPTY_VALUE)
|
||||
{
|
||||
longExit2StartBuffer[bar_index] = longExit2Buffer[bar_index];
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Short ...
|
||||
if (multiplier2 > 0 && work[bar_index][trend2Idx] == -1)
|
||||
{
|
||||
//
|
||||
if (work[bar_index][lo2Idx] > work[bar_index - 1][lo2Idx])
|
||||
{
|
||||
work[bar_index][lo2Idx] = work[bar_index - 1][lo2Idx];
|
||||
}
|
||||
|
||||
//
|
||||
shortExit2Buffer[bar_index] = work[bar_index][lo2Idx];
|
||||
|
||||
//
|
||||
if (shortExit2Buffer[bar_index - 1] == EMPTY_VALUE)
|
||||
{
|
||||
shortExit2StartBuffer[bar_index] = shortExit2Buffer[bar_index];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// END Functions ...
|
||||
//
|
||||
Binary file not shown.
@@ -0,0 +1,808 @@
|
||||
//////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Cycle Channel LH Oscillator
|
||||
// ---------------------------------------------------
|
||||
// Name: XCHLH
|
||||
// Description: detecting HH and LL based on cycles ...
|
||||
//
|
||||
//
|
||||
// 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 XCHLH Oscillator"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// START Constants ...
|
||||
//
|
||||
#define ShortName "XCHLH"
|
||||
|
||||
//
|
||||
// XCHLH Hot States ...
|
||||
enum ENUM_X_XCHLH_HOT_STATES
|
||||
{
|
||||
X_XCHLH_HOT_HH = 1,
|
||||
X_XCHLH_NEUTURAL = 0,
|
||||
X_XCHLH_HOT_LL = -1,
|
||||
};
|
||||
|
||||
//
|
||||
// END Constants ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
// Common ...
|
||||
input group "Hot Areas";
|
||||
input bool drawHotAreas = true; // Draw Hot Areas Symbol
|
||||
input uchar hotHHArrowCode = 234; // Hot HH Arrow Code
|
||||
input color hotHHArrowColor = clrAqua; // Hot HH Arrow Color
|
||||
input uchar hotLLArrowCode = 233; // Hot LL Arrow Code
|
||||
input color hotLLArrowColor = clrFuchsia; // Hot LL Arrow Color
|
||||
|
||||
//
|
||||
// LC Inputs ...
|
||||
input group "Long Cycle";
|
||||
input group "LC Market";
|
||||
input int lcLength = 28; // Length
|
||||
input double lcThresholdInPips = 0.3; // Threshold In Pips
|
||||
input ENUM_SERIESMODE lcHHMode = MODE_HIGH; // Highest High Calculation Method
|
||||
input ENUM_SERIESMODE lcLLMode = MODE_LOW; // Lowest Low Calculation Method
|
||||
input group "LC Style";
|
||||
input int lcDrawWidth = 1; // Draw Width
|
||||
input ENUM_DRAW_TYPE lcDrawType = DRAW_LINE; // Draw Type
|
||||
input ENUM_LINE_STYLE lcDrawStyle = STYLE_DOT; // Draw Style
|
||||
input color lcHHColor = clrAqua; // Highest High Color
|
||||
input color lcLLColor = clrFuchsia; // Lowest Low Color
|
||||
input group "LC Drawings";
|
||||
input bool lcDrawHH = true; // Draw Highest High
|
||||
input bool lcDrawLL = true; // Draw Lowest Low
|
||||
|
||||
//
|
||||
// MC Inputs ...
|
||||
input group "Medium Cycle";
|
||||
input group "MC Market";
|
||||
input int mcLength = 14; // Length
|
||||
input double mcThresholdInPips = 0.3; // Threshold In Pips
|
||||
input ENUM_SERIESMODE mcHHMode = MODE_HIGH; // Highest High Calculation Method
|
||||
input ENUM_SERIESMODE mcLLMode = MODE_LOW; // Lowest Low Calculation Method
|
||||
input group "MC Style";
|
||||
input int mcDrawWidth = 1; // Draw Width
|
||||
input ENUM_DRAW_TYPE mcDrawType = DRAW_LINE; // Draw Type
|
||||
input ENUM_LINE_STYLE mcDrawStyle = STYLE_DOT; // Draw Style
|
||||
input color mcHHColor = clrLime; // Highest High Color
|
||||
input color mcLLColor = clrRed; // Lowest Low Color
|
||||
input group "MC Drawings";
|
||||
input bool mcDrawHH = true; // Draw Highest High
|
||||
input bool mcDrawLL = true; // Draw Lowest Low
|
||||
|
||||
//
|
||||
// SC Inputs ...
|
||||
input group "Short Cycle";
|
||||
input group "SC Market";
|
||||
input int scLength = 7; // Length
|
||||
input double scThresholdInPips = 0.3; // Threshold In Pips
|
||||
input ENUM_SERIESMODE scHHMode = MODE_HIGH; // Highest High Calculation Method
|
||||
input ENUM_SERIESMODE scLLMode = MODE_LOW; // Lowest Low Calculation Method
|
||||
input group "SC Style";
|
||||
input int scDrawWidth = 1; // Draw Width
|
||||
input ENUM_DRAW_TYPE scDrawType = DRAW_LINE; // Draw Type
|
||||
input ENUM_LINE_STYLE scDrawStyle = STYLE_DOT; // Draw Style
|
||||
input color scHHColor = clrLightBlue; // Highest High Color
|
||||
input color scLLColor = clrLightSalmon; // Lowest Low Color
|
||||
input group "SC Drawings";
|
||||
input bool scDrawHH = true; // Draw Highest High
|
||||
input bool scDrawLL = true; // Draw Lowest Low
|
||||
//
|
||||
// END Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
// Includes Common Library ...
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5";
|
||||
|
||||
//
|
||||
// Includes Draw Library ...
|
||||
#include "../Libraries/x-saherelm.draw.lib.mq5";
|
||||
|
||||
//
|
||||
// START Buffers ...
|
||||
//
|
||||
#property indicator_separate_window
|
||||
|
||||
//
|
||||
#property indicator_buffers 7
|
||||
#property indicator_plots 6
|
||||
|
||||
//
|
||||
// LC ...
|
||||
#define lcHHBufferIndex 0
|
||||
#define lcLLBufferIndex 1
|
||||
|
||||
//
|
||||
double lcHHBuffer[];
|
||||
double lcLLBuffer[];
|
||||
|
||||
//
|
||||
// MC ...
|
||||
#define mcHHBufferIndex 2
|
||||
#define mcLLBufferIndex 3
|
||||
|
||||
//
|
||||
double mcHHBuffer[];
|
||||
double mcLLBuffer[];
|
||||
|
||||
//
|
||||
// SC ...
|
||||
#define scHHBufferIndex 4
|
||||
#define scLLBufferIndex 5
|
||||
|
||||
//
|
||||
double scHHBuffer[];
|
||||
double scLLBuffer[];
|
||||
|
||||
//
|
||||
// Hot State ...
|
||||
//
|
||||
#define hotStateBufferIndex 6
|
||||
|
||||
//
|
||||
double hotStateBuffer[];
|
||||
//
|
||||
// END Buffers ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
//
|
||||
// END Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Event Handlers ...
|
||||
//
|
||||
//
|
||||
// Initialization ...
|
||||
int OnInit()
|
||||
{
|
||||
//
|
||||
// Validate Inputs ...
|
||||
if (!ValidateInputs())
|
||||
{
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
drawPrefix = ShortName;
|
||||
|
||||
//
|
||||
// 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
|
||||
|
||||
//
|
||||
// Here we can handle De Initialization Reasons ...
|
||||
|
||||
//
|
||||
// ReDraw Chart ...
|
||||
ChartRedraw();
|
||||
|
||||
//
|
||||
Comment("");
|
||||
}
|
||||
|
||||
//
|
||||
// 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[])
|
||||
{
|
||||
//
|
||||
// Prepare Buffers ...
|
||||
ArraySetAsSeries(time, true);
|
||||
ArraySetAsSeries(open, true);
|
||||
ArraySetAsSeries(high, true);
|
||||
ArraySetAsSeries(low, true);
|
||||
ArraySetAsSeries(close, true);
|
||||
ArraySetAsSeries(tick_volume, true);
|
||||
ArraySetAsSeries(volume, true);
|
||||
ArraySetAsSeries(spread, true);
|
||||
|
||||
//
|
||||
// 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 = MathMax(lcLength, mcLength);
|
||||
maxLength = MathMax(maxLength, scLength);
|
||||
|
||||
//
|
||||
limit = prev_calculated < maxLength ? rates_total - (maxLength + 1) : rates_total - prev_calculated;
|
||||
|
||||
//
|
||||
// Main Loop ...
|
||||
for (int i = limit; i >= 0 && !IsStopped(); i--)
|
||||
{
|
||||
//
|
||||
CalculateBuffers(i);
|
||||
}
|
||||
|
||||
//
|
||||
return rates_total;
|
||||
}
|
||||
//
|
||||
// END Event Handlers ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Functions ...
|
||||
//
|
||||
//
|
||||
// Validate Input Args for Initialization ...
|
||||
bool ValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Validate Args ...
|
||||
bool isLCInputsValid =
|
||||
lcLength >= 4 &&
|
||||
lcLength > mcLength &&
|
||||
lcLength > scLength;
|
||||
bool isMCInputsValid =
|
||||
mcLength >= 4 &&
|
||||
mcLength > scLength &&
|
||||
mcLength < lcLength;
|
||||
bool isSCInputsValid =
|
||||
scLength >= 4 &&
|
||||
scLength < mcLength &&
|
||||
scLength < lcLength;
|
||||
if (
|
||||
isLCInputsValid &&
|
||||
isMCInputsValid &&
|
||||
isSCInputsValid)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Indexes and Styles ...
|
||||
void DefineBuffers()
|
||||
{
|
||||
//
|
||||
// LC ...
|
||||
LCDefineBuffers();
|
||||
|
||||
//
|
||||
// MC ...
|
||||
MCDefineBuffers();
|
||||
|
||||
//
|
||||
// SC ...
|
||||
SCDefineBuffers();
|
||||
|
||||
//
|
||||
// Hot State Buffer ...
|
||||
HotStateDefineBuffers();
|
||||
}
|
||||
|
||||
//
|
||||
// Set Indicator Short Name and also we can define Buffers Labels ...
|
||||
void SetIndicatorName()
|
||||
{
|
||||
//
|
||||
string indicatorShortName = "";
|
||||
StringConcatenate(indicatorShortName, ShortName, "");
|
||||
|
||||
//
|
||||
IndicatorSetString(INDICATOR_SHORTNAME, indicatorShortName);
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate Buffers ...
|
||||
void CalculateBuffers(
|
||||
int bar_index // Current Candle Index ...
|
||||
)
|
||||
{
|
||||
//
|
||||
// LC ...
|
||||
LCCalculateBuffers(bar_index);
|
||||
|
||||
//
|
||||
// MC ...
|
||||
MCCalculateBuffers(bar_index);
|
||||
|
||||
//
|
||||
// SC ...
|
||||
SCCalculateBuffers(bar_index);
|
||||
|
||||
//
|
||||
// SIGNAL ...
|
||||
SignalCalculateBuffers(bar_index);
|
||||
|
||||
//
|
||||
// HOT State Buffer ...
|
||||
HotStateCalculateBuffers(bar_index);
|
||||
|
||||
//
|
||||
// After all Calculations we are ready to Draw what we want ...
|
||||
DrawBuffers(bar_index);
|
||||
}
|
||||
|
||||
//
|
||||
// LC Buffers Definitions ...
|
||||
void LCDefineBuffers()
|
||||
{
|
||||
//
|
||||
// LC HH Buffer ...
|
||||
string lcHHBufferLabel = ShortName + " LC HH (" + (string)lcLength + ")";
|
||||
ENUM_DRAW_TYPE lcHHDrawType = lcDrawHH ? lcDrawType : DRAW_NONE;
|
||||
ArraySetAsSeries(lcHHBuffer, true);
|
||||
SetIndexBuffer(lcHHBufferIndex, lcHHBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(lcHHBufferIndex, PLOT_DRAW_BEGIN, lcLength);
|
||||
PlotIndexSetString(lcHHBufferIndex, PLOT_LABEL, lcHHBufferLabel);
|
||||
PlotIndexSetInteger(lcHHBufferIndex, PLOT_LINE_COLOR, lcHHColor);
|
||||
PlotIndexSetInteger(lcHHBufferIndex, PLOT_LINE_STYLE, lcDrawStyle);
|
||||
PlotIndexSetInteger(lcHHBufferIndex, PLOT_LINE_WIDTH, lcDrawWidth);
|
||||
PlotIndexSetInteger(lcHHBufferIndex, PLOT_DRAW_TYPE, lcHHDrawType);
|
||||
|
||||
//
|
||||
// LC LL Buffer ...
|
||||
string lcLLBufferLabel = ShortName + " LC LL (" + (string)lcLength + ")";
|
||||
ENUM_DRAW_TYPE lcLLDrawType = lcDrawLL ? lcDrawType : DRAW_NONE;
|
||||
ArraySetAsSeries(lcLLBuffer, true);
|
||||
SetIndexBuffer(lcLLBufferIndex, lcLLBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(lcLLBufferIndex, PLOT_DRAW_BEGIN, lcLength);
|
||||
PlotIndexSetString(lcLLBufferIndex, PLOT_LABEL, lcLLBufferLabel);
|
||||
PlotIndexSetInteger(lcLLBufferIndex, PLOT_LINE_COLOR, lcLLColor);
|
||||
PlotIndexSetInteger(lcLLBufferIndex, PLOT_LINE_STYLE, lcDrawStyle);
|
||||
PlotIndexSetInteger(lcLLBufferIndex, PLOT_LINE_WIDTH, lcDrawWidth);
|
||||
PlotIndexSetInteger(lcLLBufferIndex, PLOT_DRAW_TYPE, lcLLDrawType);
|
||||
}
|
||||
|
||||
//
|
||||
// MC Buffers Definitions ...
|
||||
void MCDefineBuffers()
|
||||
{
|
||||
//
|
||||
// MC HH Buffer ...
|
||||
string mcHHBufferLabel = ShortName + " MC HH (" + (string)mcLength + ")";
|
||||
ENUM_DRAW_TYPE mcHHDrawType = mcDrawHH ? lcDrawType : DRAW_NONE;
|
||||
ArraySetAsSeries(mcHHBuffer, true);
|
||||
SetIndexBuffer(mcHHBufferIndex, mcHHBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(mcHHBufferIndex, PLOT_DRAW_BEGIN, mcLength);
|
||||
PlotIndexSetString(mcHHBufferIndex, PLOT_LABEL, mcHHBufferLabel);
|
||||
PlotIndexSetInteger(mcHHBufferIndex, PLOT_LINE_COLOR, mcHHColor);
|
||||
PlotIndexSetInteger(mcHHBufferIndex, PLOT_LINE_STYLE, mcDrawStyle);
|
||||
PlotIndexSetInteger(mcHHBufferIndex, PLOT_LINE_WIDTH, mcDrawWidth);
|
||||
PlotIndexSetInteger(mcHHBufferIndex, PLOT_DRAW_TYPE, mcHHDrawType);
|
||||
|
||||
//
|
||||
// MC LL Buffer ...
|
||||
string mcLLBufferLabel = ShortName + " MC LL (" + (string)mcLength + ")";
|
||||
ENUM_DRAW_TYPE mcLLDrawType = mcDrawLL ? lcDrawType : DRAW_NONE;
|
||||
ArraySetAsSeries(mcLLBuffer, true);
|
||||
SetIndexBuffer(mcLLBufferIndex, mcLLBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(mcLLBufferIndex, PLOT_DRAW_BEGIN, mcLength);
|
||||
PlotIndexSetString(mcLLBufferIndex, PLOT_LABEL, mcLLBufferLabel);
|
||||
PlotIndexSetInteger(mcLLBufferIndex, PLOT_LINE_COLOR, mcLLColor);
|
||||
PlotIndexSetInteger(mcLLBufferIndex, PLOT_LINE_STYLE, mcDrawStyle);
|
||||
PlotIndexSetInteger(mcLLBufferIndex, PLOT_LINE_WIDTH, mcDrawWidth);
|
||||
PlotIndexSetInteger(mcLLBufferIndex, PLOT_DRAW_TYPE, mcLLDrawType);
|
||||
}
|
||||
|
||||
//
|
||||
// SC Buffers Definitions ...
|
||||
void SCDefineBuffers()
|
||||
{
|
||||
//
|
||||
// SC HH Buffer ...
|
||||
string scHHBufferLabel = ShortName + " SC HH (" + (string)scLength + ")";
|
||||
ENUM_DRAW_TYPE scHHDrawType = scDrawHH ? lcDrawType : DRAW_NONE;
|
||||
ArraySetAsSeries(scHHBuffer, true);
|
||||
SetIndexBuffer(scHHBufferIndex, scHHBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(scHHBufferIndex, PLOT_DRAW_BEGIN, scLength);
|
||||
PlotIndexSetString(scHHBufferIndex, PLOT_LABEL, scHHBufferLabel);
|
||||
PlotIndexSetInteger(scHHBufferIndex, PLOT_LINE_COLOR, scHHColor);
|
||||
PlotIndexSetInteger(scHHBufferIndex, PLOT_LINE_STYLE, scDrawStyle);
|
||||
PlotIndexSetInteger(scHHBufferIndex, PLOT_LINE_WIDTH, scDrawWidth);
|
||||
PlotIndexSetInteger(scHHBufferIndex, PLOT_DRAW_TYPE, scHHDrawType);
|
||||
|
||||
//
|
||||
// SC LL Buffer ...
|
||||
string scLLBufferLabel = ShortName + " SC LL (" + (string)scLength + ")";
|
||||
ENUM_DRAW_TYPE scLLDrawType = scDrawLL ? lcDrawType : DRAW_NONE;
|
||||
ArraySetAsSeries(scLLBuffer, true);
|
||||
SetIndexBuffer(scLLBufferIndex, scLLBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(scLLBufferIndex, PLOT_DRAW_BEGIN, scLength);
|
||||
PlotIndexSetString(scLLBufferIndex, PLOT_LABEL, scLLBufferLabel);
|
||||
PlotIndexSetInteger(scLLBufferIndex, PLOT_LINE_COLOR, scLLColor);
|
||||
PlotIndexSetInteger(scLLBufferIndex, PLOT_LINE_STYLE, scDrawStyle);
|
||||
PlotIndexSetInteger(scLLBufferIndex, PLOT_LINE_WIDTH, scDrawWidth);
|
||||
PlotIndexSetInteger(scLLBufferIndex, PLOT_DRAW_TYPE, scLLDrawType);
|
||||
}
|
||||
|
||||
//
|
||||
// Hot State Buffer ...
|
||||
void HotStateDefineBuffers()
|
||||
{
|
||||
//
|
||||
// Hot State Buffer ...
|
||||
ArraySetAsSeries(hotStateBuffer, true);
|
||||
SetIndexBuffer(hotStateBufferIndex, hotStateBuffer, INDICATOR_CALCULATIONS);
|
||||
}
|
||||
|
||||
//
|
||||
// LC Calculations ...
|
||||
void LCCalculateBuffers(
|
||||
int bar_index // Current Candle Index ...
|
||||
)
|
||||
{
|
||||
//
|
||||
// Detect Cycle HH and LL ...
|
||||
int length = lcLength;
|
||||
ENUM_SERIESMODE hhMode = lcHHMode;
|
||||
ENUM_SERIESMODE llMode = lcLLMode;
|
||||
double threshold = PipsToPrice(lcThresholdInPips);
|
||||
|
||||
//
|
||||
int hhIdx = iHighest(
|
||||
_Symbol,
|
||||
_Period,
|
||||
hhMode,
|
||||
length,
|
||||
bar_index
|
||||
//
|
||||
);
|
||||
double hh = iHigh(
|
||||
_Symbol,
|
||||
_Period,
|
||||
hhIdx);
|
||||
double hhValue = hh + threshold;
|
||||
|
||||
//
|
||||
int llIdx = iLowest(
|
||||
_Symbol,
|
||||
_Period,
|
||||
llMode,
|
||||
length,
|
||||
bar_index
|
||||
//
|
||||
);
|
||||
double ll = iLow(
|
||||
_Symbol,
|
||||
_Period,
|
||||
llIdx);
|
||||
double llValue = ll - threshold;
|
||||
|
||||
//
|
||||
lcHHBuffer[bar_index] = hhValue;
|
||||
lcLLBuffer[bar_index] = llValue;
|
||||
}
|
||||
|
||||
//
|
||||
// MC Calculations ...
|
||||
void MCCalculateBuffers(
|
||||
int bar_index // Current Candle Index ...
|
||||
)
|
||||
{
|
||||
//
|
||||
// Detect Cycle HH and LL ...
|
||||
int length = mcLength;
|
||||
ENUM_SERIESMODE hhMode = mcHHMode;
|
||||
ENUM_SERIESMODE llMode = mcLLMode;
|
||||
double threshold = PipsToPrice(mcThresholdInPips);
|
||||
|
||||
//
|
||||
int hhIdx = iHighest(
|
||||
_Symbol,
|
||||
_Period,
|
||||
hhMode,
|
||||
length,
|
||||
bar_index
|
||||
//
|
||||
);
|
||||
double hh = iHigh(
|
||||
_Symbol,
|
||||
_Period,
|
||||
hhIdx);
|
||||
double hhValue = hh + threshold;
|
||||
|
||||
//
|
||||
int llIdx = iLowest(
|
||||
_Symbol,
|
||||
_Period,
|
||||
llMode,
|
||||
length,
|
||||
bar_index
|
||||
//
|
||||
);
|
||||
double ll = iLow(
|
||||
_Symbol,
|
||||
_Period,
|
||||
llIdx);
|
||||
double llValue = ll - threshold;
|
||||
|
||||
//
|
||||
mcHHBuffer[bar_index] = hhValue;
|
||||
mcLLBuffer[bar_index] = llValue;
|
||||
}
|
||||
|
||||
//
|
||||
// SC Calculations ...
|
||||
void SCCalculateBuffers(
|
||||
int bar_index // Current Candle Index ...
|
||||
)
|
||||
{
|
||||
//
|
||||
// Detect Cycle HH and LL ...
|
||||
int length = scLength;
|
||||
ENUM_SERIESMODE hhMode = scHHMode;
|
||||
ENUM_SERIESMODE llMode = scLLMode;
|
||||
double threshold = PipsToPrice(scThresholdInPips);
|
||||
|
||||
//
|
||||
int hhIdx = iHighest(
|
||||
_Symbol,
|
||||
_Period,
|
||||
hhMode,
|
||||
length,
|
||||
bar_index
|
||||
//
|
||||
);
|
||||
double hh = iHigh(
|
||||
_Symbol,
|
||||
_Period,
|
||||
hhIdx);
|
||||
double hhValue = hh + threshold;
|
||||
|
||||
//
|
||||
int llIdx = iLowest(
|
||||
_Symbol,
|
||||
_Period,
|
||||
llMode,
|
||||
length,
|
||||
bar_index
|
||||
//
|
||||
);
|
||||
double ll = iLow(
|
||||
_Symbol,
|
||||
_Period,
|
||||
llIdx);
|
||||
double llValue = ll - threshold;
|
||||
|
||||
//
|
||||
scHHBuffer[bar_index] = hhValue;
|
||||
scLLBuffer[bar_index] = llValue;
|
||||
}
|
||||
|
||||
//
|
||||
// SIGNAL Calculations ...
|
||||
void SignalCalculateBuffers(
|
||||
int bar_index // Current Candle Index ...
|
||||
)
|
||||
{
|
||||
//
|
||||
// LC Values ...
|
||||
double lcHH = lcHHBuffer[bar_index];
|
||||
double lcLL = lcLLBuffer[bar_index];
|
||||
double lcDelta = lcHH - lcLL;
|
||||
double lcAvg = lcDelta / 2;
|
||||
|
||||
//
|
||||
// MC Values ...
|
||||
double mcHH = mcHHBuffer[bar_index];
|
||||
double mcLL = mcLLBuffer[bar_index];
|
||||
double mcDelta = mcHH - mcLL;
|
||||
double mcAvg = mcDelta / 2;
|
||||
|
||||
//
|
||||
// SC Values ...
|
||||
double scHH = scHHBuffer[bar_index];
|
||||
double scLL = scLLBuffer[bar_index];
|
||||
double scDelta = scHH - scLL;
|
||||
double scAvg = scDelta / 2;
|
||||
|
||||
//
|
||||
// Min Value ...
|
||||
double minValue = MathMin(
|
||||
scLL, mcLL);
|
||||
minValue = MathMin(
|
||||
lcLL, minValue);
|
||||
|
||||
//
|
||||
// Max Value ...
|
||||
double maxValue = MathMin(
|
||||
scHH, mcHH);
|
||||
maxValue = MathMin(
|
||||
lcHH, maxValue);
|
||||
}
|
||||
|
||||
//
|
||||
// HOT State Calculate Buffers ...
|
||||
void HotStateCalculateBuffers(
|
||||
int bar_index // Current Candle Index ...
|
||||
)
|
||||
{
|
||||
//
|
||||
// LC ...
|
||||
double lcHH = lcHHBuffer[bar_index];
|
||||
double lcLL = lcLLBuffer[bar_index];
|
||||
//
|
||||
double lcHH1 = lcHHBuffer[bar_index + 1];
|
||||
double lcLL1 = lcLLBuffer[bar_index + 1];
|
||||
|
||||
//
|
||||
// MC ...
|
||||
double mcHH = mcHHBuffer[bar_index];
|
||||
double mcLL = mcLLBuffer[bar_index];
|
||||
//
|
||||
double mcHH1 = mcHHBuffer[bar_index + 1];
|
||||
double mcLL1 = mcLLBuffer[bar_index + 1];
|
||||
|
||||
//
|
||||
// SC ...
|
||||
double scHH = scHHBuffer[bar_index];
|
||||
double scLL = scLLBuffer[bar_index];
|
||||
//
|
||||
double scHH1 = scHHBuffer[bar_index + 1];
|
||||
double scLL1 = scLLBuffer[bar_index + 1];
|
||||
|
||||
//
|
||||
bool isHotLLState = scLL == mcLL && mcLL == lcLL;
|
||||
bool isHotLLState1 = scLL1 == mcLL1 && mcLL1 == lcLL1;
|
||||
//
|
||||
bool isHotHHState = scHH == mcHH && mcHH == lcHH;
|
||||
bool isHotHHState1 = scHH1 == mcHH1 && mcHH1 == lcHH1;
|
||||
|
||||
//
|
||||
bool isHotLL = isHotLLState && !isHotLLState1;
|
||||
bool isHotHH = isHotHHState && !isHotHHState1;
|
||||
|
||||
//
|
||||
double hotStateValue = X_XCHLH_NEUTURAL;
|
||||
if (isHotHH)
|
||||
{
|
||||
hotStateValue = X_XCHLH_HOT_HH;
|
||||
}
|
||||
else if (isHotLL)
|
||||
{
|
||||
hotStateValue = X_XCHLH_HOT_LL;
|
||||
}
|
||||
|
||||
//
|
||||
hotStateBuffer[bar_index] = hotStateValue;
|
||||
}
|
||||
|
||||
//
|
||||
// Draw Buffers ...
|
||||
void DrawBuffers(
|
||||
int bar_index // Current Candle Index ...
|
||||
)
|
||||
{
|
||||
//
|
||||
// General Requirements ...
|
||||
|
||||
//
|
||||
// Retrieve Candle Model ...
|
||||
XOHCL candle;
|
||||
candle.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
bar_index
|
||||
//
|
||||
);
|
||||
datetime time = iTime(_Symbol, _Period, bar_index);
|
||||
|
||||
//
|
||||
// Draw Arrow on Hot Areas ...
|
||||
if (drawHotAreas)
|
||||
{
|
||||
//
|
||||
double hotStateValue = hotStateBuffer[bar_index];
|
||||
bool isHotHHArea = hotStateValue == 1;
|
||||
bool isHotLLArea = hotStateValue == -1;
|
||||
if (isHotHHArea || isHotLLArea)
|
||||
{
|
||||
//
|
||||
bool isHH = isHotHHArea;
|
||||
|
||||
//
|
||||
double price = isHH ? candle.high : candle.low;
|
||||
ENUM_ARROW_ANCHOR anchor = isHH ? ANCHOR_BOTTOM : ANCHOR_TOP;
|
||||
color clr = isHH ? hotHHArrowColor : hotLLArrowColor;
|
||||
uchar arrowCode = isHH ? hotHHArrowCode : hotLLArrowCode;
|
||||
string name = "HOT " + (isHH ? "HH" : "LL") + "_" + (string)price + "_" + (string)time;
|
||||
|
||||
//
|
||||
DrawArrow(
|
||||
0,
|
||||
name,
|
||||
0,
|
||||
time,
|
||||
price,
|
||||
arrowCode,
|
||||
anchor,
|
||||
clr,
|
||||
STYLE_SOLID,
|
||||
1);
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
// END Functions ...
|
||||
//
|
||||
Binary file not shown.
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -0,0 +1,261 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 Indicator
|
||||
// ---------------------------------------------
|
||||
// Name: XCT
|
||||
// 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 XCT Indicator"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// START Constants ...
|
||||
//
|
||||
|
||||
//
|
||||
#define ShortName "XCT"
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||
|
||||
//
|
||||
// END Constants ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
input color clr = clrYellow; // Text Color
|
||||
input ENUM_BASE_CORNER corner = CORNER_RIGHT_LOWER; // Text Position
|
||||
|
||||
//
|
||||
input group "Presentation";
|
||||
input bool showCandleTime = true; // Show Candle Time
|
||||
|
||||
//
|
||||
// END Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Buffers ...
|
||||
//
|
||||
|
||||
//
|
||||
#property indicator_chart_window
|
||||
|
||||
//
|
||||
#property indicator_buffers 0
|
||||
#property indicator_plots 0
|
||||
|
||||
//
|
||||
// END Buffers ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
|
||||
//
|
||||
// END Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Event Handlers ...
|
||||
//
|
||||
|
||||
//
|
||||
// Initialization ...
|
||||
int OnInit()
|
||||
{
|
||||
//
|
||||
// Validate Inputs ...
|
||||
if (showCandleTime)
|
||||
{
|
||||
CreateIndicatorObject();
|
||||
}
|
||||
else
|
||||
{
|
||||
ObjectDelete(0, ShortName);
|
||||
}
|
||||
|
||||
//
|
||||
// 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
|
||||
|
||||
//
|
||||
ulong chID = FindChartID(
|
||||
_Symbol,
|
||||
_Period
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Delete Object ...
|
||||
ObjectDelete(chID, ShortName);
|
||||
|
||||
//
|
||||
Comment("");
|
||||
}
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
)
|
||||
{
|
||||
//
|
||||
ArraySetAsSeries(time, true);
|
||||
|
||||
//
|
||||
if (!showCandleTime)
|
||||
{
|
||||
return rates_total;
|
||||
}
|
||||
|
||||
//
|
||||
ulong chID = FindChartID(
|
||||
_Symbol,
|
||||
_Period
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
XBarRemainsTime barRemains;
|
||||
barRemains.Init(
|
||||
_Symbol,
|
||||
_Period
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
string msg = barRemains
|
||||
.ToString(
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
"",
|
||||
":",
|
||||
true
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
long mSpread = SymbolInfoInteger(Symbol(), SYMBOL_SPREAD);
|
||||
|
||||
//
|
||||
string _sp = "";
|
||||
if (mSpread < 10)
|
||||
_sp = "..";
|
||||
else if (mSpread < 100)
|
||||
_sp = ".";
|
||||
|
||||
//
|
||||
string objText = "Spread: " + IntegerToString(mSpread) + _sp + " Next Bar in: " + msg;
|
||||
|
||||
//
|
||||
ObjectSetInteger(chID, ShortName, OBJPROP_COLOR, clr);
|
||||
ObjectSetString(chID, ShortName, OBJPROP_TEXT, objText);
|
||||
ObjectSetInteger(chID, ShortName, OBJPROP_FONTSIZE, 10);
|
||||
ObjectSetString(chID, 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()
|
||||
{
|
||||
//
|
||||
if (!showCandleTime)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
//
|
||||
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 ...
|
||||
//
|
||||
Binary file not shown.
@@ -0,0 +1,366 @@
|
||||
///////////////////////////////////////////////////////
|
||||
// SaherElm IT Center MQL5 Indicator
|
||||
// -------------------------------------------
|
||||
// Name: XDON
|
||||
// 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 XDON Indicator"
|
||||
#property strict
|
||||
|
||||
//
|
||||
#define ShortName "XDON"
|
||||
|
||||
//
|
||||
// INPUT ...
|
||||
|
||||
//
|
||||
input group "Market";
|
||||
input int length = 52; // Market Length
|
||||
input double offset = 0; // Offset
|
||||
|
||||
//
|
||||
input group "Presentation";
|
||||
input bool showOpen = true; // Show Open
|
||||
input bool showHigh = true; // Show High
|
||||
input bool showClose = true; // Show Close
|
||||
input bool showLow = true; // Show Low
|
||||
|
||||
//
|
||||
// BUFFERS ...
|
||||
|
||||
//
|
||||
#property indicator_chart_window
|
||||
|
||||
//
|
||||
#property indicator_buffers 8
|
||||
#property indicator_plots 8
|
||||
|
||||
//
|
||||
#define upperOBufferIndex 0
|
||||
double upperOBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label1 "XDON OU"
|
||||
#property indicator_type1 DRAW_LINE
|
||||
#property indicator_color1 clrCornflowerBlue
|
||||
#property indicator_width1 2
|
||||
|
||||
//
|
||||
#define lowerOBufferIndex 1
|
||||
double lowerOBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label2 "XDON OL"
|
||||
#property indicator_type2 DRAW_LINE
|
||||
#property indicator_color2 clrCornflowerBlue
|
||||
#property indicator_width2 2
|
||||
|
||||
//
|
||||
#define upperCBufferIndex 2
|
||||
double upperCBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label3 "XDON CU"
|
||||
#property indicator_type3 DRAW_LINE
|
||||
#property indicator_color3 clrCoral
|
||||
#property indicator_width3 2
|
||||
|
||||
//
|
||||
#define lowerCBufferIndex 3
|
||||
double lowerCBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label4 "XDON CL"
|
||||
#property indicator_type4 DRAW_LINE
|
||||
#property indicator_color4 clrCoral
|
||||
#property indicator_width4 2
|
||||
|
||||
//
|
||||
#define upperHBufferIndex 4
|
||||
double upperHBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label5 "XDON HU"
|
||||
#property indicator_type5 DRAW_LINE
|
||||
#property indicator_color5 clrAquamarine
|
||||
#property indicator_width5 2
|
||||
|
||||
//
|
||||
#define lowerHBufferIndex 5
|
||||
double lowerHBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label6 "XDON HL"
|
||||
#property indicator_type6 DRAW_LINE
|
||||
#property indicator_color6 clrAquamarine
|
||||
#property indicator_width6 2
|
||||
|
||||
//
|
||||
#define upperLBufferIndex 6
|
||||
double upperLBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label7 "XDON LU"
|
||||
#property indicator_type7 DRAW_LINE
|
||||
#property indicator_color7 clrDarkOrchid
|
||||
#property indicator_width7 2
|
||||
|
||||
//
|
||||
#define lowerLBufferIndex 7
|
||||
double lowerLBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label8 "XDON LL"
|
||||
#property indicator_type8 DRAW_LINE
|
||||
#property indicator_color8 clrDarkOrchid
|
||||
#property indicator_width8 2
|
||||
|
||||
//
|
||||
// EVENT Handlers ...
|
||||
|
||||
//
|
||||
// Initialization ...
|
||||
int OnInit()
|
||||
{
|
||||
//
|
||||
// Validate Inputs ...
|
||||
if (!ValidateInputs())
|
||||
{
|
||||
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
|
||||
}
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
)
|
||||
{
|
||||
//
|
||||
if (rates_total < length - 1)
|
||||
{
|
||||
return prev_calculated;
|
||||
}
|
||||
|
||||
//
|
||||
int start = prev_calculated == 0
|
||||
? length
|
||||
: prev_calculated - 1;
|
||||
|
||||
//
|
||||
// Main Loop ...
|
||||
for (int barIndex = start; barIndex < rates_total; barIndex++)
|
||||
{
|
||||
//
|
||||
// OPEN ...
|
||||
|
||||
//
|
||||
double upperOValue = open[ArrayMaximum(open, barIndex - length + 1, length)];
|
||||
double lowerOValue = open[ArrayMinimum(open, barIndex - length + 1, length)];
|
||||
|
||||
//
|
||||
double oDelta = MathAbs(upperOValue - lowerOValue);
|
||||
double oOffsetValue = oDelta * (offset) * 0.01;
|
||||
|
||||
//
|
||||
upperOBuffer[barIndex] = upperOValue - oOffsetValue;
|
||||
lowerOBuffer[barIndex] = lowerOValue + oOffsetValue;
|
||||
|
||||
//
|
||||
// CLOSE ...
|
||||
|
||||
//
|
||||
double upperCValue = close[ArrayMaximum(close, barIndex - length + 1, length)];
|
||||
double lowerCValue = close[ArrayMinimum(close, barIndex - length + 1, length)];
|
||||
|
||||
//
|
||||
double cDelta = MathAbs(upperCValue - lowerCValue);
|
||||
double cOffsetValue = cDelta * (offset) * 0.01;
|
||||
|
||||
//
|
||||
upperCBuffer[barIndex] = upperCValue - cOffsetValue;
|
||||
lowerCBuffer[barIndex] = lowerCValue + cOffsetValue;
|
||||
|
||||
//
|
||||
// HIGH ...
|
||||
|
||||
//
|
||||
double upperHValue = high[ArrayMaximum(high, barIndex - length + 1, length)];
|
||||
double lowerHValue = high[ArrayMinimum(high, barIndex - length + 1, length)];
|
||||
|
||||
//
|
||||
double hDelta = MathAbs(upperHValue - lowerHValue);
|
||||
double hOffsetValue = hDelta * (offset) * 0.01;
|
||||
|
||||
//
|
||||
upperHBuffer[barIndex] = upperHValue - hOffsetValue;
|
||||
lowerHBuffer[barIndex] = lowerHValue + hOffsetValue;
|
||||
|
||||
//
|
||||
// LOW ...
|
||||
|
||||
//
|
||||
double upperLValue = low[ArrayMaximum(low, barIndex - length + 1, length)];
|
||||
double lowerLValue = low[ArrayMinimum(low, barIndex - length + 1, length)];
|
||||
|
||||
//
|
||||
double lDelta = MathAbs(upperLValue - lowerLValue);
|
||||
double lOffsetValue = lDelta * (offset) * 0.01;
|
||||
|
||||
//
|
||||
upperLBuffer[barIndex] = upperLValue - lOffsetValue;
|
||||
lowerLBuffer[barIndex] = lowerLValue + lOffsetValue;
|
||||
}
|
||||
|
||||
//
|
||||
return rates_total;
|
||||
}
|
||||
|
||||
//
|
||||
// CUSTOM Functions ...
|
||||
|
||||
//
|
||||
// Validate Input Args for Initialization ...
|
||||
bool ValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
result = length >= 7;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Indexes and Styles ...
|
||||
void DefineBuffers()
|
||||
{
|
||||
//
|
||||
// Open ...
|
||||
ENUM_DRAW_TYPE openDrawType = showOpen ? DRAW_LINE : DRAW_NONE;
|
||||
|
||||
//
|
||||
// UPPER ...
|
||||
SetIndexBuffer(upperOBufferIndex, upperOBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(upperOBufferIndex, PLOT_SHOW_DATA, showOpen);
|
||||
PlotIndexSetDouble(upperOBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||
PlotIndexSetInteger(upperOBufferIndex, PLOT_DRAW_TYPE, openDrawType);
|
||||
|
||||
//
|
||||
// LOWER ...
|
||||
SetIndexBuffer(lowerOBufferIndex, lowerOBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(lowerOBufferIndex, PLOT_SHOW_DATA, showOpen);
|
||||
PlotIndexSetDouble(lowerOBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||
PlotIndexSetInteger(lowerOBufferIndex, PLOT_DRAW_TYPE, openDrawType);
|
||||
|
||||
//
|
||||
// Close ...
|
||||
ENUM_DRAW_TYPE closeDrawType = showClose ? DRAW_LINE : DRAW_NONE;
|
||||
|
||||
//
|
||||
// UPPER ...
|
||||
SetIndexBuffer(upperCBufferIndex, upperCBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(upperCBufferIndex, PLOT_SHOW_DATA, showClose);
|
||||
PlotIndexSetDouble(upperCBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||
PlotIndexSetInteger(upperCBufferIndex, PLOT_DRAW_TYPE, closeDrawType);
|
||||
|
||||
//
|
||||
// LOWER ...
|
||||
SetIndexBuffer(lowerCBufferIndex, lowerCBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(lowerCBufferIndex, PLOT_SHOW_DATA, showClose);
|
||||
PlotIndexSetDouble(lowerCBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||
PlotIndexSetInteger(lowerCBufferIndex, PLOT_DRAW_TYPE, closeDrawType);
|
||||
|
||||
//
|
||||
// High ...
|
||||
ENUM_DRAW_TYPE highDrawType = showHigh ? DRAW_LINE : DRAW_NONE;
|
||||
|
||||
//
|
||||
// UPPER ...
|
||||
SetIndexBuffer(upperHBufferIndex, upperHBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(upperHBufferIndex, PLOT_SHOW_DATA, showHigh);
|
||||
PlotIndexSetDouble(upperHBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||
PlotIndexSetInteger(upperHBufferIndex, PLOT_DRAW_TYPE, highDrawType);
|
||||
|
||||
//
|
||||
// LOWER ...
|
||||
SetIndexBuffer(lowerHBufferIndex, lowerHBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(lowerHBufferIndex, PLOT_SHOW_DATA, showHigh);
|
||||
PlotIndexSetDouble(lowerHBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||
PlotIndexSetInteger(lowerHBufferIndex, PLOT_DRAW_TYPE, highDrawType);
|
||||
|
||||
//
|
||||
// Low ...
|
||||
ENUM_DRAW_TYPE lowDrawType = showLow ? DRAW_LINE : DRAW_NONE;
|
||||
|
||||
//
|
||||
// UPPER ...
|
||||
SetIndexBuffer(upperLBufferIndex, upperLBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(upperLBufferIndex, PLOT_SHOW_DATA, showLow);
|
||||
PlotIndexSetDouble(upperLBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||
PlotIndexSetInteger(upperLBufferIndex, PLOT_DRAW_TYPE, lowDrawType);
|
||||
|
||||
//
|
||||
// LOWER ...
|
||||
SetIndexBuffer(lowerLBufferIndex, lowerLBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(lowerLBufferIndex, PLOT_SHOW_DATA, showLow);
|
||||
PlotIndexSetDouble(lowerLBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
|
||||
PlotIndexSetInteger(lowerLBufferIndex, PLOT_DRAW_TYPE, lowDrawType);
|
||||
}
|
||||
|
||||
//
|
||||
// Set Indicator Short Name and also we can define Buffers Labels ...
|
||||
void SetIndicatorName()
|
||||
{
|
||||
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
|
||||
}
|
||||
Binary file not shown.
@@ -0,0 +1,305 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 XFI Oscillator
|
||||
// ---------------------------------------------
|
||||
// Name: XFI
|
||||
// Description: Price Momentum Power Detection
|
||||
// Market Analysor ...
|
||||
//
|
||||
//
|
||||
// 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 XFI Oscillator"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// START Constants ...
|
||||
//
|
||||
#define ShortName "XFI"
|
||||
//
|
||||
// END Constants ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Inputs ...
|
||||
//
|
||||
input int length = 18; // Length
|
||||
input ENUM_MA_METHOD method = MODE_SMA; // MA Method
|
||||
input ENUM_APPLIED_VOLUME appliedTo = VOLUME_TICK; // Applied To
|
||||
//
|
||||
// END Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
// Includes Common Library ...
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||
|
||||
//
|
||||
// START Buffers ...
|
||||
//
|
||||
#property indicator_separate_window
|
||||
|
||||
//
|
||||
#property indicator_buffers 2
|
||||
#property indicator_plots 1
|
||||
|
||||
//
|
||||
// FI Buffer ...
|
||||
#define fiBufferIndex 0
|
||||
#define fiColorBufferIndex 1
|
||||
|
||||
//
|
||||
double fiBuffer[];
|
||||
double fiColorBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label1 "XFI"
|
||||
#property indicator_type1 DRAW_COLOR_LINE
|
||||
#property indicator_color1 clrAqua, clrGray, clrFuchsia
|
||||
#property indicator_style1 STYLE_DOT
|
||||
#property indicator_width1 1
|
||||
//
|
||||
// END Buffers ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
int fiHandler = INVALID_HANDLE;
|
||||
//
|
||||
// END Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Event Handlers ...
|
||||
//
|
||||
//
|
||||
// Initialization ...
|
||||
int OnInit()
|
||||
{
|
||||
//
|
||||
// Validate Inputs ...
|
||||
if (!ValidateInputs())
|
||||
{
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
fiHandler = iForce(
|
||||
_Symbol,
|
||||
_Period,
|
||||
length,
|
||||
method,
|
||||
appliedTo);
|
||||
if (fiHandler == INVALID_HANDLE)
|
||||
{
|
||||
return INIT_FAILED;
|
||||
}
|
||||
|
||||
//
|
||||
// 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
|
||||
|
||||
//
|
||||
// Here we can handle De Initialization Reasons ...
|
||||
IndicatorRelease(fiHandler);
|
||||
}
|
||||
|
||||
//
|
||||
// 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[])
|
||||
{
|
||||
//
|
||||
// Prepare Buffers ...
|
||||
ArraySetAsSeries(time, true);
|
||||
ArraySetAsSeries(open, true);
|
||||
ArraySetAsSeries(high, true);
|
||||
ArraySetAsSeries(low, true);
|
||||
ArraySetAsSeries(close, true);
|
||||
ArraySetAsSeries(tick_volume, true);
|
||||
ArraySetAsSeries(volume, true);
|
||||
ArraySetAsSeries(spread, true);
|
||||
|
||||
//
|
||||
// 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 = MathMax(0, length);
|
||||
|
||||
//
|
||||
// Check Calculated Bars ...
|
||||
int fiCalculatedBars = BarsCalculated(fiHandler);
|
||||
if (fiCalculatedBars < maxLength)
|
||||
{
|
||||
return prev_calculated;
|
||||
}
|
||||
|
||||
//
|
||||
limit = (prev_calculated > rates_total || prev_calculated <= 0) ? rates_total : (rates_total - prev_calculated) + 1;
|
||||
|
||||
//
|
||||
// Buffers Copy ...
|
||||
int copiedFis = CopyBuffer(fiHandler, 0, 0, limit, fiBuffer);
|
||||
if (copiedFis <= 0)
|
||||
{
|
||||
return prev_calculated;
|
||||
}
|
||||
|
||||
//
|
||||
// Main Loop ...
|
||||
for (int i = 0; i < limit && !IsStopped(); i++)
|
||||
{
|
||||
//
|
||||
CalculateBuffers(i);
|
||||
}
|
||||
|
||||
//
|
||||
return rates_total;
|
||||
}
|
||||
//
|
||||
// END Event Handlers ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Functions ...
|
||||
//
|
||||
//
|
||||
// Validate Input Args for Initialization ...
|
||||
bool ValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Validate Args ...
|
||||
if (length >= 2)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Indexes and Styles ...
|
||||
void DefineBuffers()
|
||||
{
|
||||
//
|
||||
string fiBufferLabel = "XFI " + "(" + (string)length + ")";
|
||||
|
||||
//
|
||||
// FI Buffer ...
|
||||
ArraySetAsSeries(fiBuffer, true);
|
||||
SetIndexBuffer(fiBufferIndex, fiBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetString(fiBufferIndex, PLOT_LABEL, fiBufferLabel);
|
||||
|
||||
//
|
||||
// FI Color Buffer ...
|
||||
ArraySetAsSeries(fiColorBuffer, true);
|
||||
SetIndexBuffer(fiColorBufferIndex, fiColorBuffer, INDICATOR_COLOR_INDEX);
|
||||
}
|
||||
|
||||
//
|
||||
// Set Indicator Short Name and also we can define Buffers Labels ...
|
||||
void SetIndicatorName()
|
||||
{
|
||||
//
|
||||
string indicatorShortName = "";
|
||||
StringConcatenate(indicatorShortName, ShortName, "");
|
||||
|
||||
//
|
||||
IndicatorSetString(INDICATOR_SHORTNAME, indicatorShortName);
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate Buffers ...
|
||||
void CalculateBuffers(
|
||||
int bar_index // Selected Bar Index
|
||||
)
|
||||
{
|
||||
//
|
||||
double iValue = fiBuffer[bar_index];
|
||||
|
||||
//
|
||||
double iColorIndex =
|
||||
iValue > 0 ? 0 : iValue < 0 ? 2
|
||||
: 1;
|
||||
|
||||
//
|
||||
// Set Buffer Color Index ...
|
||||
fiColorBuffer[bar_index] = iColorIndex;
|
||||
}
|
||||
//
|
||||
// END Functions ...
|
||||
//
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user