Last Works ...
This commit is contained in:
+188
-521
@@ -23,6 +23,9 @@
|
||||
// Imports ...
|
||||
#include "../Classes/x-saherelm.x-md5.class.mq5"
|
||||
|
||||
//
|
||||
#include <MovingAverages.mqh>
|
||||
|
||||
//
|
||||
// Models ...
|
||||
|
||||
@@ -6918,247 +6921,6 @@ struct XMarketParser
|
||||
//
|
||||
};
|
||||
|
||||
//
|
||||
// Styling Buffers ...
|
||||
|
||||
//
|
||||
struct XBufferPlotStyle
|
||||
{
|
||||
//
|
||||
int width; // Width
|
||||
color clr; // Color
|
||||
uchar arrow; // Arrow Code
|
||||
ENUM_DRAW_TYPE type; // Type
|
||||
ENUM_LINE_STYLE style; // Style
|
||||
|
||||
//
|
||||
// Constructor ...
|
||||
XBufferPlotStyle()
|
||||
{
|
||||
Default();
|
||||
}
|
||||
|
||||
//
|
||||
// Tools ...
|
||||
|
||||
//
|
||||
// Default ...
|
||||
void Default()
|
||||
{
|
||||
//
|
||||
width = 1;
|
||||
arrow = 0;
|
||||
clr = CLR_NONE;
|
||||
type = DRAW_NONE;
|
||||
style = STYLE_SOLID;
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Register a Buffer as Indexed Buffer ...
|
||||
void SetIndexBuffer(
|
||||
int &index, // the Index refrence for Buffer
|
||||
double &buffer[], // Buffer to Set
|
||||
XBufferPlotStyle &style, // Style to Apply to Buffer
|
||||
double &colorBuffer[], // Color Buffer
|
||||
string label = NULL, // Buffer Label
|
||||
bool showData = true, // Show Data on Data Window
|
||||
double empty = -1, // Set 0 or EMPTY_VALUE used for setting Empty Value
|
||||
int drawBegin = -1 // if Set More Than -1 applied
|
||||
)
|
||||
{
|
||||
//
|
||||
// Set Buffer Index ...
|
||||
SetIndexBuffer(index, buffer, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
// Show Date ...
|
||||
PlotIndexSetInteger(index, PLOT_SHOW_DATA, showData);
|
||||
|
||||
//
|
||||
// Set Buffer Label ...
|
||||
if (IsValid(label))
|
||||
{
|
||||
PlotIndexSetString(index, PLOT_LABEL, label);
|
||||
}
|
||||
|
||||
//
|
||||
if (empty == 0 || empty == EMPTY_VALUE)
|
||||
{
|
||||
PlotIndexSetDouble(index, PLOT_EMPTY_VALUE, empty);
|
||||
}
|
||||
|
||||
//
|
||||
if (drawBegin > -1)
|
||||
{
|
||||
PlotIndexSetInteger(index, PLOT_DRAW_BEGIN, drawBegin);
|
||||
}
|
||||
|
||||
//
|
||||
if (style.type == DRAW_ARROW)
|
||||
{
|
||||
PlotIndexSetInteger(index, PLOT_ARROW, style.arrow);
|
||||
}
|
||||
|
||||
//
|
||||
PlotIndexSetInteger(index, PLOT_LINE_STYLE, style.style);
|
||||
PlotIndexSetInteger(index, PLOT_LINE_WIDTH, style.width);
|
||||
|
||||
//
|
||||
string drawTypeStr = EnumToString(style.type);
|
||||
bool hasColorBuffer = Contains("COLOR", drawTypeStr);
|
||||
|
||||
//
|
||||
if (!hasColorBuffer)
|
||||
{
|
||||
PlotIndexSetInteger(index, PLOT_LINE_COLOR, style.clr);
|
||||
}
|
||||
else
|
||||
{
|
||||
//
|
||||
// Since Color Buffers must add as next Index of it's own Buffer
|
||||
// here before applied Color Buffer increase index ...
|
||||
index++;
|
||||
|
||||
//
|
||||
SetIndexBuffer(index, colorBuffer, INDICATOR_COLOR_INDEX);
|
||||
}
|
||||
|
||||
//
|
||||
// Increase Index for Next Buffer ...
|
||||
index++;
|
||||
}
|
||||
|
||||
//
|
||||
void SetIndexCandleBuffers(
|
||||
int &index, // the Index refrence for Buffer
|
||||
string openLabel, // Open Label
|
||||
double &open[], // Open Buffer
|
||||
string highLabel, // High Label
|
||||
double &high[], // High Buffer
|
||||
string lowLabel, // Low Label
|
||||
double &low[], // Low Buffer
|
||||
string closeLabel, // Close Label
|
||||
double &close[], // Close Buffer
|
||||
bool showData = true, // Show Data on Data Window
|
||||
double empty = -1, // Set 0 or EMPTY_VALUE used for setting Empty Value
|
||||
int drawBegin = -1 // if Set More Than -1 applied
|
||||
)
|
||||
{
|
||||
//
|
||||
bool hasLabel =
|
||||
//
|
||||
IsValid(openLabel) &&
|
||||
IsValid(highLabel) &&
|
||||
IsValid(lowLabel) &&
|
||||
IsValid(closeLabel)
|
||||
//
|
||||
;
|
||||
|
||||
//
|
||||
string label =
|
||||
!hasLabel
|
||||
? NULL
|
||||
: openLabel + ";" + highLabel + ";" + lowLabel + ";" + closeLabel;
|
||||
|
||||
//
|
||||
// Set Buffer Index ...
|
||||
SetIndexBuffer(index, open, INDICATOR_DATA);
|
||||
|
||||
//
|
||||
// Set Draw Candles Type ...
|
||||
PlotIndexSetInteger(index, PLOT_LINE_STYLE, DRAW_CANDLES);
|
||||
|
||||
//
|
||||
// Show Date ...
|
||||
PlotIndexSetInteger(index, PLOT_SHOW_DATA, showData);
|
||||
|
||||
//
|
||||
// Set Buffer Label ...
|
||||
if (IsValid(label))
|
||||
{
|
||||
PlotIndexSetString(index, PLOT_LABEL, label);
|
||||
}
|
||||
|
||||
//
|
||||
if (empty == 0 || empty == EMPTY_VALUE)
|
||||
{
|
||||
PlotIndexSetDouble(index, PLOT_EMPTY_VALUE, empty);
|
||||
}
|
||||
|
||||
//
|
||||
if (drawBegin > -1)
|
||||
{
|
||||
PlotIndexSetInteger(index, PLOT_DRAW_BEGIN, drawBegin);
|
||||
}
|
||||
|
||||
//
|
||||
index++;
|
||||
|
||||
//
|
||||
// Set Buffer Index ...
|
||||
SetIndexBuffer(index, high, INDICATOR_DATA);
|
||||
index++;
|
||||
|
||||
//
|
||||
// Set Buffer Index ...
|
||||
SetIndexBuffer(index, low, INDICATOR_DATA);
|
||||
index++;
|
||||
|
||||
//
|
||||
// Set Buffer Index ...
|
||||
SetIndexBuffer(index, close, INDICATOR_DATA);
|
||||
index++;
|
||||
}
|
||||
|
||||
//
|
||||
void SetIndexCandleBuffers(
|
||||
int &index, // the Index refrence for Buffer
|
||||
string openLabel, // Open Label
|
||||
double &open[], // Open Buffer
|
||||
string highLabel, // High Label
|
||||
double &high[], // High Buffer
|
||||
string lowLabel, // Low Label
|
||||
double &low[], // Low Buffer
|
||||
string closeLabel, // Close Label
|
||||
double &close[], // Close Buffer
|
||||
double &colorBuffer[], // Candle Color Buffer
|
||||
bool showData = true, // Show Data on Data Window
|
||||
double empty = -1, // Set 0 or EMPTY_VALUE used for setting Empty Value
|
||||
int drawBegin = -1 // if Set More Than -1 applied
|
||||
)
|
||||
{
|
||||
//
|
||||
SetIndexCandleBuffers(
|
||||
index,
|
||||
openLabel,
|
||||
open,
|
||||
highLabel,
|
||||
high,
|
||||
lowLabel,
|
||||
low,
|
||||
closeLabel,
|
||||
close,
|
||||
showData,
|
||||
empty,
|
||||
drawBegin //
|
||||
);
|
||||
|
||||
//
|
||||
int mFirstIndex = index - 4;
|
||||
|
||||
//
|
||||
// Set Draw Candles Type ...
|
||||
PlotIndexSetInteger(mFirstIndex, PLOT_LINE_STYLE, DRAW_COLOR_CANDLES);
|
||||
|
||||
//
|
||||
// Set Color Buffer ...
|
||||
SetIndexBuffer(index, colorBuffer, INDICATOR_COLOR_INDEX);
|
||||
|
||||
//
|
||||
index++;
|
||||
}
|
||||
|
||||
//
|
||||
// Functions ...
|
||||
|
||||
@@ -9785,212 +9547,6 @@ double GetFibonacciLevel(
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double MAOnArray(
|
||||
double &array[],
|
||||
int total,
|
||||
int period,
|
||||
int ma_shift,
|
||||
int ma_method,
|
||||
int shift //
|
||||
)
|
||||
{
|
||||
//
|
||||
double result = 0;
|
||||
|
||||
//
|
||||
double buf[];
|
||||
double arr[];
|
||||
|
||||
//
|
||||
if (total == 0)
|
||||
{
|
||||
total = ArraySize(array);
|
||||
}
|
||||
|
||||
//
|
||||
if (total > 0 && total <= period)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
if (shift > total - period - ma_shift)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// MA Method ...
|
||||
switch (ma_method)
|
||||
{
|
||||
//
|
||||
// Mode SMA ...
|
||||
case MODE_SMA: {
|
||||
//
|
||||
total = ArrayCopy(arr, array, 0, shift + ma_shift, period);
|
||||
if (ArrayResize(buf, total) < 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double sum = 0;
|
||||
int i, pos = total - 1;
|
||||
for (i = 1; i < period; i++, pos--)
|
||||
{
|
||||
sum += arr[pos];
|
||||
}
|
||||
|
||||
//
|
||||
while (pos >= 0)
|
||||
{
|
||||
//
|
||||
sum += arr[pos];
|
||||
buf[pos] = sum / period;
|
||||
sum -= arr[pos + period - 1];
|
||||
pos--;
|
||||
}
|
||||
|
||||
//
|
||||
result = buf[0];
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Mode EMA ...
|
||||
case MODE_EMA: {
|
||||
//
|
||||
if (ArrayResize(buf, total) < 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int pos = total - 2;
|
||||
double pr = 2.0 / (period + 1);
|
||||
|
||||
//
|
||||
while (pos >= 0)
|
||||
{
|
||||
//
|
||||
if (pos == total - 2)
|
||||
{
|
||||
buf[pos + 1] = array[pos + 1];
|
||||
}
|
||||
|
||||
//
|
||||
buf[pos] = array[pos] * pr + buf[pos + 1] * (1 - pr);
|
||||
pos--;
|
||||
}
|
||||
|
||||
//
|
||||
result = buf[shift + ma_shift];
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Mode SMMA ...
|
||||
case MODE_SMMA: {
|
||||
//
|
||||
if (ArrayResize(buf, total) < 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
int i, kk, pos;
|
||||
double sum = 0;
|
||||
pos = total - period;
|
||||
|
||||
//
|
||||
while (pos >= 0)
|
||||
{
|
||||
//
|
||||
if (pos == total - period)
|
||||
{
|
||||
//
|
||||
for (i = 0, kk = pos; i < period; i++, kk++)
|
||||
{
|
||||
//
|
||||
sum += array[kk];
|
||||
buf[kk] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
sum = buf[pos + 1] * (period - 1) + array[pos];
|
||||
}
|
||||
|
||||
//
|
||||
buf[pos] = sum / period;
|
||||
pos--;
|
||||
}
|
||||
|
||||
//
|
||||
result = buf[shift + ma_shift];
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Mode LWMA ...
|
||||
case MODE_LWMA: {
|
||||
//
|
||||
if (ArrayResize(buf, total) < 0)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
double price;
|
||||
double sum = 0.0, lsum = 0.0;
|
||||
int i, weight = 0, pos = total - 1;
|
||||
|
||||
//
|
||||
for (i = 1; i <= period; i++, pos--)
|
||||
{
|
||||
//
|
||||
price = array[pos];
|
||||
sum += price * i;
|
||||
lsum += price;
|
||||
weight += i;
|
||||
}
|
||||
|
||||
//
|
||||
pos++;
|
||||
i = pos + period;
|
||||
while (pos >= 0)
|
||||
{
|
||||
//
|
||||
buf[pos] = sum / weight;
|
||||
if (pos == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
i--;
|
||||
pos--;
|
||||
price = array[pos];
|
||||
sum = sum - lsum + price * period;
|
||||
lsum -= array[i];
|
||||
lsum += price;
|
||||
}
|
||||
|
||||
//
|
||||
result = buf[shift + ma_shift];
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
default:
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Method 1
|
||||
// Normalize between 1 and 0 ...
|
||||
@@ -12869,55 +12425,59 @@ ENUM_TIMEFRAMES GetNearestPeriod(ENUM_TIMEFRAMES mPeriod)
|
||||
//
|
||||
case PERIOD_M1:
|
||||
case PERIOD_M2:
|
||||
result = PERIOD_M4;
|
||||
case PERIOD_M3:
|
||||
result = PERIOD_M5;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_M3:
|
||||
case PERIOD_M4:
|
||||
result = PERIOD_M6;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_M5:
|
||||
case PERIOD_M6:
|
||||
case PERIOD_M10:
|
||||
case PERIOD_M12:
|
||||
result = PERIOD_M15;
|
||||
result = PERIOD_M10;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_M10:
|
||||
case PERIOD_M12:
|
||||
case PERIOD_M15:
|
||||
result = PERIOD_M20;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_M20:
|
||||
result = PERIOD_M30;
|
||||
case PERIOD_M30:
|
||||
result = PERIOD_H1;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H1:
|
||||
case PERIOD_H2:
|
||||
result = PERIOD_H3;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H3:
|
||||
result = PERIOD_H4;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H4:
|
||||
result = PERIOD_H6;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H6:
|
||||
result = PERIOD_H8;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H8:
|
||||
result = PERIOD_H12;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H12:
|
||||
result = PERIOD_D1;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_D1:
|
||||
result = PERIOD_W1;
|
||||
break;
|
||||
|
||||
//
|
||||
default:
|
||||
result = PERIOD_MN1;
|
||||
result = mPeriod;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -12941,55 +12501,59 @@ ENUM_TIMEFRAMES GetMediestPeriod(ENUM_TIMEFRAMES mPeriod)
|
||||
//
|
||||
case PERIOD_M1:
|
||||
case PERIOD_M2:
|
||||
result = PERIOD_M15;
|
||||
case PERIOD_M3:
|
||||
result = PERIOD_M10;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_M3:
|
||||
case PERIOD_M4:
|
||||
case PERIOD_M5:
|
||||
case PERIOD_M6:
|
||||
result = PERIOD_M15;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_M10:
|
||||
case PERIOD_M12:
|
||||
case PERIOD_M15:
|
||||
result = PERIOD_M30;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_M5:
|
||||
case PERIOD_M6:
|
||||
case PERIOD_M10:
|
||||
case PERIOD_M12:
|
||||
result = PERIOD_H1;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_M15:
|
||||
case PERIOD_M20:
|
||||
case PERIOD_M30:
|
||||
result = PERIOD_H2;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H1:
|
||||
case PERIOD_H2:
|
||||
result = PERIOD_H4;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H3:
|
||||
result = PERIOD_H6;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H4:
|
||||
result = PERIOD_H8;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H6:
|
||||
result = PERIOD_H12;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H8:
|
||||
result = PERIOD_D1;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H12:
|
||||
result = PERIOD_W1;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_D1:
|
||||
result = PERIOD_MN1;
|
||||
break;
|
||||
|
||||
//
|
||||
default:
|
||||
result = PERIOD_MN1;
|
||||
result = mPeriod;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -13013,55 +12577,59 @@ ENUM_TIMEFRAMES GetLongestPeriod(ENUM_TIMEFRAMES mPeriod)
|
||||
//
|
||||
case PERIOD_M1:
|
||||
case PERIOD_M2:
|
||||
case PERIOD_M3:
|
||||
result = PERIOD_M30;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_M3:
|
||||
case PERIOD_M4:
|
||||
case PERIOD_M5:
|
||||
case PERIOD_M6:
|
||||
result = PERIOD_H1;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_M5:
|
||||
case PERIOD_M6:
|
||||
case PERIOD_M10:
|
||||
case PERIOD_M12:
|
||||
case PERIOD_M15:
|
||||
result = PERIOD_H2;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_M15:
|
||||
case PERIOD_M20:
|
||||
case PERIOD_M30:
|
||||
result = PERIOD_H4;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H1:
|
||||
case PERIOD_H2:
|
||||
result = PERIOD_H6;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H3:
|
||||
result = PERIOD_H8;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H4:
|
||||
result = PERIOD_H12;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H6:
|
||||
result = PERIOD_D1;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H8:
|
||||
result = PERIOD_W1;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H12:
|
||||
result = PERIOD_MN1;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_D1:
|
||||
result = PERIOD_MN1;
|
||||
break;
|
||||
|
||||
//
|
||||
default:
|
||||
result = PERIOD_MN1;
|
||||
result = mPeriod;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -13085,55 +12653,59 @@ ENUM_TIMEFRAMES GetHindMostPeriod(ENUM_TIMEFRAMES mPeriod)
|
||||
//
|
||||
case PERIOD_M1:
|
||||
case PERIOD_M2:
|
||||
case PERIOD_M3:
|
||||
result = PERIOD_H1;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_M3:
|
||||
case PERIOD_M4:
|
||||
case PERIOD_M5:
|
||||
case PERIOD_M6:
|
||||
result = PERIOD_H2;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_M5:
|
||||
case PERIOD_M6:
|
||||
case PERIOD_M10:
|
||||
case PERIOD_M12:
|
||||
case PERIOD_M15:
|
||||
result = PERIOD_H4;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_M15:
|
||||
case PERIOD_M20:
|
||||
result = PERIOD_H8;
|
||||
case PERIOD_M30:
|
||||
result = PERIOD_H6;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H1:
|
||||
case PERIOD_H2:
|
||||
result = PERIOD_H8;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H3:
|
||||
result = PERIOD_H12;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H4:
|
||||
result = PERIOD_D1;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H6:
|
||||
result = PERIOD_W1;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H8:
|
||||
result = PERIOD_MN1;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_H12:
|
||||
result = PERIOD_MN1;
|
||||
break;
|
||||
|
||||
//
|
||||
case PERIOD_D1:
|
||||
result = PERIOD_MN1;
|
||||
break;
|
||||
|
||||
//
|
||||
default:
|
||||
result = PERIOD_MN1;
|
||||
result = mPeriod;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -13320,4 +12892,99 @@ bool IsSpecifiedBearish(ENUM_X_DIRECTION value)
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
// Moving Average ...
|
||||
|
||||
/**
|
||||
* Calculate Sspecified Buffer's Moving Averages ...
|
||||
*
|
||||
* @param rates_total: Integer, number of items ...
|
||||
* @param prev_calculated: Integer, Previous Calculate Items ...
|
||||
* @param begin: Integer, Bar Index ...
|
||||
* @param period: Integer, Moving Average Length ...
|
||||
* @param price: Double Array, Specified Array for Calculating Moving Averages ...
|
||||
* @param buffer: Double Array, Specified Array to Apply Calculated Moving Average on it ...
|
||||
* @param method: ENUM_MA_METHOD member Specified Moving Average Calculation Method ...
|
||||
*
|
||||
* @return ( int )
|
||||
*/
|
||||
int iMAOnBuffer(
|
||||
const int rates_total,
|
||||
const int prev_calculated,
|
||||
const int begin,
|
||||
const int period,
|
||||
const double &price[],
|
||||
double &buffer[],
|
||||
ENUM_MA_METHOD method = MODE_SMA //
|
||||
)
|
||||
{
|
||||
//
|
||||
int result = 0;
|
||||
|
||||
//
|
||||
if (
|
||||
period < 0 ||
|
||||
rates_total <= 0 ||
|
||||
prev_calculated < 0 ||
|
||||
prev_calculated > rates_total)
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
switch (method)
|
||||
{
|
||||
//
|
||||
case MODE_SMA:
|
||||
result = SimpleMAOnBuffer(
|
||||
rates_total,
|
||||
prev_calculated,
|
||||
begin,
|
||||
period,
|
||||
price,
|
||||
buffer //
|
||||
);
|
||||
break;
|
||||
|
||||
//
|
||||
case MODE_EMA:
|
||||
result = ExponentialMAOnBuffer(
|
||||
rates_total,
|
||||
prev_calculated,
|
||||
begin,
|
||||
period,
|
||||
price,
|
||||
buffer //
|
||||
);
|
||||
break;
|
||||
|
||||
//
|
||||
case MODE_LWMA:
|
||||
result = LinearWeightedMAOnBuffer(
|
||||
rates_total,
|
||||
prev_calculated,
|
||||
begin,
|
||||
period,
|
||||
price,
|
||||
buffer //
|
||||
);
|
||||
break;
|
||||
|
||||
//
|
||||
case MODE_SMMA:
|
||||
result = SmoothedMAOnBuffer(
|
||||
rates_total,
|
||||
prev_calculated,
|
||||
begin,
|
||||
period,
|
||||
price,
|
||||
buffer //
|
||||
);
|
||||
break;
|
||||
}
|
||||
|
||||
//
|
||||
return result;
|
||||
}
|
||||
|
||||
//
|
||||
Reference in New Issue
Block a user