diff --git a/Documents/x-saherelm.xhk.helper.mq5 b/Documents/x-saherelm.xzg.helper.mq5 similarity index 90% rename from Documents/x-saherelm.xhk.helper.mq5 rename to Documents/x-saherelm.xzg.helper.mq5 index aad34a49..5912db3c 100644 --- a/Documents/x-saherelm.xhk.helper.mq5 +++ b/Documents/x-saherelm.xzg.helper.mq5 @@ -2,7 +2,7 @@ // // SaherElm IT Center MQL5 Helper Class Library // ---------------------------------------------- -// Name: XSCXSSLCHelper +// Name: XSCXZGHelper // Description: provides all Indicator // Helper requirements ... // @@ -28,21 +28,21 @@ // Definitions ... // -enum ENUM_XSSLC_BUFFERS +enum ENUM_XZG_BUFFERS { - XSSLC_MAIN_LINE = 0 + XZG_MAIN_LINE = 0 }; // // Input Models ... -struct XSSLCInputs +struct XZGInputs { // // Props ... // // Constructor(s) ... - XSSLCInputs() + XZGInputs() { // Clean(); @@ -100,7 +100,7 @@ struct XSSLCInputs // // Class ... -class XSCXSSLCHelper : public XSCBaseHelper +class XSCXZGHelper : public XSCBaseHelper { // // Public ... @@ -110,20 +110,20 @@ public: // // Constructors ... - XSCXSSLCHelper() : XSCBaseHelper(_Symbol, _Period) + XSCXZGHelper() : XSCBaseHelper(_Symbol, _Period) { } // // Deconstructor ... - ~XSCXSSLCHelper() {} + ~XSCXZGHelper() {} // // Tools ... bool Init( string symbol, // Trading Symbol ENUM_TIMEFRAMES period, // Trading Period - XSSLCInputs &inputs // Inputs + XZGInputs &inputs // Inputs ) { // @@ -167,14 +167,14 @@ public: // Inputs ... // - XSSLCInputs GetInputs() + XZGInputs GetInputs() { return mInputs; } // bool SetInputs( - XSSLCInputs &inputs // Configs + XZGInputs &inputs // Configs ) { // @@ -247,7 +247,7 @@ protected: private: // // Props ... - XSSLCInputs mInputs; // Inputs ... + XZGInputs mInputs; // Inputs ... // // Buffers ... @@ -267,7 +267,7 @@ private: // // Main Buffer ... // CopyBuffer( // mHandler, - // XSSLC_MAIN_LINE, + // XZG_MAIN_LINE, // 0, // totalBars, // mainBuffer diff --git a/Helpers/x-saherelm.xche.helper.mq5 b/Helpers/x-saherelm.xche.helper.mq5 new file mode 100644 index 00000000..268fc298 --- /dev/null +++ b/Helpers/x-saherelm.xche.helper.mq5 @@ -0,0 +1,514 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 Helper Class Library +// ---------------------------------------------- +// Name: XSCXCHEHelper +// 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 + +// +#include "../Classes/x-saherelm.xhelper.class.mq5" + +// +// Definitions ... + +// +enum ENUM_XCHE_BUFFERS +{ + X_CHE_LONG_EXIT_1_LINE = 0, + X_CHE_SHORT_EXIT_1_LINE = 1, + X_CHE_LONG_EXIT_2_LINE = 2, + X_CHE_SHORT_EXIT_2_LINE = 3, +}; + +// +// Input Models ... +struct XCHEInputs +{ + // + // Props ... + + // + // Market ... + int length; // Length + int loopback; // Loopback + double multiplier1; // 1st Multiplier + double multiplier2; // 2nd Multiplier + + // + // Calculation ... + ENUM_APPLIED_PRICE upAppliedTo; // Up Zone Applied To + ENUM_APPLIED_PRICE downAppliedTo; // Down Zone Applied To + + // + // Presentation ... + bool showLongExit1Line; // Show 1st Long Exit + bool showShortExit1Line; // Show 1st Short Exit + bool showLongExit2Line; // Show 2st Long Exit + bool showShortExit2Line; // Show 2st Short Exit + + // + // Constructor(s) ... + XCHEInputs() + { + // + Clean(); + } + + // + // Tools ... + + // + // Clean ... + void Clean() + { + // + length = 0; + loopback = 0; + multiplier1 = 0; + multiplier2 = 0; + + // + upAppliedTo = PRICE_HIGH; + downAppliedTo = PRICE_LOW; + + // + showLongExit1Line = false; + showShortExit1Line = false; + showLongExit2Line = false; + showShortExit2Line = false; + } + + // + // Default ... + void Default() + { + // + length = 35; + loopback = 26; + multiplier1 = 3.0; + multiplier2 = 3.5; + + // + upAppliedTo = PRICE_HIGH; + downAppliedTo = PRICE_LOW; + + // + showLongExit1Line = true; + showShortExit1Line = true; + showLongExit2Line = true; + showShortExit2Line = true; + } + + // + // Validate ... + bool IsValid() + { + // + bool result = false; + + // + result = + // + length > 0 && + loopback < length && + multiplier1 > 0 && + multiplier2 > multiplier1 + // + ; + + // + return result; + } + + // + // Retrieve MAx Length ... + int Max() + { + // + int result = 0; + + // + result = MathMax(length, loopback); + + // + return result; + } +}; + +// +// Class ... +class XSCXCHEHelper : public XSCBaseHelper +{ + // + // Public ... +public: + // + // Props ... + + // + // Constructors ... + XSCXCHEHelper() : XSCBaseHelper(_Symbol, _Period) + { + } + + // + // Deconstructor ... + ~XSCXCHEHelper() {} + + // + // Tools ... + bool Init( + string symbol, // Trading Symbol + ENUM_TIMEFRAMES period, // Trading Period + XCHEInputs &inputs // Inputs + ) + { + // + bool result = false; + + // + mSymbol = symbol; + mPeriod = period; + + // + result = inputs.IsValid(); + if (!result) + { + return result; + } + + // + mInputs = inputs; + + // + ArraySetAsSeries(longExit1Buffer, true); + ArraySetAsSeries(longExit2Buffer, true); + ArraySetAsSeries(shortExit1Buffer, true); + ArraySetAsSeries(shortExit2Buffer, true); + + // + mHandler = iCustom( + mSymbol, + mPeriod, + "x-saherelm.xche", + // + // Inputs ... + // + // Market ... + "", + mInputs.length, + mInputs.loopback, + mInputs.multiplier1, + mInputs.multiplier2, + // + // Calculations ... + "", + mInputs.upAppliedTo, + mInputs.downAppliedTo, + // + // Presentation ... + "", + mInputs.showLongExit1Line, // Show 1st Long Exit, + mInputs.showShortExit1Line, // Show 1st Short Exit, + mInputs.showLongExit2Line, // Show 2st Long Exit, + mInputs.showShortExit2Line // Show 2st Short Exit + // + ); + result = mHandler != INVALID_HANDLE; + if (!result) + { + return result; + } + + // + return result; + } + + // + // Inputs ... + + // + XCHEInputs GetInputs() + { + return mInputs; + } + + // + bool SetInputs( + XCHEInputs &inputs // Configs + ) + { + // + return Init( + mSymbol, + mPeriod, + inputs); + } + + // + // Buffers ... + + // + double GetLongExit1( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return longExit1Buffer[barIndex]; + } + + // + // Copy Required Long Exits 1 ... + int CopyLongExit1( + 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, + longExit1Buffer, + buffer, + forceClean + // + ); + } + + // + double GetLongExit2( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return longExit2Buffer[barIndex]; + } + + // + // Copy Required Long Exits 2 ... + int CopyLongExit2( + 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, + longExit2Buffer, + buffer, + forceClean + // + ); + } + + // + double GetShortExit1( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return shortExit1Buffer[barIndex]; + } + + // + // Copy Required Short Exits 1 ... + int CopyShortExit1( + 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, + shortExit1Buffer, + buffer, + forceClean + // + ); + } + + // + double GetShortExit2( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return shortExit2Buffer[barIndex]; + } + + // + // Copy Required Short Exits 2 ... + int CopyShortExit2( + 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, + shortExit2Buffer, + buffer, + forceClean + // + ); + } + + // + // Protected ... +protected: + // + // Private ... +private: + // + // Props ... + XCHEInputs mInputs; // Inputs ... + + // + // Buffers ... + // + double longExit1Buffer[]; + double longExit2Buffer[]; + double shortExit1Buffer[]; + double shortExit2Buffer[]; + + // + // Tools ... + + // + // Calculate Values Until Now ... + void Calculate() + { + // + int totalBars = CountBars(); + int calculatedBars = CountCalculatedBars(); + + // + // Long Exit 1 ... + CopyBuffer( + mHandler, + X_CHE_LONG_EXIT_1_LINE, + 0, + totalBars, + longExit1Buffer + // + ); + + // + // Long Exit 2 ... + CopyBuffer( + mHandler, + X_CHE_LONG_EXIT_2_LINE, + 0, + totalBars, + longExit2Buffer + // + ); + + // + // Short Exit 1 ... + CopyBuffer( + mHandler, + X_CHE_SHORT_EXIT_1_LINE, + 0, + totalBars, + shortExit1Buffer + // + ); + + // + // Short Exit 2 ... + CopyBuffer( + mHandler, + X_CHE_SHORT_EXIT_2_LINE, + 0, + totalBars, + shortExit2Buffer + // + ); + } +}; + +// +// Tools ... diff --git a/Helpers/x-saherelm.xct.helper.mq5 b/Helpers/x-saherelm.xct.helper.mq5 new file mode 100644 index 00000000..b5030ab5 --- /dev/null +++ b/Helpers/x-saherelm.xct.helper.mq5 @@ -0,0 +1,220 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 Helper Class Library +// ---------------------------------------------- +// Name: XSCXCTHelper +// 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.xhelper.class.mq5" + +// +// Definitions ... + +// +// Input Models ... +struct XXCTInputs +{ + // + // Props ... + + // + color clr; // Text Color + ENUM_BASE_CORNER corner; // Text Position + + // + // Presentation ... + bool showCandleTime; // Show Candle Time + + // + // Constructor(s) ... + XXCTInputs() + { + // + Clean(); + } + + // + // Tools ... + + // + // Clean ... + void Clean() + { + // + clr = CLR_NONE; + corner = CORNER_RIGHT_LOWER; + + // + // Presentation ... + showCandleTime = false; + } + + // + // Default ... + void Default() + { + // + clr = clrYellow; + corner = CORNER_RIGHT_LOWER; + + // + // Presentation ... + showCandleTime = false; + } + + // + // Validate ... + bool IsValid() + { + // + bool result = false; + + // + result = + // + true + // + ; + + // + return result; + } + + // + // Retrieve MAx Length ... + int Max() + { + // + int result = 0; + + // + result = MathMax(0, 0); + + // + return result; + } +}; + +// +// Class ... +class XSCXCTHelper : public XSCBaseHelper +{ + // + // Public ... +public: + // + // Props ... + + // + // Constructors ... + XSCXCTHelper() : XSCBaseHelper(_Symbol, _Period) + { + } + + // + // Deconstructor ... + ~XSCXCTHelper() {} + + // + // Tools ... + bool Init( + string symbol, // Trading Symbol + ENUM_TIMEFRAMES period, // Trading Period + XXCTInputs &inputs // Inputs + ) + { + // + bool result = false; + + // + mSymbol = symbol; + mPeriod = period; + + // + result = inputs.IsValid(); + if (!result) + { + return result; + } + + // + mInputs = inputs; + + // + mHandler = iCustom( + mSymbol, + mPeriod, + "x-saherelm.xct", + // + // Inputs ... + mInputs.clr, // Text Color + mInputs.corner, // Text Position + // + // Presentation ... + "", + mInputs.showCandleTime // Show Candle Time + // + ); + result = mHandler != INVALID_HANDLE; + if (!result) + { + return result; + } + + // + return result; + } + + // + // Inputs ... + + // + XXCTInputs GetInputs() + { + return mInputs; + } + + // + bool SetInputs( + XXCTInputs &inputs // Configs + ) + { + // + return Init( + mSymbol, + mPeriod, + inputs + // + ); + } + + // + // Protected ... +protected: + // + // Private ... +private: + // + // Props ... + XXCTInputs mInputs; // Inputs ... +} + +// +// Tools ... \ No newline at end of file diff --git a/Helpers/x-saherelm.xdon.helper.mq5 b/Helpers/x-saherelm.xdon.helper.mq5 new file mode 100644 index 00000000..78adc020 --- /dev/null +++ b/Helpers/x-saherelm.xdon.helper.mq5 @@ -0,0 +1,831 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 Helper Class Library +// ---------------------------------------------- +// Name: XSCXDONHelper +// 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.xhelper.class.mq5" + +// +// Definitions ... + +// +enum ENUM_XDON_BUFFERS +{ + // + // Open ... + XDON_UPPER_O_LINE = 0, + XDON_LOWER_O_LINE = 1, + // + // Close ... + XDON_UPPER_C_LINE = 2, + XDON_LOWER_C_LINE = 3, + // + // High ... + XDON_UPPER_H_LINE = 4, + XDON_LOWER_H_LINE = 5, + // + // Low ... + XDON_UPPER_L_LINE = 6, + XDON_LOWER_L_LINE = 7, +}; + +// +// Input Models ... +struct XDONInputs +{ + // + // Props ... + + // + // Market ... + int length; // Market Length + double offset; // Offset + + // + // Presentation ... + bool showOpen; // Show Open + bool showHigh; // Show High + bool showClose; // Show Close + bool showLow; // Show Low + + // + // Constructor(s) ... + XDONInputs() + { + // + Clean(); + } + + // + // Tools ... + + // + // Clean ... + void Clean() + { + // + // Market ... + length = 0; + offset = 0; + + // + // Presentation ... + showOpen = false; + showHigh = false; + showClose = false; + showLow = false; + } + + // + // Default ... + void Default() + { + // + // Market ... + length = 52; + offset = 0; + + // + // Presentation ... + showOpen = true; + showHigh = true; + showClose = true; + showLow = true; + } + + // + // Validate ... + bool IsValid() + { + // + bool result = false; + + // + result = + // + length >= 5 && + offset >= 0 + // + ; + + // + return result; + } + + // + // Retrieve MAx Length ... + int Max() + { + // + int result = 0; + + // + result = MathMax(0, length); + + // + return result; + } +}; + +// +// Class ... +class XSCXDONHelper : public XSCBaseHelper +{ + // + // Public ... +public: + // + // Props ... + + // + // Constructors ... + XSCXDONHelper() : XSCBaseHelper(_Symbol, _Period) + { + } + + // + // Deconstructor ... + ~XSCXDONHelper() {} + + // + // Tools ... + bool Init( + string symbol, // Trading Symbol + ENUM_TIMEFRAMES period, // Trading Period + XDONInputs &inputs // Inputs + ) + { + // + bool result = false; + + // + mSymbol = symbol; + mPeriod = period; + + // + result = inputs.IsValid(); + if (!result) + { + return result; + } + + // + mInputs = inputs; + + // + ArraySetAsSeries(upperOBuffer, true); + ArraySetAsSeries(lowerOBuffer, true); + ArraySetAsSeries(upperCBuffer, true); + ArraySetAsSeries(lowerCBuffer, true); + ArraySetAsSeries(upperHBuffer, true); + ArraySetAsSeries(lowerHBuffer, true); + ArraySetAsSeries(upperLBuffer, true); + ArraySetAsSeries(lowerLBuffer, true); + + // + mHandler = iCustom( + mSymbol, + mPeriod, + "x-saherelm.xdon", + // + // Inputs ... + // + // Market ... + "", + mInputs.length, // Market Length + mInputs.offset, // Offset + // + // Presentation ... + "", + mInputs.showOpen, // Show Open + mInputs.showHigh, // Show High + mInputs.showClose, // Show Close + mInputs.showLow // Show Low + // + ); + result = mHandler != INVALID_HANDLE; + if (!result) + { + return result; + } + + // + return result; + } + + // + // Inputs ... + + // + XDONInputs GetInputs() + { + return mInputs; + } + + // + bool SetInputs( + XDONInputs &inputs // Configs + ) + { + // + return Init( + mSymbol, + mPeriod, + inputs + // + ); + } + + // + // Buffers ... + + // + // Open ... + + // + // Upper ... + + // + double GetUpperO( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + int count = ArraySize(upperOBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return upperOBuffer[barIndex]; + } + + // + // Copy Required Items ... + int CopyUpperO( + 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, + upperOBuffer, + buffer, + forceClean + // + ); + } + + // + // Lower ... + + // + double GetLowerO( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + int count = ArraySize(lowerOBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return lowerOBuffer[barIndex]; + } + + // + // Copy Required Items ... + int CopyLowerO( + 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, + lowerOBuffer, + buffer, + forceClean + // + ); + } + + // + // Close ... + + // + // Upper ... + + // + double GetUpperC( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + int count = ArraySize(upperCBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return upperCBuffer[barIndex]; + } + + // + // Copy Required Items ... + int CopyUpperC( + 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, + upperCBuffer, + buffer, + forceClean + // + ); + } + + // + // Lower ... + + // + double GetLowerC( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + int count = ArraySize(lowerCBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return lowerCBuffer[barIndex]; + } + + // + // Copy Required Items ... + int CopyLowerC( + 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, + lowerCBuffer, + buffer, + forceClean + // + ); + } + + // + // High ... + + // + // Upper ... + + // + double GetUpperH( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + int count = ArraySize(upperHBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return upperHBuffer[barIndex]; + } + + // + // Copy Required Items ... + int CopyUpperH( + 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, + upperHBuffer, + buffer, + forceClean + // + ); + } + + // + // Lower ... + + // + double GetLowerH( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + int count = ArraySize(lowerHBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return lowerHBuffer[barIndex]; + } + + // + // Copy Required Items ... + int CopyLowerH( + 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, + lowerHBuffer, + buffer, + forceClean + // + ); + } + + // + // Low ... + + // + // Upper ... + + // + double GetUpperL( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + int count = ArraySize(upperLBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return upperLBuffer[barIndex]; + } + + // + // Copy Required Items ... + int CopyUpperL( + 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, + upperLBuffer, + buffer, + forceClean + // + ); + } + + // + // Lower ... + + // + double GetLowerL( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + int count = ArraySize(lowerLBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return lowerLBuffer[barIndex]; + } + + // + // Copy Required Items ... + int CopyLowerL( + 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, + lowerLBuffer, + buffer, + forceClean + // + ); + } + + // + // Protected ... +protected: + // + // Private ... +private: + // + // Props ... + XDONInputs mInputs; // Inputs ... + + // + // Buffers ... + double upperOBuffer[]; + double lowerOBuffer[]; + double upperCBuffer[]; + double lowerCBuffer[]; + double upperHBuffer[]; + double lowerHBuffer[]; + double upperLBuffer[]; + double lowerLBuffer[]; + + // + // Tools ... + + // + // Calculate Values Until Now ... + void Calculate() + { + // + int totalBars = CountBars(); + + // + // Open ... + + // + // Upper Buffer ... + CopyBuffer( + mHandler, + XDON_UPPER_O_LINE, + 0, + totalBars, + upperOBuffer + // + ); + + // + // Lower Buffer ... + CopyBuffer( + mHandler, + XDON_LOWER_O_LINE, + 0, + totalBars, + lowerOBuffer + // + ); + + // + // Close ... + + // + // Upper Buffer ... + CopyBuffer( + mHandler, + XDON_UPPER_C_LINE, + 0, + totalBars, + upperCBuffer + // + ); + + // + // Lower Buffer ... + CopyBuffer( + mHandler, + XDON_LOWER_C_LINE, + 0, + totalBars, + lowerCBuffer + // + ); + + // + // High ... + + // + // Upper Buffer ... + CopyBuffer( + mHandler, + XDON_UPPER_H_LINE, + 0, + totalBars, + upperHBuffer + // + ); + + // + // Lower Buffer ... + CopyBuffer( + mHandler, + XDON_LOWER_H_LINE, + 0, + totalBars, + lowerHBuffer + // + ); + + // + // Low ... + + // + // Upper Buffer ... + CopyBuffer( + mHandler, + XDON_UPPER_L_LINE, + 0, + totalBars, + upperLBuffer + // + ); + + // + // Lower Buffer ... + CopyBuffer( + mHandler, + XDON_LOWER_L_LINE, + 0, + totalBars, + lowerLBuffer + // + ); + } +} + +// +// Tools ... \ No newline at end of file diff --git a/Helpers/x-saherelm.xhull.helper.mq5 b/Helpers/x-saherelm.xhull.helper.mq5 new file mode 100644 index 00000000..87ceb217 --- /dev/null +++ b/Helpers/x-saherelm.xhull.helper.mq5 @@ -0,0 +1,399 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 Helper Class Library +// ---------------------------------------------- +// Name: XSCXHULLCHelper +// 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.xhelper.class.mq5" + +// +// Definitions ... + +// +enum ENUM_XHULLC_BUFFERS +{ + XHULLC_UP_LINE = 0, + XHULLC_DOWN_LINE = 2, +}; + +// +// Input Models ... +struct XHULLCInputs +{ + // + // Props ... + // + // Market ... + int length; // Length + double divisor; // Divisor (Speed) + + // + // Calculation ... + ENUM_APPLIED_PRICE upAppliedTo; // Up Zone Applied to + ENUM_APPLIED_PRICE downAppliedTo; // Down Zone Applied to + + // + // Presentation ... + bool showUpZone; // Show Up Zone + bool showDownZone; // Show Down Zone + + // + // Constructor(s) ... + XHULLCInputs() + { + // + Clean(); + } + + // + // Tools ... + + // + // Clean ... + void Clean() + { + // + // Market ... + length = 0; + divisor = 0; + + // + // Calculation ... + upAppliedTo = PRICE_HIGH; + downAppliedTo = PRICE_LOW; + + // + // Presentation ... + showUpZone = false; + showDownZone = false; + } + + // + // Default ... + void Default() + { + // + // Market ... + length = 72; + divisor = 2.0; + + // + // Calculation ... + upAppliedTo = PRICE_HIGH; + downAppliedTo = PRICE_LOW; + + // + // Presentation ... + showUpZone = true; + showDownZone = true; + } + + // + // Validate ... + bool IsValid() + { + // + bool result = false; + + // + result = + // + length >= 9 && + divisor >= 0.5 + // + ; + + // + return result; + } + + // + // Retrieve MAx Length ... + int Max() + { + // + int result = 0; + + // + result = MathMax(0, length); + + // + return result; + } +}; + +// +// Class ... +class XSCXHULLCHelper : public XSCBaseHelper +{ + // + // Public ... +public: + // + // Props ... + + // + // Constructors ... + XSCXHULLCHelper() : XSCBaseHelper(_Symbol, _Period) + { + } + + // + // Deconstructor ... + ~XSCXHULLCHelper() {} + + // + // Tools ... + bool Init( + string symbol, // Trading Symbol + ENUM_TIMEFRAMES period, // Trading Period + XHULLCInputs &inputs // Inputs + ) + { + // + bool result = false; + + // + mSymbol = symbol; + mPeriod = period; + + // + result = inputs.IsValid(); + if (!result) + { + return result; + } + + // + mInputs = inputs; + + // + // ArraySetAsSeries(mainBuffer, true); + mHandler = iCustom( + mSymbol, + mPeriod, + "x-saherelm.xhull", + // + // Inputs ... + // + // Market ... + "", + mInputs.length, // Length + mInputs.divisor, // Divisor (Speed) + // + // Calculation ... + "", + mInputs.upAppliedTo, // Up Zone Applied to + mInputs.downAppliedTo, // Down Zone Applied to + // + // Presentation ... + "", + mInputs.showUpZone, // Show Up Zone + mInputs.showDownZone // Show Down Zone + // + ); + result = mHandler != INVALID_HANDLE; + if (!result) + { + return result; + } + + // + return result; + } + + // + // Inputs ... + + // + XHULLCInputs GetInputs() + { + return mInputs; + } + + // + bool SetInputs( + XHULLCInputs &inputs // Configs + ) + { + // + return Init( + mSymbol, + mPeriod, + inputs + // + ); + } + + // + // Buffers ... + + // + double GetUp( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + int count = ArraySize(upBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return upBuffer[barIndex]; + } + + // + // Copy Required Items ... + int CopyUp( + 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, + upBuffer, + buffer, + forceClean + // + ); + } + + // + double GetDown( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + int count = ArraySize(downBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return downBuffer[barIndex]; + } + + // + // Copy Required Items ... + int CopyDown( + 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, + downBuffer, + buffer, + forceClean + // + ); + } + + // + // Protected ... +protected: + // + // Private ... +private: + // + // Props ... + XHULLCInputs mInputs; // Inputs ... + + // + // Buffers ... + double upBuffer[]; + double downBuffer[]; + + // + // Tools ... + + // + // Calculate Values Until Now ... + void Calculate() + { + // + int totalBars = CountBars(); + + // + // Up Buffer ... + CopyBuffer( + mHandler, + XHULLC_UP_LINE, + 0, + totalBars, + upBuffer + // + ); + + // + // Down Buffer ... + CopyBuffer( + mHandler, + XHULLC_DOWN_LINE, + 0, + totalBars, + downBuffer + // + ); + } +} + +// +// Tools ... \ No newline at end of file diff --git a/Helpers/x-saherelm.xich.helper.mq5 b/Helpers/x-saherelm.xich.helper.mq5 new file mode 100644 index 00000000..7509f3f4 --- /dev/null +++ b/Helpers/x-saherelm.xich.helper.mq5 @@ -0,0 +1,755 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 Helper Class Library +// ---------------------------------------------- +// Name: XSCXICHHelper +// 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 + +// +#include "../Classes/x-saherelm.xhelper.class.mq5" + +// +// Definitions ... +// +// Ichimoku Lines Calculator Mode ... +enum ENUM_XICH_CALCULATION_MODE +{ + // + X_XICH_HH_LL_MODE = 1, // Highest High and Lowest Low + X_XICH_HO_LC_MODE = 2, // Highest Open and Lowest Close +}; + +// +enum ENUM_XICH_BUFFERS +{ + X_ICH_TEANKANSEN_LINE = 0, + X_ICH_KIJUNSEN_LINE = 1, + X_ICH_CHIKOUSPAN_LINE = 4, + X_ICH_SENKOUSPANA_LINE = 5, + X_ICH_SENKOUSPANB_LINE = 6, +}; + +// +// Input Models ... +struct XICHInputs +{ + // + // Props ... + + // + // Market ... + // + // Tenkan Sen ... + int tenkanSenLength; // Length + ENUM_XICH_CALCULATION_MODE tenkanSenMode; // Calculation Mode + + // + // Kijun Sen ... + int kijunSenLength; // Length + ENUM_XICH_CALCULATION_MODE kijunSenMode; // Calculation Mode + + // + // Senkou Span B ... + int senkouSpanBLength; // Length + ENUM_XICH_CALCULATION_MODE senkouSpanBMode; // Calculation Mode + + // + // Chikou Span ... + ENUM_APPLIED_PRICE chikuoSpanAppliedTo; // Price Type + + // + // Presentation ... + bool showTenkanSen; // Show Tenkan Sen + bool showKijunSen; // Show Kijun Sen + bool showKijunSenPlus; // Show Kijun Sen + + bool showKijunSenNegative; // Show Kijun Sen - + bool showChikouSpan; // Show Chikou Span + bool showSenkouSpanA; // Show Senkou Span A + bool showSenkouSpanB; // Show Senkou Span B + bool showKumo; // Show Kumo + bool shiftKumo; // Shift Kumo to Future + + // + // Constructor(s) ... + XICHInputs() + { + // + Clean(); + } + + // + // Tools ... + + // + // Clean ... + void Clean() + { + // + kijunSenLength = 0; + tenkanSenLength = 0; + senkouSpanBLength = 0; + + // + kijunSenMode = X_XICH_HH_LL_MODE; + tenkanSenMode = X_XICH_HH_LL_MODE; + senkouSpanBMode = X_XICH_HH_LL_MODE; + + // + chikuoSpanAppliedTo = PRICE_CLOSE; + + // + showTenkanSen = false; + showKijunSen = false; + showKijunSenPlus = false; + showKijunSenNegative = false; + showChikouSpan = false; + showSenkouSpanA = false; + showSenkouSpanB = false; + showKumo = false; + shiftKumo = true; + } + + // + // Default ... + void Default() + { + // + kijunSenLength = 26; + tenkanSenLength = 9; + senkouSpanBLength = 52; + + // + kijunSenMode = X_XICH_HH_LL_MODE; + tenkanSenMode = X_XICH_HH_LL_MODE; + senkouSpanBMode = X_XICH_HH_LL_MODE; + + // + chikuoSpanAppliedTo = PRICE_CLOSE; + + // + showTenkanSen = true; + showKijunSen = true; + showKijunSenPlus = false; + showKijunSenNegative = false; + showChikouSpan = true; + showSenkouSpanA = true; + showSenkouSpanB = true; + showKumo = true; + shiftKumo = true; + } + + // + // Validate ... + bool IsValid() + { + // + bool result = false; + + // + result = + // + tenkanSenLength > 2 && + kijunSenLength > tenkanSenLength && + senkouSpanBLength > kijunSenLength + // + ; + + // + return result; + } + + // + // Retrieve MAx Length ... + int Max() + { + // + int result = 0; + + // + result = MathMax(result, tenkanSenLength); + result = MathMax(result, kijunSenLength); + result = MathMax(result, senkouSpanBLength); + + // + return result; + } +}; + +// +// Class ... +class XSCXICHHelper : public XSCBaseHelper +{ + // + // Public ... +public: + // + // Props ... + + // + // Constructors ... + XSCXICHHelper() : XSCBaseHelper(_Symbol, _Period) + { + } + + // + // Deconstructor ... + ~XSCXICHHelper() {} + + // + // Tools ... + bool Init( + string symbol, // Trading Symbol + ENUM_TIMEFRAMES period, // Trading Period + XICHInputs &inputs // Inputs + ) + { + // + bool result = false; + + // + mSymbol = symbol; + mPeriod = period; + + // + result = inputs.IsValid(); + if (!result) + { + return result; + } + + // + mInputs = inputs; + + // + ArraySetAsSeries(tenkanSenBuffer, true); + ArraySetAsSeries(kijunSenBuffer, true); + ArraySetAsSeries(chikouSpanBuffer, true); + ArraySetAsSeries(senkouSpanABuffer, true); + ArraySetAsSeries(senkouSpanBBuffer, true); + + // + mHandler = iCustom( + mSymbol, + mPeriod, + "x-saherelm.xich", + // + // Inputs ... + // + // TenkanSen ... + "", + mInputs.tenkanSenLength, + mInputs.tenkanSenMode, + // + // KijunSen ... + "", + mInputs.kijunSenLength, + mInputs.kijunSenMode, + // + // SenkouSpan B ... + "", + mInputs.senkouSpanBLength, + mInputs.senkouSpanBMode, + // + // ChikouSpan ... + "", + mInputs.chikuoSpanAppliedTo, + // + // Presentation ... + "", + mInputs.showTenkanSen, // Show Tenkan Sen + mInputs.showKijunSen, // Show Kijun Sen + mInputs.showKijunSenPlus, // Show Kijun Sen + + mInputs.showKijunSenNegative, // Show Kijun Sen - + mInputs.showChikouSpan, // Show Chikou Span + mInputs.showSenkouSpanA, // Show Senkou Span A + mInputs.showSenkouSpanB, // Show Senkou Span B + mInputs.showKumo, // Show Kumo + mInputs.shiftKumo // Shift Kumo to Future + // + ); + result = mHandler != INVALID_HANDLE; + if (!result) + { + return result; + } + + // + return result; + } + + // + // Inputs ... + + // + XICHInputs GetInputs() + { + return mInputs; + } + + // + bool SetInputs( + XICHInputs &inputs // Configs + ) + { + // + return Init( + mSymbol, + mPeriod, + inputs); + } + + // + // Buffers ... + + // + // TenkanSen ... + + // + double GetTenkanSen( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return tenkanSenBuffer[barIndex]; + } + + // + // Copy Required Items ... + int CopyTenkanSen( + 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, + tenkanSenBuffer, + buffer, + forceClean + // + ); + } + + // + // KijunSen ... + + // + double GetKijunSen( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return kijunSenBuffer[barIndex]; + } + + // + // Copy Required Items ... + int CopyKijunSen( + 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, + kijunSenBuffer, + buffer, + forceClean + // + ); + } + + // + // ChikouSpan ... + + // + double GetChikouSpan( + int barIndex // Bar Index + ) + { + // + barIndex -= mInputs.kijunSenLength; + + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + if (barIndex > ArraySize(chikouSpanBuffer)) + { + barIndex = ArraySize(chikouSpanBuffer) - 1; + } + + // + Calculate(); + + // + return chikouSpanBuffer[barIndex]; + } + + // + // Copy Required Items ... + int CopyChikouSpan( + 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 - mInputs.kijunSenLength, + count, + chikouSpanBuffer, + buffer, + forceClean + // + ); + } + + // + // SenkouSpanA ... + + // + double GetSenkouSpanA( + int barIndex // Bar Index + ) + { + // + barIndex += mInputs.kijunSenLength; + + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + if (barIndex > ArraySize(senkouSpanABuffer)) + { + barIndex = ArraySize(senkouSpanABuffer) - 1; + } + + // + Calculate(); + + // + return senkouSpanABuffer[barIndex]; + } + + // + // Copy Required Items ... + int CopySenkouSpanA( + 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 + mInputs.kijunSenLength, + count, + senkouSpanABuffer, + buffer, + forceClean + // + ); + } + + // + // SenkouSpanB ... + + // + double GetSenkouSpanB( + int barIndex // Bar Index + ) + { + // + barIndex += mInputs.kijunSenLength; + + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + if (barIndex > ArraySize(senkouSpanBBuffer)) + { + barIndex = ArraySize(senkouSpanBBuffer) - 1; + } + + // + Calculate(); + + // + return senkouSpanBBuffer[barIndex + mInputs.kijunSenLength]; + } + + // + // Copy Required Items ... + int CopySenkouSpanB( + 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 + mInputs.kijunSenLength, + count, + senkouSpanBBuffer, + buffer, + forceClean + // + ); + } + + // + // Future SenkouSpanA ... + + // + double GetFutureSenkouSpanA( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return senkouSpanABuffer[barIndex]; + } + + // + // Copy Required Items ... + int CopyFutureSenkouSpanA( + 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, + senkouSpanABuffer, + buffer, + forceClean + // + ); + } + + // + // SenkouSpanB ... + + // + double GetFutureSenkouSpanB( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return senkouSpanBBuffer[barIndex]; + } + + // + // Copy Required Items ... + int CopyFutureSenkouSpanB( + 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, + senkouSpanBBuffer, + buffer, + forceClean + // + ); + } + + // + // Protected ... +protected: + // + // Private ... +private: + // + // Props ... + XICHInputs mInputs; // Inputs ... + + // + // Buffers ... + double tenkanSenBuffer[]; + double kijunSenBuffer[]; + double chikouSpanBuffer[]; + double senkouSpanABuffer[]; + double senkouSpanBBuffer[]; + + // + // Tools ... + + // + // Calculate Values Until Now ... + void Calculate() + { + // + int totalBars = CountBars(); + int calculatedBars = CountCalculatedBars(); + + // + // TenkanSen ... + CopyBuffer( + mHandler, + X_ICH_TEANKANSEN_LINE, + 0, + totalBars, + tenkanSenBuffer + // + ); + + // + // KijunSen ... + CopyBuffer( + mHandler, + X_ICH_KIJUNSEN_LINE, + 0, + totalBars, + kijunSenBuffer + // + ); + + // + // ChikouSpan ... + CopyBuffer( + mHandler, + X_ICH_CHIKOUSPAN_LINE, + 0, + totalBars, + chikouSpanBuffer + // + ); + + // + // SenkouSpan A ... + CopyBuffer( + mHandler, + X_ICH_SENKOUSPANA_LINE, + 0, + totalBars, + senkouSpanABuffer + // + ); + + // + // SenkouSpan B ... + CopyBuffer( + mHandler, + X_ICH_SENKOUSPANB_LINE, + 0, + totalBars, + senkouSpanBBuffer + // + ); + } +}; + +// +// Tools ... diff --git a/Helpers/x-saherelm.xmc.helper.mq5 b/Helpers/x-saherelm.xmc.helper.mq5 new file mode 100644 index 00000000..0ec6a851 --- /dev/null +++ b/Helpers/x-saherelm.xmc.helper.mq5 @@ -0,0 +1,497 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 Helper Class Library +// ---------------------------------------------- +// Name: XSCXMCHelper +// 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 + +// +#include "../Classes/x-saherelm.xhelper.class.mq5" + +// +// Definitions ... + +// +enum ENUM_XMC_BUFFERS +{ + X_MC_FAST_LINE = 0, + X_MC_SLOW_LINE = 1, + X_MC_VERIFIER_LINE = 2, +}; + +// +// Input Models ... +struct XMCInputs +{ + // + // Props ... + + // + // Market ... + + // + // Fast ... + int fastLength; // Length + int fastShift; // Shift + ENUM_MA_METHOD fastMethod; // Method + ENUM_APPLIED_PRICE fastAppliedTo; // Applied To + + // + // Slow ... + int slowLength; // Length + int slowShift; // Shift + ENUM_MA_METHOD slowMethod; // Method + ENUM_APPLIED_PRICE slowAppliedTo; // Applied To + + // + // Verifier ... + int verifierLength; // Length + int verifierShift; // Shift + ENUM_MA_METHOD verifierMethod; // Method + ENUM_APPLIED_PRICE verifierAppliedTo; // Applied To + + // + // Presentation ... + bool showFastMa; // Show Fast + bool showSlowMa; // Show Slow + bool showVerifierMa; // Show Verifier + + // + // Constructor(s) ... + XMCInputs() + { + // + Clean(); + } + + // + // Tools ... + + // + // Clean ... + void Clean() + { + // + fastLength = 0; + fastShift = 0; + fastMethod = 0; + fastAppliedTo = PRICE_CLOSE; + + // + slowLength = 0; + slowShift = 0; + slowMethod = 0; + slowAppliedTo = PRICE_CLOSE; + + // + verifierLength = 0; + verifierShift = 0; + verifierMethod = 0; + verifierAppliedTo = PRICE_CLOSE; + + // + showFastMa = false; + showSlowMa = false; + showVerifierMa = false; + } + + // + // Default ... + void Default() + { + // + fastLength = 9; + fastShift = 0; + fastMethod = MODE_EMA; + fastAppliedTo = PRICE_CLOSE; + + // + slowLength = 18; + slowShift = 0; + slowMethod = MODE_EMA; + slowAppliedTo = PRICE_CLOSE; + + // + verifierLength = 200; + verifierShift = 0; + verifierMethod = MODE_EMA; + verifierAppliedTo = PRICE_CLOSE; + + // + showFastMa = true; + showSlowMa = true; + showVerifierMa = true; + } + + // + // Validate ... + bool IsValid() + { + // + bool result = false; + + // + result = + // + fastLength > 1 && + slowLength > fastLength && + verifierLength > slowLength + // + ; + + // + return result; + } + + // + // Retrieve MAx Length ... + int Max() + { + // + int result = 0; + + // + result = MathMax(fastLength, slowLength); + result = MathMax(result, verifierLength); + + // + return result; + } +}; + +// +// Class ... +class XSCXMCHelper : public XSCBaseHelper +{ + // + // Public ... +public: + // + // Props ... + + // + // Constructors ... + XSCXMCHelper() : XSCBaseHelper(_Symbol, _Period) + { + } + + // + // Deconstructor ... + ~XSCXMCHelper() {} + + // + // Tools ... + bool Init( + string symbol, // Trading Symbol + ENUM_TIMEFRAMES period, // Trading Period + XMCInputs &inputs // Inputs + ) + { + // + bool result = false; + + // + mSymbol = symbol; + mPeriod = period; + + // + result = inputs.IsValid(); + if (!result) + { + return result; + } + + // + mInputs = inputs; + + // + ArraySetAsSeries(fastBuffer, true); + ArraySetAsSeries(slowBuffer, true); + ArraySetAsSeries(verifierBuffer, true); + mHandler = iCustom( + mSymbol, + mPeriod, + "x-saherelm.xmc", + // + // Inputs ... + // + // Fast ... + "", + mInputs.fastLength, + mInputs.fastShift, + mInputs.fastMethod, + mInputs.fastAppliedTo, + // + // Slow ... + "", + mInputs.slowLength, + mInputs.slowShift, + mInputs.slowMethod, + mInputs.slowAppliedTo, + // + // Verifier ... + "", + mInputs.verifierLength, + mInputs.verifierShift, + mInputs.verifierMethod, + mInputs.verifierAppliedTo, + // + // Presentation ... + "", + mInputs.showFastMa, // Show Fast, + mInputs.showSlowMa, // Show Slow, + mInputs.showVerifierMa // Show Verifier + // + ); + result = mHandler != INVALID_HANDLE; + if (!result) + { + return result; + } + + // + return result; + } + + // + // Inputs ... + + // + XMCInputs GetInputs() + { + return mInputs; + } + + // + bool SetInputs( + XMCInputs &inputs // Configs + ) + { + // + return Init( + mSymbol, + mPeriod, + inputs); + } + + // + // Buffers ... + + // + // Fast ... + + // + double GetFast( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return fastBuffer[barIndex]; + } + + // + // Copy Required Buffer ... + int CopyFast( + 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, + fastBuffer, + buffer, + forceClean + // + ); + } + + // + // Slow ... + + // + double GetSlow( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return slowBuffer[barIndex]; + } + + // + // Copy Required Buffer ... + int CopySlow( + 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, + slowBuffer, + buffer, + forceClean + // + ); + } + + // + // Verifier ... + + // + double GetVerifier( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return verifierBuffer[barIndex]; + } + + // + // Copy Required Buffer ... + int CopyVerifier( + 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, + verifierBuffer, + buffer, + forceClean + // + ); + } + + // + // Protected ... +protected: + // + // Private ... +private: + // + // Props ... + XMCInputs mInputs; // Inputs ... + + // + // Buffers ... + // + double fastBuffer[]; + double slowBuffer[]; + double verifierBuffer[]; + + // + // Tools ... + + // + // Calculate Values Until Now ... + void Calculate() + { + // + int totalBars = CountBars(); + int calculatedBars = CountCalculatedBars(); + + // + // Fast ... + CopyBuffer( + mHandler, + X_MC_FAST_LINE, + 0, + totalBars, + fastBuffer + // + ); + + // + // Slow ... + CopyBuffer( + mHandler, + X_MC_SLOW_LINE, + 0, + totalBars, + slowBuffer + // + ); + + // + // Verifier ... + CopyBuffer( + mHandler, + X_MC_VERIFIER_LINE, + 0, + totalBars, + verifierBuffer + // + ); + } +}; + +// +// Tools ... diff --git a/Helpers/x-saherelm.xosc.helper.mq5 b/Helpers/x-saherelm.xosc.helper.mq5 new file mode 100644 index 00000000..27380623 --- /dev/null +++ b/Helpers/x-saherelm.xosc.helper.mq5 @@ -0,0 +1,1319 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 Helper Class Library +// ---------------------------------------------- +// Name: XSCXOSCHelper +// 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 + +// +#include "../Classes/x-saherelm.xhelper.class.mq5" + +// +// Definitions ... + +// +enum ENUM_XOSC_BUFFERS +{ + X_OSC_ATR_LINE = 0, + X_OSC_RVI_MAIN_LINE = 1, + X_OSC_RVI_SIGNAL_LINE = 2, + X_OSC_BULL_POWER_LINE = 3, + X_OSC_BEAR_POWER_LINE = 4, + X_OSC_VOLUME_LINE = 5, + X_OSC_RSI_LINE = 6, + X_OSC_CCI_LINE = 7, + X_OSC_MOMENTUM_LINE = 8, + X_OSC_SAR_LINE = 9, + X_OSC_MACD_MAIN_LINE = 10, + X_OSC_MACD_SIGNAL_LINE = 11, + X_OSC_STOCH_MAIN_LINE = 12, + X_OSC_STOCH_SIGNAL_LINE = 13, + X_OSC_STDDEV_LINE = 14, +}; + +// +// Input Models ... +struct XOSCInputs +{ + // + // Props ... + + // + // ATR ... + int atrLength; // Length + + // + // RVI ... + int rviLength; // Length + + // + // BULLPOWER ... + int bullpLength; // Length + + // + // BEARPOWER ... + int bearpLength; // Length + + // + // VOLUME ... + ENUM_APPLIED_VOLUME volumeAppliedTo; // Applied To + + // + // RSI ... + int rsiLength; // Length + ENUM_APPLIED_PRICE rsiAppliedTo; // Applied To + + // + // CCI ... + int cciLength; // Length + ENUM_APPLIED_PRICE cciAppliedTo; // Applied To + + // + // STDDEV ... + int stddevLength; // Length + int stddevShift; // Shift + ENUM_MA_METHOD stddevMethod; // Mode + ENUM_APPLIED_PRICE stddevAppliedTo; // AppliedTo + + // + // MOMENTUM ... + int momentumLength; // Length + ENUM_APPLIED_PRICE momentumAppliedTo; // Applied To + + // + // SAR ... + double sarStep; // Step + double sarMaximum; // Maximum + + // + // MACD ... + int macdFastLength; // Fast Length + int macdSlowLength; // Slow Length + int macdSignaLength; // Signal Length + ENUM_APPLIED_PRICE macdAppliedTo; // Applied To + + // + // STOCHASTIC ... + // The buffer numbers: 0 - MAIN_LINE, 1 - SIGNAL_LINE. + int stochKLength; // K Length + int stochDLength; // D Length + int stochSlowing; // Slowing + ENUM_MA_METHOD stochMaMethod; // Ma Method + ENUM_STO_PRICE stochMode; // Calculation Mode + + // + // Constructor(s) ... + XOSCInputs() + { + // + Clean(); + } + + // + // Tools ... + + // + // Clean ... + void Clean() + { + // + atrLength = 0; // Length + rviLength = 0; // Length + bullpLength = 0; // Length + bearpLength = 0; // Length + volumeAppliedTo = VOLUME_TICK; // Applied To + rsiLength = 0; // Length + rsiAppliedTo = PRICE_CLOSE; // Applied To + cciLength = 0; // Length + cciAppliedTo = PRICE_TYPICAL; // Applied To + stddevLength = 0; // Length + stddevShift = 0; // Shift + stddevMethod = MODE_SMA; // Mode + stddevAppliedTo = PRICE_CLOSE; // AppliedTo + momentumLength = 0; // Length + momentumAppliedTo = PRICE_CLOSE; // Applied To + sarStep = 0; // Step + sarMaximum = 0; // Maximum + macdFastLength = 0; // Fast Length + macdSlowLength = 0; // Slow Length + macdSignaLength = 0; // Signal Length + macdAppliedTo = PRICE_CLOSE; // Applied To + stochKLength = 0; // K Length + stochDLength = 0; // D Length + stochSlowing = 0; // Slowing + stochMaMethod = MODE_SMA; // Ma Method + stochMode = STO_LOWHIGH; // Calculation Mode + } + + // + // Default ... + void Default() + { + // + atrLength = 14; // Length + rviLength = 10; // Length + bullpLength = 13; // Length + bearpLength = 13; // Length + volumeAppliedTo = VOLUME_TICK; // Applied To + rsiLength = 14; // Length + rsiAppliedTo = PRICE_CLOSE; // Applied To + cciLength = 14; // Length + cciAppliedTo = PRICE_TYPICAL; // Applied To + stddevLength = 20; // Length + stddevShift = 0; // Shift + stddevMethod = MODE_SMA; // Mode + stddevAppliedTo = PRICE_CLOSE; // AppliedTo + momentumLength = 14; // Length + momentumAppliedTo = PRICE_CLOSE; // Applied To + sarStep = 0.02; // Step + sarMaximum = 0.2; // Maximum + macdFastLength = 12; // Fast Length + macdSlowLength = 26; // Slow Length + macdSignaLength = 9; // Signal Length + macdAppliedTo = PRICE_CLOSE; // Applied To + stochKLength = 5; // K Length + stochDLength = 3; // D Length + stochSlowing = 3; // Slowing + stochMaMethod = MODE_SMA; // Ma Method + stochMode = STO_LOWHIGH; // Calculation Mode + } + + // + // Validate ... + bool IsValid() + { + // + bool result = false; + + // + result = + // + atrLength >= 2 && + rviLength >= 2 && + bullpLength >= 2 && + bearpLength >= 2 && + rsiLength >= 2 && + cciLength >= 2 && + momentumLength >= 2 && + sarStep > 0 && + sarStep < sarMaximum && + macdFastLength >= 2 && + macdSlowLength > macdFastLength && + macdSignaLength >= 2 && + stochKLength >= 2 && + stochDLength >= 2 && + stochSlowing >= 2 && + stddevLength >= 2 && + stddevShift >= 0 + // + ; + + // + return result; + } + + // + // Retrieve MAx Length ... + int Max() + { + // + int result = 0; + + // + result = MathMax(atrLength, rviLength); + result = MathMax(result, bullpLength); + result = MathMax(result, bearpLength); + result = MathMax(result, rsiLength); + result = MathMax(result, cciLength); + result = MathMax(result, momentumLength); + result = MathMax(result, macdFastLength); + result = MathMax(result, macdSlowLength); + result = MathMax(result, macdSignaLength); + result = MathMax(result, stochKLength); + result = MathMax(result, stochDLength); + result = MathMax(result, stochSlowing); + result = MathMax(result, stddevLength); + + // + return result; + } +}; + +// +// Class ... +class XSCXOSCHelper : public XSCBaseHelper +{ + // + // Public ... +public: + // + // Props ... + + // + // Constructors ... + XSCXOSCHelper() : XSCBaseHelper(_Symbol, _Period) + { + } + + // + // Deconstructor ... + ~XSCXOSCHelper() {} + + // + // Tools ... + bool Init( + string symbol, // Trading Symbol + ENUM_TIMEFRAMES period, // Trading Period + XOSCInputs &inputs // Inputs + ) + { + // + bool result = false; + + // + mSymbol = symbol; + mPeriod = period; + + // + result = inputs.IsValid(); + if (!result) + { + return result; + } + + // + mInputs = inputs; + + // + ArraySetAsSeries(atrBuffer, true); + ArraySetAsSeries(rviMainBuffer, true); + ArraySetAsSeries(rviSignalBuffer, true); + ArraySetAsSeries(bullPBuffer, true); + ArraySetAsSeries(bearPBuffer, true); + ArraySetAsSeries(volumeBuffer, true); + ArraySetAsSeries(rsiBuffer, true); + ArraySetAsSeries(cciBuffer, true); + ArraySetAsSeries(momentumBuffer, true); + ArraySetAsSeries(sarBuffer, true); + ArraySetAsSeries(macdMainBuffer, true); + ArraySetAsSeries(macdSignalBuffer, true); + ArraySetAsSeries(stochMainBuffer, true); + ArraySetAsSeries(stochSignalBuffer, true); + ArraySetAsSeries(stddevBuffer, true); + mHandler = iCustom( + mSymbol, + mPeriod, + "x-saherelm.xosc", + // + // Inputs ... + // + // ATR ... + "", + mInputs.atrLength, + // + // RVI ... + "", + mInputs.rviLength, + // + // Bulls Power ... + "", + mInputs.bullpLength, + // + // Bears Power ... + "", + mInputs.bearpLength, + // + // Voluem ... + "", + mInputs.volumeAppliedTo, + // + // RSI ... + "", + mInputs.rsiLength, + mInputs.rsiAppliedTo, + // + // CCI ... + "", + mInputs.cciLength, + mInputs.cciAppliedTo, + // + // STDDev ... + "", + mInputs.stddevLength, + mInputs.stddevShift, + mInputs.stddevMethod, + mInputs.stddevAppliedTo, + // + // Momentum ... + "", + mInputs.momentumLength, + mInputs.momentumAppliedTo, + // + // SAR ... + "", + mInputs.sarStep, + mInputs.sarMaximum, + // + // MACD ... + "", + mInputs.macdFastLength, + mInputs.macdSlowLength, + mInputs.macdSignaLength, + mInputs.macdAppliedTo, + // + // Stochastic ... + "", + mInputs.stochKLength, + mInputs.stochDLength, + mInputs.stochSlowing, + mInputs.stochMaMethod, + mInputs.stochMode + // + ); + result = mHandler != INVALID_HANDLE; + if (!result) + { + return result; + } + + // + return result; + } + + // + // Inputs ... + + // + XOSCInputs GetInputs() + { + return mInputs; + } + + // + bool SetInputs( + XOSCInputs &inputs // Configs + ) + { + // + return Init( + mSymbol, + mPeriod, + inputs); + } + + // + // Buffers ... + + // + // ATR ... + + // + double GetATR( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return atrBuffer[barIndex]; + } + + // + // Copy Required Buffer ... + 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 + // + ); + } + + // + // RVI ... + + // + double GetRVI( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return rviMainBuffer[barIndex]; + } + + // + // Copy Required Buffer ... + int CopyRVI( + 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, + rviMainBuffer, + buffer, + forceClean + // + ); + } + + // + double GetRVISignal( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return rviSignalBuffer[barIndex]; + } + + // + // Copy Required Buffer ... + int CopyRVISignal( + 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, + rviSignalBuffer, + buffer, + forceClean + // + ); + } + + // + // BULLP ... + + // + double GetBullPower( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return bullPBuffer[barIndex]; + } + + // + // Copy Required Buffer ... + int CopyBullPower( + 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, + bullPBuffer, + buffer, + forceClean + // + ); + } + + // + // BEARP ... + + // + double GetBearPower( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return bearPBuffer[barIndex]; + } + + // + // Copy Required Buffer ... + int CopyBearPower( + 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, + bearPBuffer, + buffer, + forceClean + // + ); + } + + // + // VOLUME ... + + // + double GetVolume( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return volumeBuffer[barIndex]; + } + + // + // Copy Required Buffer ... + int CopyVolume( + 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, + volumeBuffer, + buffer, + forceClean + // + ); + } + + // + // RSI ... + + // + double GetRSI( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return rsiBuffer[barIndex]; + } + + // + // Copy Required Buffer ... + int CopyRSI( + 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, + rsiBuffer, + buffer, + forceClean + // + ); + } + + // + // CCI ... + + // + double GetCCI( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return cciBuffer[barIndex]; + } + + // + // Copy Required Buffer ... + int CopyCCI( + 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, + cciBuffer, + buffer, + forceClean + // + ); + } + + // + // MOMENTUM ... + + // + double GetMomentum( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return momentumBuffer[barIndex]; + } + + // + // Copy Required Buffer ... + int CopyMomentum( + 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, + momentumBuffer, + buffer, + forceClean + // + ); + } + + // + // SAR ... + + // + double GetSAR( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return sarBuffer[barIndex]; + } + + // + // Copy Required Buffer ... + int CopySAR( + 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, + sarBuffer, + buffer, + forceClean + // + ); + } + + // + // STDDEV ... + + // + double GetSTDDEV( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return stddevBuffer[barIndex]; + } + + // + // Copy Required Buffer ... + int CopySTDDEV( + 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, + stddevBuffer, + buffer, + forceClean + // + ); + } + + // + // MACD ... + + // + double GetMACD( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return macdMainBuffer[barIndex]; + } + + // + // Copy Required Buffer ... + int CopyMACD( + 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, + macdMainBuffer, + buffer, + forceClean + // + ); + } + + // + double GetMACDSignal( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return macdSignalBuffer[barIndex]; + } + + // + // Copy Required Buffer ... + int CopyMACDSignal( + 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, + macdSignalBuffer, + buffer, + forceClean + // + ); + } + + // + // STOCH ... + + // + double GetSTOCH( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return stochMainBuffer[barIndex]; + } + + // + // Copy Required Buffer ... + int CopySTOCH( + 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, + stochMainBuffer, + buffer, + forceClean + // + ); + } + + // + double GetSTOCHSignal( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return stochSignalBuffer[barIndex]; + } + + // + // Copy Required Buffer ... + int CopySTOCHSignal( + 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, + stochSignalBuffer, + buffer, + forceClean + // + ); + } + + // + // Protected ... +protected: + // + // Private ... +private: + // + // Props ... + XOSCInputs mInputs; // Inputs ... + + // + // Buffers ... + double atrBuffer[]; + double rviMainBuffer[]; + double rviSignalBuffer[]; + double bullPBuffer[]; + double bearPBuffer[]; + double volumeBuffer[]; + double rsiBuffer[]; + double cciBuffer[]; + double momentumBuffer[]; + double sarBuffer[]; + double macdMainBuffer[]; + double macdSignalBuffer[]; + double stochMainBuffer[]; + double stochSignalBuffer[]; + double stddevBuffer[]; + + // + // Tools ... + + // + // Calculate Values Until Now ... + void Calculate() + { + // + int totalBars = CountBars(); + int calculatedBars = CountCalculatedBars(); + + // + // ATR ... + CopyBuffer( + mHandler, + X_OSC_ATR_LINE, + 0, + totalBars, + atrBuffer + // + ); + + // + // BULLP ... + CopyBuffer( + mHandler, + X_OSC_BULL_POWER_LINE, + 0, + totalBars, + bullPBuffer + // + ); + + // + // BEARP ... + CopyBuffer( + mHandler, + X_OSC_BEAR_POWER_LINE, + 0, + totalBars, + bearPBuffer + // + ); + + // + // VOLUME ... + CopyBuffer( + mHandler, + X_OSC_VOLUME_LINE, + 0, + totalBars, + volumeBuffer + // + ); + + // + // RSI ... + CopyBuffer( + mHandler, + X_OSC_RSI_LINE, + 0, + totalBars, + rsiBuffer + // + ); + + // + // CCI ... + CopyBuffer( + mHandler, + X_OSC_CCI_LINE, + 0, + totalBars, + cciBuffer + // + ); + + // + // MOMENTUM ... + CopyBuffer( + mHandler, + X_OSC_MOMENTUM_LINE, + 0, + totalBars, + momentumBuffer + // + ); + + // + // SAR ... + CopyBuffer( + mHandler, + X_OSC_SAR_LINE, + 0, + totalBars, + sarBuffer + // + ); + + // + // STDDEV ... + CopyBuffer( + mHandler, + X_OSC_STDDEV_LINE, + 0, + totalBars, + stddevBuffer + // + ); + + // + // RVI ... + + // + // RVI Main ... + CopyBuffer( + mHandler, + X_OSC_RVI_MAIN_LINE, + 0, + totalBars, + rviMainBuffer + // + ); + + // + // RVI Signal ... + CopyBuffer( + mHandler, + X_OSC_RVI_SIGNAL_LINE, + 0, + totalBars, + rviSignalBuffer + // + ); + + // + // MACD ... + + // + // MACD Main ... + CopyBuffer( + mHandler, + X_OSC_MACD_MAIN_LINE, + 0, + totalBars, + macdMainBuffer + // + ); + + // + // MACD Signal ... + CopyBuffer( + mHandler, + X_OSC_MACD_SIGNAL_LINE, + 0, + totalBars, + macdSignalBuffer + // + ); + + // + // STOCH ... + + // + // STOCH Main ... + CopyBuffer( + mHandler, + X_OSC_STOCH_MAIN_LINE, + 0, + totalBars, + stochMainBuffer + // + ); + + // + // STOCH Signal ... + CopyBuffer( + mHandler, + X_OSC_STOCH_SIGNAL_LINE, + 0, + totalBars, + stochSignalBuffer + // + ); + } +}; + +// +// Tools ... diff --git a/Helpers/x-saherelm.xstr.helper.mq5 b/Helpers/x-saherelm.xstr.helper.mq5 new file mode 100644 index 00000000..9d954f6c --- /dev/null +++ b/Helpers/x-saherelm.xstr.helper.mq5 @@ -0,0 +1,421 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 Helper Class Library +// ---------------------------------------------- +// Name: XSCXSTRRHelper +// 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 + +// +#include "../Classes/x-saherelm.xhelper.class.mq5" + +// +// Definitions ... + +// +enum ENUM_XSTR_BUFFERS +{ + X_STR_TREND_LINE = 0, + X_STR_STATE_LINE = 5, +}; + +// +enum ENUM_XSTR_TREND_STATES +{ + X_STR_BULLISH = 1, // Bullish + X_STR_BEARISH = -1, // Bearish +}; + +// +// Input Models ... +struct XSTRRInputs +{ + // + // Props ... + + // + // Market ... + int length; // Length + double multiplier; // Multiplier + ENUM_APPLIED_PRICE appliedTo; // Applied To + + // + // Presentation ... + bool showTrends; // Show Trends + bool fillTrends; // Fill Trends + + // + // Constructor(s) ... + XSTRRInputs() + { + // + Clean(); + } + + // + // Tools ... + + // + // Clean ... + void Clean() + { + // + length = 0; + multiplier = 0; + appliedTo = PRICE_CLOSE; + // + showTrends = false; + fillTrends = false; + } + + // + // Default ... + void Default() + { + // + length = 14; + multiplier = 3.5; + appliedTo = PRICE_MEDIAN; + // + showTrends = true; + fillTrends = false; + } + + // + // Validate ... + bool IsValid() + { + // + bool result = false; + + // + result = + // + length > 0 && + multiplier > 0 + // + ; + + // + return result; + } + + // + // Retrieve MAx Length ... + int Max() + { + // + int result = 0; + + // + result = length; + + // + return result; + } +}; + +// +// Class ... +class XSCXSTRRHelper : public XSCBaseHelper +{ + // + // Public ... +public: + // + // Props ... + + // + // Constructors ... + XSCXSTRRHelper() : XSCBaseHelper(_Symbol, _Period) + { + } + + // + // Deconstructor ... + ~XSCXSTRRHelper() {} + + // + // Tools ... + bool Init( + string symbol, // Trading Symbol + ENUM_TIMEFRAMES period, // Trading Period + XSTRRInputs &inputs // Inputs + ) + { + // + bool result = false; + + // + mSymbol = symbol; + mPeriod = period; + + // + result = inputs.IsValid(); + if (!result) + { + return result; + } + + // + mInputs = inputs; + + // + ArraySetAsSeries(trendBuffer, true); + ArraySetAsSeries(stateBuffer, true); + + // + mHandler = iCustom( + mSymbol, + mPeriod, + "x-saherelm.xstr", + // + // Inputs ... + // + // ATR ... + "", + mInputs.length, // Length + mInputs.multiplier, // Multiplier + mInputs.appliedTo, // Applied To + // + // Presentation ... + "", + mInputs.showTrends, // Show Trends + mInputs.fillTrends // Fill Trends + // + ); + result = mHandler != INVALID_HANDLE; + if (!result) + { + return result; + } + + // + return result; + } + + // + // Inputs ... + + // + XSTRRInputs GetInputs() + { + return mInputs; + } + + // + bool SetInputs( + XSTRRInputs &inputs // Configs + ) + { + // + return Init( + mSymbol, + mPeriod, + inputs); + } + + // + // Buffers ... + + // + // Trend ... + + // + double GetTrend( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return trendBuffer[barIndex]; + } + + // + // Copy Required Buffer ... + int CopyTrend( + 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, + trendBuffer, + buffer, + forceClean + // + ); + } + + // + // State ... + + // + ENUM_XSTR_TREND_STATES GetState( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + return (ENUM_XSTR_TREND_STATES)((int)stateBuffer[barIndex]); + } + + // + // Copy Required Buffer ... + int CopyState( + 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, + stateBuffer, + buffer, + forceClean + // + ); + } + + // + // Tools ... + + // + ENUM_XSTR_TREND_STATES ToState(double state) + { + return (ENUM_XSTR_TREND_STATES)((int)state); + } + + // + bool IsBullish(double state) + { + // + bool result = false; + + // + result = + // + ToState(state) == X_STR_BULLISH; + // + ; + + // + return result; + } + + // + bool IsBearish(double state) + { + // + bool result = false; + + // + result = + // + ToState(state) == X_STR_BEARISH; + // + ; + + // + return result; + } + + // + // Protected ... +protected: + // + // Private ... +private: + // + // Props ... + XSTRRInputs mInputs; // Inputs ... + + // + // Buffers ... + double trendBuffer[]; + double stateBuffer[]; + + // + // Tools ... + + // + // Calculate Values Until Now ... + void Calculate() + { + // + int totalBars = CountBars(); + int calculatedBars = CountCalculatedBars(); + + // + // Trend ... + CopyBuffer( + mHandler, + X_STR_TREND_LINE, + 0, + totalBars, + trendBuffer + // + ); + + // + // State ... + CopyBuffer( + mHandler, + X_STR_STATE_LINE, + 0, + totalBars, + stateBuffer + // + ); + } +}; + +// +// Tools ... diff --git a/Helpers/x-saherelm.xzg.helper.mq5 b/Helpers/x-saherelm.xzg.helper.mq5 new file mode 100644 index 00000000..097c084e --- /dev/null +++ b/Helpers/x-saherelm.xzg.helper.mq5 @@ -0,0 +1,527 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 Helper Class Library +// ---------------------------------------------- +// Name: XSCXZGHelper +// 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.xhelper.class.mq5" + +// +// Definitions ... + +// +// How to Calculate Up and Down Price ... +enum ENUM_X_ZG_PRICE_MODE +{ + // + X_ZG_PRICE_HIGH_LOW_MODE = 1, + X_ZG_PRICE_OPEN_CLOSE_MODE = 2, +}; + +// +enum ENUM_XZG_BUFFERS +{ + // + XZG_MAIN_LINE = 0, + XZG_PEAKSANDVALES_LINE = 2, + XZG_HIGHS_LINE = 4, + XZG_LOWS_LINE = 5, +}; + +// +// Input Models ... +struct XZGInputs +{ + // + // Props ... + + // + // Market ... + int depth; // Depth + int deviation; // Deviation + int backStep; // Back Step + ENUM_X_ZG_PRICE_MODE mode; // Mode + // + // Presentation ... + bool showZigZag; // Show ZigZag + bool showPeaksAndVales; // Show Peaks and Vales + + // + // Constructor(s) ... + XZGInputs() + { + // + Clean(); + } + + // + // Tools ... + + // + // Clean ... + void Clean() + { + // + // Market ... + depth = 0; + deviation = 0; + backStep = 0; + mode = X_ZG_PRICE_HIGH_LOW_MODE; + // + // Presentation ... + showZigZag = false; + showPeaksAndVales = false; + } + + // + // Default ... + void Default() + { + // + // Market ... + depth = 12; + deviation = 5; + backStep = 3; + mode = X_ZG_PRICE_HIGH_LOW_MODE; + // + // Presentation ... + showZigZag = true; + showPeaksAndVales = true; + } + + // + // Validate ... + bool IsValid() + { + // + bool result = false; + + // + result = + // + depth > 0 && + deviation > 0 && + backStep > 0 + // + ; + + // + return result; + } + + // + // Retrieve MAx Length ... + int Max() + { + // + int result = 0; + + // + result = MathMax(backStep, depth); + + // + return result; + } +}; + +// +// Class ... +class XSCXZGHelper : public XSCBaseHelper +{ + // + // Public ... +public: + // + // Props ... + + // + // Constructors ... + XSCXZGHelper() : XSCBaseHelper(_Symbol, _Period) + { + } + + // + // Deconstructor ... + ~XSCXZGHelper() {} + + // + // Tools ... + bool Init( + string symbol, // Trading Symbol + ENUM_TIMEFRAMES period, // Trading Period + XZGInputs &inputs // Inputs + ) + { + // + bool result = false; + + // + mSymbol = symbol; + mPeriod = period; + + // + result = inputs.IsValid(); + if (!result) + { + return result; + } + + // + mInputs = inputs; + + // + ArraySetAsSeries(mainBuffer, true); + ArraySetAsSeries(PeaksAndValesBuffer, true); + ArraySetAsSeries(highsBuffer, true); + ArraySetAsSeries(lowsBuffer, true); + + // + mHandler = iCustom( + mSymbol, + mPeriod, + "x-saherelm.xzg", + // + // Inputs ... + // + // Market ... + "", + mInputs.depth, // Depth + mInputs.deviation, // Deviation + mInputs.backStep, // Back Step + mInputs.mode, // Mode + // + // Presentation ... + "", + mInputs.showZigZag, // Show ZigZag + mInputs.showPeaksAndVales // Show Peaks and Vales + // + ); + result = mHandler != INVALID_HANDLE; + if (!result) + { + return result; + } + + // + return result; + } + + // + // Inputs ... + + // + XZGInputs GetInputs() + { + return mInputs; + } + + // + bool SetInputs( + XZGInputs &inputs // Configs + ) + { + // + return Init( + mSymbol, + mPeriod, + inputs + // + ); + } + + // + // Buffers ... + + // + double GetMain( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + int count = ArraySize(mainBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return mainBuffer[barIndex]; + } + + // + // Copy Required Items ... + int CopyMain( + 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, + mainBuffer, + buffer, + forceClean + // + ); + } + + // + double GetPeaksAndValues( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + int count = ArraySize(PeaksAndValesBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return PeaksAndValesBuffer[barIndex]; + } + + // + // Copy Required Items ... + int CopyPeaksAndValues( + 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, + PeaksAndValesBuffer, + buffer, + forceClean + // + ); + } + + // + double GetHigh( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + int count = ArraySize(highsBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return highsBuffer[barIndex]; + } + + // + // Copy Required Items ... + int CopyHigh( + 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, + highsBuffer, + buffer, + forceClean + // + ); + } + + // + double GetLow( + int barIndex // Bar Index + ) + { + // + if (barIndex < 0) + { + barIndex = 0; + } + + // + Calculate(); + + // + int count = ArraySize(lowsBuffer); + if (barIndex >= count) + { + barIndex = count - 1; + } + + // + return lowsBuffer[barIndex]; + } + + // + // Copy Required Items ... + int CopyLow( + 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, + lowsBuffer, + buffer, + forceClean + // + ); + } + + // + // Protected ... +protected: + // + // Private ... +private: + // + // Props ... + XZGInputs mInputs; // Inputs ... + + // + // Buffers ... + double mainBuffer[]; + double PeaksAndValesBuffer[]; + double highsBuffer[]; + double lowsBuffer[]; + + // + // Tools ... + + // + // Calculate Values Until Now ... + void Calculate() + { + // + int totalBars = CountBars(); + + // + // Main Buffer ... + CopyBuffer( + mHandler, + XZG_MAIN_LINE, + 0, + totalBars, + mainBuffer + // + ); + + // + // Peaks and Vales Buffer ... + CopyBuffer( + mHandler, + XZG_PEAKSANDVALES_LINE, + 0, + totalBars, + PeaksAndValesBuffer + // + ); + + // + // Highs Buffer ... + CopyBuffer( + mHandler, + XZG_HIGHS_LINE, + 0, + totalBars, + highsBuffer + // + ); + + // + // Lows Buffer ... + CopyBuffer( + mHandler, + XZG_LOWS_LINE, + 0, + totalBars, + lowsBuffer + // + ); + } +} + +// +// Tools ... \ No newline at end of file diff --git a/Indicators/x-saherelm.xdon.mq5 b/Indicators/x-saherelm.xdon.mq5 index e479e65c..c96e2bf7 100644 --- a/Indicators/x-saherelm.xdon.mq5 +++ b/Indicators/x-saherelm.xdon.mq5 @@ -24,9 +24,17 @@ // INPUT ... // +input group "Market"; input int length = 52; // Market Length input double offset = 0; // Offset +// +input group "Presentation"; +input bool showOpen = true; // Show Open +input bool showHigh = true; // Show High +input bool showClose = true; // Show Close +input bool showLow = true; // Show Low + // // BUFFERS ... @@ -164,36 +172,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 ... +) { // if (rates_total < length - 1) @@ -298,63 +287,75 @@ void DefineBuffers() { // // Open ... + ENUM_DRAW_TYPE openDrawType = showOpen ? DRAW_LINE : DRAW_NONE; // // UPPER ... SetIndexBuffer(upperOBufferIndex, upperOBuffer, INDICATOR_DATA); - PlotIndexSetInteger(upperOBufferIndex, PLOT_SHOW_DATA, true); + PlotIndexSetInteger(upperOBufferIndex, PLOT_SHOW_DATA, showOpen); PlotIndexSetDouble(upperOBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); + PlotIndexSetInteger(upperOBufferIndex, PLOT_DRAW_TYPE, openDrawType); // // LOWER ... SetIndexBuffer(lowerOBufferIndex, lowerOBuffer, INDICATOR_DATA); - PlotIndexSetInteger(lowerOBufferIndex, PLOT_SHOW_DATA, true); + PlotIndexSetInteger(lowerOBufferIndex, PLOT_SHOW_DATA, showOpen); PlotIndexSetDouble(lowerOBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); + PlotIndexSetInteger(lowerOBufferIndex, PLOT_DRAW_TYPE, openDrawType); // // Close ... + ENUM_DRAW_TYPE closeDrawType = showClose ? DRAW_LINE : DRAW_NONE; // // UPPER ... SetIndexBuffer(upperCBufferIndex, upperCBuffer, INDICATOR_DATA); - PlotIndexSetInteger(upperCBufferIndex, PLOT_SHOW_DATA, true); + PlotIndexSetInteger(upperCBufferIndex, PLOT_SHOW_DATA, showClose); PlotIndexSetDouble(upperCBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); + PlotIndexSetInteger(upperCBufferIndex, PLOT_DRAW_TYPE, closeDrawType); // // LOWER ... SetIndexBuffer(lowerCBufferIndex, lowerCBuffer, INDICATOR_DATA); - PlotIndexSetInteger(lowerCBufferIndex, PLOT_SHOW_DATA, true); + PlotIndexSetInteger(lowerCBufferIndex, PLOT_SHOW_DATA, showClose); PlotIndexSetDouble(lowerCBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); + PlotIndexSetInteger(lowerCBufferIndex, PLOT_DRAW_TYPE, closeDrawType); // // High ... + ENUM_DRAW_TYPE highDrawType = showHigh ? DRAW_LINE : DRAW_NONE; // // UPPER ... SetIndexBuffer(upperHBufferIndex, upperHBuffer, INDICATOR_DATA); - PlotIndexSetInteger(upperHBufferIndex, PLOT_SHOW_DATA, true); + PlotIndexSetInteger(upperHBufferIndex, PLOT_SHOW_DATA, showHigh); PlotIndexSetDouble(upperHBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); + PlotIndexSetInteger(upperHBufferIndex, PLOT_DRAW_TYPE, highDrawType); // // LOWER ... SetIndexBuffer(lowerHBufferIndex, lowerHBuffer, INDICATOR_DATA); - PlotIndexSetInteger(lowerHBufferIndex, PLOT_SHOW_DATA, true); + PlotIndexSetInteger(lowerHBufferIndex, PLOT_SHOW_DATA, showHigh); PlotIndexSetDouble(lowerHBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); + PlotIndexSetInteger(lowerHBufferIndex, PLOT_DRAW_TYPE, highDrawType); // // Low ... + ENUM_DRAW_TYPE lowDrawType = showLow ? DRAW_LINE : DRAW_NONE; // // UPPER ... SetIndexBuffer(upperLBufferIndex, upperLBuffer, INDICATOR_DATA); - PlotIndexSetInteger(upperLBufferIndex, PLOT_SHOW_DATA, true); + PlotIndexSetInteger(upperLBufferIndex, PLOT_SHOW_DATA, showLow); PlotIndexSetDouble(upperLBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); + PlotIndexSetInteger(upperLBufferIndex, PLOT_DRAW_TYPE, lowDrawType); // // LOWER ... SetIndexBuffer(lowerLBufferIndex, lowerLBuffer, INDICATOR_DATA); - PlotIndexSetInteger(lowerLBufferIndex, PLOT_SHOW_DATA, true); + PlotIndexSetInteger(lowerLBufferIndex, PLOT_SHOW_DATA, showLow); PlotIndexSetDouble(lowerLBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); + PlotIndexSetInteger(lowerLBufferIndex, PLOT_DRAW_TYPE, lowDrawType); } // diff --git a/Indicators/x-saherelm.xhull.mq5 b/Indicators/x-saherelm.xhull.mq5 index f822995f..ffc17928 100644 --- a/Indicators/x-saherelm.xhull.mq5 +++ b/Indicators/x-saherelm.xhull.mq5 @@ -378,36 +378,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 ... +) { // // this counts Available Bars ... diff --git a/Indicators/x-saherelm.xzg.mq5 b/Indicators/x-saherelm.xzg.mq5 index 4a7ea22e..0abb3684 100644 --- a/Indicators/x-saherelm.xzg.mq5 +++ b/Indicators/x-saherelm.xzg.mq5 @@ -44,11 +44,17 @@ enum ENUM_X_ZG_PRICE_MODE // INPUT ... // +input group "Market"; input int depth = 12; // Depth input int deviation = 5; // Deviation input int backStep = 3; // Back Step input ENUM_X_ZG_PRICE_MODE mode = X_ZG_PRICE_HIGH_LOW_MODE; // Mode +// +input group "Presentation"; +input bool showZigZag = true; // Show ZigZag +input bool showPeaksAndVales = true; // Show Peaks and Vales + // // BUFFERS ... @@ -56,8 +62,8 @@ input ENUM_X_ZG_PRICE_MODE mode = X_ZG_PRICE_HIGH_LOW_MODE; // Mode #property indicator_chart_window // -#property indicator_buffers 5 -#property indicator_plots 3 +#property indicator_buffers 6 +#property indicator_plots 4 // // ZigZag ... @@ -67,10 +73,13 @@ input ENUM_X_ZG_PRICE_MODE mode = X_ZG_PRICE_HIGH_LOW_MODE; // Mode #define mainBufferPlotIndex 0 double mainBuffer[]; +#define mainColorBufferIndex 1 +double mainColorBuffer[]; + // #property indicator_label1 "XZG Main" -#property indicator_type1 DRAW_SECTION -#property indicator_color1 clrYellow +#property indicator_type1 DRAW_COLOR_SECTION +#property indicator_color1 CLR_NONE, clrRoyalBlue, clrSaddleBrown #property indicator_width1 2 // @@ -78,29 +87,29 @@ double mainBuffer[]; // // ZigZag Pointer or Line Indicator ... -#define arrowBufferIndex 1 +#define arrowBufferIndex 2 #define arrowBufferPlotIndex 1 double arrowBuffer[]; // -#define arrowColorBufferIndex 2 +#define arrowColorBufferIndex 3 double arrowColorBuffer[]; // #property indicator_label2 "XZG PV" #property indicator_type2 DRAW_COLOR_ARROW -#property indicator_color2 clrAqua, clrMagenta +#property indicator_color2 CLR_NONE, clrAqua, clrMagenta #property indicator_width2 1 // -#define highsBufferIndex 3 +#define highsBufferIndex 4 double highsBuffer[]; // // Lows ... // -#define lowsBufferIndex 4 +#define lowsBufferIndex 5 double lowsBuffer[]; // @@ -159,36 +168,16 @@ 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 ... ) { // @@ -278,9 +267,10 @@ void DefineBuffers() // SetIndexBuffer(mainBufferIndex, mainBuffer, INDICATOR_DATA); + SetIndexBuffer(mainColorBufferIndex, mainColorBuffer, INDICATOR_COLOR_INDEX); // - PlotIndexSetInteger(mainBufferPlotIndex, PLOT_SHOW_DATA, true); + PlotIndexSetInteger(mainBufferPlotIndex, PLOT_SHOW_DATA, showZigZag); PlotIndexSetInteger(mainBufferPlotIndex, PLOT_DRAW_BEGIN, 0); PlotIndexSetDouble(mainBufferPlotIndex, PLOT_EMPTY_VALUE, 0); @@ -291,7 +281,7 @@ void DefineBuffers() SetIndexBuffer(arrowBufferIndex, arrowBuffer, INDICATOR_DATA); // - PlotIndexSetInteger(arrowBufferPlotIndex, PLOT_SHOW_DATA, true); + PlotIndexSetInteger(arrowBufferPlotIndex, PLOT_SHOW_DATA, showPeaksAndVales); PlotIndexSetInteger(arrowBufferPlotIndex, PLOT_DRAW_BEGIN, 0); PlotIndexSetInteger(arrowBufferPlotIndex, PLOT_ARROW, 159); PlotIndexSetInteger(arrowBufferPlotIndex, PLOT_ARROW_SHIFT, 0); @@ -664,11 +654,14 @@ int CalcukateZigZag( // colorIDX = lastZigZagValue > iZigZagForColor - ? 0 - : lastZigZagValue < iZigZagForColor ? 1 + : lastZigZagValue < iZigZagForColor + ? 2 : colorIDX; - arrowColorBuffer[shift] = colorIDX; + + // + mainColorBuffer[shift] = showZigZag ? colorIDX : 0; + arrowColorBuffer[shift] = showPeaksAndVales ? colorIDX : 0; } //