last works on xom1 ea ...

This commit is contained in:
2025-09-07 18:48:24 +03:30
parent 19497ba6ef
commit 5987194e51
7 changed files with 4771 additions and 749 deletions
+179 -93
View File
@@ -65,19 +65,21 @@ input ENUM_SERIESMODE lowerMode = MODE_LOW; // Vale Method
//
// Others ...
input ENUM_X_FIBO_LEVELS upperZoneLevel = X_FIBO_LEVEL_618; // Upper Zone Level
input ENUM_X_FIBO_LEVELS lowerZoneLevel = X_FIBO_LEVEL_764; // Lower Zone Level
input ENUM_X_FIBO_LEVELS lowerZoneLevel = X_FIBO_LEVEL_382; // Lower Zone Level
input double sarStep = 0.02; // SAR Step
input double sarMax = 0.2; // SAR Maximum
input ENUM_MA_METHOD maMethod = MODE_EMA; // MA Method
input ENUM_APPLIED_PRICE maAppliedTo = PRICE_CLOSE; // MA Applied To
input int maLength = 10; // MA Length
input int maFastLength = 7; // Fast MA Length
input int maSlowLength = 20; // Slow MA Length
//
// Presentation ...
input group "Presentation";
input bool showPV = true; // Show PV
input bool showMA = true; // Show MA
input bool showSAR = true; // Show Sar
input bool showMAFast = true; // Show MA Fast
input bool showMASlow = true; // Show MA Slow
input bool showFiboZone = true; // Show Fibo Zone
//
@@ -112,122 +114,144 @@ input int valeArrowCode = 159; // Vales Arrow Code
#property indicator_chart_window
//
#property indicator_buffers 18
#property indicator_plots 6
#property indicator_buffers 21
#property indicator_plots 7
//
// Plot Buffers ...
//
// MA ...
// Fast MA ...
//
#define maBufferIndex 0
#define maBufferPlotIndex 0
double maBuffer[];
#define maFastBufferIndex 0
#define maFastBufferPlotIndex 0
double maFastBuffer[];
//
#define maColorBufferIndex 1
double maColorBuffer[];
#define maFastColorBufferIndex 1
double maFastColorBuffer[];
//
#property indicator_label1 "MA"
#property indicator_label1 "FastMA"
#property indicator_type1 DRAW_COLOR_LINE
#property indicator_color1 CLR_NONE, clrLime, clrRed, clrGray
#property indicator_color1 CLR_NONE, clrYellow, clrOrangeRed, clrGray
#property indicator_width1 2
//
// Slow MA ...
//
#define maSlowBufferIndex 2
#define maSlowBufferPlotIndex 1
double maSlowBuffer[];
//
#define maSlowColorBufferIndex 3
double maSlowColorBuffer[];
//
#property indicator_label2 "SlowMA"
#property indicator_type2 DRAW_COLOR_LINE
#property indicator_color2 CLR_NONE, clrLime, clrRed, clrGray
#property indicator_width2 2
//
// SAR ...
//
#define sarBufferIndex 2
#define sarBufferPlotIndex 1
#define sarBufferIndex 4
#define sarBufferPlotIndex 2
double sarBuffer[];
//
#define sarColorBufferIndex 3
#define sarColorBufferIndex 5
double sarColorBuffer[];
//
#property indicator_label2 "SAR"
#property indicator_type2 DRAW_COLOR_ARROW
#property indicator_color2 CLR_NONE, clrLime, clrRed, clrGray
#property indicator_width2 2
#property indicator_label3 "SAR"
#property indicator_type3 DRAW_COLOR_ARROW
#property indicator_color3 CLR_NONE, clrLime, clrRed, clrGray
#property indicator_width3 2
//
// PEAKS ...
//
#define peakBufferIndex 4
#define peakBufferPlotIndex 2
#define peakBufferIndex 6
#define peakBufferPlotIndex 3
double peakBuffer[];
//
#property indicator_label3 "PEAK"
#property indicator_type3 DRAW_ARROW
#property indicator_color3 clrMagenta
#property indicator_width3 3
#property indicator_label4 "PEAK"
#property indicator_type4 DRAW_ARROW
#property indicator_color4 clrMagenta
#property indicator_width4 3
//
// VALES ...
//
#define valeBufferIndex 5
#define valeBufferPlotIndex 3
#define valeBufferIndex 7
#define valeBufferPlotIndex 4
double valeBuffer[];
//
#property indicator_label4 "VALE"
#property indicator_type4 DRAW_ARROW
#property indicator_color4 clrAqua
#property indicator_width4 3
#property indicator_label5 "VALE"
#property indicator_type5 DRAW_ARROW
#property indicator_color5 clrAqua
#property indicator_width5 3
//
// FIBO Upper ...
//
#define fiboUpperBufferIndex 6
#define fiboUpperBufferPlotIndex 4
#define fiboUpperBufferIndex 8
#define fiboUpperBufferPlotIndex 5
double fiboUpperBuffer[];
//
#property indicator_label5 "FIBUP"
#property indicator_type5 DRAW_LINE
#property indicator_color5 clrAqua
#property indicator_width5 2
#property indicator_label6 "FIBUP"
#property indicator_type6 DRAW_LINE
#property indicator_color6 clrAqua
#property indicator_width6 2
//
// FIBO Lower ...
//
#define fiboLowerBufferIndex 7
#define fiboLowerBufferPlotIndex 5
#define fiboLowerBufferIndex 9
#define fiboLowerBufferPlotIndex 6
double fiboLowerBuffer[];
//
#property indicator_label6 "FIBLO"
#property indicator_type6 DRAW_LINE
#property indicator_color6 clrMagenta
#property indicator_width6 2
#property indicator_label7 "FIBLO"
#property indicator_type7 DRAW_LINE
#property indicator_color7 clrMagenta
#property indicator_width7 2
//
// Data Buffers ...
//
#define mLastBufferIndex 7
#define mLastBufferIndex 9
//
// MA ...
//
#define maStateBufferIndex mLastBufferIndex + 1
double maStateBuffer[];
#define maFastStateBufferIndex mLastBufferIndex + 1
double maFastStateBuffer[];
//
#define maSlowStateBufferIndex mLastBufferIndex + 2
double maSlowStateBuffer[];
//
// SAR ...
//
#define sarStateBufferIndex mLastBufferIndex + 2
#define sarStateBufferIndex mLastBufferIndex + 3
double sarStateBuffer[];
//
@@ -237,44 +261,44 @@ double sarStateBuffer[];
// SC ...
//
#define sHHBufferIndex mLastBufferIndex + 3
#define sHHBufferIndex mLastBufferIndex + 4
double sHHBuffer[];
//
#define sLLBufferIndex mLastBufferIndex + 4
#define sLLBufferIndex mLastBufferIndex + 5
double sLLBuffer[];
//
// MC ...
//
#define mHHBufferIndex mLastBufferIndex + 5
#define mHHBufferIndex mLastBufferIndex + 6
double mHHBuffer[];
//
#define mLLBufferIndex mLastBufferIndex + 6
#define mLLBufferIndex mLastBufferIndex + 7
double mLLBuffer[];
//
// LC ...
//
#define lHHBufferIndex mLastBufferIndex + 7
#define lHHBufferIndex mLastBufferIndex + 8
double lHHBuffer[];
//
#define lLLBufferIndex mLastBufferIndex + 8
#define lLLBufferIndex mLastBufferIndex + 9
double lLLBuffer[];
//
// HC ...
//
#define hHHBufferIndex mLastBufferIndex + 9
#define hHHBufferIndex mLastBufferIndex + 10
double hHHBuffer[];
//
#define hLLBufferIndex mLastBufferIndex + 10
#define hLLBufferIndex mLastBufferIndex + 11
double hLLBuffer[];
//
@@ -301,8 +325,9 @@ int mHCLength = 0;
ENUM_TIMEFRAMES mHCPeriod = NULL;
//
int maHandler = INVALID_HANDLE;
int sarHandler = INVALID_HANDLE;
int maFastHandler = INVALID_HANDLE;
int maSlowHandler = INVALID_HANDLE;
//
int limit;
@@ -404,8 +429,9 @@ void OnDeinit(const int reason)
//
// De Initialize all Handlers and etc ...
IndicatorRelease(maHandler);
IndicatorRelease(sarHandler);
IndicatorRelease(maFastHandler);
IndicatorRelease(maSlowHandler);
}
/**
@@ -453,7 +479,8 @@ int OnCalculate(
//
// MA ...
int maCalculatedBars = BarsCalculated(maHandler);
int maFastCalculatedBars = BarsCalculated(maFastHandler);
int maSlowCalculatedBars = BarsCalculated(maSlowHandler);
//
// SAR ...
@@ -463,7 +490,8 @@ int OnCalculate(
bool isPassedRequiredCalculatedBars =
//
// MA ...
maCalculatedBars >= maxLength &&
maFastCalculatedBars >= maxLength &&
maSlowCalculatedBars >= maxLength &&
//
// SAR ...
sarCalculatedBars >= maxLength
@@ -484,7 +512,8 @@ int OnCalculate(
//
// MA ...
int copiedMAs = CopyBuffer(maHandler, MAIN_LINE, 0, limit, maBuffer);
int copiedMAFasts = CopyBuffer(maFastHandler, MAIN_LINE, 0, limit, maFastBuffer);
int copiedMASlows = CopyBuffer(maSlowHandler, MAIN_LINE, 0, limit, maSlowBuffer);
//
// SAR ...
@@ -495,7 +524,8 @@ int OnCalculate(
bool isPassedRequiredCopiedItems =
//
// MA ...
copiedMAs >= limit &&
copiedMAFasts >= limit &&
copiedMASlows >= limit &&
//
// SAR ...
copiedSARs >= limit
@@ -555,7 +585,9 @@ bool ValidateInputs()
result =
//
// MA ...
maLength >= 2 &&
maFastLength >= 2 &&
maSlowLength >= 2 &&
maSlowLength > maFastLength &&
//
// SAR ...
sarMax > 0 &&
@@ -588,7 +620,8 @@ int ExtractMaxLengthOfInputs()
result = MathMax(mSCLength, mMCLength);
result = MathMax(result, mLCLength);
result = MathMax(result, mHCLength);
result = MathMax(result, maLength);
result = MathMax(result, maFastLength);
result = MathMax(result, maSlowLength);
//
return result;
@@ -600,23 +633,42 @@ int ExtractMaxLengthOfInputs()
void DefineBuffers()
{
//
// MA ...
// Fast MA ...
//
ArraySetAsSeries(maBuffer, true);
SetIndexBuffer(maBufferIndex, maBuffer, INDICATOR_DATA);
ArraySetAsSeries(maFastBuffer, true);
SetIndexBuffer(maFastBufferIndex, maFastBuffer, INDICATOR_DATA);
//
PlotIndexSetInteger(maBufferPlotIndex, PLOT_SHOW_DATA, showMA);
PlotIndexSetDouble(maBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
PlotIndexSetInteger(maFastBufferPlotIndex, PLOT_SHOW_DATA, showMAFast);
PlotIndexSetDouble(maFastBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
//
ArraySetAsSeries(maColorBuffer, true);
SetIndexBuffer(maColorBufferIndex, maColorBuffer, INDICATOR_COLOR_INDEX);
ArraySetAsSeries(maFastColorBuffer, true);
SetIndexBuffer(maFastColorBufferIndex, maFastColorBuffer, INDICATOR_COLOR_INDEX);
//
ArraySetAsSeries(maStateBuffer, true);
SetIndexBuffer(maStateBufferIndex, maStateBuffer, INDICATOR_CALCULATIONS);
ArraySetAsSeries(maFastStateBuffer, true);
SetIndexBuffer(maFastStateBufferIndex, maFastStateBuffer, INDICATOR_CALCULATIONS);
//
// Slow MA ...
//
ArraySetAsSeries(maSlowBuffer, true);
SetIndexBuffer(maSlowBufferIndex, maSlowBuffer, INDICATOR_DATA);
//
PlotIndexSetInteger(maSlowBufferPlotIndex, PLOT_SHOW_DATA, showMASlow);
PlotIndexSetDouble(maSlowBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
//
ArraySetAsSeries(maSlowColorBuffer, true);
SetIndexBuffer(maSlowColorBufferIndex, maSlowColorBuffer, INDICATOR_COLOR_INDEX);
//
ArraySetAsSeries(maSlowStateBuffer, true);
SetIndexBuffer(maSlowStateBufferIndex, maSlowStateBuffer, INDICATOR_CALCULATIONS);
//
// SAR ...
@@ -879,16 +931,32 @@ bool InitRequirements()
// Handlers ...
//
// MA ...
maHandler = iMA(
// Fast MA ...
maFastHandler = iMA(
_Symbol,
_Period,
maLength,
maFastLength,
0,
maMethod,
maAppliedTo //
);
result = maHandler != INVALID_HANDLE;
result = maFastHandler != INVALID_HANDLE;
if (!result)
{
return result;
}
//
// Slow MA ...
maSlowHandler = iMA(
_Symbol,
_Period,
maSlowLength,
0,
maMethod,
maAppliedTo //
);
result = maSlowHandler != INVALID_HANDLE;
if (!result)
{
return result;
@@ -1053,22 +1121,40 @@ void CalculateValues(
);
//
// MA ...
double iMa = maBuffer[barIndex];
double maState = close[barIndex] > iMa
? bullishState
: close[barIndex] < iMa
? bearishState
: neuturalState;
double maColor = close[barIndex] > iMa
? bullishColorIDX
: close[barIndex] < iMa
? bearishColorIDX
: neuturalColorIDX;
maStateBuffer[barIndex] = maState;
maColorBuffer[barIndex] = showMA
? maColor
: hideColorIDX;
// Fast MA ...
double iFastMa = maFastBuffer[barIndex];
double maFastState = close[barIndex] > iFastMa
? bullishState
: close[barIndex] < iFastMa
? bearishState
: neuturalState;
double maFastColor = close[barIndex] > iFastMa
? bullishColorIDX
: close[barIndex] < iFastMa
? bearishColorIDX
: neuturalColorIDX;
maFastStateBuffer[barIndex] = maFastState;
maFastColorBuffer[barIndex] = showMAFast
? maFastColor
: hideColorIDX;
//
// Slow MA ...
double iSlowMa = maSlowBuffer[barIndex];
double maSlowState = close[barIndex] > iSlowMa
? bullishState
: close[barIndex] < iSlowMa
? bearishState
: neuturalState;
double maSlowColor = close[barIndex] > iSlowMa
? bullishColorIDX
: close[barIndex] < iSlowMa
? bearishColorIDX
: neuturalColorIDX;
maSlowStateBuffer[barIndex] = maSlowState;
maSlowColorBuffer[barIndex] = showMASlow
? maSlowColor
: hideColorIDX;
//
// SAR ...