Files
xMQL5/MQLTestWorkspace/BKPS/14030309/Helpers/x-saherelm.xobd.helper.mq5
T
2024-05-29 16:59:29 +03:30

306 lines
5.2 KiB
Plaintext

///////////////////////////////////////////////////////
//
// 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 ...