1229 lines
22 KiB
Plaintext
1229 lines
22 KiB
Plaintext
///////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 Helper Class Library
|
|
// ----------------------------------------------
|
|
// Name: XSCXMRBHelper
|
|
// 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_XMRB_BUFFERS
|
|
{
|
|
//
|
|
// Ribbon ...
|
|
XMRB_FAST_LINE = 0,
|
|
XMRB_SLOW_LINE = 1,
|
|
//
|
|
// Ribbon 1 ...
|
|
XMRB_R1_FAST_LINE = 2,
|
|
XMRB_R1_SLOW_LINE = 3,
|
|
//
|
|
// Ribbon 2 ...
|
|
XMRB_R2_FAST_LINE = 4,
|
|
XMRB_R2_SLOW_LINE = 5,
|
|
//
|
|
// Ribbon 3 ...
|
|
XMRB_R3_FAST_LINE = 6,
|
|
XMRB_R3_SLOW_LINE = 7,
|
|
//
|
|
// Ribbon 4 ...
|
|
XMRB_R4_FAST_LINE = 8,
|
|
XMRB_R4_SLOW_LINE = 9,
|
|
//
|
|
// Ribbon 5 ...
|
|
XMRB_R5_FAST_LINE = 10,
|
|
XMRB_R5_SLOW_LINE = 11,
|
|
};
|
|
|
|
//
|
|
// Input Models ...
|
|
struct XMRBInputs
|
|
{
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
// Ribbon 1 ...
|
|
int fast1Length; // Fast
|
|
int slow1Length; // Slow
|
|
|
|
//
|
|
// Ribbon 2 ...
|
|
int fast2Length; // Fast
|
|
int slow2Length; // Slow
|
|
|
|
//
|
|
// Ribbon 3 ...
|
|
int fast3Length; // Fast
|
|
int slow3Length; // Slow
|
|
|
|
//
|
|
// Ribbon 4 ...
|
|
int fast4Length; // Fast
|
|
int slow4Length; // Slow
|
|
|
|
//
|
|
// Ribbon 5 ...
|
|
int fast5Length; // Fast
|
|
int slow5Length; // Slow
|
|
|
|
//
|
|
// Calculation ...
|
|
ENUM_MA_METHOD ribbonMode; // Mode
|
|
ENUM_APPLIED_PRICE ribbonAppliedTo; // Applied To
|
|
|
|
//
|
|
// Presentation ...
|
|
bool showFastMa; // Show Fast
|
|
bool showSlowMa; // Show Slow
|
|
bool showRibbon; // Show Ribbon
|
|
|
|
//
|
|
// Constructor(s) ...
|
|
XMRBInputs()
|
|
{
|
|
//
|
|
Clean();
|
|
}
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
// Clean ...
|
|
void Clean()
|
|
{
|
|
//
|
|
// Ribbon 1 ...
|
|
fast1Length = 0; // Fast
|
|
slow1Length = 0; // Slow
|
|
|
|
//
|
|
// Ribbon 2 ...
|
|
fast2Length = 0; // Fast
|
|
slow2Length = 0; // Slow
|
|
|
|
//
|
|
// Ribbon 3 ...
|
|
fast3Length = 0; // Fast
|
|
slow3Length = 0; // Slow
|
|
|
|
//
|
|
// Ribbon 4 ...
|
|
fast4Length = 0; // Fast
|
|
slow4Length = 0; // Slow
|
|
|
|
//
|
|
// Ribbon 5 ...
|
|
fast5Length = 0; // Fast
|
|
slow5Length = 0; // Slow
|
|
|
|
//
|
|
// Calculation ...
|
|
ribbonMode = MODE_EMA; // Mode
|
|
ribbonAppliedTo = PRICE_CLOSE; // Applied To
|
|
|
|
//
|
|
// Presentation ...
|
|
showFastMa = false; // Show Fast
|
|
showSlowMa = false; // Show Slow
|
|
showRibbon = false; // Show Ribbon
|
|
}
|
|
|
|
//
|
|
// Default ...
|
|
void Default()
|
|
{
|
|
//
|
|
// Ribbon 1 ...
|
|
fast1Length = 3; // Fast
|
|
slow1Length = 5; // Slow
|
|
|
|
//
|
|
// Ribbon 2 ...
|
|
fast2Length = 8; // Fast
|
|
slow2Length = 13; // Slow
|
|
|
|
//
|
|
// Ribbon 3 ...
|
|
fast3Length = 21; // Fast
|
|
slow3Length = 34; // Slow
|
|
|
|
//
|
|
// Ribbon 4 ...
|
|
fast4Length = 55; // Fast
|
|
slow4Length = 89; // Slow
|
|
|
|
//
|
|
// Ribbon 5 ...
|
|
fast5Length = 144; // Fast
|
|
slow5Length = 233; // Slow
|
|
|
|
//
|
|
// Calculation ...
|
|
ribbonMode = MODE_EMA; // Mode
|
|
ribbonAppliedTo = PRICE_CLOSE; // Applied To
|
|
|
|
//
|
|
// Presentation ...
|
|
showFastMa = true; // Show Fast
|
|
showSlowMa = true; // Show Slow
|
|
showRibbon = true; // Show Ribbon
|
|
}
|
|
|
|
//
|
|
// Validate ...
|
|
bool IsValid()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
result =
|
|
//
|
|
(fast1Length > 2 &&
|
|
fast2Length > fast1Length &&
|
|
fast3Length > fast2Length &&
|
|
fast4Length > fast3Length &&
|
|
fast5Length > fast4Length &&
|
|
slow1Length > fast1Length &&
|
|
slow2Length > fast2Length &&
|
|
slow3Length > fast3Length &&
|
|
slow4Length > fast4Length &&
|
|
slow5Length > fast5Length &&
|
|
slow2Length > slow1Length &&
|
|
slow3Length > slow2Length &&
|
|
slow4Length > slow3Length &&
|
|
slow5Length > slow4Length
|
|
//
|
|
)
|
|
//
|
|
;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Retrieve MAx Length ...
|
|
int Max()
|
|
{
|
|
//
|
|
int result = 0;
|
|
|
|
//
|
|
result = MathMax(fast1Length, fast2Length);
|
|
result = MathMax(result, fast3Length);
|
|
result = MathMax(result, fast4Length);
|
|
result = MathMax(result, fast5Length);
|
|
|
|
//
|
|
result = MathMax(result, slow1Length);
|
|
result = MathMax(result, slow2Length);
|
|
result = MathMax(result, slow3Length);
|
|
result = MathMax(result, slow4Length);
|
|
result = MathMax(result, slow5Length);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
};
|
|
|
|
//
|
|
// Class ...
|
|
class XSCXMRBHelper : public XSCBaseHelper
|
|
{
|
|
//
|
|
// Public ...
|
|
public:
|
|
//
|
|
// Props ...
|
|
|
|
//
|
|
// Constructors ...
|
|
XSCXMRBHelper() : XSCBaseHelper(_Symbol, _Period)
|
|
{
|
|
}
|
|
|
|
//
|
|
// Deconstructor ...
|
|
~XSCXMRBHelper() {}
|
|
|
|
//
|
|
// Tools ...
|
|
bool Init(
|
|
string symbol, // Trading Symbol
|
|
ENUM_TIMEFRAMES period, // Trading Period
|
|
XMRBInputs &inputs // Inputs
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
mSymbol = symbol;
|
|
mPeriod = period;
|
|
|
|
//
|
|
result = inputs.IsValid();
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
mInputs = inputs;
|
|
|
|
//
|
|
ArraySetAsSeries(fastBuffer, true);
|
|
ArraySetAsSeries(slowBuffer, true);
|
|
ArraySetAsSeries(r1FastBuffer, true);
|
|
ArraySetAsSeries(r1SlowBuffer, true);
|
|
ArraySetAsSeries(r2FastBuffer, true);
|
|
ArraySetAsSeries(r2SlowBuffer, true);
|
|
ArraySetAsSeries(r3FastBuffer, true);
|
|
ArraySetAsSeries(r3SlowBuffer, true);
|
|
ArraySetAsSeries(r4FastBuffer, true);
|
|
ArraySetAsSeries(r4SlowBuffer, true);
|
|
ArraySetAsSeries(r5FastBuffer, true);
|
|
ArraySetAsSeries(r5SlowBuffer, true);
|
|
|
|
//
|
|
mHandler = iCustom(
|
|
mSymbol,
|
|
mPeriod,
|
|
"x-saherelm.xmrb",
|
|
//
|
|
// Inputs ...
|
|
//
|
|
// Ribbon 1 ...
|
|
"",
|
|
mInputs.fast1Length, // Fast
|
|
mInputs.slow1Length, // Slow
|
|
//
|
|
// Ribbon 2 ...
|
|
"",
|
|
mInputs.fast2Length, // Fast
|
|
mInputs.slow2Length, // Slow
|
|
//
|
|
// Ribbon 3 ...
|
|
"",
|
|
mInputs.fast3Length, // Fast
|
|
mInputs.slow3Length, // Slow
|
|
//
|
|
// Ribbon 4 ...
|
|
"",
|
|
mInputs.fast4Length, // Fast
|
|
mInputs.slow4Length, // Slow
|
|
//
|
|
// Ribbon 5 ...
|
|
"",
|
|
mInputs.fast5Length, // Fast
|
|
mInputs.slow5Length, // Slow
|
|
//
|
|
// Calculation ...
|
|
"",
|
|
mInputs.ribbonMode, // Mode
|
|
mInputs.ribbonAppliedTo, // Applied To
|
|
//
|
|
// Presentation ...
|
|
"",
|
|
mInputs.showFastMa, // Show Fast
|
|
mInputs.showSlowMa, // Show Slow
|
|
mInputs.showRibbon // Show Ribbon
|
|
//
|
|
);
|
|
result = mHandler != INVALID_HANDLE;
|
|
if (!result)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Inputs ...
|
|
|
|
//
|
|
XMRBInputs GetInputs()
|
|
{
|
|
return mInputs;
|
|
}
|
|
|
|
//
|
|
bool SetInputs(
|
|
XMRBInputs &inputs // Configs
|
|
)
|
|
{
|
|
//
|
|
return Init(
|
|
mSymbol,
|
|
mPeriod,
|
|
inputs
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// Buffers ...
|
|
|
|
//
|
|
// Fast ...
|
|
|
|
//
|
|
double GetFast(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(fastBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return fastBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyFast(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
start,
|
|
count,
|
|
fastBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// Slow ...
|
|
|
|
//
|
|
double GetSlow(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(slowBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return slowBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopySlow(
|
|
int start, // Start
|
|
int count, // Number of Items for read
|
|
double &buffer[], // Dest Buffer
|
|
bool forceClean = true // Force To Clean buffer
|
|
)
|
|
{
|
|
//
|
|
// Update Calculations ...
|
|
Calculate();
|
|
|
|
//
|
|
// Copy Items ...
|
|
return Copy(
|
|
start,
|
|
count,
|
|
slowBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// Ribbon 1 ...
|
|
|
|
//
|
|
// Fast ...
|
|
|
|
//
|
|
double GetR1Fast(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(r1FastBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return r1FastBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyR1Fast(
|
|
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,
|
|
r1FastBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// Slow ...
|
|
|
|
//
|
|
double GetR1Slow(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(r1SlowBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return r1SlowBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyR1Slow(
|
|
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,
|
|
r1SlowBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// Ribbon 2 ...
|
|
|
|
//
|
|
// Fast ...
|
|
|
|
//
|
|
double GetR2Fast(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(r2FastBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return r2FastBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int Copy21Fast(
|
|
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,
|
|
r2FastBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// Slow ...
|
|
|
|
//
|
|
double GetR2Slow(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(r2SlowBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return r2SlowBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyR2Slow(
|
|
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,
|
|
r2SlowBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// Ribbon 3 ...
|
|
|
|
//
|
|
// Fast ...
|
|
|
|
//
|
|
double GetR3Fast(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(r3FastBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return r3FastBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyR3Fast(
|
|
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,
|
|
r3FastBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// Slow ...
|
|
|
|
//
|
|
double GetR3Slow(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(r3SlowBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return r3SlowBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyR3Slow(
|
|
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,
|
|
r3SlowBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// Ribbon 4 ...
|
|
|
|
//
|
|
// Fast ...
|
|
|
|
//
|
|
double GetR4Fast(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(r4FastBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return r4FastBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyR4Fast(
|
|
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,
|
|
r4FastBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// Slow ...
|
|
|
|
//
|
|
double GetR4Slow(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(r4SlowBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return r4SlowBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyR4Slow(
|
|
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,
|
|
r4SlowBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// Ribbon 5 ...
|
|
|
|
//
|
|
// Fast ...
|
|
|
|
//
|
|
double GetR5Fast(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(r5FastBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return r5FastBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyR5Fast(
|
|
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,
|
|
r5FastBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// Slow ...
|
|
|
|
//
|
|
double GetR5Slow(
|
|
int barIndex // Bar Index
|
|
)
|
|
{
|
|
//
|
|
if (barIndex < 0)
|
|
{
|
|
barIndex = 0;
|
|
}
|
|
|
|
//
|
|
Calculate();
|
|
|
|
//
|
|
int count = ArraySize(r5SlowBuffer);
|
|
if (barIndex >= count)
|
|
{
|
|
barIndex = count - 1;
|
|
}
|
|
|
|
//
|
|
return r5SlowBuffer[barIndex];
|
|
}
|
|
|
|
//
|
|
// Copy Required Items ...
|
|
int CopyR5Slow(
|
|
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,
|
|
r5SlowBuffer,
|
|
buffer,
|
|
forceClean
|
|
//
|
|
);
|
|
}
|
|
|
|
//
|
|
// Protected ...
|
|
protected:
|
|
//
|
|
// Private ...
|
|
private:
|
|
//
|
|
// Props ...
|
|
XMRBInputs mInputs; // Inputs ...
|
|
|
|
//
|
|
// Buffers ...
|
|
double fastBuffer[];
|
|
double slowBuffer[];
|
|
double r1FastBuffer[];
|
|
double r1SlowBuffer[];
|
|
double r2FastBuffer[];
|
|
double r2SlowBuffer[];
|
|
double r3FastBuffer[];
|
|
double r3SlowBuffer[];
|
|
double r4FastBuffer[];
|
|
double r4SlowBuffer[];
|
|
double r5FastBuffer[];
|
|
double r5SlowBuffer[];
|
|
|
|
//
|
|
// Tools ...
|
|
|
|
//
|
|
// Calculate Values Until Now ...
|
|
void Calculate()
|
|
{
|
|
//
|
|
int totalBars = CountBars();
|
|
|
|
//
|
|
// Fast Buffer ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XMRB_FAST_LINE,
|
|
0,
|
|
totalBars,
|
|
fastBuffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// Slow Buffer ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XMRB_SLOW_LINE,
|
|
0,
|
|
totalBars,
|
|
slowBuffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// Ribbon 1 ...
|
|
|
|
//
|
|
// Fast Buffer ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XMRB_R1_FAST_LINE,
|
|
0,
|
|
totalBars,
|
|
r1FastBuffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// Slow Buffer ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XMRB_R1_SLOW_LINE,
|
|
0,
|
|
totalBars,
|
|
r1SlowBuffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// Ribbon 2 ...
|
|
|
|
//
|
|
// Fast Buffer ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XMRB_R2_FAST_LINE,
|
|
0,
|
|
totalBars,
|
|
r2FastBuffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// Slow Buffer ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XMRB_R2_SLOW_LINE,
|
|
0,
|
|
totalBars,
|
|
r2SlowBuffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// Ribbon 3 ...
|
|
|
|
//
|
|
// Fast Buffer ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XMRB_R3_FAST_LINE,
|
|
0,
|
|
totalBars,
|
|
r3FastBuffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// Slow Buffer ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XMRB_R3_SLOW_LINE,
|
|
0,
|
|
totalBars,
|
|
r3SlowBuffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// Ribbon 4 ...
|
|
|
|
//
|
|
// Fast Buffer ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XMRB_R4_FAST_LINE,
|
|
0,
|
|
totalBars,
|
|
r4FastBuffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// Slow Buffer ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XMRB_R4_SLOW_LINE,
|
|
0,
|
|
totalBars,
|
|
r4SlowBuffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// Ribbon 5 ...
|
|
|
|
//
|
|
// Fast Buffer ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XMRB_R5_FAST_LINE,
|
|
0,
|
|
totalBars,
|
|
r5FastBuffer
|
|
//
|
|
);
|
|
|
|
//
|
|
// Slow Buffer ...
|
|
CopyBuffer(
|
|
mHandler,
|
|
XMRB_R5_SLOW_LINE,
|
|
0,
|
|
totalBars,
|
|
r5SlowBuffer
|
|
//
|
|
);
|
|
}
|
|
};
|
|
|
|
//
|
|
// Tools ... |