try to remove matd and put XMC instead it for controllingbehaviour ...

This commit is contained in:
2024-06-21 16:52:05 +03:30
parent fdf5442255
commit 238941960a
7 changed files with 768 additions and 126 deletions
+77 -40
View File
@@ -38,27 +38,33 @@
//
input group "Fast";
input int fastMaLength = 9; // Length
input int fastMaLength = 21; // Length
input int fastMaShift = 0; // Shift
input ENUM_MA_METHOD fastMaMethod = MODE_EMA; // Method
input ENUM_APPLIED_PRICE fastMaAppliedTo = PRICE_CLOSE; // Applied To
//
input group "Slow";
input int slowMaLength = 18; // Length
input int slowMaLength = 50; // Length
input int slowMaShift = 0; // Shift
input ENUM_MA_METHOD slowMaMethod = MODE_EMA; // Method
input ENUM_APPLIED_PRICE slowMaAppliedTo = PRICE_CLOSE; // Applied To
//
input group "Verifier";
input int verifierMaLength = 50; // Length
input int verifierMaLength = 200; // Length
input int verifierMaShift = 0; // Shift
input ENUM_MA_METHOD verifierMaMethod = MODE_EMA; // Method
input ENUM_APPLIED_PRICE verifierMaAppliedTo = PRICE_CLOSE; // Applied To
//
input group "PSar";
input double sarStep = 0.02; // Step
input double sarMaximum = 0.2; // Maximum
//
input group "Presentation";
input bool showSar = true; // Show Sar
input bool showFastMa = true; // Show Fast
input bool showSlowMa = true; // Show Slow
input bool showVerifierMa = true; // Show Verifier
@@ -85,8 +91,8 @@ input bool showVerifierMa = true; // Show Verifier
#property indicator_chart_window
//
#property indicator_buffers 3
#property indicator_plots 3
#property indicator_buffers 4
#property indicator_plots 4
//
// PLOTTED Buffers ...
@@ -130,6 +136,17 @@ double verifierMaBuffer[];
#property indicator_style3 STYLE_SOLID
#property indicator_width3 2
//
// SAR ...
#define sarBufferIndex 3
double sarBuffer[];
//
#property indicator_label4 "XMC SAR"
#property indicator_type4 DRAW_ARROW
#property indicator_color4 clrDarkGreen
#property indicator_width4 2
//
// END Buffers ...
//
@@ -142,6 +159,7 @@ double verifierMaBuffer[];
int maxLength;
//
int sarHandler = INVALID_HANDLE;
int fastMaHandler = INVALID_HANDLE;
int slowMaHandler = INVALID_HANDLE;
int verifierMaHandler = INVALID_HANDLE;
@@ -180,6 +198,19 @@ int OnInit()
// Set Indicator ShortName ...
SetIndicatorName();
//
// SAR Initializer ...
sarHandler = iSAR(
_Symbol,
_Period,
sarStep,
sarMaximum //
);
if (sarHandler == INVALID_HANDLE)
{
return INIT_FAILED;
}
//
// MA Initialization ...
@@ -248,6 +279,7 @@ void OnDeinit(const int reason)
//
// Here we can handle De Initialization Reasons ...
IndicatorRelease(sarHandler);
IndicatorRelease(fastMaHandler);
IndicatorRelease(slowMaHandler);
IndicatorRelease(verifierMaHandler);
@@ -258,36 +290,17 @@ void OnDeinit(const int reason)
//
// Calculating what we want ...
int OnCalculate(
//
// total Candles on chart ...
const int rates_total,
//
// total calculated Candles on charts ...
const int prev_calculated,
//
// history of Candles Open Time ...
const datetime &time[],
//
// history of Candles Open Price ...
const double &open[],
//
// history of Candles High Price ...
const double &high[],
//
// history of Candles Low Price ...
const double &low[],
//
// history of Candles Close Price ...
const double &close[],
//
// history of Tick Volumes on Candle ...
const long &tick_volume[],
//
// history of Trade Volumes ...
const long &volume[],
//
// history of Candles Spread Price ...
const int &spread[])
const int rates_total, // Total Bars on Chart ...
const int prev_calculated, // Total Calculated Bars on Charts ...
const datetime &time[], // History of Open Time ...
const double &open[], // History of Open Price ...
const double &high[], // History of High Price ...
const double &low[], // History of Low Price ...
const double &close[], // History of Close Price ...
const long &tick_volume[], // History of Tick Volumes on Bar ...
const long &volume[], // History of Trade Volumes ...
const int &spread[] // History of Spread Price ...
)
{
//
// Prepare Buffers ...
@@ -306,10 +319,12 @@ int OnCalculate(
//
// Check Calculated Bars ...
int sarCalculatedBars = BarsCalculated(sarHandler);
int fastMaCalculatedBars = BarsCalculated(fastMaHandler);
int slowMaCalculatedBars = BarsCalculated(slowMaHandler);
int verifierMaCalculatedBars = BarsCalculated(verifierMaHandler);
if (fastMaCalculatedBars < maxLength ||
if (sarCalculatedBars < maxLength ||
fastMaCalculatedBars < maxLength ||
slowMaCalculatedBars < maxLength ||
verifierMaCalculatedBars < maxLength)
{
@@ -321,10 +336,12 @@ int OnCalculate(
//
// Buffers Copy ...
int copiedSars = CopyBuffer(sarHandler, 0, 0, limit, sarBuffer);
int copiedFastMas = CopyBuffer(fastMaHandler, 0, 0, limit, fastMaBuffer);
int copiedSlowMas = CopyBuffer(slowMaHandler, 0, 0, limit, slowMaBuffer);
int copiedVerifierMas = CopyBuffer(verifierMaHandler, 0, 0, limit, verifierMaBuffer);
if (copiedFastMas <= 0 ||
if (copiedSars <= 0 ||
copiedFastMas <= 0 ||
copiedSlowMas <= 0 ||
copiedVerifierMas <= 0)
{
@@ -362,6 +379,11 @@ bool ValidateInputs()
slowMaLength > fastMaLength &&
verifierMaLength > slowMaLength)
//
&&
//
(sarStep > 0 &&
sarMaximum > sarStep)
//
;
//
@@ -390,6 +412,21 @@ int ExtractMaxLengthOfInputs()
// Define Indexes and Styles ...
void DefineBuffers()
{
//
// SAR ...
ENUM_DRAW_TYPE sarDrawType = showSar ? DRAW_ARROW : DRAW_NONE;
//
// PEAKS ...
ArraySetAsSeries(sarBuffer, true);
SetIndexBuffer(sarBufferIndex, sarBuffer, INDICATOR_DATA);
PlotIndexSetInteger(sarBufferIndex, PLOT_ARROW, 225);
PlotIndexSetDouble(sarBufferIndex, PLOT_EMPTY_VALUE, 0);
//
PlotIndexSetInteger(sarBufferIndex, PLOT_SHOW_DATA, showSar);
PlotIndexSetInteger(sarBufferIndex, PLOT_DRAW_TYPE, sarDrawType);
//
// MA ...
@@ -399,7 +436,7 @@ void DefineBuffers()
ArraySetAsSeries(fastMaBuffer, true);
SetIndexBuffer(fastMaBufferIndex, fastMaBuffer, INDICATOR_DATA);
PlotIndexSetInteger(fastMaBufferIndex, PLOT_DRAW_BEGIN, maxLength);
PlotIndexSetInteger(fastMaBufferIndex, PLOT_SHOW_DATA, false);
PlotIndexSetInteger(fastMaBufferIndex, PLOT_SHOW_DATA, showFastMa);
PlotIndexSetInteger(fastMaBufferIndex, PLOT_DRAW_TYPE, fastMaDrawType);
//
@@ -408,7 +445,7 @@ void DefineBuffers()
ArraySetAsSeries(slowMaBuffer, true);
SetIndexBuffer(slowMaBufferIndex, slowMaBuffer, INDICATOR_DATA);
PlotIndexSetInteger(slowMaBufferIndex, PLOT_DRAW_BEGIN, maxLength);
PlotIndexSetInteger(slowMaBufferIndex, PLOT_SHOW_DATA, false);
PlotIndexSetInteger(slowMaBufferIndex, PLOT_SHOW_DATA, showSlowMa);
PlotIndexSetInteger(slowMaBufferIndex, PLOT_DRAW_TYPE, slowMaDrawType);
//
@@ -417,7 +454,7 @@ void DefineBuffers()
ArraySetAsSeries(verifierMaBuffer, true);
SetIndexBuffer(verifierMaBufferIndex, verifierMaBuffer, INDICATOR_DATA);
PlotIndexSetInteger(verifierMaBufferIndex, PLOT_DRAW_BEGIN, maxLength);
PlotIndexSetInteger(verifierMaBufferIndex, PLOT_SHOW_DATA, false);
PlotIndexSetInteger(verifierMaBufferIndex, PLOT_SHOW_DATA, showVerifierMa);
PlotIndexSetInteger(verifierMaBufferIndex, PLOT_DRAW_TYPE, verifierMaDrawType);
}