last ...
This commit is contained in:
+171
-7
@@ -16,14 +16,14 @@
|
|||||||
#property copyright "Copyright 2023, SaherElm IT Center"
|
#property copyright "Copyright 2023, SaherElm IT Center"
|
||||||
#property link "https://saherelm.ir"
|
#property link "https://saherelm.ir"
|
||||||
#property version "1.00"
|
#property version "1.00"
|
||||||
#property description "SaherElm X121 XCZone Indicator"
|
#property description "SaherElm X121 XTB Indicator"
|
||||||
#property strict
|
#property strict
|
||||||
|
|
||||||
//
|
//
|
||||||
// Definitions ...
|
// Definitions ...
|
||||||
|
|
||||||
//
|
//
|
||||||
#define ShortName "X121 XCZone"
|
#define ShortName "X121 XTB"
|
||||||
|
|
||||||
//
|
//
|
||||||
// Includes Common Library ...
|
// Includes Common Library ...
|
||||||
@@ -204,6 +204,10 @@ input double rsiOBLevel = 70.0; // RSI OB Level
|
|||||||
input double rsiOSLevel = 30.0; // RSI OS Level
|
input double rsiOSLevel = 30.0; // RSI OS Level
|
||||||
input ENUM_APPLIED_PRICE rsiAppliedTo = PRICE_CLOSE; // RSI Applied To
|
input ENUM_APPLIED_PRICE rsiAppliedTo = PRICE_CLOSE; // RSI Applied To
|
||||||
input int atrLength = 14; // ATR Length
|
input int atrLength = 14; // ATR Length
|
||||||
|
input double atrMultiplier = 1.5; // ATR Band Multiplier
|
||||||
|
input ENUM_X_PRICE atrUpperPriceType = X_PRICE_HIGH; // ATR Upper Zone Applied To
|
||||||
|
input ENUM_X_PRICE atrLowerPriceType = X_PRICE_LOW; // ATR Lower Zone Applied To
|
||||||
|
input ENUM_X_MA_METHOD atrSignalMethod = X_MA_MODE_SMA; // ATR Signalling Method
|
||||||
input int barsSignalLength = 14; // Bars Signal Length
|
input int barsSignalLength = 14; // Bars Signal Length
|
||||||
input ENUM_X_MA_METHOD barsSignalMethod = X_MA_MODE_EMA; // Bars Signalling Method
|
input ENUM_X_MA_METHOD barsSignalMethod = X_MA_MODE_EMA; // Bars Signalling Method
|
||||||
input int deltaSignalLength = 14; // Delta Signal Length
|
input int deltaSignalLength = 14; // Delta Signal Length
|
||||||
@@ -228,6 +232,7 @@ input group "Filtering";
|
|||||||
input bool filterBasedOnSar = false; // Filter Based on Sar
|
input bool filterBasedOnSar = false; // Filter Based on Sar
|
||||||
input bool filterBasedOnRSI = false; // Filter Based on RSI
|
input bool filterBasedOnRSI = false; // Filter Based on RSI
|
||||||
input bool filterBasedOnADX = false; // Filter Based on ADX
|
input bool filterBasedOnADX = false; // Filter Based on ADX
|
||||||
|
input bool filterBasedOnATR = false; // Filter Based on ATR
|
||||||
input bool filterBasedOnTrend = false; // Filter Based on Trend
|
input bool filterBasedOnTrend = false; // Filter Based on Trend
|
||||||
input bool filterBasedOnDelta = false; // Filter Based on Delta
|
input bool filterBasedOnDelta = false; // Filter Based on Delta
|
||||||
input bool filterBasedOnVolume = false; // Filter Based on Volume
|
input bool filterBasedOnVolume = false; // Filter Based on Volume
|
||||||
@@ -251,14 +256,15 @@ input bool showBars = true; // Show Bars
|
|||||||
input bool showSar = false; // Show Sar
|
input bool showSar = false; // Show Sar
|
||||||
input bool showTrend = false; // Show Trend
|
input bool showTrend = false; // Show Trend
|
||||||
input bool showHKBars = false; // Show Hiken Ashi Bars
|
input bool showHKBars = false; // Show Hiken Ashi Bars
|
||||||
|
input bool showATRBand = false; // Show ATR Band
|
||||||
input bool showTrendBars = false; // Show Trend Bars
|
input bool showTrendBars = false; // Show Trend Bars
|
||||||
input bool showSignalBars = false; // Show Signal Bars
|
input bool showSignalBars = false; // Show Signal Bars
|
||||||
input bool showHKSignalBars = false; // Show Hiken Ashi Signal Bars
|
input bool showHKSignalBars = false; // Show Hiken Ashi Signal Bars
|
||||||
|
|
||||||
//
|
//
|
||||||
// Draws ...
|
// Draws ...
|
||||||
input bool drawZones = true; // Draw Detected Zones
|
input bool drawZones = false; // Draw Detected Zones
|
||||||
input bool drawSignals = true; // Draw Zone's Signal
|
input bool drawSignals = false; // Draw Zone's Signal
|
||||||
|
|
||||||
//
|
//
|
||||||
input int startCalculationForLastBars = 1000; // Calculate Last n Bars
|
input int startCalculationForLastBars = 1000; // Calculate Last n Bars
|
||||||
@@ -312,8 +318,8 @@ input ENUM_LINE_STYLE fvgStyle = STYLE_SOLID; // FVG Style
|
|||||||
#property indicator_chart_window
|
#property indicator_chart_window
|
||||||
|
|
||||||
//
|
//
|
||||||
#property indicator_buffers 32
|
#property indicator_buffers 36
|
||||||
#property indicator_plots 5
|
#property indicator_plots 7
|
||||||
|
|
||||||
//
|
//
|
||||||
// Plot Buffers ...
|
// Plot Buffers ...
|
||||||
@@ -447,10 +453,41 @@ double barHKSignalColorBuffer[];
|
|||||||
#property indicator_type5 DRAW_COLOR_CANDLES
|
#property indicator_type5 DRAW_COLOR_CANDLES
|
||||||
#property indicator_color5 CLR_NONE, clrAqua, clrMagenta
|
#property indicator_color5 CLR_NONE, clrAqua, clrMagenta
|
||||||
|
|
||||||
|
//
|
||||||
|
// ATR ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Upper ...
|
||||||
|
|
||||||
|
//
|
||||||
|
#define atrUpperBufferIndex 19
|
||||||
|
#define atrUpperBufferPlotIndex 5
|
||||||
|
double atrUpperBuffer[];
|
||||||
|
|
||||||
|
#property indicator_label6 "X121 XATRU"
|
||||||
|
#property indicator_type6 DRAW_LINE
|
||||||
|
#property indicator_color6 clrYellow
|
||||||
|
#property indicator_style6 STYLE_SOLID
|
||||||
|
#property indicator_width6 1
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lower ...
|
||||||
|
|
||||||
|
//
|
||||||
|
#define atrLowerBufferIndex 20
|
||||||
|
#define atrLowerBufferPlotIndex 6
|
||||||
|
double atrLowerBuffer[];
|
||||||
|
|
||||||
|
#property indicator_label7 "X121 XATRL"
|
||||||
|
#property indicator_type7 DRAW_LINE
|
||||||
|
#property indicator_color7 clrYellow
|
||||||
|
#property indicator_style7 STYLE_SOLID
|
||||||
|
#property indicator_width7 1
|
||||||
|
|
||||||
//
|
//
|
||||||
// Data Buffers ...
|
// Data Buffers ...
|
||||||
|
|
||||||
#define mLastBufferIndex 18
|
#define mLastBufferIndex 20
|
||||||
|
|
||||||
//
|
//
|
||||||
// TREND State ...
|
// TREND State ...
|
||||||
@@ -523,6 +560,12 @@ double bearishVolumeSignalBuffer[];
|
|||||||
#define atrBufferIndex mLastBufferIndex + 13
|
#define atrBufferIndex mLastBufferIndex + 13
|
||||||
double atrBuffer[];
|
double atrBuffer[];
|
||||||
|
|
||||||
|
#define atrUpperRawBufferIndex mLastBufferIndex + 14
|
||||||
|
double atrUpperRawBuffer[];
|
||||||
|
|
||||||
|
#define atrLowerRawBufferIndex mLastBufferIndex + 15
|
||||||
|
double atrLowerRawBuffer[];
|
||||||
|
|
||||||
//
|
//
|
||||||
// Variables, Properties and etc ...
|
// Variables, Properties and etc ...
|
||||||
|
|
||||||
@@ -933,6 +976,14 @@ int OnCalculate(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
if (prev_calculated == 0)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
string message = "History Finished ...";
|
||||||
|
Print(message);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
return rates_total;
|
return rates_total;
|
||||||
}
|
}
|
||||||
@@ -961,10 +1012,13 @@ bool ValidateInputs()
|
|||||||
rsiOBLevel > 0 &&
|
rsiOBLevel > 0 &&
|
||||||
rsiOSLevel > 0 &&
|
rsiOSLevel > 0 &&
|
||||||
sarMax > sarStep &&
|
sarMax > sarStep &&
|
||||||
|
atrMultiplier > 0 &&
|
||||||
barsSignalLength > 2 &&
|
barsSignalLength > 2 &&
|
||||||
deltaSignalLength > 2 &&
|
deltaSignalLength > 2 &&
|
||||||
hkSignalBarLength > 2 &&
|
hkSignalBarLength > 2 &&
|
||||||
volumeSignalLength > 2 &&
|
volumeSignalLength > 2 &&
|
||||||
|
IsValid(atrUpperPriceType) &&
|
||||||
|
IsValid(atrLowerPriceType) &&
|
||||||
barsSignalMethod != X_MA_MODE_NONE &&
|
barsSignalMethod != X_MA_MODE_NONE &&
|
||||||
deltaSignalMethod != X_MA_MODE_NONE &&
|
deltaSignalMethod != X_MA_MODE_NONE &&
|
||||||
hkSignalBarMethod != X_MA_MODE_NONE &&
|
hkSignalBarMethod != X_MA_MODE_NONE &&
|
||||||
@@ -1140,6 +1194,27 @@ void DefineBuffers()
|
|||||||
ArraySetAsSeries(lowHKSignalBuffer, true);
|
ArraySetAsSeries(lowHKSignalBuffer, true);
|
||||||
SetIndexBuffer(lowHKSignalBufferIndex, lowHKSignalBuffer, INDICATOR_DATA);
|
SetIndexBuffer(lowHKSignalBufferIndex, lowHKSignalBuffer, INDICATOR_DATA);
|
||||||
|
|
||||||
|
//
|
||||||
|
// ATR ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// UPPER ...
|
||||||
|
ENUM_DRAW_TYPE atrUpperDrawType = showATRBand ? DRAW_LINE : DRAW_NONE;
|
||||||
|
ArraySetAsSeries(atrUpperBuffer, true);
|
||||||
|
SetIndexBuffer(atrUpperBufferIndex, atrUpperBuffer, INDICATOR_DATA);
|
||||||
|
PlotIndexSetDouble(atrUpperBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||||
|
PlotIndexSetInteger(atrUpperBufferPlotIndex, PLOT_SHOW_DATA, showATRBand);
|
||||||
|
PlotIndexSetInteger(atrUpperBufferPlotIndex, PLOT_DRAW_TYPE, atrUpperDrawType);
|
||||||
|
|
||||||
|
//
|
||||||
|
// LOWER ...
|
||||||
|
ENUM_DRAW_TYPE atrLowerDrawType = showATRBand ? DRAW_LINE : DRAW_NONE;
|
||||||
|
ArraySetAsSeries(atrLowerBuffer, true);
|
||||||
|
SetIndexBuffer(atrLowerBufferIndex, atrLowerBuffer, INDICATOR_DATA);
|
||||||
|
PlotIndexSetDouble(atrLowerBufferPlotIndex, PLOT_EMPTY_VALUE, emptyValue);
|
||||||
|
PlotIndexSetInteger(atrLowerBufferPlotIndex, PLOT_SHOW_DATA, showATRBand);
|
||||||
|
PlotIndexSetInteger(atrLowerBufferPlotIndex, PLOT_DRAW_TYPE, atrLowerDrawType);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Data Buffers ...
|
// Data Buffers ...
|
||||||
|
|
||||||
@@ -1201,6 +1276,14 @@ void DefineBuffers()
|
|||||||
// ATR ...
|
// ATR ...
|
||||||
ArraySetAsSeries(atrBuffer, true);
|
ArraySetAsSeries(atrBuffer, true);
|
||||||
SetIndexBuffer(atrBufferIndex, atrBuffer, INDICATOR_CALCULATIONS);
|
SetIndexBuffer(atrBufferIndex, atrBuffer, INDICATOR_CALCULATIONS);
|
||||||
|
|
||||||
|
//
|
||||||
|
ArraySetAsSeries(atrUpperRawBuffer, true);
|
||||||
|
SetIndexBuffer(atrUpperRawBufferIndex, atrUpperRawBuffer, INDICATOR_CALCULATIONS);
|
||||||
|
|
||||||
|
//
|
||||||
|
ArraySetAsSeries(atrLowerRawBuffer, true);
|
||||||
|
SetIndexBuffer(atrLowerRawBufferIndex, atrLowerRawBuffer, INDICATOR_CALCULATIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1589,6 +1672,69 @@ void CalculateValues(
|
|||||||
? iHKSignalColorValue
|
? iHKSignalColorValue
|
||||||
: hideColorIDX;
|
: hideColorIDX;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Calculate ATR Band ...
|
||||||
|
double iATR = atrBuffer[bar_index];
|
||||||
|
double iAppliedATR = atrMultiplier * iATR;
|
||||||
|
double iATRUpperPrice = GetAppliedPrice(
|
||||||
|
atrUpperPriceType,
|
||||||
|
open,
|
||||||
|
high,
|
||||||
|
low,
|
||||||
|
close,
|
||||||
|
bar_index //
|
||||||
|
);
|
||||||
|
double iATRLowerPrice = GetAppliedPrice(
|
||||||
|
atrLowerPriceType,
|
||||||
|
open,
|
||||||
|
high,
|
||||||
|
low,
|
||||||
|
close,
|
||||||
|
bar_index //
|
||||||
|
);
|
||||||
|
double iATRUpper = iATRUpperPrice + iAppliedATR;
|
||||||
|
double iATRLower = iATRLowerPrice - iAppliedATR;
|
||||||
|
atrUpperRawBuffer[bar_index] = iATRUpper;
|
||||||
|
atrLowerRawBuffer[bar_index] = iATRLower;
|
||||||
|
|
||||||
|
//
|
||||||
|
bool canSignalATR = IsValid(atrSignalMethod);
|
||||||
|
if (canSignalATR)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
// Upper ...
|
||||||
|
iMAOnBuffer(
|
||||||
|
ratesTotal,
|
||||||
|
prevCalculated,
|
||||||
|
bar_index,
|
||||||
|
atrLength,
|
||||||
|
atrUpperRawBuffer,
|
||||||
|
atrUpperBuffer,
|
||||||
|
atrSignalMethod //
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// Lower ...
|
||||||
|
iMAOnBuffer(
|
||||||
|
ratesTotal,
|
||||||
|
prevCalculated,
|
||||||
|
bar_index,
|
||||||
|
atrLength,
|
||||||
|
atrLowerRawBuffer,
|
||||||
|
atrLowerBuffer,
|
||||||
|
atrSignalMethod //
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//
|
||||||
|
atrUpperBuffer[bar_index] = iATRUpper;
|
||||||
|
atrLowerBuffer[bar_index] = iATRLower;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Trigger Block ...
|
||||||
|
|
||||||
//
|
//
|
||||||
DetectTriggerBlock(
|
DetectTriggerBlock(
|
||||||
bar_index,
|
bar_index,
|
||||||
@@ -2113,6 +2259,24 @@ void DetectTriggerBlock(
|
|||||||
: isHKSignalBarSwitchedToBearish);
|
: isHKSignalBarSwitchedToBearish);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// ATR ...
|
||||||
|
if (has &&
|
||||||
|
filterBasedOnATR)
|
||||||
|
{
|
||||||
|
//
|
||||||
|
fromIDX = tb.FromIndex();
|
||||||
|
double iATRUpper = atrUpperBuffer[fromIDX];
|
||||||
|
double iATRLower = atrLowerBuffer[fromIDX];
|
||||||
|
|
||||||
|
//
|
||||||
|
has =
|
||||||
|
has &&
|
||||||
|
(isBullish
|
||||||
|
? tb.trigger.lower < iATRLower
|
||||||
|
: tb.trigger.upper > iATRUpper);
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// SAR ...
|
// SAR ...
|
||||||
if (has &&
|
if (has &&
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
///////////////////////////////////////////////////////
|
||||||
|
//
|
||||||
|
// SaherElm IT Center MQL5 Helper Class Library
|
||||||
|
// ----------------------------------------------
|
||||||
|
// Name: XCX121XCTBHelper
|
||||||
|
// Description: provides all Indicator
|
||||||
|
// Helper requirements ...
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
|
||||||
|
//
|
||||||
|
// Imports ...
|
||||||
|
#include "../Classes/x-saherelm.x-helper.class.mq5"
|
||||||
|
|
||||||
|
//
|
||||||
|
// Definitions ...
|
||||||
|
|
||||||
|
//
|
||||||
|
// Buffers ...
|
||||||
|
enum ENUM_X121_XTB_BUFFERS
|
||||||
|
{
|
||||||
|
X121_XTB_TREND_LINE = 0,
|
||||||
|
X121_XTB_SAR_LINE = 2,
|
||||||
|
X121_XTB_SBAR_O_LINE = 4,
|
||||||
|
X121_XTB_SBAR_H_LINE = 5,
|
||||||
|
X121_XTB_SBAR_L_LINE = 6,
|
||||||
|
X121_XTB_SBAR_C_LINE = 7,
|
||||||
|
X121_XTB_HK_BAR_O_LINE = 9,
|
||||||
|
X121_XTB_HK_BAR_H_LINE = 10,
|
||||||
|
X121_XTB_HK_BAR_L_LINE = 11,
|
||||||
|
X121_XTB_HK_BAR_C_LINE = 12,
|
||||||
|
X121_XTB_HK_SBAR_O_LINE = 14,
|
||||||
|
X121_XTB_HK_SBAR_H_LINE = 15,
|
||||||
|
X121_XTB_HK_SBAR_L_LINE = 16,
|
||||||
|
X121_XTB_HK_SBAR_C_LINE = 17,
|
||||||
|
X121_XTB_ATR_BAND_UPPER_LINE = 19,
|
||||||
|
X121_XTB_ATR_BAND_LOWER_LINE = 20,
|
||||||
|
X121_XTB_TREND_STATE_LINE = 21,
|
||||||
|
X121_XTB_SAR_STATE_LINE = 22,
|
||||||
|
X121_XTB_RSI_LINE = 23,
|
||||||
|
X121_XTB_ADX_LINE = 24,
|
||||||
|
X121_XTB_ADXP_LINE = 25,
|
||||||
|
X121_XTB_ADXN_LINE = 26,
|
||||||
|
X121_XTB_DELTA_LINE = 27,
|
||||||
|
X121_XTB_DELTA_SIGNAL_LINE = 28,
|
||||||
|
X121_XTB_VOLUME_BULLISH_LINE = 29,
|
||||||
|
X121_XTB_VOLUME_BEARISH_LINE = 30,
|
||||||
|
X121_XTB_VOLUME_VOLUME_BULLISH_SIGNAL_LINE = 31,
|
||||||
|
X121_XTB_VOLUME_VOLUME_BEARISH_SIGNAL_LINE = 32,
|
||||||
|
X121_XTB_ATR_LINE = 33,
|
||||||
|
X121_XTB_ATR_BAND_RAW_UPPER_LINE = 34,
|
||||||
|
X121_XTB_ATR_BAND_RAW_LOWER_LINE = 35,
|
||||||
|
};
|
||||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user