Add Support for atr in x121 indicator ...

This commit is contained in:
2024-12-30 16:58:15 +03:30
parent 1868587608
commit 0bfed000db
3 changed files with 870 additions and 487 deletions
+488 -195
View File
@@ -33,47 +33,50 @@ enum ENUM_X121_BUFFERS
X121_PEAKS_LINE = 0,
X121_VALES_LINE = 1,
X121_SAR_LINE = 2,
X121_VWAP_FAST_LINE = 3,
X121_VWAP_MID_LINE = 5,
X121_VWAP_SLOW_LINE = 7,
X121_DON_OPEN_UPPER_LINE = 9,
X121_DON_OPEN_LOWER_LINE = 10,
X121_DON_HIGH_UPPER_LINE = 11,
X121_DON_HIGH_LOWER_LINE = 12,
X121_DON_LOW_UPPER_LINE = 13,
X121_DON_LOW_LOWER_LINE = 14,
X121_DON_CLOSE_UPPER_LINE = 15,
X121_DON_CLOSE_LOWER_LINE = 16,
X121_FIB_LEVEL_1_LINE = 17,
X121_FIB_LEVEL_2_LINE = 18,
X121_FIB_LEVEL_3_LINE = 19,
X121_FIB_LEVEL_4_LINE = 20,
X121_FIB_LEVEL_5_LINE = 21,
X121_ATR_UPPER_LINE = 3,
X121_ATR_LOWER_LINE = 4,
X121_VWAP_FAST_LINE = 5,
X121_VWAP_MID_LINE = 7,
X121_VWAP_SLOW_LINE = 9,
X121_DON_OPEN_UPPER_LINE = 11,
X121_DON_OPEN_LOWER_LINE = 12,
X121_DON_HIGH_UPPER_LINE = 13,
X121_DON_HIGH_LOWER_LINE = 14,
X121_DON_LOW_UPPER_LINE = 15,
X121_DON_LOW_LOWER_LINE = 16,
X121_DON_CLOSE_UPPER_LINE = 17,
X121_DON_CLOSE_LOWER_LINE = 18,
X121_FIB_LEVEL_1_LINE = 19,
X121_FIB_LEVEL_2_LINE = 20,
X121_FIB_LEVEL_3_LINE = 21,
X121_FIB_LEVEL_4_LINE = 22,
X121_FIB_LEVEL_5_LINE = 23,
//
// Data Buffers ...
//
// XPV Data ...
X121_CURRENT_HH_LINE = 22,
X121_CURRENT_LL_LINE = 23,
X121_SHORT_HH_LINE = 24,
X121_SHORT_LL_LINE = 25,
X121_MEDIUM_HH_LINE = 26,
X121_MEDIUM_LL_LINE = 27,
X121_LONG_HH_LINE = 28,
X121_LONG_LL_LINE = 29,
X121_HIND_HH_LINE = 30,
X121_HIND_LL_LINE = 31,
X121_CURRENT_HH_LINE = 24,
X121_CURRENT_LL_LINE = 25,
X121_SHORT_HH_LINE = 26,
X121_SHORT_LL_LINE = 27,
X121_MEDIUM_HH_LINE = 28,
X121_MEDIUM_LL_LINE = 29,
X121_LONG_HH_LINE = 30,
X121_LONG_LL_LINE = 31,
X121_HIND_HH_LINE = 32,
X121_HIND_LL_LINE = 33,
//
// VWAP Data ...
X121_VWAP_VOLUME_LINE = 32,
X121_VWAP_PRICE_LINE = 33,
X121_VWAP_FAST_STATE_LINE = 34,
X121_VWAP_MID_STATE_LINE = 35,
X121_VWAP_SLOW_STATE_LINE = 36,
X121_VWAP_VOLUME_LINE = 34,
X121_VWAP_PRICE_LINE = 35,
X121_VWAP_FAST_STATE_LINE = 36,
X121_VWAP_MID_STATE_LINE = 37,
X121_VWAP_SLOW_STATE_LINE = 38,
//
// VALID PEAKS and VALES ...
X121_VALID_PEAKS_LINE = 37,
X121_VALID_VALES_LINE = 38,
// ATR ...
X121_ATR_LINE = 39,
X121_ATR_UPPER_RAW_LINE = 40,
X121_ATR_LOWER_RAW_LINE = 41,
};
//
@@ -121,10 +124,18 @@ struct X121Inputs
ENUM_SERIESMODE llMode; // Lowest Low Calculation Method
//
// Paraboli Sar Detection ...
// Parabolic Sar Detection ...
double sarStep; // Step
double sarMax; // Maximum
//
// Atr Detection ...
int atrLength; // Length
double atrMultiplier; // Multiplier
ENUM_APPLIED_PRICE atrUpperAppliedTo; // Upper Zone Applied To
ENUM_APPLIED_PRICE atrLowerAppliedTo; // Lower Zone Applied To
ENUM_X_MA_METHOD atrSmoothingMode; // Smoothing Method
//
// VWap Detection ...
int vwapFastLength; // Fast Length
@@ -158,6 +169,7 @@ struct X121Inputs
//
// Global ...
bool showSar; // Show Parabolic Sar
bool showAtr; // Show Atr
bool showPeaks; // Show Peaks
bool showVales; // Show Vales
bool showVWap; // Show VWap
@@ -171,6 +183,11 @@ struct X121Inputs
bool showFibo4Levels; // Show Fibo 4th Level
bool showFibo5Levels; // Show Fibo 5th Level
//
// Atr Presentation ...
bool showAtrUpper; // Show Upper Zone
bool showAtrLower; // Show Lower Zone
//
// VWap Presentation ...
bool showVWapFast; // Show VWap Fast
@@ -238,6 +255,14 @@ struct X121Inputs
sarStep = 0;
sarMax = 0;
//
// Atr Detection ...
atrLength = 0; // Length
atrMultiplier = 0; // Multiplier
atrUpperAppliedTo = PRICE_HIGH; // Upper Zone Applied To
atrLowerAppliedTo = PRICE_LOW; // Lower Zone Applied To
atrSmoothingMode = X_MA_MODE_NONE; // Smoothing Method
//
// VWap Detection ...
vwapFastLength = 0;
@@ -271,6 +296,7 @@ struct X121Inputs
//
// Globals ...
showSar = false;
showAtr = false;
showPeaks = false;
showVales = false;
showVWap = false;
@@ -284,6 +310,11 @@ struct X121Inputs
showFibo4Levels = false;
showFibo5Levels = false;
//
// Atr Presentation ...
showAtrUpper = false; // Show Upper Zone
showAtrLower = false; // Show Lower Zone
//
// VWap Presentation ...
showVWapFast = false;
@@ -342,6 +373,14 @@ struct X121Inputs
sarStep = 0.02;
sarMax = 0.2;
//
// Atr Detection ...
atrLength = 14; // Length
atrMultiplier = 1; // Multiplier
atrUpperAppliedTo = PRICE_HIGH; // Upper Zone Applied To
atrLowerAppliedTo = PRICE_LOW; // Lower Zone Applied To
atrSmoothingMode = X_MA_MODE_EMA; // Smoothing Method
//
// VWap Detection ...
vwapFastLength = 20;
@@ -375,6 +414,7 @@ struct X121Inputs
//
// Globals ...
showSar = true;
showAtr = true;
showPeaks = true;
showVales = true;
showVWap = true;
@@ -388,6 +428,11 @@ struct X121Inputs
showFibo4Levels = false;
showFibo5Levels = false;
//
// Atr Presentation ...
showAtrUpper = true; // Show Upper Zone
showAtrLower = true; // Show Lower Zone
//
// VWap Presentation ...
showVWapFast = true;
@@ -426,6 +471,10 @@ struct X121Inputs
sarStep > 0 &&
sarMax > sarStep &&
//
// ATR ...
atrLength > 0 &&
atrMultiplier > 0 &&
//
// XDON ...
donchainLength > 0 &&
//
@@ -457,10 +506,14 @@ struct X121Inputs
int result = 0;
//
// XVWAP ...
// VWAP ...
result = MathMax(result, vwapFastLength);
result = MathMax(result, vwapFastLength);
result = MathMax(result, vwapMidLength);
result = MathMax(result, vwapSlowLength);
//
// ATR ...
result = MathMax(result, atrLength);
//
return result;
@@ -482,6 +535,8 @@ struct X121Conditions
double peaksBuffer[];
double valesBuffer[];
double sarBuffer[];
double atrUpperBuffer[];
double atrLowerBuffer[];
double vwapFastBuffer[];
double vwapMidBuffer[];
double vwapSlowBuffer[];
@@ -508,6 +563,9 @@ struct X121Conditions
double lLLBuffer[];
double hHHBuffer[];
double hLLBuffer[];
double atrBuffer[];
double atrUpperRawBuffer[];
double atrLowerRawBuffer[];
double vwapVolumeBuffer[];
double vwapPriceBuffer[];
double vwapFastStateBuffer[];
@@ -652,6 +710,8 @@ struct X121Conditions
Clean(peaksBuffer);
Clean(valesBuffer);
Clean(sarBuffer);
Clean(atrUpperBuffer);
Clean(atrLowerBuffer);
Clean(vwapFastBuffer);
Clean(vwapMidBuffer);
Clean(vwapSlowBuffer);
@@ -678,6 +738,9 @@ struct X121Conditions
Clean(lLLBuffer);
Clean(hHHBuffer);
Clean(hLLBuffer);
Clean(atrBuffer);
Clean(atrUpperRawBuffer);
Clean(atrLowerRawBuffer);
Clean(vwapVolumeBuffer);
Clean(vwapPriceBuffer);
Clean(vwapFastStateBuffer);
@@ -690,6 +753,8 @@ struct X121Conditions
ArraySetAsSeries(peaksBuffer, true);
ArraySetAsSeries(valesBuffer, true);
ArraySetAsSeries(sarBuffer, true);
ArraySetAsSeries(atrUpperBuffer, true);
ArraySetAsSeries(atrLowerBuffer, true);
ArraySetAsSeries(vwapFastBuffer, true);
ArraySetAsSeries(vwapMidBuffer, true);
ArraySetAsSeries(vwapSlowBuffer, true);
@@ -716,6 +781,9 @@ struct X121Conditions
ArraySetAsSeries(lLLBuffer, true);
ArraySetAsSeries(hHHBuffer, true);
ArraySetAsSeries(hLLBuffer, true);
ArraySetAsSeries(atrBuffer, true);
ArraySetAsSeries(atrUpperRawBuffer, true);
ArraySetAsSeries(atrLowerRawBuffer, true);
ArraySetAsSeries(vwapVolumeBuffer, true);
ArraySetAsSeries(vwapPriceBuffer, true);
ArraySetAsSeries(vwapFastStateBuffer, true);
@@ -1064,6 +1132,8 @@ class XCX121Helper : public XCBaseHelper
ArraySetAsSeries(peaksBuffer, true);
ArraySetAsSeries(valesBuffer, true);
ArraySetAsSeries(sarBuffer, true);
ArraySetAsSeries(atrUpperBuffer, true);
ArraySetAsSeries(atrLowerBuffer, true);
ArraySetAsSeries(vwapFastBuffer, true);
ArraySetAsSeries(vwapMidBuffer, true);
ArraySetAsSeries(vwapSlowBuffer, true);
@@ -1090,13 +1160,14 @@ class XCX121Helper : public XCBaseHelper
ArraySetAsSeries(lLLBuffer, true);
ArraySetAsSeries(hHHBuffer, true);
ArraySetAsSeries(hLLBuffer, true);
ArraySetAsSeries(atrBuffer, true);
ArraySetAsSeries(atrUpperRawBuffer, true);
ArraySetAsSeries(atrLowerRawBuffer, true);
ArraySetAsSeries(vwapVolumeBuffer, true);
ArraySetAsSeries(vwapPriceBuffer, true);
ArraySetAsSeries(vwapFastStateBuffer, true);
ArraySetAsSeries(vwapMidStateBuffer, true);
ArraySetAsSeries(vwapSlowStateBuffer, true);
ArraySetAsSeries(validPeaksBuffer, true);
ArraySetAsSeries(validValesBuffer, true);
//
mHandler = iCustom(
@@ -1134,11 +1205,19 @@ class XCX121Helper : public XCBaseHelper
mInputs.hhMode,
mInputs.llMode,
//
// Paraboli Sar Detection ...
// Parabolic Sar Detection ...
"",
mInputs.sarStep,
mInputs.sarMax,
//
// Atr Detection ...
"",
mInputs.atrLength,
mInputs.atrMultiplier,
mInputs.atrUpperAppliedTo,
mInputs.atrLowerAppliedTo,
mInputs.atrSmoothingMode,
//
// VWap Detection ...
"",
mInputs.vwapFastLength,
@@ -1150,23 +1229,13 @@ class XCX121Helper : public XCBaseHelper
"",
mInputs.donchainLength,
//
// Fibonacci ...
"",
mInputs.fiboLevel1,
mInputs.fiboLevel2,
mInputs.fiboLevel3,
mInputs.fiboLevel4,
mInputs.fiboLevel5,
//
// Presentation ...
"",
mInputs.startCalculationForLastBars,
mInputs.sarArrowCode,
mInputs.peaksArrowCode,
mInputs.valesArrowCode,
//
// Commons ...
mInputs.showSar,
mInputs.showAtr,
mInputs.showPeaks,
mInputs.showVales,
mInputs.showVWap,
@@ -1180,6 +1249,11 @@ class XCX121Helper : public XCBaseHelper
mInputs.showFibo4Levels,
mInputs.showFibo5Levels,
//
// Atr Presentation ...
"",
mInputs.showAtrUpper,
mInputs.showAtrLower,
//
// VWap Presentation ...
"",
mInputs.showVWapFast,
@@ -1195,6 +1269,20 @@ class XCX121Helper : public XCBaseHelper
mInputs.showClose,
mInputs.showLow
//
// Non Important Inpust ...
//
// Fibonacci ...
// "",
// mInputs.fiboLevel1,
// mInputs.fiboLevel2,
// mInputs.fiboLevel3,
// mInputs.fiboLevel4,
// mInputs.fiboLevel5,
// //
// mInputs.sarArrowCode,
// mInputs.peaksArrowCode,
// mInputs.valesArrowCode
//
);
result = mHandler != INVALID_HANDLE;
if (!result)
@@ -1241,7 +1329,8 @@ class XCX121Helper : public XCBaseHelper
*
* @return ( int )
*/
int GetDonChainLength() {
int GetDonChainLength()
{
return mInputs.donchainLength;
}
@@ -1249,7 +1338,7 @@ class XCX121Helper : public XCBaseHelper
// Implement Value Getters ...
//
// XSAR ...
// SAR ...
//
double GetSar(
@@ -1301,7 +1390,258 @@ class XCX121Helper : public XCBaseHelper
}
//
// XPV ...
// ATR ...
//
// Common ...
//
double GetAtr(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(atrBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return atrBuffer[barIndex];
}
//
int CopyAtr(
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,
atrBuffer,
buffer,
forceClean
//
);
}
//
double GetAtrUpper(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(atrUpperBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return atrUpperBuffer[barIndex];
}
//
int CopyAtrUpper(
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,
atrUpperBuffer,
buffer,
forceClean
//
);
}
//
double GetAtrUpperRaw(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(atrUpperRawBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return atrUpperRawBuffer[barIndex];
}
//
int CopyAtrUpperRaw(
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,
atrUpperRawBuffer,
buffer,
forceClean
//
);
}
//
double GetAtrLower(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(atrLowerBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return atrLowerBuffer[barIndex];
}
//
int CopyAtrLower(
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,
atrLowerBuffer,
buffer,
forceClean
//
);
}
//
double GetAtrLowerRaw(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(atrLowerRawBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return atrLowerRawBuffer[barIndex];
}
//
int CopyAtrLowerRaw(
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,
atrLowerRawBuffer,
buffer,
forceClean
//
);
}
//
// PV ...
//
// PEAKS ...
@@ -1943,111 +2283,7 @@ class XCX121Helper : public XCBaseHelper
}
//
// VALID PEAKS ...
//
double GetValidPeak(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(validPeaksBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return validPeaksBuffer[barIndex];
}
//
int CopyValidPeak(
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,
validPeaksBuffer,
buffer,
forceClean
//
);
}
//
// VALID VALES ...
//
double GetValidVale(
int barIndex // Bar Index
)
{
//
if (barIndex < 0)
{
barIndex = 0;
}
//
Calculate();
//
int count = ArraySize(validValesBuffer);
if (barIndex >= count)
{
barIndex = count - 1;
}
//
return validValesBuffer[barIndex];
}
//
int CopyValidVale(
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,
validValesBuffer,
buffer,
forceClean
//
);
}
//
// XVWAP ...
// VWAP ...
//
// FAST ...
@@ -3292,6 +3528,41 @@ class XCX121Helper : public XCBaseHelper
conditions.sarBuffer //
);
//
CopyAtr(
zIndex,
loopback,
conditions.atrBuffer //
);
//
CopyAtrUpper(
zIndex,
loopback,
conditions.atrUpperBuffer //
);
//
CopyAtrUpperRaw(
zIndex,
loopback,
conditions.atrUpperRawBuffer //
);
//
CopyAtrLower(
zIndex,
loopback,
conditions.atrLowerBuffer //
);
//
CopyAtrLowerRaw(
zIndex,
loopback,
conditions.atrLowerRawBuffer //
);
//
CopyPeak(
zIndex,
@@ -3376,20 +3647,6 @@ class XCX121Helper : public XCBaseHelper
conditions.hLLBuffer //
);
//
CopyValidPeak(
zIndex,
loopback,
conditions.validPeaksBuffer //
);
//
CopyValidVale(
zIndex,
loopback,
conditions.validValesBuffer //
);
//
CopyVWapFast(
zIndex,
@@ -3797,6 +4054,8 @@ class XCX121Helper : public XCBaseHelper
double peaksBuffer[];
double valesBuffer[];
double sarBuffer[];
double atrUpperBuffer[];
double atrLowerBuffer[];
double vwapFastBuffer[];
double vwapMidBuffer[];
double vwapSlowBuffer[];
@@ -3823,6 +4082,9 @@ class XCX121Helper : public XCBaseHelper
double lLLBuffer[];
double hHHBuffer[];
double hLLBuffer[];
double atrBuffer[];
double atrUpperRawBuffer[];
double atrLowerRawBuffer[];
double vwapVolumeBuffer[];
double vwapPriceBuffer[];
double vwapFastStateBuffer[];
@@ -3860,6 +4122,59 @@ class XCX121Helper : public XCBaseHelper
//
);
//
// ATR ...
//
CopyBuffer(
mHandler,
X121_ATR_UPPER_LINE,
0,
totalBars,
atrUpperBuffer
//
);
//
CopyBuffer(
mHandler,
X121_ATR_LOWER_LINE,
0,
totalBars,
atrLowerBuffer
//
);
//
CopyBuffer(
mHandler,
X121_ATR_LINE,
0,
totalBars,
atrBuffer
//
);
//
CopyBuffer(
mHandler,
X121_ATR_UPPER_RAW_LINE,
0,
totalBars,
atrUpperRawBuffer
//
);
//
CopyBuffer(
mHandler,
X121_ATR_LOWER_RAW_LINE,
0,
totalBars,
atrLowerRawBuffer
//
);
//
// XPV ...
@@ -3885,28 +4200,6 @@ class XCX121Helper : public XCBaseHelper
//
);
//
// VALID PEAKS ...
CopyBuffer(
mHandler,
X121_VALID_PEAKS_LINE,
0,
totalBars,
validPeaksBuffer
//
);
//
// VALID VALES ...
CopyBuffer(
mHandler,
X121_VALID_VALES_LINE,
0,
totalBars,
validValesBuffer
//
);
//
// CURRENT ...
+359 -279
View File
@@ -63,10 +63,18 @@ input ENUM_SERIESMODE hhMode = MODE_HIGH; // Highest High Calculation Method
input ENUM_SERIESMODE llMode = MODE_LOW; // Lowest Low Calculation Method
//
input group "Paraboli Sar Detection";
input group "Parabolic Sar Detection";
input double sarStep = 0.02; // Step
input double sarMax = 0.2; // Maximum
//
input group "Atr Detection";
input int atrLength = 14; // Length
input double atrMultiplier = 1; // Multiplier
input ENUM_APPLIED_PRICE atrUpperAppliedTo = PRICE_HIGH; // Upper Zone Applied To
input ENUM_APPLIED_PRICE atrLowerAppliedTo = PRICE_LOW; // Lower Zone Applied To
input ENUM_X_MA_METHOD atrSmoothingMode = X_MA_MODE_EMA; // Smoothing Method
//
input group "VWap Detection";
input int vwapFastLength = 20; // Fast Length
@@ -78,27 +86,15 @@ input ENUM_APPLIED_PRICE vwapAppliedTo = PRICE_CLOSE; // Applied To
input group "Donchain Detection";
input int donchainLength = 40; // Donchain Length
//
input group "Fibonacci";
input double fiboLevel1 = 0.236; // Fibio 1st Level
input double fiboLevel2 = 0.382; // Fibio 2st Level
input double fiboLevel3 = 0.5; // Fibio 3rd Level
input double fiboLevel4 = 0.618; // Fibio 4th Level
input double fiboLevel5 = 0.764; // Fibio 5th Level
//
input group "Presentation";
//
input int startCalculationForLastBars = 1000; // Calculate Last n Bars
//
input int sarArrowCode = 159; // Parabolic Sar Arrow Code
input int peaksArrowCode = 159; // Peaks Arrow Code
input int valesArrowCode = 159; // Vales Arrow Code
//
input bool showSar = true; // Show Parabolic Sar
input bool showAtr = true; // Show Atr
input bool showPeaks = true; // Show Peaks
input bool showVales = true; // Show Vales
input bool showVWap = true; // Show VWap
@@ -112,6 +108,11 @@ input bool showFibo3Levels = false; // Show Fibo 3rd Level
input bool showFibo4Levels = false; // Show Fibo 4th Level
input bool showFibo5Levels = false; // Show Fibo 5th Level
//
input group "Atr Presentation";
input bool showAtrUpper = true; // Show Upper Zone
input bool showAtrLower = true; // Show Lower Zone
//
input group "VWap Presentation";
input bool showVWapFast = true; // Show VWap Fast
@@ -127,6 +128,22 @@ input bool showHigh = false; // Show High
input bool showClose = true; // Show Close
input bool showLow = false; // Show Low
//
// Non Important Inputs ...
//
input group "Fibonacci";
input double fiboLevel1 = 0.236; // Fibio 1st Level
input double fiboLevel2 = 0.382; // Fibio 2st Level
input double fiboLevel3 = 0.5; // Fibio 3rd Level
input double fiboLevel4 = 0.618; // Fibio 4th Level
input double fiboLevel5 = 0.764; // Fibio 5th Level
//
input int sarArrowCode = 159; // Parabolic Sar Arrow Code
input int peaksArrowCode = 159; // Peaks Arrow Code
input int valesArrowCode = 159; // Vales Arrow Code
//
// Buffers ...
@@ -140,8 +157,8 @@ input bool showLow = false; // Show Low
#property indicator_chart_window
//
#property indicator_buffers 39
#property indicator_plots 19
#property indicator_buffers 42
#property indicator_plots 21
//
// PEAKS ...
@@ -169,6 +186,9 @@ double valesBuffer[];
#property indicator_color2 clrMagenta
#property indicator_width2 1
//
// SAR ...
//
#define sarBufferIndex 2
double sarBuffer[];
@@ -180,52 +200,84 @@ double sarBuffer[];
#property indicator_width3 1
//
// FAST ...
#define vwapFastBufferIndex 3
double vwapFastBuffer[];
#define vwapFastColorBufferIndex 4
double vwapFastColorBuffer[];
// ATR ...
//
#define vwapFastPlotBufferIndex 3
#property indicator_label4 "X121 VWF"
#property indicator_type4 DRAW_COLOR_LINE
#property indicator_color4 CLR_NONE, clrAqua, clrMagenta, clrGray
#property indicator_style4 STYLE_SOLID
// Upper ...
//
#define atrUpperBufferIndex 3
double atrUpperBuffer[];
#property indicator_label4 "X121 ATRU"
#property indicator_type4 DRAW_LINE
#property indicator_color4 clrYellow
#property indicator_style4 STYLE_DOT
#property indicator_width4 2
//
// MID ...
#define vwapMidBufferIndex 5
double vwapMidBuffer[];
#define vwapMidColorBufferIndex 6
double vwapMidColorBuffer[];
// Lower ...
//
#define vwapMidPlotBufferIndex 4
#property indicator_label5 "X121 VWM"
#property indicator_type5 DRAW_COLOR_LINE
#property indicator_color5 CLR_NONE, clrGreen, clrRed, clrGray
#property indicator_style5 STYLE_SOLID
#define atrLowerBufferIndex 4
double atrLowerBuffer[];
#property indicator_label5 "X121 ATRL"
#property indicator_type5 DRAW_LINE
#property indicator_color5 clrYellow
#property indicator_style5 STYLE_DOT
#property indicator_width5 2
//
// VWAP ...
//
// FAST ...
#define vwapFastBufferIndex 5
double vwapFastBuffer[];
#define vwapFastColorBufferIndex 6
double vwapFastColorBuffer[];
//
#define vwapFastPlotBufferIndex 5
#property indicator_label6 "X121 VWF"
#property indicator_type6 DRAW_COLOR_LINE
#property indicator_color6 CLR_NONE, clrAqua, clrMagenta, clrGray
#property indicator_style6 STYLE_SOLID
#property indicator_width6 2
//
// MID ...
#define vwapMidBufferIndex 7
double vwapMidBuffer[];
#define vwapMidColorBufferIndex 8
double vwapMidColorBuffer[];
//
#define vwapMidPlotBufferIndex 6
#property indicator_label7 "X121 VWM"
#property indicator_type7 DRAW_COLOR_LINE
#property indicator_color7 CLR_NONE, clrGreen, clrRed, clrGray
#property indicator_style7 STYLE_SOLID
#property indicator_width7 2
//
// SLOW ...
#define vwapSlowBufferIndex 7
#define vwapSlowBufferIndex 9
double vwapSlowBuffer[];
#define vwapSlowColorBufferIndex 8
#define vwapSlowColorBufferIndex 10
double vwapSlowColorBuffer[];
//
#define vwapSlowPlotBufferIndex 5
#property indicator_label6 "X121 VWS"
#property indicator_type6 DRAW_COLOR_LINE
#property indicator_color6 CLR_NONE, clrSteelBlue, clrDarkRed, clrGray
#property indicator_style6 STYLE_SOLID
#property indicator_width6 2
#define vwapSlowPlotBufferIndex 7
#property indicator_label8 "X121 VWS"
#property indicator_type8 DRAW_COLOR_LINE
#property indicator_color8 CLR_NONE, clrSteelBlue, clrDarkRed, clrGray
#property indicator_style8 STYLE_SOLID
#property indicator_width8 2
//
// XDON ...
@@ -234,101 +286,101 @@ double vwapSlowColorBuffer[];
// Open ...
//
#define donOpenUpperBufferIndex 9
#define donOpenUpperBufferIndex 11
double donOpenUpperBuffer[];
//
#define donOpenUpperPlotBufferIndex 6
#property indicator_label7 "X121 O U"
#property indicator_type7 DRAW_LINE
#property indicator_color7 clrCornflowerBlue
#property indicator_width7 1
#define donOpenUpperPlotBufferIndex 8
#property indicator_label9 "X121 O U"
#property indicator_type9 DRAW_LINE
#property indicator_color9 clrCornflowerBlue
#property indicator_width9 1
//
#define donOpenLowerBufferIndex 10
#define donOpenLowerBufferIndex 12
double donOpenLowerBuffer[];
//
#define donOpenLowerPlotBufferIndex 7
#property indicator_label8 "X121 O L"
#property indicator_type8 DRAW_LINE
#property indicator_color8 clrCornflowerBlue
#property indicator_width8 1
#define donOpenLowerPlotBufferIndex 9
#property indicator_label10 "X121 O L"
#property indicator_type10 DRAW_LINE
#property indicator_color10 clrCornflowerBlue
#property indicator_width10 1
//
// High ...
//
#define donHighUpperBufferIndex 11
#define donHighUpperBufferIndex 13
double donHighUpperBuffer[];
//
#define donHighUpperPlotBufferIndex 8
#property indicator_label9 "X121 H U"
#property indicator_type9 DRAW_LINE
#property indicator_color9 clrAquamarine
#property indicator_width9 1
#define donHighUpperPlotBufferIndex 10
#property indicator_label11 "X121 H U"
#property indicator_type11 DRAW_LINE
#property indicator_color11 clrAquamarine
#property indicator_width11 1
//
#define donHighLowerBufferIndex 12
#define donHighLowerBufferIndex 14
double donHighLowerBuffer[];
//
#define donHighLowerPlotBufferIndex 9
#property indicator_label10 "X121 H L"
#property indicator_type10 DRAW_LINE
#property indicator_color10 clrAquamarine
#property indicator_width10 1
#define donHighLowerPlotBufferIndex 11
#property indicator_label12 "X121 H L"
#property indicator_type12 DRAW_LINE
#property indicator_color12 clrAquamarine
#property indicator_width12 1
//
// Low ...
//
#define donLowUpperBufferIndex 13
#define donLowUpperBufferIndex 15
double donLowUpperBuffer[];
//
#define donLowUpperPlotBufferIndex 10
#property indicator_label11 "X121 L U"
#property indicator_type11 DRAW_LINE
#property indicator_color11 clrDarkOrchid
#property indicator_width11 1
#define donLowUpperPlotBufferIndex 12
#property indicator_label13 "X121 L U"
#property indicator_type13 DRAW_LINE
#property indicator_color13 clrDarkOrchid
#property indicator_width13 1
//
#define donLowLowerBufferIndex 14
#define donLowLowerBufferIndex 16
double donLowLowerBuffer[];
//
#define donLowLowerPlotBufferIndex 11
#property indicator_label12 "X121 L L"
#property indicator_type12 DRAW_LINE
#property indicator_color12 clrDarkOrchid
#property indicator_width12 1
#define donLowLowerPlotBufferIndex 13
#property indicator_label14 "X121 L L"
#property indicator_type14 DRAW_LINE
#property indicator_color14 clrDarkOrchid
#property indicator_width14 1
//
// Close ...
//
#define donCloseUpperBufferIndex 15
#define donCloseUpperBufferIndex 17
double donCloseUpperBuffer[];
//
#define donCloseUpperPlotBufferIndex 12
#property indicator_label13 "X121 C U"
#property indicator_type13 DRAW_LINE
#property indicator_color13 clrCoral
#property indicator_width13 1
#define donCloseUpperPlotBufferIndex 14
#property indicator_label15 "X121 C U"
#property indicator_type15 DRAW_LINE
#property indicator_color15 clrCoral
#property indicator_width15 1
//
#define donCloseLowerBufferIndex 16
#define donCloseLowerBufferIndex 18
double donCloseLowerBuffer[];
//
#define donCloseLowerPlotBufferIndex 13
#property indicator_label14 "X121 C L"
#property indicator_type14 DRAW_LINE
#property indicator_color14 clrCoral
#property indicator_width14 1
#define donCloseLowerPlotBufferIndex 15
#property indicator_label16 "X121 C L"
#property indicator_type16 DRAW_LINE
#property indicator_color16 clrCoral
#property indicator_width16 1
//
// FIBONACCI ...
@@ -337,82 +389,82 @@ double donCloseLowerBuffer[];
// FIBBO Level 1 ...
//
#define fl1BufferIndex 17
#define fl1BufferIndex 19
double fl1Buffer[];
//
#define fl1PlotBufferIndex 14
#property indicator_label15 "X121 FL1"
#property indicator_type15 DRAW_LINE
#property indicator_color15 clrGold
#property indicator_style15 STYLE_DASHDOTDOT
#property indicator_width15 1
//
// FIBBO Level 2 ...
//
#define fl2BufferIndex 18
double fl2Buffer[];
//
#define fl2PlotBufferIndex 15
#property indicator_label16 "X121 FL2"
#property indicator_type16 DRAW_LINE
#property indicator_color16 clrGold
#property indicator_style16 STYLE_DASHDOTDOT
#property indicator_width16 1
//
// FIBBO Level 3 ...
//
#define fl3BufferIndex 19
double fl3Buffer[];
//
#define fl3PlotBufferIndex 16
#property indicator_label17 "X121 FL3"
#define fl1PlotBufferIndex 16
#property indicator_label17 "X121 FL1"
#property indicator_type17 DRAW_LINE
#property indicator_color17 clrGold
#property indicator_style17 STYLE_DASHDOTDOT
#property indicator_width17 1
//
// FIBBO Level 4 ...
// FIBBO Level 2 ...
//
#define fl4BufferIndex 20
double fl4Buffer[];
#define fl2BufferIndex 20
double fl2Buffer[];
//
#define fl4PlotBufferIndex 17
#property indicator_label18 "X121 FL4"
#define fl2PlotBufferIndex 17
#property indicator_label18 "X121 FL2"
#property indicator_type18 DRAW_LINE
#property indicator_color18 clrGold
#property indicator_style18 STYLE_DASHDOTDOT
#property indicator_width18 1
//
// FIBBO Level 5 ...
// FIBBO Level 3 ...
//
#define fl5BufferIndex 21
double fl5Buffer[];
#define fl3BufferIndex 21
double fl3Buffer[];
//
#define fl5PlotBufferIndex 18
#property indicator_label19 "X121 FL5"
#define fl3PlotBufferIndex 18
#property indicator_label19 "X121 FL3"
#property indicator_type19 DRAW_LINE
#property indicator_color19 clrGold
#property indicator_style19 STYLE_DASHDOTDOT
#property indicator_width19 1
//
// FIBBO Level 4 ...
//
#define fl4BufferIndex 22
double fl4Buffer[];
//
#define fl4PlotBufferIndex 19
#property indicator_label20 "X121 FL4"
#property indicator_type20 DRAW_LINE
#property indicator_color20 clrGold
#property indicator_style20 STYLE_DASHDOTDOT
#property indicator_width20 1
//
// FIBBO Level 5 ...
//
#define fl5BufferIndex 23
double fl5Buffer[];
//
#define fl5PlotBufferIndex 20
#property indicator_label21 "X121 FL5"
#property indicator_type21 DRAW_LINE
#property indicator_color21 clrGold
#property indicator_style21 STYLE_DASHDOTDOT
#property indicator_width21 1
//
// Data Buffers ...
//
int mLastBufferIndex = 21;
int mLastBufferIndex = 23;
//
// CURRENT ...
@@ -495,13 +547,16 @@ double vwapMidStateBuffer[];
double vwapSlowStateBuffer[];
//
// Valid Peaks and Vales ...
// ATR ...
#define validPeaksBufferIndex mLastBufferIndex + 16
double validPeaksBuffer[];
#define atrBufferIndex mLastBufferIndex + 16
double atrBuffer[];
#define validValesBufferIndex mLastBufferIndex + 17
double validValesBuffer[];
#define atrUpperRawBufferIndex mLastBufferIndex + 17
double atrUpperRawBuffer[];
#define atrLowerRawBufferIndex mLastBufferIndex + 18
double atrLowerRawBuffer[];
//
// Variables, Properties and etc ...
@@ -517,6 +572,10 @@ int maxLength;
// SAR Handler ...
int sarHandler = INVALID_HANDLE;
//
// ATR Handler ...
int atrHandler = INVALID_HANDLE;
//
double mHideColorIDX = 0;
@@ -574,6 +633,19 @@ int OnInit()
return INIT_FAILED;
}
//
// ATR ...
atrHandler = iATR(
_Symbol,
_Period,
atrLength //
);
isInited = atrHandler != INVALID_HANDLE;
if (!isInited)
{
return INIT_FAILED;
}
//
if (!InitMarketCycles())
{
@@ -621,6 +693,7 @@ void OnDeinit(const int reason)
//
IndicatorRelease(sarHandler);
IndicatorRelease(atrHandler);
}
/**
@@ -680,10 +753,17 @@ int OnCalculate(
// SAR ...
int sarCalculatedBars = BarsCalculated(sarHandler);
//
// ATR ...
int atrCalculatedBars = BarsCalculated(atrHandler);
//
bool isPassedRequiredCalculatedBars =
//
// SAR ...
sarCalculatedBars >= maxLength &&
//
// ATR...
sarCalculatedBars >= maxLength
//
;
@@ -702,13 +782,18 @@ int OnCalculate(
// SAR ...
int copiedSars = CopyBuffer(sarHandler, 0, 0, limit, sarBuffer);
//
// ATR ...
int copiedAtrs = CopyBuffer(atrHandler, 0, 0, limit, atrBuffer);
//
// Validate Copied Items ...
bool isPassedRequiredCopiedItems =
//
//
// SAR ...
copiedSars > 0
copiedSars > 0 &&
copiedAtrs > 0
//
;
if (!isPassedRequiredCopiedItems)
@@ -756,6 +841,10 @@ bool ValidateInputs()
sarStep > 0 &&
sarMax > sarStep &&
//
// ATR ...
atrLength > 0 &&
atrMultiplier > 0 &&
//
// XDON ...
donchainLength > 0 &&
//
@@ -798,6 +887,10 @@ int ExtractMaxLengthOfInputs()
result = MathMax(result, vwapMidLength);
result = MathMax(result, vwapSlowLength);
//
// ATR ...
result = MathMax(result, atrLength);
//
return result;
}
@@ -827,6 +920,7 @@ void DefineBuffers()
//
// VALES ...
//
ENUM_DRAW_TYPE valesDrawType = showVales ? DRAW_ARROW : DRAW_NONE;
@@ -844,6 +938,7 @@ void DefineBuffers()
//
// SAR ...
//
ENUM_DRAW_TYPE sarDrawType = showSar ? DRAW_ARROW : DRAW_NONE;
@@ -859,6 +954,29 @@ void DefineBuffers()
PlotIndexSetDouble(sarBufferIndex, PLOT_EMPTY_VALUE, 0);
PlotIndexSetInteger(sarBufferIndex, PLOT_ARROW, sarArrowCode);
//
// ATR ...
//
// UPPER ...
bool canShowAtrUpper = showAtr && showAtrUpper;
ENUM_DRAW_TYPE atrUpperDrawType = canShowAtrUpper ? DRAW_LINE : DRAW_NONE;
ArraySetAsSeries(atrUpperBuffer, true);
SetIndexBuffer(atrUpperBufferIndex, atrUpperBuffer, INDICATOR_DATA);
PlotIndexSetDouble(atrUpperBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
PlotIndexSetInteger(atrUpperBufferIndex, PLOT_SHOW_DATA, canShowAtrUpper);
PlotIndexSetInteger(atrUpperBufferIndex, PLOT_DRAW_TYPE, atrUpperDrawType);
//
// LOWER ...
bool canShowAtrLower = showAtr && showAtrLower;
ENUM_DRAW_TYPE atrLowerDrawType = canShowAtrLower ? DRAW_LINE : DRAW_NONE;
ArraySetAsSeries(atrLowerBuffer, true);
SetIndexBuffer(atrLowerBufferIndex, atrLowerBuffer, INDICATOR_DATA);
PlotIndexSetDouble(atrLowerBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE);
PlotIndexSetInteger(atrLowerBufferIndex, PLOT_SHOW_DATA, canShowAtrLower);
PlotIndexSetInteger(atrLowerBufferIndex, PLOT_DRAW_TYPE, atrLowerDrawType);
//
// XVWAP ...
@@ -1118,15 +1236,19 @@ void DefineBuffers()
SetIndexBuffer(vwapSlowStateBufferIndex, vwapSlowStateBuffer, INDICATOR_CALCULATIONS);
//
// VALID Peaks and Vales ...
// ATR ...
//
ArraySetAsSeries(validPeaksBuffer, true);
SetIndexBuffer(validPeaksBufferIndex, validPeaksBuffer, INDICATOR_CALCULATIONS);
ArraySetAsSeries(atrBuffer, true);
SetIndexBuffer(atrBufferIndex, atrBuffer, INDICATOR_CALCULATIONS);
//
ArraySetAsSeries(validValesBuffer, true);
SetIndexBuffer(validValesBufferIndex, validValesBuffer, INDICATOR_CALCULATIONS);
ArraySetAsSeries(atrUpperRawBuffer, true);
SetIndexBuffer(atrUpperRawBufferIndex, atrUpperRawBuffer, INDICATOR_CALCULATIONS);
//
ArraySetAsSeries(atrLowerRawBuffer, true);
SetIndexBuffer(atrLowerRawBufferIndex, atrLowerRawBuffer, INDICATOR_CALCULATIONS);
}
/**
@@ -1192,14 +1314,15 @@ void CalculateBuffers(
);
//
// if (bar_index <= barsLimit + 576)
// {
// //
// CalculateValidPeaksAndVales(
// bar_index,
// prevCalculated //
// );
// }
CalculateAtrZones(
bar_index,
prevCalculated,
ratesTotal,
open,
high,
close,
low //
);
//
CalculateFibonacci(
@@ -1416,6 +1539,14 @@ void FillBuffersZero(int barIndex)
// SARS ...
sarBuffer[barIndex] = 0;
//
// ATRS ...
atrBuffer[barIndex] = 0;
atrUpperBuffer[barIndex] = 0;
atrUpperRawBuffer[barIndex] = 0;
atrUpperBuffer[barIndex] = 0;
atrLowerRawBuffer[barIndex] = 0;
//
// VWAP ...
@@ -1434,10 +1565,6 @@ void FillBuffersZero(int barIndex)
vwapMidStateBuffer[barIndex] = hideColorIDX;
vwapSlowStateBuffer[barIndex] = hideColorIDX;
//
validPeaksBuffer[barIndex] = 0;
validValesBuffer[barIndex] = 0;
//
donOpenUpperBuffer[barIndex] = 0;
donOpenLowerBuffer[barIndex] = 0;
@@ -1989,147 +2116,100 @@ void CalculateDonchains(
}
/**
* Calculate Valid Vales and Peaks ...
* Calculate Different VWaps ...
*
* @param bar_index: Integer, current Bar Index ...
* @param bar_index: Integer, Represent Current Bar ...
* @param prevCalculated: Integer, Represent Previous Calculated Bars ...
* @param ratesTotal: Integer, Represents All Available Bars ...
* @param open: Double Array, History of Open Prices ...
* @param high: Double Array, History of High Prices ...
* @param close: Double Array, History of Close Prices ...
* @param low: Double Array, History of Low Prices ...
*/
void CalculateValidPeaksAndVales(
int bar_index,
int prevCalculated //
void CalculateAtrZones(
int bar_index, // Selected Bar Index
const int prevCalculated,
const int ratesTotal,
const double &open[],
const double &high[],
const double &close[],
const double &low[] //
)
{
//
int minRepetition = donchainLength;
int maxAllowedLoopbackBars = 576;
// Select ATr Value ...
double atrValue = atrBuffer[bar_index];
double appliedAtrMultiplierValue = atrValue * atrMultiplier;
//
int barIndex = bar_index;
int start = barIndex;
int end = start + maxAllowedLoopbackBars;
// Select Upper Price ...
double upperPrice = GetAppliedPrice(
atrUpperAppliedTo,
open,
high,
low,
close,
bar_index //
);
//
double peak = 0;
int peakRepeate = 0;
int peakToBarIndex = 0;
int peakFromBarIndex = 0;
// Select Lower Price ...
double lowerPrice = GetAppliedPrice(
atrLowerAppliedTo,
open,
high,
low,
close,
bar_index //
);
//
double vale = 0;
int valeRepeate = 0;
int valeToBarIndex = 0;
int valeFromBarIndex = 0;
// Calculate Raw Atrs ...
//
bool canLookupPeak = true;
bool canLookupVale = true;
bool canLookup = true;
// Upper ...
double atrUpperRawValue = upperPrice + appliedAtrMultiplierValue;
atrUpperRawBuffer[bar_index] = atrUpperRawValue;
//
while (canLookup)
// Lower ...
double atrLowerRawValue = lowerPrice - appliedAtrMultiplierValue;
atrLowerRawBuffer[bar_index] = atrLowerRawValue;
//
bool canSmooth = atrSmoothingMode != X_MA_MODE_NONE;
if (canSmooth)
{
//
// Check Peak ...
if (canLookupPeak)
{
//
double iPeak = peaksBuffer[barIndex];
if (iPeak != peak)
{
//
if (peak != 0 &&
peakRepeate >= minRepetition)
{
//
canLookupPeak = false;
}
else
{
//
peak = iPeak;
peakRepeate = 0;
peakFromBarIndex = 0;
peakToBarIndex = barIndex;
}
}
else if (iPeak == peak)
{
//
peakRepeate++;
peakFromBarIndex = barIndex;
}
}
// Upper ...
iMAOnBuffer(
ratesTotal,
prevCalculated,
bar_index,
atrLength,
atrUpperRawBuffer,
atrUpperBuffer,
atrSmoothingMode //
);
//
// Check Vale ...
if (canLookupVale)
{
//
double iVale = valesBuffer[barIndex];
if (iVale != vale)
{
//
if (vale != 0 &&
valeRepeate >= minRepetition)
{
canLookupVale = false;
}
else
{
//
vale = iVale;
valeRepeate = 0;
valeFromBarIndex = 0;
valeToBarIndex = barIndex;
}
}
else if (iVale == vale)
{
//
valeRepeate++;
valeFromBarIndex = barIndex;
}
}
//
canLookup = barIndex < end &&
(canLookupPeak ||
canLookupVale);
if (canLookup)
{
barIndex++;
}
}
//
if (!canLookupPeak)
{
validPeaksBuffer[bar_index] = peak;
// Lower ...
iMAOnBuffer(
ratesTotal,
prevCalculated,
bar_index,
atrLength,
atrLowerRawBuffer,
atrLowerBuffer,
atrSmoothingMode //
);
}
else
{
//
double lastValidPeak = prevCalculated == 0
? 0
: validPeaksBuffer[bar_index + 1];
//
validPeaksBuffer[bar_index] = lastValidPeak;
}
//
if (!canLookupVale)
{
validValesBuffer[bar_index] = vale;
}
else
{
//
double lastValidVale = prevCalculated == 0
? 0
: validValesBuffer[bar_index + 1];
//
validValesBuffer[bar_index] = lastValidVale;
// Use Raw Values ...
atrUpperBuffer[bar_index] = atrUpperRawValue;
atrLowerBuffer[bar_index] = atrLowerRawValue;
}
}
+21 -11
View File
@@ -13390,6 +13390,15 @@ ENUM_X_DIRECTION Opposit(ENUM_X_DIRECTION value)
//
// Moving Average ...
enum ENUM_X_MA_METHOD
{
X_MA_MODE_NONE, // None
X_MA_MODE_SMA, // SMA
X_MA_MODE_EMA, // EMA
X_MA_MODE_LWMA, // LWMA
X_MA_MODE_SMMA, // SMMA
};
/**
* Calculate Sspecified Buffer's Moving Averages ...
*
@@ -13397,7 +13406,7 @@ ENUM_X_DIRECTION Opposit(ENUM_X_DIRECTION value)
* @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 source: 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 ...
*
@@ -13408,9 +13417,9 @@ int iMAOnBuffer(
const int _prev_calculated,
const int _begin,
const int _period,
const double &_price[],
const double &_source[],
double &_buffer[],
ENUM_MA_METHOD _method = MODE_SMA //
ENUM_X_MA_METHOD _method = X_MA_MODE_SMA //
)
{
//
@@ -13421,6 +13430,7 @@ int iMAOnBuffer(
_period < 0 ||
_rates_total <= 0 ||
_prev_calculated < 0 ||
_method == X_MA_MODE_NONE ||
_prev_calculated > _rates_total)
{
return result;
@@ -13430,49 +13440,49 @@ int iMAOnBuffer(
switch (_method)
{
//
case MODE_SMA:
case X_MA_MODE_SMA:
result = SimpleMAOnBuffer(
_rates_total,
_prev_calculated,
_begin,
_period,
_price,
_source,
_buffer //
);
break;
//
case MODE_EMA:
case X_MA_MODE_EMA:
result = ExponentialMAOnBuffer(
_rates_total,
_prev_calculated,
_begin,
_period,
_price,
_source,
_buffer //
);
break;
//
case MODE_LWMA:
case X_MA_MODE_LWMA:
result = LinearWeightedMAOnBuffer(
_rates_total,
_prev_calculated,
_begin,
_period,
_price,
_source,
_buffer //
);
break;
//
case MODE_SMMA:
case X_MA_MODE_SMMA:
result = SmoothedMAOnBuffer(
_rates_total,
_prev_calculated,
_begin,
_period,
_price,
_source,
_buffer //
);
break;