last works ...
This commit is contained in:
Vendored
+67
-29
@@ -14,20 +14,6 @@
|
||||
"references": [],
|
||||
"title": "Add all Trail and Position State Managements inside Guards"
|
||||
},
|
||||
{
|
||||
"assignedTo": {
|
||||
"name": "Hadi Khazaee Asl"
|
||||
},
|
||||
"category": "X121 Provider",
|
||||
"creation_time": "2024-05-30T21:40:26.010Z",
|
||||
"description": {
|
||||
"content": "implement a Signaller Struct to Describe a Signaller state;\nuse it in X121ProviderDescriptor;\ninside X121Provider use this Struct to Handle Signaller's State;",
|
||||
"mime": "text/markdown"
|
||||
},
|
||||
"id": "63",
|
||||
"references": [],
|
||||
"title": "Implement a Signaller Struct"
|
||||
},
|
||||
{
|
||||
"assignedTo": {
|
||||
"name": "Hadi Khazaee Asl"
|
||||
@@ -72,20 +58,6 @@
|
||||
}
|
||||
],
|
||||
"in-progress": [
|
||||
{
|
||||
"assignedTo": {
|
||||
"name": "Hadi Khazaee Asl"
|
||||
},
|
||||
"category": "XTrade",
|
||||
"creation_time": "2024-05-30T21:54:13.427Z",
|
||||
"description": {
|
||||
"content": "- [] SLS;\n- [] TPS;\n- [] ACTION;\n\n- [] also solve all side affects;\n",
|
||||
"mime": "text/markdown"
|
||||
},
|
||||
"id": "67",
|
||||
"references": [],
|
||||
"title": "Remove all Signal unused stuffs"
|
||||
},
|
||||
{
|
||||
"assignedTo": {
|
||||
"name": "Hadi Khazaee Asl"
|
||||
@@ -93,12 +65,50 @@
|
||||
"category": "X121 Market Conditions",
|
||||
"creation_time": "2024-05-30T21:38:04.455Z",
|
||||
"description": {
|
||||
"content": "- [] Remove all Unused Indicators and Helpers;\n-- [] XCHLH;\n-- [] XCHMA;\n-- [] XFI;\n-- [] XTS;\n-- [] XRSI;\n-- [] XOBD;\n-- [] XLH;\n- [] Cleanup Market Conditions;\n- [] Merge reading Required Data to XMarket Conditions;",
|
||||
"content": "- [x] Remove all Unused Indicators and Helpers;\n-- [x] XCHLH;\n-- [x] XCHMA;\n-- [x] XFI;\n-- [x] XTS;\n-- [x] XRSI;\n-- [x] XOBD;\n-- [x] XLH;\n- [x] resolve side affects;\n- [x] Cleanup Market Conditions;\n- [] Merge reading Required Data to XMarket Conditions;",
|
||||
"mime": "text/markdown"
|
||||
},
|
||||
"id": "62",
|
||||
"references": [],
|
||||
"title": "Cleanup all Old Indicator"
|
||||
},
|
||||
{
|
||||
"assignedTo": {
|
||||
"name": "Hadi Khazaee Asl"
|
||||
},
|
||||
"category": "XTrade",
|
||||
"creation_time": "2024-05-30T22:23:48.918Z",
|
||||
"id": "68",
|
||||
"references": [],
|
||||
"title": "fix cc and ct indicator issues ..."
|
||||
},
|
||||
{
|
||||
"assignedTo": {
|
||||
"name": "Hadi Khazaee Asl"
|
||||
},
|
||||
"category": "XMQL",
|
||||
"creation_time": "2024-05-30T22:34:15.388Z",
|
||||
"description": {
|
||||
"content": "in this way all class can Has his own Alerts ...",
|
||||
"mime": "text/markdown"
|
||||
},
|
||||
"id": "69",
|
||||
"references": [],
|
||||
"title": "make provider and ea classes to instance XSCBaseAlert class"
|
||||
},
|
||||
{
|
||||
"assignedTo": {
|
||||
"name": "Hadi Khazaee Asl"
|
||||
},
|
||||
"category": "X121 Provider",
|
||||
"creation_time": "2024-05-30T21:40:26.010Z",
|
||||
"description": {
|
||||
"content": "implement a Signaller Struct to Describe a Signaller state;\nuse it in X121ProviderDescriptor;\ninside X121Provider use this Struct to Handle Signaller's State;",
|
||||
"mime": "text/markdown"
|
||||
},
|
||||
"id": "63",
|
||||
"references": [],
|
||||
"title": "Implement a Signaller Struct"
|
||||
}
|
||||
],
|
||||
"testing": [],
|
||||
@@ -737,6 +747,34 @@
|
||||
"references": [],
|
||||
"title": "Refactor XSignal and Create a new One also New Trader"
|
||||
},
|
||||
{
|
||||
"assignedTo": {
|
||||
"name": "Hadi Khazaee Asl"
|
||||
},
|
||||
"category": "XTrade",
|
||||
"creation_time": "2024-05-30T21:54:13.427Z",
|
||||
"description": {
|
||||
"content": "- [x] SLS;\n- [x] TPS;\n- [x] ACTION;\n\n- [x] also solve all side affects;\n",
|
||||
"mime": "text/markdown"
|
||||
},
|
||||
"id": "67",
|
||||
"references": [],
|
||||
"title": "Remove all Signal unused stuffs"
|
||||
},
|
||||
{
|
||||
"assignedTo": {
|
||||
"name": "Hadi Khazaee Asl"
|
||||
},
|
||||
"category": "XMQL",
|
||||
"creation_time": "2024-05-30T22:35:24.082Z",
|
||||
"description": {
|
||||
"content": "since they doesnt use ... \nremove them or comment them as for implementation document ...",
|
||||
"mime": "text/markdown"
|
||||
},
|
||||
"id": "70",
|
||||
"references": [],
|
||||
"title": "remove default base Market Conditions and Descriptor"
|
||||
},
|
||||
{
|
||||
"assignedTo": {
|
||||
"name": "Hadi Khazaee Asl"
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -47,7 +47,7 @@
|
||||
|
||||
//
|
||||
// X121 Specified Market Cycle Structure ...
|
||||
class X121MCycleInputs : public XSCBaseProviderInpts
|
||||
class X121MCycleInputs : public XSCBase
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
@@ -401,19 +401,24 @@ public:
|
||||
|
||||
//
|
||||
// Specific Market Sense Based on Specified Bar Index on Host Period ...
|
||||
class X121MCycleConditions : public XSCBaseProviderMarketConditions
|
||||
class X121MCycleConditions : public XSCBase
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
public:
|
||||
//
|
||||
// Props ...
|
||||
datetime time; // Time
|
||||
string symbol; // Symbol
|
||||
ENUM_TIMEFRAMES period; // Period
|
||||
|
||||
//
|
||||
// Common ...
|
||||
string prefix; // Cycle Prefix ...
|
||||
ENUM_TIMEFRAMES hostPeriod; // Hosting Time Frame ...
|
||||
ENUM_X_MARKET_CYCLES cycle; // Init Cycle ...
|
||||
string prefix; // Cycle Prefix
|
||||
ENUM_X_MARKET_CYCLES cycle; // Init Cycle
|
||||
ENUM_TIMEFRAMES hostPeriod; // Hosting Time Frame
|
||||
|
||||
//
|
||||
XOHCL bars[]; // Number of Bars
|
||||
|
||||
//
|
||||
// Candlestic Conditions ...
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
//
|
||||
// Imports ...
|
||||
#include <Generic/HashMap.mqh>
|
||||
#include "../Classes/x-saherelm.base.class.mq5"
|
||||
#include "../Classes/x-saherelm.xalert.class.mq5"
|
||||
#include "../Classes/x-saherelm.xtrade.class.mq5"
|
||||
|
||||
@@ -2133,7 +2132,7 @@ private:
|
||||
//
|
||||
// Class Definition ...
|
||||
|
||||
class XSCBaseEA : public XSCBase
|
||||
class XSCBaseEA : public XSCBaseAlert
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
@@ -2245,18 +2244,6 @@ public:
|
||||
mTrader.AddOnTradeStateChangedEventHandler(mOnTradeStateChangedHandler);
|
||||
}
|
||||
|
||||
//
|
||||
// Instantiate Alert Class ...
|
||||
mAlert = new XSCAlert(
|
||||
GetTag(),
|
||||
enableAlerts,
|
||||
logAlerts,
|
||||
terminalAlerts,
|
||||
mailAlerts,
|
||||
pushAlerts
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Instantiate XPositionTracker Class ...
|
||||
mPositionTracker = new XSCPositionTracker();
|
||||
@@ -2276,7 +2263,6 @@ public:
|
||||
{
|
||||
//
|
||||
delete mTrader;
|
||||
delete mAlert;
|
||||
delete mPositionTracker;
|
||||
}
|
||||
|
||||
@@ -2426,126 +2412,6 @@ public:
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Alert ...
|
||||
|
||||
//
|
||||
bool GetLogAlerts()
|
||||
{
|
||||
return mAlert.GetLogAlerts();
|
||||
}
|
||||
|
||||
//
|
||||
void SetLogAlerts(bool value)
|
||||
{
|
||||
mAlert.SetLogAlerts(value);
|
||||
}
|
||||
|
||||
//
|
||||
bool GetEnableAlerts()
|
||||
{
|
||||
return mAlert.GetEnableAlerts();
|
||||
}
|
||||
|
||||
//
|
||||
void SetEnableAlerts(bool value)
|
||||
{
|
||||
mAlert.SetEnableAlerts(value);
|
||||
}
|
||||
|
||||
//
|
||||
bool GetPushAlerts()
|
||||
{
|
||||
return mAlert.GetPushAlerts();
|
||||
}
|
||||
|
||||
//
|
||||
void SetPushAlerts(bool value)
|
||||
{
|
||||
mAlert.SetPushAlerts(value);
|
||||
}
|
||||
|
||||
//
|
||||
bool GetMailAlerts()
|
||||
{
|
||||
return mAlert.GetMailAlerts();
|
||||
}
|
||||
|
||||
//
|
||||
void SetMailAlerts(bool value)
|
||||
{
|
||||
mAlert.SetMailAlerts(value);
|
||||
}
|
||||
|
||||
//
|
||||
bool GetTerminalAlerts()
|
||||
{
|
||||
return mAlert.GetTerminalAlerts();
|
||||
}
|
||||
|
||||
//
|
||||
void SetTerminalAlerts(bool value)
|
||||
{
|
||||
mAlert.SetTerminalAlerts(value);
|
||||
}
|
||||
|
||||
//
|
||||
void SetAlertPrefix(string value)
|
||||
{
|
||||
mAlert.SetPrefix(value);
|
||||
}
|
||||
|
||||
//
|
||||
// Event Listeners ...
|
||||
void AddOnSignalEventHandler(TOnSignal listener)
|
||||
{
|
||||
//
|
||||
Add(
|
||||
listener,
|
||||
mOnSignalEventHandlers
|
||||
//
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Alert Functions ...
|
||||
|
||||
//
|
||||
// Logging an Alert ...
|
||||
void LogAlert(string message)
|
||||
{
|
||||
mAlert.LogAlert(message);
|
||||
}
|
||||
|
||||
//
|
||||
// Terminal Alert ...
|
||||
void TerminalAlert(string message)
|
||||
{
|
||||
mAlert.TerminalAlert(message);
|
||||
}
|
||||
|
||||
//
|
||||
// Mail Alert ...
|
||||
void MailAlert(string message)
|
||||
{
|
||||
mAlert.MailAlert(message);
|
||||
}
|
||||
|
||||
//
|
||||
// Send Push Notification ...
|
||||
void PushAlert(string message)
|
||||
{
|
||||
mAlert.PushAlert(message);
|
||||
}
|
||||
|
||||
//
|
||||
// Send an Alert by Handling all Different Specified
|
||||
// type's of Alert's if they are Enabled ...
|
||||
void Alert(string message)
|
||||
{
|
||||
mAlert.Alert(message);
|
||||
}
|
||||
|
||||
//
|
||||
// Overrides ...
|
||||
|
||||
@@ -2933,7 +2799,6 @@ protected:
|
||||
//
|
||||
// Trade Class Instance ...
|
||||
XSCTrade *mTrader;
|
||||
XSCAlert *mAlert;
|
||||
XSCPositionTracker *mPositionTracker;
|
||||
|
||||
//
|
||||
|
||||
@@ -22,82 +22,15 @@
|
||||
|
||||
//
|
||||
// Includes ...
|
||||
#include "../Classes/x-saherelm.base.class.mq5"
|
||||
#include "../Classes/x-saherelm.xalert.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
|
||||
class XSCBaseProvider : public XSCBaseAlert
|
||||
{
|
||||
//
|
||||
// Public ...
|
||||
@@ -139,39 +72,10 @@ public:
|
||||
//
|
||||
// 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 ...
|
||||
|
||||
|
||||
@@ -1094,17 +1094,6 @@ public:
|
||||
);
|
||||
bool isLong = IsLong(mSignal.type);
|
||||
|
||||
//
|
||||
// Select SL and TP ...
|
||||
|
||||
//
|
||||
double selectedSL = 0;
|
||||
mSignal.RegularSL(selectedSL);
|
||||
|
||||
//
|
||||
double selectedTP = 0;
|
||||
mSignal.RegularTP(selectedTP);
|
||||
|
||||
//
|
||||
if (!mSignal.IsValid())
|
||||
{
|
||||
@@ -1142,8 +1131,8 @@ public:
|
||||
mSignal.period,
|
||||
mSignal.volume,
|
||||
mSignal.entry,
|
||||
selectedSL,
|
||||
selectedTP,
|
||||
mSignal.sl,
|
||||
mSignal.tp,
|
||||
mSignal.comment
|
||||
//
|
||||
);
|
||||
@@ -1156,8 +1145,8 @@ public:
|
||||
mSignal.period,
|
||||
mSignal.volume,
|
||||
mSignal.entry,
|
||||
selectedSL,
|
||||
selectedTP,
|
||||
mSignal.sl,
|
||||
mSignal.tp,
|
||||
mSignal.comment
|
||||
//
|
||||
);
|
||||
@@ -1194,8 +1183,8 @@ public:
|
||||
mSignal.period,
|
||||
mSignal.volume,
|
||||
mSignal.entry,
|
||||
selectedSL,
|
||||
selectedTP,
|
||||
mSignal.sl,
|
||||
mSignal.tp,
|
||||
lifetime,
|
||||
expiration,
|
||||
mSignal.comment
|
||||
@@ -1210,8 +1199,8 @@ public:
|
||||
mSignal.period,
|
||||
mSignal.volume,
|
||||
mSignal.entry,
|
||||
selectedSL,
|
||||
selectedTP,
|
||||
mSignal.sl,
|
||||
mSignal.tp,
|
||||
lifetime,
|
||||
expiration,
|
||||
mSignal.comment
|
||||
@@ -1248,8 +1237,8 @@ public:
|
||||
mSignal.period,
|
||||
mSignal.volume,
|
||||
mSignal.entry,
|
||||
selectedSL,
|
||||
selectedTP,
|
||||
mSignal.sl,
|
||||
mSignal.tp,
|
||||
lifetime,
|
||||
expiration,
|
||||
mSignal.comment
|
||||
@@ -1264,8 +1253,8 @@ public:
|
||||
mSignal.period,
|
||||
mSignal.volume,
|
||||
mSignal.entry,
|
||||
selectedSL,
|
||||
selectedTP,
|
||||
mSignal.sl,
|
||||
mSignal.tp,
|
||||
lifetime,
|
||||
expiration,
|
||||
mSignal.comment
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
|
||||
//
|
||||
// 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 Implementation Method ...
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//
|
||||
// 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);
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
// );
|
||||
@@ -298,14 +298,6 @@ void ConfigureDescriptor(
|
||||
X121ProviderDescriptor &iDescriptor //
|
||||
)
|
||||
{
|
||||
//
|
||||
// XHK ...
|
||||
iDescriptor.inputs.tmInputs.showLine = false;
|
||||
|
||||
//
|
||||
// XAMA ...
|
||||
iDescriptor.inputs.amaInputs.showLine = false;
|
||||
|
||||
//
|
||||
// XHK ...
|
||||
iDescriptor.inputs.hkInputs.drawHikenAshi = false;
|
||||
|
||||
@@ -1,967 +0,0 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 ...
|
||||
@@ -1,960 +0,0 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 ...
|
||||
@@ -1,292 +0,0 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 ...
|
||||
@@ -1,422 +0,0 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 ...
|
||||
@@ -1,306 +0,0 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 ...
|
||||
@@ -1,392 +0,0 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 ...
|
||||
@@ -1,550 +0,0 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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.
@@ -1,816 +0,0 @@
|
||||
//////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_chart_window
|
||||
|
||||
//
|
||||
#property indicator_buffers 7
|
||||
// #property indicator_plots 6
|
||||
#property indicator_plots 0
|
||||
|
||||
//
|
||||
// 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_CALCULATIONS);
|
||||
// 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_CALCULATIONS);
|
||||
// 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_CALCULATIONS);
|
||||
// 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_CALCULATIONS);
|
||||
// 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_CALCULATIONS);
|
||||
// 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_CALCULATIONS);
|
||||
// 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 ...
|
||||
//
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,309 +0,0 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_chart_window
|
||||
|
||||
//
|
||||
#property indicator_buffers 2
|
||||
// #property indicator_plots 1
|
||||
#property indicator_plots 0
|
||||
|
||||
//
|
||||
// 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_CALCULATIONS);
|
||||
// SetIndexBuffer(fiBufferIndex, fiBuffer, INDICATOR_DATA);
|
||||
// PlotIndexSetString(fiBufferIndex, PLOT_LABEL, fiBufferLabel);
|
||||
|
||||
// //
|
||||
// // FI Color Buffer ...
|
||||
ArraySetAsSeries(fiColorBuffer, true);
|
||||
// SetIndexBuffer(fiColorBufferIndex, fiColorBuffer, INDICATOR_COLOR_INDEX);
|
||||
SetIndexBuffer(fiColorBufferIndex, fiColorBuffer, INDICATOR_CALCULATIONS);
|
||||
}
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
//
|
||||
@@ -1,309 +0,0 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// 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_chart_window
|
||||
|
||||
//
|
||||
#property indicator_buffers 2
|
||||
#property indicator_plots 1
|
||||
// #property indicator_plots 0
|
||||
|
||||
//
|
||||
// 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_CALCULATIONS);
|
||||
SetIndexBuffer(fiBufferIndex, fiBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetString(fiBufferIndex, PLOT_LABEL, fiBufferLabel);
|
||||
|
||||
//
|
||||
// FI Color Buffer ...
|
||||
ArraySetAsSeries(fiColorBuffer, true);
|
||||
SetIndexBuffer(fiColorBufferIndex, fiColorBuffer, INDICATOR_COLOR_INDEX);
|
||||
// SetIndexBuffer(fiColorBufferIndex, fiColorBuffer, INDICATOR_CALCULATIONS);
|
||||
}
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
//
|
||||
@@ -1,352 +0,0 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 XLH Indicator
|
||||
// ---------------------------------------------
|
||||
// Name: XLH
|
||||
// Description: Moving Average Indicator
|
||||
// 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 XLH Indicator"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// START Constants ...
|
||||
//
|
||||
#define ShortName "XLH"
|
||||
//
|
||||
// END Constants ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Inputs ...
|
||||
//
|
||||
input int length = 14; // Length
|
||||
input ENUM_SERIESMODE hhMode = MODE_HIGH; // Highest High Calculation Method
|
||||
input ENUM_SERIESMODE llMode = MODE_LOW; // Lowest Low Calculation Method
|
||||
//
|
||||
// END Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
// Includes Common Library ...
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||
|
||||
//
|
||||
// START Buffers ...
|
||||
//
|
||||
#property indicator_chart_window
|
||||
|
||||
//
|
||||
#property indicator_buffers 3
|
||||
#property indicator_plots 3
|
||||
|
||||
//
|
||||
// HH Buffer ...
|
||||
#define hhBufferIndex 0
|
||||
|
||||
//
|
||||
double hhBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label1 "XLH HH"
|
||||
#property indicator_type1 DRAW_LINE
|
||||
#property indicator_color1 CLR_NONE, // clrAqua
|
||||
#property indicator_style1 STYLE_DOT
|
||||
#property indicator_width1 1
|
||||
|
||||
//
|
||||
// LL Buffer ...
|
||||
#define llBufferIndex 1
|
||||
|
||||
//
|
||||
double llBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label2 "XLH LL"
|
||||
#property indicator_type2 DRAW_LINE
|
||||
#property indicator_color2 CLR_NONE, // clrFuchsia
|
||||
#property indicator_style2 STYLE_DOT
|
||||
#property indicator_width2 1
|
||||
|
||||
//
|
||||
// Signal Buffer ...
|
||||
#define signalBufferIndex 2
|
||||
|
||||
//
|
||||
double signalBuffer[];
|
||||
|
||||
//
|
||||
#property indicator_label3 "XLH S"
|
||||
#property indicator_type3 DRAW_LINE
|
||||
#property indicator_color3 CLR_NONE, // clrGold
|
||||
#property indicator_style3 STYLE_DOT
|
||||
#property indicator_width3 1
|
||||
//
|
||||
// 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;
|
||||
}
|
||||
|
||||
//
|
||||
// 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 ...
|
||||
}
|
||||
|
||||
//
|
||||
// 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);
|
||||
|
||||
//
|
||||
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 = false;
|
||||
|
||||
//
|
||||
// Validate Args ...
|
||||
if (length >= 2)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Indexes and Styles ...
|
||||
void DefineBuffers()
|
||||
{
|
||||
//
|
||||
// HH Buffer ...
|
||||
string hhBufferLabel = ShortName + " HH " + "(" + (string)length + ")";
|
||||
ArraySetAsSeries(hhBuffer, true);
|
||||
SetIndexBuffer(hhBufferIndex, hhBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(hhBufferIndex, PLOT_DRAW_BEGIN, length);
|
||||
PlotIndexSetString(hhBufferIndex, PLOT_LABEL, hhBufferLabel);
|
||||
|
||||
//
|
||||
// LL Buffer ...
|
||||
string llBufferLabel = ShortName + " LL " + "(" + (string)length + ")";
|
||||
ArraySetAsSeries(llBuffer, true);
|
||||
SetIndexBuffer(llBufferIndex, llBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(llBufferIndex, PLOT_DRAW_BEGIN, length);
|
||||
PlotIndexSetString(llBufferIndex, PLOT_LABEL, llBufferLabel);
|
||||
|
||||
//
|
||||
// Signal Buffer ...
|
||||
string signalBufferLabel = ShortName + " S " + "(" + (string)length + ")";
|
||||
ArraySetAsSeries(signalBuffer, true);
|
||||
SetIndexBuffer(signalBufferIndex, signalBuffer, INDICATOR_DATA);
|
||||
PlotIndexSetInteger(signalBufferIndex, PLOT_DRAW_BEGIN, length);
|
||||
PlotIndexSetString(signalBufferIndex, PLOT_LABEL, signalBufferLabel);
|
||||
}
|
||||
|
||||
//
|
||||
// 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
|
||||
)
|
||||
{
|
||||
//
|
||||
// Calculate Threshold ...
|
||||
//
|
||||
// HH Buffer ...
|
||||
int hhIndex = iHighest(
|
||||
_Symbol,
|
||||
_Period,
|
||||
hhMode,
|
||||
length,
|
||||
bar_index
|
||||
//
|
||||
);
|
||||
XOHCL hhBar;
|
||||
hhBar.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
hhIndex
|
||||
//
|
||||
);
|
||||
double hhValue = hhBar.GetPrice(hhMode);
|
||||
|
||||
//
|
||||
hhBuffer[bar_index] = hhValue;
|
||||
|
||||
//
|
||||
// LL Buffer ...
|
||||
int llIndex = iLowest(
|
||||
_Symbol,
|
||||
_Period,
|
||||
llMode,
|
||||
length,
|
||||
bar_index
|
||||
//
|
||||
);
|
||||
XOHCL llBar;
|
||||
llBar.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
llIndex
|
||||
//
|
||||
);
|
||||
double llValue = llBar.GetPrice(llMode);
|
||||
|
||||
//
|
||||
llBuffer[bar_index] = llValue;
|
||||
|
||||
//
|
||||
double lhDiff = hhValue - llValue;
|
||||
double signalValue = (lhDiff / 2);
|
||||
|
||||
//
|
||||
signalBuffer[bar_index] = (hhValue - signalValue);
|
||||
}
|
||||
//
|
||||
// END Functions ...
|
||||
//
|
||||
@@ -1,242 +0,0 @@
|
||||
///////////////////////////////////////////////////////
|
||||
// SaherElm IT Center MQL5 Indicator
|
||||
// -------------------------------------------
|
||||
// Name: XMidTest
|
||||
// Description: DONCHAIN Channel ...
|
||||
//
|
||||
// Maintainer:
|
||||
// ------------
|
||||
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
||||
//
|
||||
//////////////////////////////////////////////////////
|
||||
//
|
||||
// Global Properties ...
|
||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||
#property link "https://saherelm.ir"
|
||||
#property version "1.00"
|
||||
#property description "SaherElm XMidTest Indicator"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// Imports ...
|
||||
#include "../Classes/Indicators/x-saherelm.mid.class.mq5"
|
||||
|
||||
//
|
||||
#define ShortName "XMidTest"
|
||||
|
||||
//
|
||||
#property indicator_chart_window
|
||||
|
||||
//
|
||||
#property indicator_buffers 1
|
||||
#property indicator_plots 1
|
||||
|
||||
//
|
||||
// Variables ...
|
||||
XSCMid *mMid;
|
||||
|
||||
//
|
||||
#property indicator_type1 DRAW_LINE
|
||||
double mainBuffer[];
|
||||
double mainColorBuffer[];
|
||||
|
||||
//
|
||||
// Initialization ...
|
||||
int OnInit()
|
||||
{
|
||||
//
|
||||
// Initialize Indicator Class ...
|
||||
bool isInited = InitIndicatorClass();
|
||||
if (!isInited)
|
||||
{
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Index Buffers ...
|
||||
DefineBuffers();
|
||||
|
||||
//
|
||||
// Set Indicator ShortName ...
|
||||
SetIndicatorName();
|
||||
|
||||
//
|
||||
// Init Succeed ...
|
||||
return INIT_SUCCEEDED;
|
||||
}
|
||||
|
||||
//
|
||||
// DeInitialization ...
|
||||
void OnDeinit(const int reason)
|
||||
{
|
||||
//
|
||||
// REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function
|
||||
// REASON_REMOVE 1 Program removed from a chart
|
||||
// REASON_RECOMPILE 2 Program recompiled
|
||||
// REASON_CHARTCHANGE 3 A symbol or a chart period is changed
|
||||
// REASON_CHARTCLOSE 4 Chart closed
|
||||
// REASON_PARAMETERS 5 Inputs changed by a user
|
||||
// REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings
|
||||
// REASON_TEMPLATE 7 Another chart template applied
|
||||
// REASON_INITFAILED 8 The OnInit() handler returned a non-zero value
|
||||
// REASON_CLOSE 9 Terminal closed
|
||||
|
||||
//
|
||||
mMid.DeInit(reason);
|
||||
delete mMid;
|
||||
}
|
||||
|
||||
//
|
||||
// Calculating what we want ...
|
||||
int OnCalculate(
|
||||
const int rates_total, // Total Bars on Chart ...
|
||||
const int prev_calculated, // Total Calculated Bars on Charts ...
|
||||
const datetime &time[], // History of Open Time ...
|
||||
const double &open[], // History of Open Price ...
|
||||
const double &high[], // History of High Price ...
|
||||
const double &low[], // History of Low Price ...
|
||||
const double &close[], // History of Close Price ...
|
||||
const long &tick_volume[], // History of Tick Volumes on Bar ...
|
||||
const long &volume[], // History of Trade Volumes ...
|
||||
const int &spread[] // History of Spread Price ...
|
||||
)
|
||||
{
|
||||
//
|
||||
// this counts Available Bars ...
|
||||
int limit;
|
||||
|
||||
//
|
||||
// because in some cases we may have more than one input for
|
||||
// calculation and we must prevent any calculation
|
||||
// untill we pass the biggest input length, here we get max Input length
|
||||
// and then wait until pass it ...
|
||||
int maxLength = mMid.GetInputs().Max();
|
||||
|
||||
//
|
||||
int midCalculatedBars = mMid.GetCalculatedBars();
|
||||
if (midCalculatedBars < 0)
|
||||
{
|
||||
return prev_calculated;
|
||||
}
|
||||
|
||||
//
|
||||
limit = prev_calculated < maxLength ? rates_total - (maxLength + 1) : rates_total - prev_calculated;
|
||||
|
||||
//
|
||||
// Main Loop ...
|
||||
for (int i = limit; i >= 0 && !IsStopped(); i--)
|
||||
{
|
||||
//
|
||||
CalculateBuffers(i);
|
||||
}
|
||||
|
||||
//
|
||||
return rates_total;
|
||||
}
|
||||
|
||||
//
|
||||
// CUSTOM Functions ...
|
||||
|
||||
//
|
||||
// Validate Input Args for Initialization ...
|
||||
bool InitIndicatorClass()
|
||||
{
|
||||
//
|
||||
bool result = false;
|
||||
|
||||
//
|
||||
// Initialize and Prepare
|
||||
// Inputs of Indicator ...
|
||||
XSCMidInputs inputs;
|
||||
result = inputs.Init(2);
|
||||
if (!result)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Instantiate Class ...
|
||||
mMid = new XSCMid(
|
||||
_Symbol,
|
||||
_Period //
|
||||
);
|
||||
|
||||
//
|
||||
// Now Initialize Indicator Class using Given Inputs ...
|
||||
result = mMid.Init(
|
||||
inputs //
|
||||
);
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Indexes and Styles ...
|
||||
void DefineBuffers()
|
||||
{
|
||||
//
|
||||
// Start Styling and Indexing Buffers ...
|
||||
|
||||
//
|
||||
int mainIDX = mMid.GetBufferIndex("XSCMid");
|
||||
XBuffer mainBufferStruct;
|
||||
mMid.GetBuffer(
|
||||
"XSCMid",
|
||||
mainBufferStruct //
|
||||
);
|
||||
|
||||
//
|
||||
int bufferIndex = 0;
|
||||
|
||||
//
|
||||
int max = mMid.GetInputs().Max();
|
||||
|
||||
//
|
||||
// mainBufferStruct.asSeries
|
||||
// ArraySetAsSeries(mainBuffer, false);
|
||||
|
||||
//
|
||||
XBufferPlotStyle mainBufferStyle;
|
||||
mainBufferStyle.clr = clrAqua;
|
||||
mainBufferStyle.type = DRAW_LINE;
|
||||
|
||||
//
|
||||
SetIndexBuffer(
|
||||
bufferIndex,
|
||||
mainBuffer,
|
||||
mainBufferStyle,
|
||||
mainColorBuffer,
|
||||
"XMID",
|
||||
true,
|
||||
0,
|
||||
max //
|
||||
);
|
||||
}
|
||||
|
||||
//
|
||||
// Set Indicator Short Name and also we can define Buffers Labels ...
|
||||
void SetIndicatorName()
|
||||
{
|
||||
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
|
||||
}
|
||||
|
||||
//
|
||||
void CalculateBuffers(int barIndex)
|
||||
{
|
||||
//
|
||||
double iValue = mMid.GetBufferValue(
|
||||
"XSCMid",
|
||||
barIndex //
|
||||
);
|
||||
|
||||
//
|
||||
// double iValue = iClose(
|
||||
// _Symbol,
|
||||
// _Period,
|
||||
// barIndex //
|
||||
// );
|
||||
|
||||
//
|
||||
mainBuffer[barIndex] = iValue;
|
||||
}
|
||||
@@ -1,392 +0,0 @@
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 OrderBlock Detector Indicator
|
||||
// -----------------------------------------------------
|
||||
// Name: XOBD
|
||||
// Description: detect Order Blocks based on Swings ...
|
||||
//
|
||||
//
|
||||
// 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 XOBD Indicator"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// START Constants ...
|
||||
//
|
||||
#define ShortName "XOBD"
|
||||
//
|
||||
// END Constants ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Inputs ...
|
||||
//
|
||||
//
|
||||
input int length = 5; // Swing Length
|
||||
|
||||
//
|
||||
input uchar swingHighArrowCode = 108; // Swing High Arrow Code
|
||||
input color swingHighArrowColor = clrMagenta; // Swing High Arrow Color
|
||||
|
||||
//
|
||||
input uchar swingLowArrowCode = 108; // Swing Low Arrow Code
|
||||
input color swingLowArrowColor = clrAqua; // Swing Low Arrow Color
|
||||
//
|
||||
// END Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
// Include Common and Models Library ...
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||
|
||||
//
|
||||
// Include Draw Library ...
|
||||
#include "../Libraries/x-saherelm.draw.lib.mq5"
|
||||
|
||||
//
|
||||
// START Buffers ...
|
||||
//
|
||||
#property indicator_chart_window
|
||||
|
||||
//
|
||||
#property indicator_buffers 1
|
||||
#property indicator_plots 0
|
||||
|
||||
//
|
||||
#define swingBufferIndex 0
|
||||
double swingBuffer[];
|
||||
//
|
||||
// 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
|
||||
}
|
||||
|
||||
//
|
||||
// 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 * 3);
|
||||
|
||||
//
|
||||
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 ...
|
||||
if (length >= 2)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Indexes and Styles ...
|
||||
void DefineBuffers()
|
||||
{
|
||||
//
|
||||
ArraySetAsSeries(swingBuffer, true);
|
||||
SetIndexBuffer(swingBufferIndex, swingBuffer, 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)
|
||||
{
|
||||
//
|
||||
// GetCandleSwing(bar_index);
|
||||
ENUM_X_SWING_TYPE type = X_NO_SWING;
|
||||
|
||||
//
|
||||
// Try To Detect Order Blocks ...
|
||||
bool isSwingLow = false;
|
||||
bool isSwingHigh = false;
|
||||
|
||||
//
|
||||
// Reading Candles Data ...
|
||||
int start = bar_index;
|
||||
int count = (length * 2) + 2;
|
||||
int end = start + count;
|
||||
XOHCL bars[];
|
||||
GetBars(
|
||||
bars,
|
||||
_Symbol,
|
||||
_Period,
|
||||
start,
|
||||
count
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
// Swing Low ...
|
||||
isSwingLow =
|
||||
//
|
||||
bars[1].close > bars[2].close &&
|
||||
bars[2].close > bars[3].close &&
|
||||
//
|
||||
bars[3].close < bars[4].close &&
|
||||
//
|
||||
bars[5].close > bars[4].close &&
|
||||
bars[6].close > bars[5].close
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
if (isSwingLow)
|
||||
{
|
||||
type = X_SWING_LOW;
|
||||
}
|
||||
|
||||
//
|
||||
if (!isSwingLow)
|
||||
{
|
||||
//
|
||||
// Swing High ...
|
||||
isSwingHigh =
|
||||
//
|
||||
bars[1].close < bars[2].close &&
|
||||
bars[2].close < bars[3].close &&
|
||||
//
|
||||
bars[3].close > bars[4].close &&
|
||||
//
|
||||
bars[5].close < bars[4].close &&
|
||||
bars[6].close < bars[5].close
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
if (isSwingHigh)
|
||||
{
|
||||
type = X_SWING_HIGH;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
switch (type)
|
||||
{
|
||||
//
|
||||
// Swing High ...
|
||||
case X_SWING_HIGH:
|
||||
//
|
||||
swingBuffer[bar_index] = type;
|
||||
DrawSwingArrow(1, bar_index);
|
||||
break;
|
||||
|
||||
//
|
||||
// Swinmg Low ...
|
||||
case X_SWING_LOW:
|
||||
//
|
||||
swingBuffer[bar_index] = type;
|
||||
DrawSwingArrow(0, bar_index);
|
||||
break;
|
||||
|
||||
//
|
||||
// No Swing ...
|
||||
default:
|
||||
case X_NO_SWING:
|
||||
//
|
||||
swingBuffer[bar_index] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Draw a Swing Arrow Shape ...
|
||||
void DrawSwingArrow(
|
||||
int type, // Swing Type: 0 - Low / 1 - High ...
|
||||
int bar_index //
|
||||
)
|
||||
{
|
||||
//
|
||||
bool isSwingHigh = type == 1;
|
||||
|
||||
//
|
||||
if ((isSwingHigh && swingHighArrowCode == 0) ||
|
||||
(!isSwingHigh && swingLowArrowCode == 0))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
XOHCL candle;
|
||||
candle.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
bar_index + 3);
|
||||
double arrowDistanceInPoint = 0;
|
||||
|
||||
//
|
||||
// Define Required Object Properties fro Draw an Arrow ...
|
||||
datetime time = iTime(_Symbol, _Period, bar_index + 3);
|
||||
double purePrice = isSwingHigh ? candle.high : candle.low;
|
||||
color clr = isSwingHigh ? swingHighArrowColor : swingLowArrowColor;
|
||||
ENUM_ARROW_ANCHOR anchor = isSwingHigh ? ANCHOR_BOTTOM : ANCHOR_TOP;
|
||||
uchar arrowCode = uchar(isSwingHigh ? swingHighArrowCode : swingLowArrowCode);
|
||||
double price = isSwingHigh ? purePrice + arrowDistanceInPoint : purePrice - arrowDistanceInPoint;
|
||||
string name = "Swing " + (isSwingHigh ? "High" : "Low") + "_" + (string)time + "_" + (string)purePrice;
|
||||
|
||||
//
|
||||
// Draw desired Arrow ...
|
||||
DrawArrow(
|
||||
0,
|
||||
name,
|
||||
0,
|
||||
time,
|
||||
price,
|
||||
arrowCode,
|
||||
anchor,
|
||||
clr);
|
||||
}
|
||||
//
|
||||
// END Functions ...
|
||||
//
|
||||
@@ -1,394 +0,0 @@
|
||||
/////////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 OrderBlock Detector Oscillator
|
||||
// ------------------------------------------------------
|
||||
// Name: XRSI
|
||||
// Description: detect market conditions based on RSI ...
|
||||
//
|
||||
//
|
||||
// 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 XRSI Oscillator"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// START Constants ...
|
||||
//
|
||||
|
||||
#define ShortName "XRSI"
|
||||
|
||||
//
|
||||
// END Constants ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
input group "Market";
|
||||
input int length = 14; // Market Length
|
||||
input ENUM_APPLIED_PRICE appliedTo = PRICE_CLOSE; // Applied To
|
||||
|
||||
//
|
||||
input group "Short Entry";
|
||||
input double shortEntryValue = 70; // Short Entry Level
|
||||
input color shortEntryColor = clrRed; // Short Entry Level Color
|
||||
input ENUM_LINE_STYLE shortEntryLineStyle = STYLE_DOT; // Short Entry Style
|
||||
|
||||
//
|
||||
input group "Short Exit";
|
||||
input double shortExitValue = 40; // Short Exit Level
|
||||
input color shortExitColor = clrRed; // Short Exit Level Color
|
||||
input ENUM_LINE_STYLE shortExitLineStyle = STYLE_DOT; // Short Exit Style
|
||||
|
||||
//
|
||||
input group "Long Entry";
|
||||
input double longEntryValue = 30; // Long Entry Level
|
||||
input color longEntryColor = clrRed; // Long Entry Level Color
|
||||
input ENUM_LINE_STYLE longEntryLineStyle = STYLE_DOT; // Long Entry Style
|
||||
|
||||
//
|
||||
input group "Long Exit";
|
||||
input double longExitValue = 60; // Long Exit Level
|
||||
input color longExitColor = clrRed; // Long Exit Level Color
|
||||
input ENUM_LINE_STYLE longExitLineStyle = STYLE_DOT; // Long Exit Style
|
||||
|
||||
//
|
||||
// START Inputs ...
|
||||
//
|
||||
|
||||
//
|
||||
// Include Common and Models Library ...
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||
|
||||
//
|
||||
// START Buffers ...
|
||||
//
|
||||
|
||||
//
|
||||
// #property indicator_separate_window
|
||||
#property indicator_chart_window
|
||||
#property indicator_buffers 2
|
||||
// #property indicator_plots 1
|
||||
#property indicator_plots 0
|
||||
|
||||
//
|
||||
#define rsiBufferIndex 0
|
||||
#define rsiColorBufferIndex 1
|
||||
|
||||
//
|
||||
double rsiBuffer[];
|
||||
double rsiColorBuffer[];
|
||||
|
||||
//
|
||||
// #property indicator_label1 "XRSI"
|
||||
// #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 rsiHandler = INVALID_HANDLE;
|
||||
|
||||
//
|
||||
// END Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Event Handlers ...
|
||||
//
|
||||
//
|
||||
// Initialization ...
|
||||
int OnInit()
|
||||
{
|
||||
//
|
||||
// Validate Inputs ...
|
||||
if (!ValidateInputs())
|
||||
{
|
||||
return INIT_PARAMETERS_INCORRECT;
|
||||
}
|
||||
|
||||
//
|
||||
rsiHandler = iRSI(
|
||||
_Symbol,
|
||||
_Period,
|
||||
length,
|
||||
appliedTo);
|
||||
if (rsiHandler == 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(rsiHandler);
|
||||
}
|
||||
|
||||
//
|
||||
// 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);
|
||||
|
||||
//
|
||||
int rsiCalculatedBars = BarsCalculated(rsiHandler);
|
||||
if (rsiCalculatedBars < maxLength)
|
||||
{
|
||||
return prev_calculated;
|
||||
}
|
||||
|
||||
//
|
||||
limit = prev_calculated < maxLength ? rates_total - (maxLength + 1) : rates_total - prev_calculated;
|
||||
|
||||
//
|
||||
int rsiCopiedItems = CopyBuffer(rsiHandler, 0, 0, limit, rsiBuffer);
|
||||
if (rsiCopiedItems <= 0)
|
||||
{
|
||||
return prev_calculated;
|
||||
}
|
||||
|
||||
//
|
||||
// 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 = false;
|
||||
|
||||
//
|
||||
// Validate Args ...
|
||||
if (length >= 2)
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Indexes and Styles ...
|
||||
void DefineBuffers()
|
||||
{
|
||||
//
|
||||
// RSI ...
|
||||
string rsiBufferLabel = ShortName + " (" + (string)length + ")";
|
||||
ArraySetAsSeries(rsiBuffer, true);
|
||||
SetIndexBuffer(rsiBufferIndex, rsiBuffer, INDICATOR_CALCULATIONS);
|
||||
// SetIndexBuffer(rsiBufferIndex, rsiBuffer, INDICATOR_DATA);
|
||||
// PlotIndexSetInteger(rsiBufferIndex, PLOT_DRAW_BEGIN, length);
|
||||
// PlotIndexSetString(rsiBufferIndex, PLOT_LABEL, rsiBufferLabel);
|
||||
|
||||
// //
|
||||
// // RSI Color Buffer ...
|
||||
ArraySetAsSeries(rsiColorBuffer, true);
|
||||
SetIndexBuffer(rsiColorBufferIndex, rsiColorBuffer, INDICATOR_CALCULATIONS);
|
||||
// SetIndexBuffer(rsiColorBufferIndex, rsiColorBuffer, INDICATOR_COLOR_INDEX);
|
||||
|
||||
//
|
||||
// Set Indicator Levels here ...
|
||||
// OB, ExitLong, ExitShort, OS ...
|
||||
IndicatorSetInteger(INDICATOR_LEVELS, 4);
|
||||
|
||||
//
|
||||
// SHORTENTRY ...
|
||||
IndicatorSetDouble(INDICATOR_LEVELVALUE, 0, shortEntryValue);
|
||||
IndicatorSetInteger(INDICATOR_LEVELCOLOR, 0, shortEntryColor);
|
||||
IndicatorSetInteger(INDICATOR_LEVELSTYLE, 0, shortEntryLineStyle);
|
||||
IndicatorSetString(INDICATOR_LEVELTEXT, 0, "Short Entry");
|
||||
|
||||
//
|
||||
// LONGEXIT ...
|
||||
IndicatorSetDouble(INDICATOR_LEVELVALUE, 1, longExitValue);
|
||||
IndicatorSetInteger(INDICATOR_LEVELCOLOR, 1, longExitColor);
|
||||
IndicatorSetInteger(INDICATOR_LEVELSTYLE, 1, shortExitLineStyle);
|
||||
IndicatorSetString(INDICATOR_LEVELTEXT, 1, "Long Exit");
|
||||
|
||||
//
|
||||
// SHORTEXIT ...
|
||||
IndicatorSetDouble(INDICATOR_LEVELVALUE, 2, shortExitValue);
|
||||
IndicatorSetInteger(INDICATOR_LEVELCOLOR, 2, shortExitColor);
|
||||
IndicatorSetInteger(INDICATOR_LEVELSTYLE, 2, longEntryLineStyle);
|
||||
IndicatorSetString(INDICATOR_LEVELTEXT, 2, "Short Exit");
|
||||
|
||||
//
|
||||
// LONGENTRY ...
|
||||
IndicatorSetDouble(INDICATOR_LEVELVALUE, 3, longEntryValue);
|
||||
IndicatorSetInteger(INDICATOR_LEVELCOLOR, 3, longEntryColor);
|
||||
IndicatorSetInteger(INDICATOR_LEVELSTYLE, 3, longExitLineStyle);
|
||||
IndicatorSetString(INDICATOR_LEVELTEXT, 3, "Long Entry");
|
||||
|
||||
//
|
||||
// Set Maximum and Minimum for subwindow
|
||||
IndicatorSetInteger(INDICATOR_DIGITS, 2);
|
||||
IndicatorSetDouble(INDICATOR_MINIMUM, 0);
|
||||
IndicatorSetDouble(INDICATOR_MAXIMUM, 100);
|
||||
}
|
||||
|
||||
//
|
||||
// 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)
|
||||
{
|
||||
//
|
||||
double iValue = rsiBuffer[bar_index];
|
||||
|
||||
//
|
||||
double iColorIndex = 0;
|
||||
|
||||
//
|
||||
if (
|
||||
iValue >= shortEntryValue ||
|
||||
iValue <= longEntryValue ||
|
||||
(iValue < longExitValue &&
|
||||
iValue > shortExitValue))
|
||||
{
|
||||
iColorIndex = 0;
|
||||
}
|
||||
else if (
|
||||
iValue <= shortEntryValue &&
|
||||
iValue >= longExitValue)
|
||||
{
|
||||
iColorIndex = 2;
|
||||
}
|
||||
else if (
|
||||
iValue < shortExitValue &&
|
||||
iValue > longEntryValue)
|
||||
{
|
||||
iColorIndex = 1;
|
||||
}
|
||||
|
||||
//
|
||||
rsiColorBuffer[bar_index] = iColorIndex;
|
||||
}
|
||||
|
||||
//
|
||||
// END Functions ...
|
||||
//
|
||||
@@ -1,548 +0,0 @@
|
||||
///////////////////////////////////////////////////////
|
||||
//
|
||||
// SaherElm IT Center MQL5 XTS Oscillator
|
||||
// ---------------------------------------------
|
||||
// Name: XTS
|
||||
// Description: Time Sections Oscillator ...
|
||||
//
|
||||
//
|
||||
// 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 XTS Oscillator"
|
||||
#property strict
|
||||
|
||||
//
|
||||
// START Constants ...
|
||||
//
|
||||
|
||||
//
|
||||
#define ShortName "XTS"
|
||||
|
||||
//
|
||||
// Includes Draw Library ...
|
||||
#include "../Libraries/x-saherelm.draw.lib.mq5"
|
||||
|
||||
//
|
||||
// Includes Common Library ...
|
||||
#include "../Libraries/x-saherelm.common.lib.mq5"
|
||||
|
||||
//
|
||||
// END Constants ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Inputs ...
|
||||
//
|
||||
input group "Current Period";
|
||||
input ENUM_APPLIED_PRICE currentAppliedTo = PRICE_CLOSE; // Current Applied To
|
||||
//
|
||||
input group "Nearest Period";
|
||||
input ENUM_X_PERIOD_METHOD nearestMethod = X_PERIOD_AUTO; // How to Find Nearest Period
|
||||
input ENUM_TIMEFRAMES nearestPeriod = NULL; // Nearest Time Frame
|
||||
input ENUM_APPLIED_PRICE nearestAppliedTo = PRICE_CLOSE; // Nearest Applied To
|
||||
//
|
||||
input group "Mediest Period";
|
||||
input ENUM_X_PERIOD_METHOD mediestMethod = X_PERIOD_AUTO; // How to Find Mediest Period
|
||||
input ENUM_TIMEFRAMES mediestPeriod = NULL; // Mediest Time Frame
|
||||
input ENUM_APPLIED_PRICE mediestAppliedTo = PRICE_CLOSE; // Mediest Applied To
|
||||
//
|
||||
input group "Farest Period";
|
||||
input ENUM_X_PERIOD_METHOD farestMethod = X_PERIOD_AUTO; // How to Find Farest Period
|
||||
input ENUM_TIMEFRAMES farestPeriod = NULL; // Farest Time Frame
|
||||
input ENUM_APPLIED_PRICE farestAppliedTo = PRICE_CLOSE; // Farest Applied To
|
||||
|
||||
//
|
||||
// START Buffers ...
|
||||
//
|
||||
// #property indicator_separate_window
|
||||
#property indicator_chart_window
|
||||
|
||||
//
|
||||
#property indicator_buffers 4
|
||||
// #property indicator_plots 4
|
||||
#property indicator_plots 0
|
||||
|
||||
//
|
||||
// Current ...
|
||||
#define currentBufferIndex 0
|
||||
|
||||
double currentBuffer[];
|
||||
|
||||
// #property indicator_label1 "XTS C"
|
||||
// #property indicator_type1 DRAW_LINE
|
||||
// #property indicator_color1 clrBrown
|
||||
// #property indicator_style1 STYLE_SOLID
|
||||
// #property indicator_width1 1
|
||||
|
||||
//
|
||||
// Nearest ...
|
||||
#define nearestBufferIndex 1
|
||||
|
||||
double nearestBuffer[];
|
||||
|
||||
// #property indicator_label2 "XTS N"
|
||||
// #property indicator_type2 DRAW_LINE
|
||||
// #property indicator_color2 clrAqua
|
||||
// #property indicator_style2 STYLE_SOLID
|
||||
// #property indicator_width2 1
|
||||
|
||||
//
|
||||
// Mediest ...
|
||||
#define mediestBufferIndex 2
|
||||
|
||||
double mediestBuffer[];
|
||||
|
||||
// #property indicator_label3 "XTS M"
|
||||
// #property indicator_type3 DRAW_LINE
|
||||
// #property indicator_color3 clrLime
|
||||
// #property indicator_style3 STYLE_SOLID
|
||||
// #property indicator_width3 1
|
||||
|
||||
//
|
||||
// Farest ...
|
||||
#define farestBufferIndex 3
|
||||
|
||||
double farestBuffer[];
|
||||
|
||||
// #property indicator_label4 "XTS F"
|
||||
// #property indicator_type4 DRAW_LINE
|
||||
// #property indicator_color4 clrLightBlue
|
||||
// #property indicator_style4 STYLE_SOLID
|
||||
// #property indicator_width4 1
|
||||
|
||||
//
|
||||
// END Buffers ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Global Definitions: Variables, Properties and etc ...
|
||||
//
|
||||
|
||||
//
|
||||
ENUM_TIMEFRAMES mNearestPeriod = NULL;
|
||||
ENUM_TIMEFRAMES mMediestPeriod = NULL;
|
||||
ENUM_TIMEFRAMES mFarestPeriod = NULL;
|
||||
|
||||
//
|
||||
// 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 Oscillator ShortName ...
|
||||
SetOscillatorName();
|
||||
|
||||
//
|
||||
// Init Succeed ...
|
||||
return INIT_SUCCEEDED;
|
||||
}
|
||||
|
||||
//
|
||||
// DeInitialization ...
|
||||
void OnDeinit(const int reason)
|
||||
{
|
||||
// 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 = 30;
|
||||
|
||||
//
|
||||
limit = (prev_calculated > rates_total || prev_calculated <= 0) ? rates_total : (rates_total - prev_calculated) + 1;
|
||||
|
||||
//
|
||||
// Main Loop ...
|
||||
for (int i = 0; i < limit && !IsStopped(); i++)
|
||||
{
|
||||
//
|
||||
// Do Buffers Calculation ...
|
||||
CalculateBuffers(i);
|
||||
}
|
||||
|
||||
//
|
||||
return rates_total;
|
||||
}
|
||||
|
||||
//
|
||||
// END Event Handlers ...
|
||||
//
|
||||
|
||||
//
|
||||
// START Functions ...
|
||||
//
|
||||
//
|
||||
// Validate Input Args for Initialization ...
|
||||
bool ValidateInputs()
|
||||
{
|
||||
//
|
||||
bool result = true;
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Define Indexes and Styles ...
|
||||
void DefineBuffers()
|
||||
{
|
||||
//
|
||||
int maxLength = 30;
|
||||
|
||||
//
|
||||
// Current ...
|
||||
ArraySetAsSeries(currentBuffer, true);
|
||||
SetIndexBuffer(currentBufferIndex, currentBuffer, INDICATOR_CALCULATIONS);
|
||||
// SetIndexBuffer(currentBufferIndex, currentBuffer, INDICATOR_DATA);
|
||||
// PlotIndexSetInteger(currentBufferIndex, PLOT_DRAW_BEGIN, maxLength);
|
||||
|
||||
//
|
||||
// Nearest ...
|
||||
ArraySetAsSeries(nearestBuffer, true);
|
||||
SetIndexBuffer(nearestBufferIndex, nearestBuffer, INDICATOR_CALCULATIONS);
|
||||
// SetIndexBuffer(nearestBufferIndex, nearestBuffer, INDICATOR_DATA);
|
||||
// PlotIndexSetInteger(nearestBufferIndex, PLOT_DRAW_BEGIN, maxLength);
|
||||
|
||||
//
|
||||
// Mediest ...
|
||||
ArraySetAsSeries(mediestBuffer, true);
|
||||
SetIndexBuffer(mediestBufferIndex, mediestBuffer, INDICATOR_CALCULATIONS);
|
||||
// SetIndexBuffer(mediestBufferIndex, mediestBuffer, INDICATOR_DATA);
|
||||
// PlotIndexSetInteger(mediestBufferIndex, PLOT_DRAW_BEGIN, maxLength);
|
||||
|
||||
//
|
||||
// Farest ...
|
||||
ArraySetAsSeries(farestBuffer, true);
|
||||
SetIndexBuffer(farestBufferIndex, farestBuffer, INDICATOR_CALCULATIONS);
|
||||
// SetIndexBuffer(farestBufferIndex, farestBuffer, INDICATOR_DATA);
|
||||
// PlotIndexSetInteger(farestBufferIndex, PLOT_DRAW_BEGIN, maxLength);
|
||||
}
|
||||
|
||||
//
|
||||
// Set Oscillator Short Name and also we can define Buffers Labels ...
|
||||
void SetOscillatorName()
|
||||
{
|
||||
IndicatorSetString(INDICATOR_SHORTNAME, ShortName);
|
||||
}
|
||||
|
||||
//
|
||||
// Calculate Buffers ...
|
||||
void CalculateBuffers(int bar_index)
|
||||
{
|
||||
//
|
||||
// Current ...
|
||||
CalculateCurrent(bar_index);
|
||||
|
||||
//
|
||||
// Nearest ...
|
||||
CalculateNearest(bar_index);
|
||||
|
||||
//
|
||||
// Mediest ...
|
||||
CalculateMediest(bar_index);
|
||||
|
||||
//
|
||||
// Farest ...
|
||||
CalculateFarest(bar_index);
|
||||
|
||||
//
|
||||
// Commenting ...
|
||||
// string comment = GenerateDescriptionComment();
|
||||
// Comment(comment);
|
||||
}
|
||||
|
||||
//
|
||||
// Current ...
|
||||
void CalculateCurrent(int bar_index)
|
||||
{
|
||||
//
|
||||
datetime barTime = iTime(
|
||||
_Symbol,
|
||||
_Period,
|
||||
bar_index);
|
||||
datetime startTime = GetPeriodStartTime(
|
||||
_Symbol,
|
||||
_Period,
|
||||
barTime);
|
||||
int startBarIndex = iBarShift(
|
||||
_Symbol,
|
||||
_Period,
|
||||
startTime);
|
||||
|
||||
//
|
||||
XOHCL c;
|
||||
c.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
startBarIndex
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
double value = c.GetPrice(currentAppliedTo);
|
||||
|
||||
//
|
||||
currentBuffer[bar_index] = value;
|
||||
}
|
||||
|
||||
//
|
||||
// Nearest ...
|
||||
void CalculateNearest(int bar_index)
|
||||
{
|
||||
//
|
||||
if (mNearestPeriod == NULL)
|
||||
{
|
||||
//
|
||||
switch (nearestMethod)
|
||||
{
|
||||
//
|
||||
case X_PERIOD_AUTO:
|
||||
mNearestPeriod = GetNearestPeriod(_Period);
|
||||
break;
|
||||
|
||||
//
|
||||
case X_PERIOD_NOTHING:
|
||||
case X_PERIOD_MANUALLY:
|
||||
mNearestPeriod = nearestPeriod;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
datetime barTime = iTime(
|
||||
_Symbol,
|
||||
_Period,
|
||||
bar_index);
|
||||
datetime startTime = GetPeriodStartTime(
|
||||
_Symbol,
|
||||
mNearestPeriod,
|
||||
barTime);
|
||||
int startBarIndex = iBarShift(
|
||||
_Symbol,
|
||||
_Period,
|
||||
startTime);
|
||||
|
||||
//
|
||||
XOHCL c;
|
||||
c.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
startBarIndex
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
double value = c.GetPrice(nearestAppliedTo);
|
||||
|
||||
//
|
||||
nearestBuffer[bar_index] = value;
|
||||
}
|
||||
|
||||
//
|
||||
// Mediest ...
|
||||
void CalculateMediest(int bar_index)
|
||||
{
|
||||
//
|
||||
if (mMediestPeriod == NULL)
|
||||
{
|
||||
//
|
||||
switch (mediestMethod)
|
||||
{
|
||||
//
|
||||
case X_PERIOD_AUTO:
|
||||
mMediestPeriod = GetMediestPeriod(_Period);
|
||||
break;
|
||||
|
||||
//
|
||||
case X_PERIOD_NOTHING:
|
||||
case X_PERIOD_MANUALLY:
|
||||
mMediestPeriod = mediestPeriod;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
datetime barTime = iTime(
|
||||
_Symbol,
|
||||
_Period,
|
||||
bar_index);
|
||||
datetime startTime = GetPeriodStartTime(
|
||||
_Symbol,
|
||||
mMediestPeriod,
|
||||
barTime);
|
||||
int startBarIndex = iBarShift(
|
||||
_Symbol,
|
||||
_Period,
|
||||
startTime);
|
||||
|
||||
//
|
||||
XOHCL c;
|
||||
c.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
startBarIndex
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
double value = c.GetPrice(mediestAppliedTo);
|
||||
|
||||
//
|
||||
mediestBuffer[bar_index] = value;
|
||||
}
|
||||
|
||||
//
|
||||
// Farest ...
|
||||
void CalculateFarest(int bar_index)
|
||||
{
|
||||
//
|
||||
if (mFarestPeriod == NULL)
|
||||
{
|
||||
//
|
||||
switch (farestMethod)
|
||||
{
|
||||
//
|
||||
case X_PERIOD_AUTO:
|
||||
mFarestPeriod = GetLongestPeriod(_Period);
|
||||
break;
|
||||
|
||||
//
|
||||
case X_PERIOD_NOTHING:
|
||||
case X_PERIOD_MANUALLY:
|
||||
mFarestPeriod = farestPeriod;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
datetime barTime = iTime(
|
||||
_Symbol,
|
||||
_Period,
|
||||
bar_index);
|
||||
datetime startTime = GetPeriodStartTime(
|
||||
_Symbol,
|
||||
mFarestPeriod,
|
||||
barTime);
|
||||
int startBarIndex = iBarShift(
|
||||
_Symbol,
|
||||
_Period,
|
||||
startTime);
|
||||
|
||||
//
|
||||
XOHCL c;
|
||||
c.Init(
|
||||
_Symbol,
|
||||
_Period,
|
||||
startBarIndex
|
||||
//
|
||||
);
|
||||
|
||||
//
|
||||
double value = c.GetPrice(farestAppliedTo);
|
||||
|
||||
//
|
||||
farestBuffer[bar_index] = value;
|
||||
}
|
||||
|
||||
//
|
||||
// Generate Comment ...
|
||||
string GenerateDescriptionComment()
|
||||
{
|
||||
//
|
||||
string result = "";
|
||||
|
||||
//
|
||||
result += "Nearest : " + EnumToString(mNearestPeriod) + "\n";
|
||||
result += "Mediest : " + EnumToString(mMediestPeriod) + "\n";
|
||||
result += "Farest : " + EnumToString(mFarestPeriod) + "\n";
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// END Functions ...
|
||||
//
|
||||
+336
-554
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user