1203 lines
23 KiB
Plaintext
1203 lines
23 KiB
Plaintext
////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// SaherElm IT Center MQL5 XCHMA Oscillator Helper for Signal Providers
|
|
// ---------------------------------------------------------------------
|
|
//
|
|
//
|
|
// Maintainer:
|
|
// ------------
|
|
// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com)
|
|
//
|
|
//////////////////////////////////////////////////////////////////////////
|
|
//
|
|
// Global Properties ...
|
|
#property library
|
|
#property copyright "Copyright 2023, SaherElm IT Center"
|
|
#property link "https://www.saherelm.ir"
|
|
#property version "1.00"
|
|
#property strict
|
|
|
|
//
|
|
#include "..\Libraries\x-saherelm.log.lib.mq5"
|
|
#include "..\Libraries\x-saherelm.common.lib.mq5"
|
|
#include "x-saherelm.xmap.provider.inputs.lib.mq5"
|
|
|
|
//
|
|
// START Enum Definitions ...
|
|
//
|
|
//
|
|
// XCHMA Oscillator Hot State Presentation ...
|
|
enum ENUM_XCHMA_HOT_STATES
|
|
{
|
|
X_XCHMA_HOT_BULLISH = 1,
|
|
X_XCHMA_HOT_NEUTURAL = 0,
|
|
X_XCHMA_HOT_BEARISH = -1,
|
|
};
|
|
|
|
//
|
|
// XCHMA Oscillator Cycles State Presentation ...
|
|
enum ENUM_XCHMA_CYCLE_STATES
|
|
{
|
|
X_XCHMA_FAST_CROSSED_OVER_SLOW = 2,
|
|
X_XCHMA_FAST_OVER_SLOW = 1,
|
|
X_XCHMA_NEUTURAL = 0,
|
|
X_XCHMA_FAST_UNDER_SLOW = -1,
|
|
X_XCHMA_FAST_CROSSED_UNDER_SLOW = -2,
|
|
};
|
|
|
|
//
|
|
// XCHMA Oscillator Buffer Lines ...
|
|
enum ENUM_X_XCHMA_BUFFER_LINES
|
|
{
|
|
X_XCHMA_LC_FAST_LINE = 0,
|
|
X_XCHMA_LC_SLOW_LINE = 1,
|
|
X_XCHMA_LC_STATE_LINE = 6,
|
|
X_XCHMA_MC_FAST_LINE = 2,
|
|
X_XCHMA_MC_SLOW_LINE = 3,
|
|
X_XCHMA_MC_STATE_LINE = 7,
|
|
X_XCHMA_SC_FAST_LINE = 4,
|
|
X_XCHMA_SC_SLOW_LINE = 5,
|
|
X_XCHMA_SC_STATE_LINE = 8,
|
|
X_XCHMA_HOT_STATE_LINE = 9,
|
|
};
|
|
//
|
|
// END Enum Definitions ...
|
|
//
|
|
|
|
//
|
|
// START Inputs ...
|
|
//
|
|
input group "XCHMA Oscillator";
|
|
|
|
//
|
|
// Commons ...
|
|
input group "XCHMA Hot Areas";
|
|
input bool xCHMADrawHotAreas = false; // Draw Hot Areas Symbol;
|
|
input uchar xCHMAHotBullishArrowCode = 228; // Hot Bullish Arrow Code;
|
|
input color xCHMAHotBullishArrowColor = clrAqua; // Hot Bullish Arrow Color;
|
|
input uchar xCHMAHotBearishArrowCode = 230; // Hot Bearish Arrow Code;
|
|
input color xCHMAHotBearishArrowColor = clrFuchsia; // Hot Bearish Arrow Color;
|
|
|
|
//
|
|
// LC Inputs ...
|
|
input group "XCHMA Long Cycle";
|
|
input group "XCHMA LC Market";
|
|
input int xCHMALcFastLength = 288; // Fast Length
|
|
input int xCHMALcSlowLength = 576; // Slow Length
|
|
input ENUM_MA_METHOD xCHMALcMethod = MODE_EMA; // Calculation Method
|
|
input ENUM_APPLIED_PRICE xCHMALcAppliedTo = PRICE_CLOSE; // Applied To
|
|
input group "XCHMA LC Style";
|
|
input int xCHMALcDrawWidth = 1; // Draw Width
|
|
input ENUM_DRAW_TYPE xCHMALcDrawType = DRAW_LINE; // Draw Type
|
|
input ENUM_LINE_STYLE xCHMALcDrawStyle = STYLE_DOT; // Draw Style
|
|
input color xCHMALcFastColor = clrAqua; // Fast Color
|
|
input color xCHMALcSlowColor = clrFuchsia; // Slow Color
|
|
input group "XCHMA LC Drawings";
|
|
input bool xCHMALcDrawFast = true; // Draw Fast
|
|
input bool xCHMALcDrawSlow = true; // Draw Slow
|
|
input bool xCHMALcDrawCrosses = false; // Draw Cross Lines
|
|
|
|
//
|
|
// MC Inputs ...
|
|
input group "XCHMA Medium Cycle";
|
|
input group "XCHMA MC Market";
|
|
input int xCHMAMcFastLength = 72; // Fast Length
|
|
input int xCHMAMcSlowLength = 144; // Slow Length
|
|
input ENUM_MA_METHOD xCHMAMcMethod = MODE_EMA; // Calculation Method
|
|
input ENUM_APPLIED_PRICE xCHMAMcAppliedTo = PRICE_CLOSE; // Applied To
|
|
input group "XCHMA MC Style";
|
|
input int xCHMAMcDrawWidth = 1; // Draw Width
|
|
input ENUM_DRAW_TYPE xCHMAMcDrawType = DRAW_LINE; // Draw Type
|
|
input ENUM_LINE_STYLE xCHMAMcDrawStyle = STYLE_DOT; // Draw Style
|
|
input color xCHMAMcFastColor = clrLime; // Fast Color
|
|
input color xCHMAMcSlowColor = clrRed; // Slow Color
|
|
input group "XCHMA MC Drawings";
|
|
input bool xCHMAMcDrawFast = true; // Draw Fast
|
|
input bool xCHMAMcDrawSlow = true; // Draw Slow
|
|
input bool xCHMAMcDrawCrosses = false; // Draw Cross Lines
|
|
|
|
//
|
|
// SC Inputs ...
|
|
input group "XCHMA Short Cycle";
|
|
input group "XCHMA SC Market";
|
|
input int xCHMAScFastLength = 7; // Fast Length
|
|
input int xCHMAScSlowLength = 14; // Slow Length
|
|
input ENUM_MA_METHOD xCHMAScMethod = MODE_EMA; // Calculation Method
|
|
input ENUM_APPLIED_PRICE xCHMAScAppliedTo = PRICE_CLOSE; // Applied To
|
|
input group "XCHMA SC Style";
|
|
input int xCHMAScDrawWidth = 1; // Draw Width
|
|
input ENUM_DRAW_TYPE xCHMAScDrawType = DRAW_LINE; // Draw Type
|
|
input ENUM_LINE_STYLE xCHMAScDrawStyle = STYLE_SOLID; // Draw Style
|
|
input color xCHMAScFastColor = clrLightBlue; // Fast Color
|
|
input color xCHMAScSlowColor = clrLightSalmon; // Slow Color
|
|
input group "XCHMA SC Drawings";
|
|
input bool xCHMAScDrawFast = true; // Draw Fast
|
|
input bool xCHMAScDrawSlow = true; // Draw Slow
|
|
input bool xCHMAScDrawCrosses = false; // Draw Cross Lines
|
|
//
|
|
// END Inputs ...
|
|
//
|
|
|
|
//
|
|
// START Definitions ...
|
|
//
|
|
int xCHMAHandler = INVALID_HANDLE;
|
|
double xCHMALcFastBuffer[];
|
|
double xCHMALcSlowBuffer[];
|
|
double xCHMAMcFastBuffer[];
|
|
double xCHMAMcSlowBuffer[];
|
|
double xCHMAScFastBuffer[];
|
|
double xCHMAScSlowBuffer[];
|
|
double xCHMAHotStateBuffer[];
|
|
//
|
|
// END Definitions ...
|
|
//
|
|
|
|
//
|
|
// START Handler Functions ...
|
|
//
|
|
//
|
|
// Init Indicators ...
|
|
bool XCHMAInitHandlers()
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Initialize Indicator/Oscillator Handlers ...
|
|
ResetLastError();
|
|
|
|
//
|
|
// XCHMA Handler ...
|
|
ArraySetAsSeries(xCHMALcFastBuffer, true);
|
|
ArraySetAsSeries(xCHMALcSlowBuffer, true);
|
|
ArraySetAsSeries(xCHMAMcFastBuffer, true);
|
|
ArraySetAsSeries(xCHMAMcSlowBuffer, true);
|
|
ArraySetAsSeries(xCHMAScFastBuffer, true);
|
|
ArraySetAsSeries(xCHMAScSlowBuffer, true);
|
|
ArraySetAsSeries(xCHMAHotStateBuffer, true);
|
|
xCHMAHandler = iCustom(
|
|
_Symbol,
|
|
_Period,
|
|
"x-saherelm.xchma.oscillator",
|
|
//
|
|
// Inputs ...
|
|
"",
|
|
xCHMADrawHotAreas,
|
|
xCHMAHotBullishArrowCode,
|
|
xCHMAHotBullishArrowColor,
|
|
xCHMAHotBearishArrowCode,
|
|
xCHMAHotBearishArrowColor,
|
|
//
|
|
// Long Cycle ...
|
|
"",
|
|
"",
|
|
xCHMALcFastLength,
|
|
xCHMALcSlowLength,
|
|
xCHMALcMethod,
|
|
xCHMALcAppliedTo,
|
|
"",
|
|
xCHMALcDrawWidth,
|
|
xCHMALcDrawType,
|
|
xCHMALcDrawStyle,
|
|
xCHMALcFastColor,
|
|
xCHMALcSlowColor,
|
|
"",
|
|
xCHMALcDrawFast,
|
|
xCHMALcDrawSlow,
|
|
xCHMALcDrawCrosses,
|
|
//
|
|
// Medium Cycle ...
|
|
"",
|
|
"",
|
|
xCHMAMcFastLength,
|
|
xCHMAMcSlowLength,
|
|
xCHMAMcMethod,
|
|
xCHMAMcAppliedTo,
|
|
"",
|
|
xCHMAMcDrawWidth,
|
|
xCHMAMcDrawType,
|
|
xCHMAMcDrawStyle,
|
|
xCHMAMcFastColor,
|
|
xCHMAMcSlowColor,
|
|
"",
|
|
xCHMAMcDrawFast,
|
|
xCHMAMcDrawSlow,
|
|
xCHMAMcDrawCrosses,
|
|
//
|
|
// Short Cycle ...
|
|
"",
|
|
"",
|
|
xCHMAScFastLength,
|
|
xCHMAScSlowLength,
|
|
xCHMAScMethod,
|
|
xCHMAScAppliedTo,
|
|
"",
|
|
xCHMAScDrawWidth,
|
|
xCHMAScDrawType,
|
|
xCHMAScDrawStyle,
|
|
xCHMAScFastColor,
|
|
xCHMAScSlowColor,
|
|
"",
|
|
xCHMAScDrawFast,
|
|
xCHMAScDrawSlow,
|
|
xCHMAScDrawCrosses);
|
|
if (xCHMAHandler == INVALID_HANDLE)
|
|
{
|
|
//
|
|
LogMessage("failed to Initialize XCHMA Oscillator: " + (string)GetLastError());
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result = true;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Release Indicators ...
|
|
void XCHMAReleaseHandlers()
|
|
{
|
|
IndicatorRelease(xCHMAHandler);
|
|
}
|
|
|
|
//
|
|
// Handle Reading Buffers ...
|
|
void XCHMAReadBuffers()
|
|
{
|
|
//
|
|
// XCHMA Long Cycle ...
|
|
//
|
|
// XCHMA Fast ...
|
|
CopyBuffer(
|
|
xCHMAHandler,
|
|
X_XCHMA_LC_FAST_LINE,
|
|
0,
|
|
xMAPNumberOfItemsPerTick,
|
|
xCHMALcFastBuffer);
|
|
|
|
//
|
|
// XCHMA Slow ...
|
|
CopyBuffer(
|
|
xCHMAHandler,
|
|
X_XCHMA_LC_SLOW_LINE,
|
|
0,
|
|
xMAPNumberOfItemsPerTick,
|
|
xCHMALcSlowBuffer);
|
|
|
|
//
|
|
// XCHMA Medium Cycle ...
|
|
//
|
|
// XCHMA Fast ...
|
|
CopyBuffer(
|
|
xCHMAHandler,
|
|
X_XCHMA_MC_FAST_LINE,
|
|
0,
|
|
xMAPNumberOfItemsPerTick,
|
|
xCHMAMcFastBuffer);
|
|
|
|
//
|
|
// XCHMA Slow ...
|
|
CopyBuffer(
|
|
xCHMAHandler,
|
|
X_XCHMA_MC_SLOW_LINE,
|
|
0,
|
|
xMAPNumberOfItemsPerTick,
|
|
xCHMAMcSlowBuffer);
|
|
|
|
//
|
|
// XCHMA Short Cycle ...
|
|
//
|
|
// XCHMA Fast ...
|
|
CopyBuffer(
|
|
xCHMAHandler,
|
|
X_XCHMA_SC_FAST_LINE,
|
|
0,
|
|
xMAPNumberOfItemsPerTick,
|
|
xCHMAScFastBuffer);
|
|
|
|
//
|
|
// XCHMA Slow ...
|
|
CopyBuffer(
|
|
xCHMAHandler,
|
|
X_XCHMA_SC_SLOW_LINE,
|
|
0,
|
|
xMAPNumberOfItemsPerTick,
|
|
xCHMAScSlowBuffer);
|
|
|
|
//
|
|
// XCHMA Hot State ...
|
|
CopyBuffer(
|
|
xCHMAHandler,
|
|
X_XCHMA_HOT_STATE_LINE,
|
|
0,
|
|
xMAPNumberOfItemsPerTick,
|
|
xCHMAHotStateBuffer);
|
|
}
|
|
//
|
|
// END Handler Funcions ...
|
|
//
|
|
|
|
//
|
|
// START XCHMA Custom Functions ...
|
|
//
|
|
//
|
|
// Find Peak based On this Indicator ...
|
|
bool XCHMAIsPeak(
|
|
int loopback // loopback length
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Find Vale based On this Indicator ...
|
|
bool XCHMAIsVale(
|
|
int loopback // loopback length
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Fast Crossed Over Slow in LC ...
|
|
bool XCHMAIsLCFastCrossedOverSlow(
|
|
int bar_index // sepcified Bar Index
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate Args ...
|
|
if (bar_index < 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result =
|
|
xCHMALcFastBuffer[bar_index] > xCHMALcSlowBuffer[bar_index] &&
|
|
xCHMALcFastBuffer[bar_index + 1] <= xCHMALcSlowBuffer[bar_index + 1];
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Fast Crossed Under Slow in LC ...
|
|
bool XCHMAIsLCFastCrossedUnderSlow(
|
|
int bar_index // sepcified Bar Index
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate Args ...
|
|
if (bar_index < 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result =
|
|
xCHMALcFastBuffer[bar_index] < xCHMALcSlowBuffer[bar_index] &&
|
|
xCHMALcFastBuffer[bar_index + 1] >= xCHMALcSlowBuffer[bar_index + 1];
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Fast Over Slow in LC ...
|
|
bool XCHMAIsLCFastOverSlow(
|
|
int bar_index // sepcified Bar Index
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate Args ...
|
|
if (bar_index < 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result =
|
|
xCHMALcFastBuffer[bar_index] > xCHMALcSlowBuffer[bar_index];
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Fast Under Slow in LC ...
|
|
bool XCHMAIsLCFastUnderSlow(
|
|
int bar_index // sepcified Bar Index
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate Args ...
|
|
if (bar_index < 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result =
|
|
xCHMALcFastBuffer[bar_index] < xCHMALcSlowBuffer[bar_index];
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Fast Crossed Over Slow in MC ...
|
|
bool XCHMAIsMCFastCrossedOverSlow(
|
|
int bar_index // sepcified Bar Index
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate Args ...
|
|
if (bar_index < 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result =
|
|
xCHMAMcFastBuffer[bar_index] > xCHMAMcSlowBuffer[bar_index] &&
|
|
xCHMAMcFastBuffer[bar_index + 1] <= xCHMAMcSlowBuffer[bar_index + 1];
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Fast Crossed Under Slow in MC ...
|
|
bool XCHMAIsMCFastCrossedUnderSlow(
|
|
int bar_index // sepcified Bar Index
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate Args ...
|
|
if (bar_index < 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result =
|
|
xCHMAMcFastBuffer[bar_index] < xCHMAMcSlowBuffer[bar_index] &&
|
|
xCHMAMcFastBuffer[bar_index + 1] >= xCHMAMcSlowBuffer[bar_index + 1];
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Fast Over Slow in MC ...
|
|
bool XCHMAIsMCFastOverSlow(
|
|
int bar_index // sepcified Bar Index
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate Args ...
|
|
if (bar_index < 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result =
|
|
xCHMAMcFastBuffer[bar_index] > xCHMAMcSlowBuffer[bar_index];
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Fast Under Slow in MC ...
|
|
bool XCHMAIsMCFastUnderSlow(
|
|
int bar_index // sepcified Bar Index
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate Args ...
|
|
if (bar_index < 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result =
|
|
xCHMAMcFastBuffer[bar_index] < xCHMAMcSlowBuffer[bar_index];
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Fast Crossed Over Slow in SC ...
|
|
bool XCHMAIsSCFastCrossedOverSlow(
|
|
int bar_index // sepcified Bar Index
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate Args ...
|
|
if (bar_index < 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result =
|
|
xCHMAScFastBuffer[bar_index] > xCHMAScSlowBuffer[bar_index] &&
|
|
xCHMAScFastBuffer[bar_index + 1] <= xCHMAScSlowBuffer[bar_index + 1];
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Fast Crossed Under Slow in SC ...
|
|
bool XCHMAIsSCFastCrossedUnderSlow(
|
|
int bar_index // sepcified Bar Index
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate Args ...
|
|
if (bar_index < 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result =
|
|
xCHMAScFastBuffer[bar_index] < xCHMAScSlowBuffer[bar_index] &&
|
|
xCHMAScFastBuffer[bar_index + 1] >= xCHMAScSlowBuffer[bar_index + 1];
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Fast Over Slow in SC ...
|
|
bool XCHMAIsSCFastOverSlow(
|
|
int bar_index // sepcified Bar Index
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate Args ...
|
|
if (bar_index < 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result =
|
|
xCHMAScFastBuffer[bar_index] > xCHMAScSlowBuffer[bar_index];
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Check Fast Under Slow in SC ...
|
|
bool XCHMAIsSCFastUnderSlow(
|
|
int bar_index // sepcified Bar Index
|
|
)
|
|
{
|
|
//
|
|
bool result = false;
|
|
|
|
//
|
|
// Validate Args ...
|
|
if (bar_index < 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
result =
|
|
xCHMAScFastBuffer[bar_index] < xCHMAScSlowBuffer[bar_index];
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Retrieve All Cycles Max Value at Specific Index ...
|
|
double XCHMAGetMaxValue(
|
|
int bar_index // sepcified Bar Index
|
|
)
|
|
{
|
|
//
|
|
double result = 0;
|
|
|
|
//
|
|
// Long Cycle ...
|
|
result =
|
|
MathMax(
|
|
//
|
|
xCHMALcFastBuffer[bar_index],
|
|
//
|
|
xCHMALcSlowBuffer[bar_index]
|
|
//
|
|
);
|
|
|
|
//
|
|
// Medium Cycle ...
|
|
result =
|
|
MathMax(
|
|
//
|
|
result,
|
|
//
|
|
xCHMAMcFastBuffer[bar_index]
|
|
//
|
|
);
|
|
result =
|
|
MathMax(
|
|
//
|
|
result,
|
|
//
|
|
xCHMAMcSlowBuffer[bar_index]
|
|
//
|
|
);
|
|
|
|
//
|
|
// Short Cycle ...
|
|
result =
|
|
MathMax(
|
|
//
|
|
result,
|
|
//
|
|
xCHMAScFastBuffer[bar_index]
|
|
//
|
|
);
|
|
result =
|
|
MathMax(
|
|
//
|
|
result,
|
|
//
|
|
xCHMAScSlowBuffer[bar_index]
|
|
//
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
double XCHMAGetMaxMCLCValue(
|
|
int bar_index // sepcified Bar Index
|
|
)
|
|
{
|
|
//
|
|
double result = 0;
|
|
|
|
//
|
|
// Long Cycle ...
|
|
result =
|
|
MathMax(
|
|
//
|
|
xCHMALcFastBuffer[bar_index],
|
|
//
|
|
xCHMALcSlowBuffer[bar_index]
|
|
//
|
|
);
|
|
|
|
//
|
|
// Medium Cycle ...
|
|
result =
|
|
MathMax(
|
|
//
|
|
result,
|
|
//
|
|
xCHMAMcFastBuffer[bar_index]
|
|
//
|
|
);
|
|
result =
|
|
MathMax(
|
|
//
|
|
result,
|
|
//
|
|
xCHMAMcSlowBuffer[bar_index]
|
|
//
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Retrieve All Cycles Min Value at Specific Index ...
|
|
double XCHMAGetMinValue(
|
|
int bar_index // sepcified Bar Index
|
|
)
|
|
{
|
|
//
|
|
double result = 0;
|
|
|
|
//
|
|
// Long Cycle ...
|
|
result =
|
|
MathMin(
|
|
//
|
|
xCHMALcFastBuffer[bar_index],
|
|
//
|
|
xCHMALcSlowBuffer[bar_index]
|
|
//
|
|
);
|
|
|
|
//
|
|
// Medium Cycle ...
|
|
result =
|
|
MathMin(
|
|
//
|
|
result,
|
|
//
|
|
xCHMAMcFastBuffer[bar_index]
|
|
//
|
|
);
|
|
result =
|
|
MathMin(
|
|
//
|
|
result,
|
|
//
|
|
xCHMAMcSlowBuffer[bar_index]
|
|
//
|
|
);
|
|
|
|
//
|
|
// Short Cycle ...
|
|
result =
|
|
MathMin(
|
|
//
|
|
result,
|
|
//
|
|
xCHMAScFastBuffer[bar_index]
|
|
//
|
|
);
|
|
result =
|
|
MathMin(
|
|
//
|
|
result,
|
|
//
|
|
xCHMAScSlowBuffer[bar_index]
|
|
//
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
double XCHMAGetMinMCLCValue(
|
|
int bar_index // sepcified Bar Index
|
|
)
|
|
{
|
|
//
|
|
double result = 0;
|
|
|
|
//
|
|
// Long Cycle ...
|
|
result =
|
|
MathMin(
|
|
//
|
|
xCHMALcFastBuffer[bar_index],
|
|
//
|
|
xCHMALcSlowBuffer[bar_index]
|
|
//
|
|
);
|
|
|
|
//
|
|
// Medium Cycle ...
|
|
result =
|
|
MathMin(
|
|
//
|
|
result,
|
|
//
|
|
xCHMAMcFastBuffer[bar_index]
|
|
//
|
|
);
|
|
result =
|
|
MathMin(
|
|
//
|
|
result,
|
|
//
|
|
xCHMAMcSlowBuffer[bar_index]
|
|
//
|
|
);
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Retrieve Spcific Length Max Value of All Cycles ...
|
|
double XCHMAGetMaxValueInLoopback(
|
|
int loopback // loopback length
|
|
)
|
|
{
|
|
//
|
|
double result = 0;
|
|
|
|
//
|
|
// Validate Args ...
|
|
if (loopback <= 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Loopbak Loop for Calculations ...
|
|
for (int i = 1; i <= loopback && !result; i++)
|
|
{
|
|
//
|
|
double maxValue = XCHMAGetMaxValue(i);
|
|
|
|
//
|
|
result = result <= 0 || result < maxValue ? maxValue : result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Retrieve Spcific Length Min Value of All Cycles ...
|
|
double XCHMAGetMinValueInLoopback(
|
|
int loopback // loopback length
|
|
)
|
|
{
|
|
//
|
|
double result = 0;
|
|
|
|
//
|
|
// Validate Args ...
|
|
if (loopback <= 0)
|
|
{
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// Loopbak Loop for Calculations ...
|
|
for (int i = 1; i <= loopback && !result; i++)
|
|
{
|
|
//
|
|
double minValue = XCHMAGetMinValue(i);
|
|
|
|
//
|
|
result = result <= 0 || result > minValue ? minValue : result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// XCHMA Retrieve Max and Min Value of Specific Cycles Fast Or Slow ...
|
|
|
|
//
|
|
// LC Fast Min ...
|
|
double XCHMAGetLCFastMinInLoopback(
|
|
int loopback // loopback length
|
|
)
|
|
{
|
|
//
|
|
double result = 0;
|
|
|
|
//
|
|
// Loop Through Loopback ...
|
|
for (int i = 0; i < loopback; i++)
|
|
{
|
|
//
|
|
double value = xCHMALcFastBuffer[i];
|
|
result = result == 0 || result > value ? value : result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// LC Slow Min ...
|
|
double XCHMAGetLCSlowMinInLoopback(
|
|
int loopback // loopback length
|
|
)
|
|
{
|
|
//
|
|
double result = 0;
|
|
|
|
//
|
|
// Loop Through Loopback ...
|
|
for (int i = 0; i < loopback; i++)
|
|
{
|
|
//
|
|
double value = xCHMALcSlowBuffer[i];
|
|
result = result == 0 || result > value ? value : result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// LC Fast Max ...
|
|
double XCHMAGetLCFastMaxInLoopback(
|
|
int loopback // loopback length
|
|
)
|
|
{
|
|
//
|
|
double result = 0;
|
|
|
|
//
|
|
// Loop Through Loopback ...
|
|
for (int i = 0; i < loopback; i++)
|
|
{
|
|
//
|
|
double value = xCHMALcFastBuffer[i];
|
|
result = result == 0 || result < value ? value : result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// LC Slow Max ...
|
|
double XCHMAGetLCSlowMaxInLoopback(
|
|
int loopback // loopback length
|
|
)
|
|
{
|
|
//
|
|
double result = 0;
|
|
|
|
//
|
|
// Loop Through Loopback ...
|
|
for (int i = 0; i < loopback; i++)
|
|
{
|
|
//
|
|
double value = xCHMALcSlowBuffer[i];
|
|
result = result == 0 || result < value ? value : result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// MC Fast Min ...
|
|
double XCHMAGetMCFastMinInLoopback(
|
|
int loopback // loopback length
|
|
)
|
|
{
|
|
//
|
|
double result = 0;
|
|
|
|
//
|
|
// Loop Through Loopback ...
|
|
for (int i = 0; i < loopback; i++)
|
|
{
|
|
//
|
|
double value = xCHMAMcFastBuffer[i];
|
|
result = result == 0 || result > value ? value : result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// MC Slow Min ...
|
|
double XCHMAGetMCSlowMinInLoopback(
|
|
int loopback // loopback length
|
|
)
|
|
{
|
|
//
|
|
double result = 0;
|
|
|
|
//
|
|
// Loop Through Loopback ...
|
|
for (int i = 0; i < loopback; i++)
|
|
{
|
|
//
|
|
double value = xCHMAMcSlowBuffer[i];
|
|
result = result == 0 || result > value ? value : result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// MC Fast Max ...
|
|
double XCHMAGetMCFastMaxInLoopback(
|
|
int loopback // loopback length
|
|
)
|
|
{
|
|
//
|
|
double result = 0;
|
|
|
|
//
|
|
// Loop Through Loopback ...
|
|
for (int i = 0; i < loopback; i++)
|
|
{
|
|
//
|
|
double value = xCHMAMcFastBuffer[i];
|
|
result = result == 0 || result < value ? value : result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// MC Slow Max ...
|
|
double XCHMAGetMCSlowMaxInLoopback(
|
|
int loopback // loopback length
|
|
)
|
|
{
|
|
//
|
|
double result = 0;
|
|
|
|
//
|
|
// Loop Through Loopback ...
|
|
for (int i = 0; i < loopback; i++)
|
|
{
|
|
//
|
|
double value = xCHMAMcSlowBuffer[i];
|
|
result = result == 0 || result < value ? value : result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// SC Fast Min ...
|
|
double XCHMAGetSCFastMinInLoopback(
|
|
int loopback // loopback length
|
|
)
|
|
{
|
|
//
|
|
double result = 0;
|
|
|
|
//
|
|
// Loop Through Loopback ...
|
|
for (int i = 0; i < loopback; i++)
|
|
{
|
|
//
|
|
double value = xCHMAScFastBuffer[i];
|
|
result = result == 0 || result > value ? value : result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// SC Slow Min ...
|
|
double XCHMAGetSCSlowMinInLoopback(
|
|
int loopback // loopback length
|
|
)
|
|
{
|
|
//
|
|
double result = 0;
|
|
|
|
//
|
|
// Loop Through Loopback ...
|
|
for (int i = 0; i < loopback; i++)
|
|
{
|
|
//
|
|
double value = xCHMAScSlowBuffer[i];
|
|
result = result == 0 || result > value ? value : result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// SC Fast Max ...
|
|
double XCHMAGetSCFastMaxInLoopback(
|
|
int loopback // loopback length
|
|
)
|
|
{
|
|
//
|
|
double result = 0;
|
|
|
|
//
|
|
// Loop Through Loopback ...
|
|
for (int i = 0; i < loopback; i++)
|
|
{
|
|
//
|
|
double value = xCHMAScFastBuffer[i];
|
|
result = result == 0 || result < value ? value : result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
|
|
//
|
|
// SC Slow Max ...
|
|
double XCHMAGetSCSlowMaxInLoopback(
|
|
int loopback // loopback length
|
|
)
|
|
{
|
|
//
|
|
double result = 0;
|
|
|
|
//
|
|
// Loop Through Loopback ...
|
|
for (int i = 0; i < loopback; i++)
|
|
{
|
|
//
|
|
double value = xCHMAScSlowBuffer[i];
|
|
result = result == 0 || result < value ? value : result;
|
|
}
|
|
|
|
//
|
|
return result;
|
|
}
|
|
//
|
|
// END XCHMA Custom Functions ...
|
|
//
|