diff --git a/Classes/XCObjects/x-saherelm.x-button.class.mq5 b/Classes/XCObjects/x-saherelm.x-button.class.mq5 deleted file mode 100644 index 1d9d6abb..00000000 --- a/Classes/XCObjects/x-saherelm.x-button.class.mq5 +++ /dev/null @@ -1,156 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Class Library -// -------------------------------------- -// Name: XCButton -// Description: provides all based classes for use ... -// -// -// 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 "../XCObjects/x-saherelm.xcobject.class.mq5" - -// -// Definitions ... - -// -// Implementation ... - -// -// a Button Creation Class ... -class XCButton : public XCObject -{ - // - // Public ... - public: - // - // Constructor(s) ... - void XCButton() - { - } - - // - // Deconstructor ... - void ~XCButton() - { - } - - // - // Actions ... - - /** - * Create an Instance of Class Object ... - * - * @param name: Object Name - * @param xDis: X Distance - * @param yDis: Y Distance - * @param xSize: X Size - * @param ySize: Y Size - */ - bool Create( - string name, - int xDis, - int yDis, - int xSize, - int ySize, - long chartID = 0 // - ) - { - // - // Object creation and property settings - bool result = false; - - // - result = ObjectCreate(chartID, name, OBJ_BUTTON, 0, 0, 0); - if (!result) - { - return result; - } - - // - ObjectSetInteger(chartID, name, OBJPROP_XDISTANCE, xDis); - ObjectSetInteger(chartID, name, OBJPROP_YDISTANCE, yDis); - ObjectSetInteger(chartID, name, OBJPROP_XSIZE, xSize); - ObjectSetInteger(chartID, name, OBJPROP_YSIZE, ySize); - - // - mName = name; - mChartID = chartID; - - // - return result; - } - - // - // Getter(s) / Setter(s) ... - - /** - * Set Object Border Color ... - * - * @param value: color - */ - void BorderColor(color value) - { - ObjectSetInteger(mChartID, mName, OBJPROP_BORDER_COLOR, value); - } - - /** - * Set Object Background Color ... - * - * @param value: color - */ - void BGColor(color value) - { - ObjectSetInteger(mChartID, mName, OBJPROP_BGCOLOR, value); - } - - /** - * Set Object Text Color ... - * - * @param value: Color - */ - void Color(color value) - { - ObjectSetInteger(mChartID, mName, OBJPROP_COLOR, value); - } - - /** - * Set Object Text ... - * - * @param value: text - */ - void Text(string value) - { - ObjectSetString(mChartID, mName, OBJPROP_TEXT, value); - } - - /** - * Set Button Click State ... - * - * @param value: state - */ - void State(bool value) - { - ObjectSetInteger(mChartID, mName, OBJPROP_STATE, value); - } - - // - // Protected ... - protected: - // - // Private ... - private: - // -}; diff --git a/Classes/XCObjects/x-saherelm.x-edit.class.mq5 b/Classes/XCObjects/x-saherelm.x-edit.class.mq5 deleted file mode 100644 index dab9ffea..00000000 --- a/Classes/XCObjects/x-saherelm.x-edit.class.mq5 +++ /dev/null @@ -1,186 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Class Library -// -------------------------------------- -// Name: XCEdit -// Description: provides all based classes for use ... -// -// -// 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 "../XCObjects/x-saherelm.xcobject.class.mq5" - -// -// Definitions ... - -// -// Implementation ... - -// -// a Label Creation Class ... -class XCEdit : public XCObject -{ - // - // Public ... - public: - // - // Constructor(s) ... - void XCEdit() - { - } - - // - // Deconstructor ... - void ~XCEdit() - { - } - - // - // Actions ... - - /** - * Create an Instance of Class Object ... - * - * @param name: Object Name - * @param xDis: X Distance - * @param yDis: Y Distance - * @param xSize: X Size - * @param ySize: Y Size - */ - bool Create( - string name, - int xDis, - int yDis, - int xSize, - int ySize, - long chartID = 0 // - ) - { - // - // Object creation and property settings - bool result = false; - - // - result = ObjectCreate(chartID, name, OBJ_EDIT, 0, 0, 0); - if (!result) - { - return result; - } - - // - ObjectSetInteger(chartID, name, OBJPROP_XDISTANCE, xDis); - ObjectSetInteger(chartID, name, OBJPROP_YDISTANCE, yDis); - ObjectSetInteger(chartID, name, OBJPROP_XSIZE, xSize); - ObjectSetInteger(chartID, name, OBJPROP_YSIZE, ySize); - - // - mName = name; - mChartID = chartID; - - // - return result; - } - - // - // Getter(s) / Setter(s) ... - - /** - * Set Object Border Color ... - * - * @param value: color - */ - void BorderColor(color value) - { - ObjectSetInteger(mChartID, mName, OBJPROP_BORDER_COLOR, value); - } - - /** - * Set Background Color of Object ... - * - * @param value: color - */ - void BGColor(color value) - { - ObjectSetInteger(mChartID, mName, OBJPROP_BGCOLOR, value); - } - - /** - * Set Object Text Color ... - * - * @param value: color - */ - void Color(color value) - { - ObjectSetInteger(mChartID, mName, OBJPROP_COLOR, value); - } - - /** - * Set Text of Object ... - * - * @param value: text - */ - void Text(string value) - { - ObjectSetString(mChartID, mName, OBJPROP_TEXT, value); - } - - /** - * Get Current Text of Object ... - * - * @return ( string ) - */ - string Text() - { - return ObjectGetString(mChartID, mName, OBJPROP_TEXT); - } - - /** - * Set Font Size of Object ... - * - * @param value: size - */ - void FontSize(int value) - { - ObjectSetInteger(mChartID, mName, OBJPROP_FONTSIZE, value); - } - - /** - * Set Font Name Of Object ... - * - * @param value: font name - */ - void Font(string value) - { - ObjectSetString(mChartID, mName, OBJPROP_FONT, value); - } - - /** - * Set ReadOnly State of Object ... - * - * @param value: boolean value - */ - void ReadOnly(bool value) - { - ObjectSetInteger(mChartID, mName, OBJPROP_READONLY, value); - } - - // - // Protected ... - protected: - // - // Private ... - private: - // -}; diff --git a/Classes/XCObjects/x-saherelm.x-label.class.mq5 b/Classes/XCObjects/x-saherelm.x-label.class.mq5 deleted file mode 100644 index ddb91e8f..00000000 --- a/Classes/XCObjects/x-saherelm.x-label.class.mq5 +++ /dev/null @@ -1,160 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Class Library -// -------------------------------------- -// Name: XCLabel -// Description: provides all based classes for use ... -// -// -// 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 "../XCObjects/x-saherelm.xcobject.class.mq5" - -// -// Definitions ... - -// -// Implementation ... - -// -// a Label Creation Class ... -class XCLabel : public XCObject -{ - // - // Public ... - public: - // - // Constructor(s) ... - void XCLabel() - { - } - - // - // Deconstructor ... - void ~XCLabel() - { - } - - // - // Actions ... - - /** - * Create an Instance of Class Object ... - * - * @param name: Object Name - * @param xDis: X Distance - * @param yDis: Y Distance - */ - bool Create( - string name, - int xDis, - int yDis, - long chartID = 0 // - ) - { - // - // Object creation and property settings - bool result = false; - - // - result = ObjectCreate(chartID, name, OBJ_LABEL, 0, 0, 0); - if (!result) - { - return result; - } - - // - ObjectSetInteger(chartID, name, OBJPROP_XDISTANCE, xDis); - ObjectSetInteger(chartID, name, OBJPROP_YDISTANCE, yDis); - - // - mName = name; - mChartID = chartID; - - // - return result; - } - - // - // Getter(s) / Setter(s) ... - - /** - * Set Text Color ... - * - * @param value: color - */ - void Color(color value) - { - ObjectSetInteger(mChartID, mName, OBJPROP_COLOR, value); - } - - /** - * Set Text of Object ... - * - * @param value: text - */ - void Text(string value) - { - ObjectSetString(mChartID, mName, OBJPROP_TEXT, value); - } - - /** - * Get Text Of Object ... - * - * @return ( string ) - */ - string Text() - { - return ObjectGetString(mChartID, mName, OBJPROP_TEXT); - } - - /** - * Set Font Size of Object ... - * - * @param value: size - */ - void FontSize(int value) - { - ObjectSetInteger(mChartID, mName, OBJPROP_FONTSIZE, value); - } - - /** - * Set Font Name Of Object ... - * - * @param value: font name - */ - void Font(string value) - { - ObjectSetString(mChartID, mName, OBJPROP_FONT, value); - } - - /** - * Set Object Anchor ... - * - * @param value: anchor - */ - void Anchor(ENUM_ANCHOR_POINT value) - { - ObjectSetInteger(mChartID, mName, OBJPROP_ANCHOR, value); - } - - // - // Protected ... - protected: - // - // Private ... - private: - // -}; diff --git a/Classes/XCObjects/x-saherelm.x-panel.class.mq5 b/Classes/XCObjects/x-saherelm.x-panel.class.mq5 deleted file mode 100644 index ee441357..00000000 --- a/Classes/XCObjects/x-saherelm.x-panel.class.mq5 +++ /dev/null @@ -1,299 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Class Library -// -------------------------------------- -// Name: XCPanel -// Description: provides all based classes for use ... -// -// -// 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 "../XCObjects/x-saherelm.x-button.class.mq5" -#include "../XCObjects/x-saherelm.x-edit.class.mq5" -#include "../XCObjects/x-saherelm.x-label.class.mq5" -#include "../XCObjects/x-saherelm.x-rectangle.label.class.mq5" - -// -// Implementation ... - -// -class XCPanel : XCObject -{ - public: - // - // Constructor(s) ... - void XCPanel() - { - } - - // - // Deconstructor ... - void ~XCPanel() - { - Destroy(); - } - - // - // Action ... - - /** - * Create an instance of Panel Object ... - * - * @param name: Object name - * @param xDis: X Distance - * @param yDis: Y Distance - * @param xSize: X Size - * @param ySize: Y Size - * @param titleBarBorderType: Border Type of Panel TitleBar - * @param titleBarBGColor: Background Color of Panel TitleBar - * @param caption: Caption Text of Panel TitleBar - * @param captionontSize: Font Size of Panel Caption - * @param captionColor: Text Color of Panel Caption - * @param captionAnchor: Anchor Point of Panel Caption - * @param bodyBorderType: Border Type of Panel Body - * @param bodyBGColor: Background Color of Panel Body - * - * @return ( bool ) - */ - bool Create( - string name, - int xDis, - int yDis, - int xSize, - int ySize, - // - long chartID = 0, - // - // Title Bar ... - ENUM_BORDER_TYPE titleBarBorderType = BORDER_FLAT, - color titleBarBGColor = clrBlueViolet, - // - // Caption ... - string caption = "", - int captionontSize = 9, - color captionColor = clrWhite, - ENUM_ANCHOR_POINT captionAnchor = ANCHOR_LEFT_UPPER, - // - // Body ... - ENUM_BORDER_TYPE bodyBorderType = BORDER_FLAT, - color bodyBGColor = clrMediumSlateBlue // - ) - { - // - bool result = false; - - // - // Enables mouse move events on the chart - ChartSetInteger(chartID, CHART_EVENT_MOUSE_MOVE, true); - - // - result = IsValid(name); - if (!result) - { - // - Destroy(); - return result; - } - - // - mTitleBarName = name + "_TITLE_BAR"; - mCaptionLblName = name + "_CAPTION"; - mBodyName = name + "_BODY"; - - // - if (!IsValid(caption)) - { - caption = name; - } - - // - // Title Bar ... - int titleBarHeight = 20; - result = mTitleBar.Create( - mTitleBarName, - xDis, - yDis, - xSize, - titleBarHeight // - ); - if (!result) - { - // - Destroy(); - return result; - } - mTitleBar.BorderType(titleBarBorderType); - mTitleBar.BGColor(titleBarBGColor); - - // - // Body ... - result = mBody.Create( - mBodyName, - xDis, - yDis + titleBarHeight - 1, - xSize, - ySize // - ); - if (!result) - { - // - Destroy(); - return result; - } - mBody.BorderType(bodyBorderType); - mBody.BGColor(bodyBGColor); - mBody.AsBackGround(true); - - // - // Caption ... - result = mCaptionLbl.Create(mCaptionLblName, xDis, yDis); - if (!result) - { - // - Destroy(); - return result; - } - mCaptionLbl.Text(caption); - mCaptionLbl.Color(captionColor); - mCaptionLbl.Anchor(captionAnchor); - mCaptionLbl.FontSize(captionontSize); - - // - // Adding Child Objects ... - mTitleBar.Add(mBodyName); - mTitleBar.Add(mCaptionLblName); - - // - return result; - } - - /** - * Destroy Panel Object and all of it's Child - */ - void Destroy() - { - // - mBodyName = NULL; - mTitleBarName = NULL; - mCaptionLblName = NULL; - - // - mBody.Destroy(); - mTitleBar.Destroy(); - mCaptionLbl.Destroy(); - } - - /** - * Event Handling for Mouse Movement ... - * @param id: Event ID - * @param lparam: Event parameter of long type - * @param dparam: Event parameter of double type - * @param sparam: Event parameter of string type - */ - void OnEvent( - int id, - long lparam, - double dparam, - string sparam // - ) - { - // - mTitleBar.OnEvent( - id, - lparam, - dparam, - sparam // - ); - } - - /** - * Add Specific Child Object ... - * - * @param name: object name - */ - void Add(string name) - { - mTitleBar.Add(name); - } - - /** - * Retrieve Panel Caption ... - * - * @return ( string ) - */ - string Caption() - { - return mCaptionLbl.Text(); - } - - /** - * Set Panel Caption ... - * - * @param value: Caption - */ - void Caption(string value) - { - mCaptionLbl.Text(value); - } - - /** - * Set Caption Color ... - * - * @param value: Color - */ - void CptionColor(color value) - { - mCaptionLbl.Color(value); - } - - /** - * Set Panel Body BG Color ... - * - * @param value: Color - */ - void BodyColor(color value) - { - mBody.BGColor(value); - } - - /** - * Set Panel Titlebar BG Color ... - * - * @param value: Color - */ - void TitleBarBGColor(color value) - { - mTitleBar.BGColor(value); - } - - // - protected: - private: - // - // Props ... - - // - string mBodyName; - string mTitleBarName; - string mCaptionLblName; - - // - XCLabel mCaptionLbl; - XCRectangleLabel mBody; - XCRectangleLabel mTitleBar; - - // -}; \ No newline at end of file diff --git a/Classes/XCObjects/x-saherelm.x-rectangle.label.class.mq5 b/Classes/XCObjects/x-saherelm.x-rectangle.label.class.mq5 deleted file mode 100644 index 055cc712..00000000 --- a/Classes/XCObjects/x-saherelm.x-rectangle.label.class.mq5 +++ /dev/null @@ -1,259 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Class Library -// -------------------------------------- -// Name: XCRectangleLabel -// Description: provides all based classes for use ... -// -// -// 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 "../XCObjects/x-saherelm.xcobject.class.mq5" - -// -// Definitions ... - -// -// Implementation ... - -// -// a Rectangle Label Creation Class ... -class XCRectangleLabel : public XCObject -{ - // - // Public ... - public: - // - // Constructor(s) ... - void XCRectangleLabel() - { - } - - // - // Deconstructor ... - void ~XCRectangleLabel() - { - } - - // - // Actions ... - - /** - * Create an Instance of Class Object ... - * - * @param name: Object Name - * @param xDis: X Distance - * @param yDis: Y Distance - * @param xSize: X Size - * @param ySize: Y Size - */ - bool Create( - string name, - int xDis, - int yDis, - int xSize, - int ySize, - long chartID = 0 // - ) - { - // - // Object creation and property settings - bool result = false; - - // - result = ObjectCreate(chartID, name, OBJ_RECTANGLE_LABEL, 0, 0, 0); - if (!result) - { - return result; - } - - // - ObjectSetInteger(chartID, name, OBJPROP_XDISTANCE, xDis); - ObjectSetInteger(chartID, name, OBJPROP_YDISTANCE, yDis); - ObjectSetInteger(chartID, name, OBJPROP_XSIZE, xSize); - ObjectSetInteger(chartID, name, OBJPROP_YSIZE, ySize); - - // - mName = name; - mChartID = chartID; - - // - return result; - } - - /** - * Add a Name to Object - * @param name: name - */ - void Add(string name) - { - // - // Add a new object by name to the rectangle label and track distances - ArrayResize(mAddedNames, ArraySize(mAddedNames) + 1); - ArrayResize(mAddedXDisDiffrence, ArraySize(mAddedXDisDiffrence) + 1); - ArrayResize(mAddedYDisDiffrence, ArraySize(mAddedYDisDiffrence) + 1); - - // - mAddedNames[ArraySize(mAddedNames) - 1] = name; - mAddedXDisDiffrence[ArraySize(mAddedXDisDiffrence) - 1] = ObjectGetInteger(0, mName, OBJPROP_XDISTANCE) - ObjectGetInteger(0, name, OBJPROP_XDISTANCE); - mAddedYDisDiffrence[ArraySize(mAddedYDisDiffrence) - 1] = ObjectGetInteger(0, mName, OBJPROP_YDISTANCE) - ObjectGetInteger(0, name, OBJPROP_YDISTANCE); - } - - // - // Handlers ... - - /** - * Event Handling for Mouse Movement ... - * @param id: Event ID - * @param lparam: Event parameter of long type - * @param dparam: Event parameter of double type - * @param sparam: Event parameter of string type - */ - void OnEvent( - int id, - long lparam, - double dparam, - string sparam // - ) - { - // - // Handle mouse movement events for dragging the rectangle label - if (id == CHARTEVENT_MOUSE_MOVE) - { - // - int X = (int)lparam; - int Y = (int)dparam; - int MouseState = (int)sparam; - - // - string name = mName; - int XSize = (int)ObjectGetInteger(0, name, OBJPROP_XSIZE); - int YSize = (int)ObjectGetInteger(0, name, OBJPROP_YSIZE); - int XDistance = (int)ObjectGetInteger(0, name, OBJPROP_XDISTANCE); - int YDistance = (int)ObjectGetInteger(0, name, OBJPROP_YDISTANCE); - - // - if (MouseState == 1 && - mPreviousMouseState == 0) - { - // - mlbDownX = X; - mlbDownY = Y; - mlbDownXDistance = XDistance; - mlbDownYDistance = YDistance; - - // - if (X >= XDistance && - Y >= YDistance && - X <= XDistance + XSize && - Y <= YDistance + YSize) - { - mMovingState = true; - } - } - - // - if (mMovingState) - { - // - ChartSetInteger(0, CHART_MOUSE_SCROLL, false); - ObjectSetInteger(0, name, OBJPROP_XDISTANCE, mlbDownXDistance + X - mlbDownX); - ObjectSetInteger(0, name, OBJPROP_YDISTANCE, mlbDownYDistance + Y - mlbDownY); - - // - for (int i = 0; i < ArraySize(mAddedNames); i++) - { - // - ObjectSetInteger(0, mAddedNames[i], OBJPROP_XDISTANCE, mlbDownXDistance + X - mlbDownX - mAddedXDisDiffrence[i]); - ObjectSetInteger(0, mAddedNames[i], OBJPROP_YDISTANCE, mlbDownYDistance + Y - mlbDownY - mAddedYDisDiffrence[i]); - } - - // - ChartRedraw(0); - } - - // - if (MouseState == 0) - { - // - mMovingState = false; - ChartSetInteger(0, CHART_MOUSE_SCROLL, true); - } - - // - mPreviousMouseState = MouseState; - } - } - - // - // Getter(s) / Setter(s) ... - - /** - * Set Object Border Type ... - * - * @param borderType: Specified border type - */ - void BorderType(ENUM_BORDER_TYPE borderType) - { - // - ObjectSetInteger( - mChartID, - mName, - OBJPROP_BORDER_TYPE, - borderType // - ); - } - - /** - * Set Object Background Color - * - * @param value: color - */ - void BGColor(color value) - { - // - ObjectSetInteger( - mChartID, - mName, - OBJPROP_BGCOLOR, - value // - ); - } - - // - // Protected ... - protected: - // - // Private ... - private: - // - // Props ... - - // - // Mouse state tracking variables ... - int mlbDownX; - int mlbDownY; - int mlbDownXDistance; - int mlbDownYDistance; - int mPreviousMouseState; - - // - bool mMovingState; // State for whether the object is moving - - // - string mAddedNames[]; // Array of added names - long mAddedXDisDiffrence[]; // Arrays to store added distance differences - long mAddedYDisDiffrence[]; // Arrays to store added distance differences -}; diff --git a/Classes/XCObjects/x-saherelm.xcobject.class.mq5 b/Classes/XCObjects/x-saherelm.xcobject.class.mq5 deleted file mode 100644 index 4252b2c4..00000000 --- a/Classes/XCObjects/x-saherelm.xcobject.class.mq5 +++ /dev/null @@ -1,116 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Class Library -// -------------------------------------- -// Name: XCObject -// Description: Base Class Of Chart Object Class -// -// -// 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 "../x-saherelm.base.class.mq5" - -// -// Definitions ... - -// -// Implementation ... - -// -// a Button Creation Class ... -class XCObject : XSCBase -{ - // - // Public ... - public: - // - // Constructor(s) ... - void XCObject() - { - mChartID = 0; - } - - // - // Deconstructor ... - void ~XCObject() - { - Destroy(); - } - - /** - * Destroy Class Instance ... - */ - void Destroy() - { - // - mName = NULL; - ObjectDelete(0, mName); - } - - // - // Getter(s) / Setter(s) ... - - /** - * Retrieve Object Name ... - * - * @return ( string ) - */ - string Name() - { - return mName; - } - - /** - * Retrieve Registered Chart ID ... - * - * @return ( long ) - */ - long ChartID() - { - return mChartID; - } - - /** - * Set Object ZOrder ... - * - * @param value: z order - */ - void ZOrder(int value) - { - ObjectSetInteger(0, mName, OBJPROP_ZORDER, value); - } - - /** - * Set Object as Background ... - * - * @param value: boolean value - */ - void AsBackGround(bool value) - { - ObjectSetInteger(0, mName, OBJPROP_BACK, value); - } - - // - // Protected ... - protected: - // - string mName; // Name of Object ... - long mChartID; // Chart ID ... - - // - // Private ... - private: - // -}; diff --git a/Classes/z-saherelm.x-bar.analyser.class.mq5 b/Classes/x-saherelm.x-bar.analyser.class.mq5 similarity index 100% rename from Classes/z-saherelm.x-bar.analyser.class.mq5 rename to Classes/x-saherelm.x-bar.analyser.class.mq5 diff --git a/Classes/x-saherelm.x121.xtrade.handler.class.mq5 b/Classes/x-saherelm.x121.xtrade.handler.class.mq5 deleted file mode 100644 index fb58cbe9..00000000 Binary files a/Classes/x-saherelm.x121.xtrade.handler.class.mq5 and /dev/null differ diff --git a/Classes/x-saherelm.xstrategy.class.mq5 b/Classes/x-saherelm.xstrategy.class.mq5 deleted file mode 100644 index c8cbe531..00000000 --- a/Classes/x-saherelm.xstrategy.class.mq5 +++ /dev/null @@ -1,1689 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Class Library -// -------------------------------------- -// Name: XSCBaseStrategy -// Description: provides all based classes for use ... -// -// -// 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 "../Libraries/x-saherelm.tools.lib.mq5" -#include "../Classes/x-saherelm.xtrade.class.mq5" -#include "../Classes/x-saherelm.xalert.class.mq5" - -// -// Definitions ... - -// -class XSCBaseStrategy : public XSCBaseAlert -{ - // - // Public ... -public: - // - // Constructors ... - void XSCBaseStrategy( - string _symbol, // Trading Symbol - ENUM_TIMEFRAMES _period, // Trading TimeFrame - ENUM_TIMEFRAMES _analizePeriod, // Important Area Detect Time Frame - double _volume, // Voluem - double _r2r, // Risk/Reward Ratio - int _slippage, // Trader Slippage - long _magicNumber, // Trader Magic Number - bool _ignoreSignalExecution = false, // Ignore Signal Execution - bool _useTPSLAsPoint = false, // Converts TP and SL by Provided Points - bool _forceMaxTPSLAsPoint = false, // Force Max TP and SL by Provided Points - double _tpPoint = 0, // TP As Point - double _slPoint = 0, // SL As Point - bool _ignoreTP = false, // TP set to 0 - bool _ignoreSL = false, // SL set to 0 - bool _allowLong = true, - bool _allowShort = true, - int _maxAllowedLongs = 0, - int _maxAllowedShorts = 0 // - ) - { - // - // Fill Properties ... - mR2R = _r2r; - mVolume = _volume; - mSymbol = _symbol; - mPeriod = _period; - mTPPoint = _tpPoint; - mSLPoint = _slPoint; - mIgnoreTP = _ignoreTP; - mIgnoreSL = _ignoreSL; - mSlippage = _slippage; - mAllowLong = _allowLong; - mAllowShort = _allowShort; - mMagicNumber = _magicNumber; - mAnalizePeriod = _analizePeriod; - mUseTPSLAsPoint = _useTPSLAsPoint; - mMaxAllowedLongs = _maxAllowedLongs; - mMaxAllowedShorts = _maxAllowedShorts; - mForceMaxTPSLAsPoint = _forceMaxTPSLAsPoint; - mIgnoreSignalExecution = _ignoreSignalExecution; - - // - mForceDisabled = false; - - // - // Initial Trader Class Instance ... - trader = new XSCTrade( - mSlippage, - mMagicNumber // - ); - - // - // Initial Time Tracker ... - barTracker.Init( - mSymbol, - mPeriod // - ); - - // - SetAlertPrefix(GetTag()); - } - - // - // Deconstructor ... - void ~XSCBaseStrategy() - { - // - delete trader; - - // - Reset(); - } - - // - // Getter and Setter (s) ... - - // - int Slippage() - { - return mSlippage; - } - - // - long MagicNumber() - { - return mMagicNumber; - } - - // - string Symbol() - { - return mSymbol; - } - - // - ENUM_TIMEFRAMES Period() - { - return mPeriod; - } - - // - bool IsDisabled() - { - return mForceDisabled; - } - - // - void Disable() - { - mForceDisabled = true; - } - - // - void Enable() - { - mForceDisabled = false; - } - - // - double Volume() - { - return mVolume; - } - - // - void Volume(double value) - { - // - if (value < 0.01) - { - value = 0.01; - } - - // - mVolume = value; - } - - // - double R2R() - { - return mR2R; - } - - // - bool AllowLong() - { - return mAllowLong; - } - - // - void AllowLong(bool value) - { - mAllowLong = value; - } - - // - bool AllowShort() - { - return mAllowShort; - } - - // - void AllowShort(bool value) - { - mAllowShort = value; - } - - // - int MaxAllowedLongs() - { - return mMaxAllowedLongs; - } - - // - void MaxAllowedLongs(int value) - { - // - if (value < 0) - { - value = 0; - } - - // - mMaxAllowedLongs = value; - } - - // - int MaxAllowedShorts() - { - return mMaxAllowedShorts; - } - - // - void MaxAllowedShorts(int value) - { - // - if (value < 0) - { - value = 0; - } - - // - mMaxAllowedShorts = value; - } - - // - int RequiredPivots() - { - return mRequiredPivots; - } - - // - void RequiredPivots(int value) - { - // - if (value < 3) - { - value = 3; - } - - // - mRequiredPivots = value; - } - - // - int RequiredShoulders() - { - return mRequiredShoulders; - } - - // - void RequiredShoulders(int value) - { - // - if (value < 5) - { - value = 5; - } - - // - mRequiredShoulders = value; - } - - // - bool UseTPSLAsPoint() - { - return mUseTPSLAsPoint; - } - - // - void UseTPSLAsPoint(bool value) - { - mUseTPSLAsPoint = value; - } - - // - bool ForceMaxTPSLAsPoint() - { - return mForceMaxTPSLAsPoint; - } - - // - void ForceMaxTPSLAsPoint(bool value) - { - mForceMaxTPSLAsPoint = value; - } - - // - double TPPoint() - { - return mTPPoint; - } - - // - void TPPoint(double value) - { - // - if (value < 0) - { - value = 0; - } - - // - mTPPoint = value; - } - - // - double SLPoint() - { - return mSLPoint; - } - - // - void SLPoint(double value) - { - // - if (value < 0) - { - value = 0; - } - - // - mSLPoint = value; - } - - // - bool IgnoreTP() - { - return mIgnoreTP; - } - - // - void IgnoreTP(bool value) - { - mIgnoreTP = value; - } - - // - bool IgnoreSL() - { - return mIgnoreSL; - } - - // - void IgnoreSL(bool value) - { - mIgnoreSL = value; - } - - // - bool IgnoreSignalExecution() - { - return mIgnoreSignalExecution; - } - - // - void IgnoreSignalExecution(bool value) - { - mIgnoreSignalExecution = value; - } - - // - // On Signal Handlers ... - void AddSignalEventHandler(TOnSignal handler) - { - // - Add( - handler, - mOnSignalEventHandlers // - ); - } - - // - ENUM_TIMEFRAMES AnalizePeriod() - { - return mAnalizePeriod; - } - - // - void AnalizePeriod(ENUM_TIMEFRAMES value) - { - mAnalizePeriod = value; - } - - // - bool DrawImportantAreas() - { - return mDrawImportantAreas; - } - - // - void DrawImportantAreas(bool value) - { - mDrawImportantAreas = value; - } - - // - // Important Areas Getters ... - - // - bool GetSupport( - XOHCL &bar // - ) - { - // - bool result = false; - - // - bar.Clean(); - - // - result = support.IsValid(); - if (result) - { - bar = support; - } - - // - return result; - } - - // - bool GetResistance( - XOHCL &bar // - ) - { - // - bool result = false; - - // - bar.Clean(); - - // - result = resistance.IsValid(); - if (result) - { - bar = resistance; - } - - // - return result; - } - - // - bool GetBullishOB( - XOHCL &bar // - ) - { - // - bool result = false; - - // - bar.Clean(); - - // - result = bullishOB.IsValid(); - if (result) - { - bar = bullishOB; - } - - // - return result; - } - - // - bool GetBearishOB( - XOHCL &bar // - ) - { - // - bool result = false; - - // - bar.Clean(); - - // - result = bearishOB.IsValid(); - if (result) - { - bar = bearishOB; - } - - // - return result; - } - - // - bool GetBullishFVG( - XOHCL &bar, - double upper, - double lower // - ) - { - // - bool result = false; - - // - upper = 0; - lower = 0; - bar.Clean(); - - // - result = bullishFVG.IsValid(); - if (result) - { - // - bar = bullishFVG; - upper = bullishFVGUpper; - lower = bullishFVGLower; - } - - // - return result; - } - - // - bool GetBearishFVG( - XOHCL &bar, - double upper, - double lower // - ) - { - // - bool result = false; - - // - upper = 0; - lower = 0; - bar.Clean(); - - // - result = bearishFVG.IsValid(); - if (result) - { - // - bar = bearishFVG; - upper = bearishFVGUpper; - lower = bearishFVGLower; - } - - // - return result; - } - - // - bool GetBullishTrend( - XOHCL &bar, - XOHCL &swingHighs[], - XOHCL &swingLows[] // - ) - { - // - bool result = false; - - // - bar.Clean(); - Clean(swingHighs); - Clean(swingLows); - - // - result = bullishTrend.IsValid(); - if (result) - { - // - bar = bullishTrend; - - // - Copy( - bullishTrendSwingHighs, - swingHighs // - ); - Copy( - bullishTrendSwingLows, - swingLows // - ); - } - - // - return result; - } - - // - bool GetBearishTrend( - XOHCL &bar, - XOHCL &swingHighs[], - XOHCL &swingLows[] // - ) - { - // - bool result = false; - - // - bar.Clean(); - Clean(swingHighs); - Clean(swingLows); - - // - result = bearishTrend.IsValid(); - if (result) - { - // - bar = bearishTrend; - - // - Copy( - bearishTrendSwingHighs, - swingHighs // - ); - Copy( - bearishTrendSwingLows, - swingLows // - ); - } - - // - return result; - } - - // - // Virtual Methods ... - - // - // Tag ... - virtual string GetTag() - { - return "XBaseStrategy"; - } - - // - // Check Conditions for Signal ... - // this must be Override based on each Strategy ... - virtual bool HasSignal( - XSignal &signal // - ) - { - return false; - } - - // - // Check Conditions For Signal and Execute Signal ... - virtual void HandleTick() - { - // - if (IsDisabled()) - { - return; - } - - // - if (!AllowLong() && !AllowShort()) - { - return; - } - - // - if (!barTracker.CanProcessBar()) - { - return; - } - - // - MqlTick cTick; - bool hasTick = GetTick( - mSymbol, - cTick // - ); - bool isSameAsLast = cTick.time == lastTick.time; - if (isSameAsLast) - { - return; - } - - // - lastTick = cTick; - - // - XSignal signal; - bool hasSignal = HasSignal(signal); - if (!hasSignal) - { - return; - } - - // - barTracker.Waits(); - - // - Execute(signal); - } - - // - // Handle Signal Execution ... - virtual bool Execute(XSignal &signal) - { - // - bool result = false; - - // - // Prepare and Normalize Signal ... - result = PrepareSignal(signal); - if (!result) - { - return result; - } - - // - // Notify Signal Event Handler(s) ... - NotifyOnSignalEventHandlers(signal); - - // - // Check Signal Execution Enabled or not ... - result = !mIgnoreSignalExecution; - if (!result) - { - return result; - } - - // - bool isLong = IsLong(signal.type); - - // - ENUM_X_SIGNAL_EXECUTION_RESULT state; - result = trader.ExecuteSignal( - signal, - state // - ); - if (result) - { - // - string message = "Execute " + (isLong ? "Long" : "Short") + " " + signal.symbol + "/" + ToString(signal.period) + " ..."; - Alert(message); - - // - OnSignalExecuted(signal); - } - else - { - OnSignalExecutionFailed(signal, state); - } - - // - return result; - } - - // - // Calls When a Signal Executed Successfully ... - virtual void OnSignalExecuted(XSignal &signal) - { - } - - // - // Calls When a Signal Execution Failed ... - virtual void OnSignalExecutionFailed( - XSignal &signal, - ENUM_X_SIGNAL_EXECUTION_RESULT result // - ) - { - } - - // - // Protected ... -protected: - // - int mSlippage; // Trader Slippage - long mMagicNumber; // Trader Magic Number - bool mForceDisabled; // Force Disabled - bool mAllowLong; // Allow Long Signals - bool mAllowShort; // Allow Short Signals - int mMaxAllowedLongs; // Max Allowed Longs - int mMaxAllowedShorts; // Max Allowed Shorts - - // - bool mUseTPSLAsPoint; // Converts TP and SL by Provided Points - bool mForceMaxTPSLAsPoint; // Force Max TP and SL by Provided Points - double mTPPoint; // TP As Point - double mSLPoint; // SL As Point - bool mIgnoreTP; // TP set to 0 - bool mIgnoreSL; // SL set to 0 - bool mIgnoreSignalExecution; // Ignore Signal Execution - - // - string mSymbol; // Trading Symbol ... - ENUM_TIMEFRAMES mPeriod; // Trading TimeFrame ... - - // - double mR2R; // Risk/Rewar Ratio ... - double mVolume; // Static Volume Per Trades ... - - // - XBarTracker barTracker; // Strategy Time Tracker ... - - // - // Trend Detecting ... - int mRequiredPivots; // Required Pivots For Trend Detecting ... - int mRequiredShoulders; // Required Pivots Shoulders ... - - // - XSCTrade *trader; - - // - MqlTick lastTick; - - // - void Reset() - { - barTracker.Clean(); - } - - // - // Prepare and Normalize Signal for Execution in Strategy ... - bool PrepareSignal(XSignal &signal) - { - // - bool result = false; - - // - // Check Strategy Is Enables ... - result = !IsDisabled(); - if (!result) - { - return result; - } - - // - // Validate Signal ... - result = signal.IsValid(); - if (!result) - { - return result; - } - - // - bool isLong = IsLong(signal.type); - - // - // Check Type Enabled ... - result = - // - isLong - ? AllowLong() - : AllowShort() - // - ; - if (!result) - { - return result; - } - - // - // Check Max Allowed Trades Limitation ... - if ( - (isLong && MaxAllowedLongs() > 0) || - (!isLong && MaxAllowedShorts() > 0)) - { - // - // Here We Have to Count Positions ... - - // - // Get and Count Positions ... - XPosition longs[]; - XPosition shorts[]; - trader.GetPositions( - longs, - shorts, - signal.symbol // - ); - - // - int longsCount = ArraySize(longs); - int shortsCount = ArraySize(shorts); - - // - result = - // - isLong - ? longsCount < MaxAllowedLongs() - : shortsCount < MaxAllowedShorts() - // - ; - if (!result) - { - return result; - } - } - - // - // Check TP and SL ... - double points = GetPoints(signal.symbol); - if (mUseTPSLAsPoint) - { - // - double sl = 0; - double tp = 0; - bool isCalculated = !(mSLPoint > 0 || mTPPoint > 0) - ? false - : CalculateTPSLByPoint( - sl, - tp, - signal.type, - signal.entry, - points, - mR2R, - mSLPoint, - mTPPoint // - ); - if (isCalculated) - { - // - signal.sl = sl; - signal.tp = tp; - } - } - else if (mForceMaxTPSLAsPoint) - { - // - if (mSLPoint > 0) - { - // - double risk = signal.GetRisk(); - double riskPoints = risk / points; - - // - if (riskPoints > mSLPoint) - { - // - signal.sl = - isLong - ? signal.entry - (mSLPoint * points) - : signal.entry + (mSLPoint * points); - } - } - - // - if (mTPPoint > 0) - { - // - double reward = signal.GetReward(); - double rewardPoints = reward / points; - - // - if (rewardPoints > mTPPoint) - { - // - signal.tp = - isLong - ? signal.entry + (mTPPoint * points) - : signal.entry - (mTPPoint * points); - } - } - } - - // - if (mIgnoreTP) - { - signal.tp = 0; - } - - // - if (mIgnoreSL) - { - signal.sl = 0; - } - - // - return result; - } - - // - // Notified Signal Event Handler(s) ... - void NotifyOnSignalEventHandlers(XSignal &signal) - { - // - if (!signal.IsValid()) - { - return; - } - - // - int count = ArraySize(mOnSignalEventHandlers); - if (!IsValidSize(count)) - { - return; - } - - // - for (int i = 0; i < count; i++) - { - mOnSignalEventHandlers[i](signal); - } - } - - // - ENUM_TIMEFRAMES mAnalizePeriod; // Important Area Detect Time Frame - bool mDrawImportantAreas; // Draw Important Areas where Founded in Analyzing Time Frame - - // - XOHCL support; - XOHCL resistance; - XOHCL bullishOB; - XOHCL bearishOB; - - // - double bullishFVGUpper; - double bullishFVGLower; - XOHCL bullishFVG; - - // - double bearishFVGUpper; - double bearishFVGLower; - XOHCL bearishFVG; - - // - XOHCL bullishTrendSwingHighs[]; - XOHCL bullishTrendSwingLows[]; - XOHCL bullishTrend; - - // - XOHCL bearishTrendSwingHighs[]; - XOHCL bearishTrendSwingLows[]; - XOHCL bearishTrend; - - // - void DetectImportantAreas() - { - // - int zIndex = 0; - int cIndex = zIndex + 1; - - // - // Last Bar ... - XOHCL cBar; - bool result = cBar.Init( - mSymbol, - mPeriod, - cIndex // - ); - if (!result) - { - return; - } - - // - // Analyzing Bar ... - XOHCL aBar; - if (IsValid(mAnalizePeriod)) - { - // - result = aBar.Init( - mSymbol, - mAnalizePeriod, - cIndex // - ); - - // - if (!result) - { - return; - } - } - else - { - aBar = cBar; - } - - // - // Support nad Resistance ... - - // - // Check Support Exists or Find ... - bool hasSupport = support.IsValid(); - if (!hasSupport) - { - // - hasSupport = - // - aBar.HasSupport(support) - // - ; - - // - if (hasSupport) - { - // - if (mDrawImportantAreas) - { - // - DrawSupport( - support, - ChartID() // - ); - } - - // - supportTime = aBar.time; - } - } - - // - // Check Resistance Exists or Find ... - bool hasResistance = resistance.IsValid(); - if (!hasResistance) - { - // - hasResistance = - // - aBar.HasResistance(resistance) - // - ; - - // - if (hasResistance) - { - // - if (mDrawImportantAreas) - { - // - DrawResistance( - resistance, - ChartID() // - ); - } - - // - resistanceTime = aBar.time; - } - } - - // - // Order Blocks ... - - // - bool hasBullishOB = bullishOB.IsValid(); - if (!hasBullishOB) - { - // - hasBullishOB = - // - aBar.HasBullishOrderBlock(bullishOB) - // - ; - - // - if (hasBullishOB) - { - // - if (mDrawImportantAreas) - { - // - DrawBullishOrderBlock( - bullishOB, - ChartID() // - ); - } - - // - bullishOBTime = aBar.time; - } - } - - // - bool hasBearishOB = bearishOB.IsValid(); - if (!hasBearishOB) - { - // - hasBearishOB = - // - aBar.HasBearishOrderBlock(bearishOB) - // - ; - - // - if (hasBearishOB) - { - // - if (mDrawImportantAreas) - { - // - DrawBearishOrderBlock( - bearishOB, - ChartID() // - ); - } - - // - bearishOBTime = aBar.time; - } - } - - // - // FVG ... - - // - bool hasBullishFVG = bullishFVG.IsValid(); - if (!hasBullishFVG) - { - // - hasBullishFVG = - // - aBar.HasBullishFVG( - bullishFVGUpper, - bullishFVGLower // - ) - // - ; - - // - if (hasBullishFVG) - { - // - bullishFVG = aBar; - - // - if (mDrawImportantAreas) - { - // - DrawBullishFVG( - bullishFVG, - bullishFVGUpper, - bullishFVGLower, - ChartID() // - ); - } - - // - bullishFVGTime = aBar.time; - } - } - - // - bool hasBearishFVG = bearishFVG.IsValid(); - if (!hasBearishFVG) - { - // - hasBearishFVG = - // - aBar.HasBearishFVG( - bearishFVGUpper, - bearishFVGLower // - ) - // - ; - - // - if (hasBearishFVG) - { - // - bearishFVG = aBar; - - // - if (mDrawImportantAreas) - { - // - DrawBearishFVG( - bearishFVG, - bearishFVGUpper, - bearishFVGLower, - ChartID() // - ); - } - - // - bearishFVGTime = aBar.time; - } - } - - // - // TREND ... - - // - bool hasBullishTrend = bullishTrend.IsValid(); - if (!hasBullishTrend) - { - // - hasBullishTrend = aBar.HasBullishTrend( - bullishTrendSwingHighs, - bullishTrendSwingLows, - false // - ); - - // - if (hasBullishTrend) - { - // - bullishTrend = aBar; - - // - if (mDrawImportantAreas) - { - // - DrawBullishTrend( - bullishTrend, - bullishTrendSwingHighs, - bullishTrendSwingLows, - ChartID() // - ); - } - } - } - - // - bool hasBearishTrend = bearishTrend.IsValid(); - if (!hasBearishTrend) - { - // - hasBearishTrend = aBar.HasBearishTrend( - bearishTrendSwingHighs, - bearishTrendSwingLows, - false // - ); - - // - if (hasBearishTrend) - { - // - bearishTrend = aBar; - - // - if (mDrawImportantAreas) - { - // - DrawBearishTrend( - bearishTrend, - bearishTrendSwingHighs, - bearishTrendSwingLows, - ChartID() // - ); - } - } - } - - // - } - - // - void DestroyImportantAreas() - { - // - bool hasSupport = support.IsValid(); - if (hasSupport) - { - // - supportTime = NULL; - isSupportTested = false; - RemoveSupport(support); - support.Clean(); - } - - // - bool hasResistance = resistance.IsValid(); - if (hasResistance) - { - // - resistanceTime = NULL; - isResistanceTested = false; - RemoveResistance(resistance); - resistance.Clean(); - } - - // - bool hasBullishOB = bullishOB.IsValid(); - if (hasBullishOB) - { - // - bullishOBTime = NULL; - RemoveBullishOrderBlock(bullishOB); - bullishOB.Clean(); - } - - // - bool hasBearishOB = bearishOB.IsValid(); - if (hasBearishOB) - { - // - bearishOBTime = NULL; - RemoveBearishOrderBlock(bearishOB); - bearishOB.Clean(); - } - - // - bool hasBullishFVG = bullishFVG.IsValid(); - if (hasBullishFVG) - { - // - bullishFVGUpper = 0; - bullishFVGLower = 0; - bullishFVGTime = NULL; - RemoveBullishFVG(bullishFVG); - bullishFVG.Clean(); - } - - // - bool hasBearishFVG = bearishFVG.IsValid(); - if (hasBearishFVG) - { - // - bearishFVGUpper = 0; - bearishFVGLower = 0; - bearishFVGTime = NULL; - RemoveBullishFVG(bearishFVG); - bearishFVG.Clean(); - } - - // - bool hasBullishTrend = bullishTrend.IsValid(); - if (hasBullishTrend) - { - // - RemoveBullishTrend(bullishTrend); - bullishTrend.Clean(); - } - - // - bool hasBearishTrend = bearishTrend.IsValid(); - if (hasBearishTrend) - { - // - RemoveBearishTrend(bearishTrend); - bearishTrend.Clean(); - } - } - - // - void CheckImportantAreasValidation() - { - // - CheckSupportValidation(); - CheckResistanceValidation(); - - // - CheckBullishOBValidation(); - CheckBearishOBValidation(); - - // - CheckBullishFVGValidation(); - CheckBearishFVgValidation(); - - // - CheckBullishTrendValidation(); - CheckBearishTrendValidation(); - } - - // - bool isSupportTested; - datetime supportTime; - void CheckSupportValidation() - { - // - if (!isSupportTested) - { - // - if (support.IsValid() && IsValid(supportTime)) - { - // - int age = (int)(((int)(TimeToSeconds(TimeCurrent()) - TimeToSeconds(supportTime))) / PeriodSeconds(mPeriod)); - if (age >= 50) - { - // - isSupportTested = false; - supportTime = NULL; - RemoveSupport(support); - support.Clean(); - } - } - return; - } - - // - XOHCL cBar; - bool isInited = cBar.Init( - mSymbol, - mPeriod, - 1 // - ); - if (!isInited) - { - return; - } - - // - double points = GetPoints(mSymbol); - - // - // Find Price Distance ... - double highDiff = MathAbs(cBar.high - support.high); - double lowDiff = MathAbs(cBar.low - support.high); - - // - bool isBreaked = MathMax(highDiff, lowDiff) >= 100 * points; - if (!isBreaked) - { - return; - } - - // - isSupportTested = false; - RemoveSupport(support); - supportTime = NULL; - support.Clean(); - } - - // - bool isResistanceTested; - datetime resistanceTime; - void CheckResistanceValidation() - { - // - if (!isResistanceTested) - { - // - if (resistance.IsValid() && IsValid(resistanceTime)) - { - // - int age = (int)(((int)(TimeToSeconds(TimeCurrent()) - TimeToSeconds(resistanceTime))) / PeriodSeconds(mPeriod)); - if (age >= 50) - { - // - isResistanceTested = false; - resistanceTime = NULL; - RemoveResistance(resistance); - resistance.Clean(); - } - } - return; - } - - // - XOHCL cBar; - bool isInited = cBar.Init( - mSymbol, - mPeriod, - 1 // - ); - if (!isInited) - { - return; - } - - // - double points = GetPoints(mSymbol); - - // - // Find Price Distance ... - double highDiff = MathAbs(cBar.high - resistance.low); - double lowDiff = MathAbs(cBar.low - resistance.low); - - // - bool isBreaked = MathMax(highDiff, lowDiff) >= 100 * points; - if (!isBreaked) - { - return; - } - - // - isResistanceTested = false; - RemoveResistance(resistance); - resistanceTime = NULL; - resistance.Clean(); - } - - // - datetime bullishOBTime; - void CheckBullishOBValidation() - { - // - if (!IsValid(bullishOBTime)) - { - return; - } - - // - int age = (int)(((int)(TimeToSeconds(TimeCurrent()) - TimeToSeconds(bullishOBTime))) / PeriodSeconds(mPeriod)); - if (age >= 50) - { - // - bullishOBTime = NULL; - RemoveBullishOrderBlock(bullishOB); - bullishOB.Clean(); - } - } - - // - datetime bearishOBTime; - void CheckBearishOBValidation() - { - // - if (!IsValid(bearishOBTime)) - { - return; - } - - // - int age = (int)(((int)(TimeToSeconds(TimeCurrent()) - TimeToSeconds(bearishOBTime))) / PeriodSeconds(mPeriod)); - if (age >= 50) - { - // - bearishOBTime = NULL; - RemoveBearishOrderBlock(bearishOB); - bearishOB.Clean(); - } - } - - // - datetime bullishFVGTime; - void CheckBullishFVGValidation() - { - // - if (!IsValid(bullishFVGTime)) - { - return; - } - - // - int age = (int)(((int)(TimeToSeconds(TimeCurrent()) - TimeToSeconds(bullishFVGTime))) / PeriodSeconds(mPeriod)); - if (age >= 50) - { - // - bullishFVGTime = NULL; - RemoveBullishFVG(bullishFVG); - bullishFVG.Clean(); - } - } - - // - datetime bearishFVGTime; - void CheckBearishFVgValidation() - { - // - if (!IsValid(bearishFVGTime)) - { - return; - } - - // - int age = (int)(((int)(TimeToSeconds(TimeCurrent()) - TimeToSeconds(bearishFVGTime))) / PeriodSeconds(mPeriod)); - if (age >= 50) - { - // - bearishFVGTime = NULL; - RemoveBearishFVG(bearishFVG); - bearishFVG.Clean(); - } - } - - // - void CheckBullishTrendValidation() - { - // - // TODO: Complete this ... - } - - // - void CheckBearishTrendValidation() - { - // - // TODO: Complete this ... - } - - // - // Private ... -private: - // - // Props ... - - // - // On Signal Recieved Event Handler(s) ... - TOnSignal mOnSignalEventHandlers[]; -}; - -// \ No newline at end of file diff --git a/Classes/x-saherelm.zone.class.mq5 b/Classes/x-saherelm.zone.class.mq5 deleted file mode 100644 index 5951af81..00000000 --- a/Classes/x-saherelm.zone.class.mq5 +++ /dev/null @@ -1,79 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Class Library -// ---------------------------------------------- -// Name: XSCZone -// Description: provides all Zone 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 -#include "../Libraries/x-saherelm.common.lib.mq5" - -// -// Specific Zone ... -class XSCZone : public CObject -{ - // - // Public ... -public: - // - // Props ... - double high; - double low; - int ticks; - double percent; - - // - ENUM_TIMEFRAMES period; - datetime start; - datetime end; - - // - // Compare Two Zone With Each Other ... - virtual int Compare( - const CObject *node, - const int mode = 0 // - ) const - { - // - const XSCZone *other = (XSCZone *)node; - - // - return other.ticks - ticks; - } - - // - // Props ... - string GetTag() { - // - string result = ""; - - // - result = "XZ_" + ToString(period) + "_" + ToString(start); - - // - return result; - } - - // - // Protected ... -protected: - // - // Private ... -private: -}; diff --git a/Classes/z-saherelm.x-bar.analyser.class_@!!@.mq5 b/Classes/z-saherelm.x-bar.analyser.class_@!!@.mq5 deleted file mode 100644 index c2086a13..00000000 --- a/Classes/z-saherelm.x-bar.analyser.class_@!!@.mq5 +++ /dev/null @@ -1,1363 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Class Library -// -------------------------------------- -// Name: XPOI -// Description: Bar Analysing ... -// -// 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.base.class.mq5" -#include "../Libraries/x-saherelm.x-poi.lib.mq5" - -// -// Definitions ... - -// -// Implementations ... -class XCBarAnalyser : public XSCBase -{ - // - public: - // - - // - // Constructor(s) ... - void XCBarAnalyser() - { - } - - // - // Deconstructor ... - void ~XCBarAnalyser() - { - } - - // - // Getter(s) / Setter(s) ... - - // - // Providers ... - - // - // Actions ... - - // - // Commons ... - - /** - * Check Specified Bar's Range is Extended or not ... - * - * @param bar: XOHCL instance, Specified Bar ... - * @param loopback: Integer, Loopback Length ... - * - * @return ( bool ) - */ - bool HasExtendedRange( - XOHCL &bar, - int loopback = 3 // - ) - { - // - bool result = false; - - // - if (loopback < 3) - { - loopback = 3; - } - - // - result = bar.IsValid(); - if (!result) - { - return result; - } - - // - int index = bar.Index(); - int start = index + 1; - int end = start + loopback; - int count = end - start; - result = count >= 1; - if (!result) - { - return result; - } - - // - double sum = 0; - XOHCL iBar = bar; - for (int i = start; i < end; i++) - { - // - bool isRetrieved = iBar.GetPreviousBar(iBar); - if (!isRetrieved) - { - continue; - } - - // - sum += iBar.GetRange(); - } - - // - result = sum > 0; - if (!result) - { - return result; - } - - // - double avg = sum / count; - - // - result = bar.GetRange() >= avg; - - // - return result; - } - - /** - * Check Specified Bar's Body is Extended or not ... - * - * @param bar: XOHCL instance, Specified Bar ... - * @param loopback: Integer, Loopback Length ... - * - * @return ( bool ) - */ - bool HasExtendedBody( - XOHCL &bar, - int loopback = 3 // - ) - { - // - bool result = false; - - // - if (loopback < 3) - { - loopback = 3; - } - - // - result = bar.IsValid(); - if (!result) - { - return result; - } - - // - int index = bar.Index(); - int start = index + 1; - int end = start + loopback; - int count = end - start; - result = count >= 1; - if (!result) - { - return result; - } - - // - double sum = 0; - XOHCL iBar = bar; - for (int i = start; i < end; i++) - { - // - bool isRetrieved = iBar.GetPreviousBar(iBar); - if (!isRetrieved) - { - continue; - } - - // - sum += iBar.GetBody(); - } - - // - result = sum > 0; - if (!result) - { - return result; - } - - // - double avg = sum / count; - - // - result = bar.GetBody() >= avg; - - // - return result; - } - - /** - * Check Specified Bar's Body and Range is Extended or not ... - * - * @param bar: XOHCL instance, Specified Bar ... - * @param loopback: Integer, Loopback Length ... - * - * @return ( bool ) - */ - bool IsExtended( - XOHCL &bar, - int loopback = 3 // - ) - { - // - bool result = false; - - // - bool hasExtendedBody = HasExtendedBody(bar, loopback); - bool hasExtendedRange = HasExtendedRange(bar, loopback); - result = hasExtendedBody && - hasExtendedRange; - - // - return result; - } - - /** - * Converts an Specified Bar to Zone ... - * - * @param bar: XOHCL instance, Specified Bar ... - * @param zone: XZone instance, Converted Zone Reference ... - * @param dir: ENUM_X_DIRECTION member, Specified Bar Type to Convertion ... - * - * @return ( bool ) - */ - bool ToZone( - XOHCL &bar, - XZone &zone, - ENUM_X_DIRECTION dir = X_DIRECTION_BULLISH // - ) - { - // - bool result = false; - - // - zone.Clean(); - - // - result = bar.IsValid() && - (dir == X_DIRECTION_BULLISH || - dir == X_DIRECTION_BEARISH); - if (!result) - { - return result; - } - - // - bool isBullish = dir == X_DIRECTION_BULLISH; - - // - zone.from = bar.time; - zone.to = TimeCurrent(); - zone.prefix = "XBarZone"; - - // - zone.upper = isBullish - ? bar.high - : bar.GetDown(); - - // - zone.lower = isBullish - ? bar.GetUp() - : bar.low; - - // - result = zone.IsValid(); - - // - return result; - } - - // - // Regular ... - - /** - * Check a Zone is Rejected in Specified Direction or not ... - * - * @param bar: XOHCL instance, Specified Bar ... - * @param zone: XZone instance, Specified Zone ... - * @param dir: ENUM_X_DIRECTION member, Specified Rejection Direction ... - * - * @return ( bool ) - */ - bool IsRejected( - XOHCL &bar, - XZone &zone, - ENUM_X_DIRECTION dir // - ) - { - // - bool result = false; - - // - result = bar.IsValid() && - zone.IsValid() && - (dir == X_DIRECTION_BULLISH || - dir == X_DIRECTION_BEARISH); - if (!result) - { - return result; - } - - // - bool isBullish = dir == X_DIRECTION_BULLISH; - - // - ENUM_X_DIRECTION rejectionDir; - bool isRejection = IsRejectionBar( - rejectionDir, - bar, - 40 // - ); - bool isBullishRejection = isRejection && - rejectionDir == X_DIRECTION_BULLISH; - bool isBearishRejection = isRejection && - rejectionDir == X_DIRECTION_BEARISH; - - // - result = isRejection && - rejectionDir == dir && - (isBullishRejection - ? bar.low < zone.upper && - bar.low > zone.lower - : bar.high > zone.lower && - bar.high < zone.upper); - - // - return result; - } - - /** - * Check a Zone is Breaked in Specified Direction or not ... - * - * @param bar: XOHCL instance, Specified Bar ... - * @param zone: XZone instance, Specified Zone ... - * @param dir: ENUM_X_DIRECTION member, Specified Rejection Direction ... - * - * @return ( bool ) - */ - bool IsBreaked( - XOHCL &bar, - XZone &zone, - ENUM_X_DIRECTION dir, - bool forceBody = true // - ) - { - // - bool result = false; - - // - result = bar.IsValid() && - zone.IsValid() && - (dir == X_DIRECTION_BULLISH || - dir == X_DIRECTION_BEARISH); - if (!result) - { - return result; - } - - // - bool isBullish = dir == X_DIRECTION_BULLISH; - - // - ENUM_X_DIRECTION momentumDir; - bool isMomentum = IsMomentumBar( - momentumDir, - bar, - 50 // - ); - bool isBullishBreaked = isMomentum && - momentumDir == X_DIRECTION_BULLISH; - bool isBearishBreaked = isMomentum && - momentumDir == X_DIRECTION_BEARISH; - - // - result = isMomentum && - momentumDir == dir && - (isBullishBreaked - ? bar.IsBullish() && - bar.low < zone.lower && - bar.high > zone.upper - : bar.IsBearish() && - bar.high > zone.lower && - bar.low < zone.lower); - if (result && - forceBody) - { - // - result = isBullishBreaked - ? bar.IsBullish() && - bar.GetUp() > zone.upper && - bar.GetDown() < zone.lower - : bar.IsBearish() && - bar.GetUp() > zone.upper && - bar.GetDown() < zone.lower; - } - - // - return result; - } - - // - // Rejection Bar ... - - /** - * Check Specific Bar is Rejection Bar or not ... - * - * @param dir: ENUM_X_DIRECTION member, Specified Direction ... - * @param bar: XOHCL instance, Specified Bar ... - * @param strength: Double, Specified Shadow Percent Range ... - * - * @return ( bool ) - */ - bool IsRejectionBar( - ENUM_X_DIRECTION &dir, - XOHCL &bar, - double strength // - ) - { - // - bool result = false; - - // - if (strength < 20) - { - strength = 20; - } - - // - dir = X_DIRECTION_NONE; - - // - result = bar.IsValid(); - if (!result) - { - return result; - } - - // - double barLowShadow = bar.GetLowShadow(); - double barHighShadow = bar.GetHighShadow(); - double barRange = bar.GetRange(); - double barRangePercent = barRange / 100; - - // - bool isBullishRejectionBar = - barLowShadow > barHighShadow && - barLowShadow > barRangePercent * 40; - - // - bool isBearishRejectionBar = - barHighShadow > barLowShadow && - barHighShadow > barRangePercent * 40; - - // - result = isBullishRejectionBar || - isBearishRejectionBar; - if (result) - { - // - dir = isBullishRejectionBar - ? X_DIRECTION_BULLISH - : X_DIRECTION_BEARISH; - } - - // - return result; - } - - /** - * Check Specific Bar is Bullish Rejection Bar or not ... - * - * @param bar: XOHCL instance, Specified Bar ... - * @param strength: Double, Specified Shadow Percent Range ... - * - * @return ( bool ) - */ - bool IsBullishRejectionBar( - XOHCL &bar, - double strength = 40 // - ) - { - // - bool result = false; - - // - ENUM_X_DIRECTION dir; - result = IsRejectionBar( - dir, - bar, - strength // - ); - result = - result && - dir == X_DIRECTION_BULLISH; - - // - return result; - } - - /** - * Check Specific Bar is Bearish Rejection Bar or not ... - * - * @param bar: XOHCL instance, Specified Bar ... - * @param strength: Double, Specified Shadow Percent Range ... - * - * @return ( bool ) - */ - bool IsBearishRejectionBar( - XOHCL &bar, - double strength = 40 // - ) - { - // - bool result = false; - - // - ENUM_X_DIRECTION dir; - result = IsRejectionBar( - dir, - bar, - strength // - ); - result = - result && - dir == X_DIRECTION_BEARISH; - - // - return result; - } - - // - // Momentum Bar ... - - /** - * Check Specific Bar is Momentum Bar or not ... - * - * @param dir: ENUM_X_DIRECTION member, Specified Direction ... - * @param bar: XOHCL instance, Specified Bar ... - * @param strength: Double, Specified Shadow Percent Range ... - * - * @return ( bool ) - */ - bool IsMomentumBar( - ENUM_X_DIRECTION &dir, - XOHCL &bar, - double strength // - ) - { - // - bool result = false; - - // - if (strength < 50) - { - strength = 50; - } - - // - dir = X_DIRECTION_NONE; - - // - double rangePercent = GetBarRangePercent(bar); - bool isStrong = bar.GetBody() > rangePercent * strength; - - // - result = isStrong; - if (result) - { - // - dir = bar.IsBullish() - ? X_DIRECTION_BULLISH - : X_DIRECTION_BEARISH; - } - - // - return result; - } - - /** - * Check Specific Bar is Bullish Momentum Bar or not ... - * - * @param bar: XOHCL instance, Specified Bar ... - * @param strength: Double, Specified Shadow Percent Range ... - * - * @return ( bool ) - */ - bool IsBullishMomentumBar( - XOHCL &bar, - double strength = 40 // - ) - { - // - bool result = false; - - // - ENUM_X_DIRECTION dir; - result = IsMomentumBar( - dir, - bar, - strength // - ); - result = - result && - dir == X_DIRECTION_BULLISH; - - // - return result; - } - - /** - * Check Specific Bar is Bearish Momentum Bar or not ... - * - * @param bar: XOHCL instance, Specified Bar ... - * @param strength: Double, Specified Shadow Percent Range ... - * - * @return ( bool ) - */ - bool IsBearishMomentumBar( - XOHCL &bar, - double strength = 40 // - ) - { - // - bool result = false; - - // - ENUM_X_DIRECTION dir; - result = IsMomentumBar( - dir, - bar, - strength // - ); - result = - result && - dir == X_DIRECTION_BEARISH; - - // - return result; - } - - // - // Engulfing ... - - /** - * Check Bar is Engulfed or not ... - * - * @param dir: ENUM_X_DIRECTION member, Specified Direction ... - * @param bar: XOHCL instance, Speciied Bar ... - * @param loopback: Integer, loopback Length ... - * - * @return ( bool ) - */ - bool IsEngulfed( - ENUM_X_DIRECTION &dir, - XOHCL &bar, - int loopback // - ) - { - // - bool result = false; - - // - dir = X_DIRECTION_NONE; - - // - int hhIDX = 0; - double hh = 0; - - // - int llIDX = 0; - double ll = 0; - - // - result = CalculateLoopbackHLData( - hhIDX, - hh, - llIDX, - ll, - bar, - loopback // - ); - if (!result) - { - return result; - } - - // - result = bar.GetDown() < ll && - bar.GetUp() > hh; - if (result) - { - // - dir = bar.IsBullish() - ? X_DIRECTION_BULLISH - : X_DIRECTION_BEARISH; - } - - // - return result; - } - - /** - * Check Bar is Bullish Engulfed or not ... - * - * @param bar: XOHCL instance, Speciied Bar ... - * @param loopback: Integer, loopback Length ... - * - * @return ( bool ) - */ - bool IsBullishEngulfed( - XOHCL &bar, - int loopback = 2 // - ) - { - // - bool result = false; - - // - ENUM_X_DIRECTION dir; - result = IsEngulfed( - dir, - bar, - loopback // - ); - result = - result && - dir == X_DIRECTION_BULLISH; - - // - return result; - } - - /** - * Check Bar is Bearish Engulfed or not ... - * - * @param bar: XOHCL instance, Speciied Bar ... - * @param loopback: Integer, loopback Length ... - * - * @return ( bool ) - */ - bool IsBearishEngulfed( - XOHCL &bar, - int loopback = 2 // - ) - { - // - bool result = false; - - // - ENUM_X_DIRECTION dir; - result = IsEngulfed( - dir, - bar, - loopback // - ); - result = - result && - dir == X_DIRECTION_BEARISH; - - // - return result; - } - - // - // Bar CHOCH ... - - /** - * Check Specified Bar Has CHOCH or not ... - * - * @param dir: ENUM_X_DIRECTION member, Specified Direction ... - * @param bar: XOHCL instance, Speciied Bar ... - * @param loopback: Integer, loopback Length ... - * @param forceBody: Boolean, Specified Choch Happens only by Bar's Body ... - * - * @return ( bool ) - */ - bool HasCHOCH( - ENUM_X_DIRECTION &dir, - XOHCL &bar, - int loopback = 2, - bool forceBody = false // - ) - { - // - bool result = false; - - // - dir = X_DIRECTION_NONE; - - // - if (loopback < 1) - { - loopback = 1; - } - - // - result = bar.IsValid(); - if (!result) - { - return result; - } - - // - string symbol = bar.symbol; - ENUM_TIMEFRAMES period = bar.period; - - // - // Calculate Loopback Data ... - int index = -1; - int start = -1; - int end = -1; - int count = -1; - result = CalculateLoopBackData( - index, - start, - end, - count, - bar, - loopback // - ); - if (!result) - { - return result; - } - - // - // Calculate Loopback HH and LL Data ... - int hhIDX = -1; - double hh = -1; - int llIDX = -1; - double ll = -1; - result = CalculateLoopbackHLData( - hhIDX, - hh, - llIDX, - ll, - bar, - loopback // - ); - if (!result) - { - return result; - } - - // - bool isBullishDirection = - bar.high > hh && - bar.low > ll; - bool isBearishDirection = - bar.high < hh && - bar.low < ll; - result = isBullishDirection || - isBearishDirection; - if (!result) - { - return result; - } - - // - if (forceBody) - { - // - isBullishDirection = - bar.GetUp() > hh && - bar.GetDown() > ll; - isBearishDirection = - bar.GetUp() < hh && - bar.GetDown() < ll; - result = isBullishDirection || - isBearishDirection; - if (!result) - { - return result; - } - } - - // - // Check Bar's Direction in related to CHOCH Direction ... - result = - isBullishDirection - ? bar.IsBullish() - : bar.IsBearish(); - if (!result) - { - return result; - } - - // - // Set Direction ... - dir = - isBullishDirection - ? X_DIRECTION_BULLISH - : X_DIRECTION_BEARISH; - - // - // Check Loopback End Bar ... - XOHCL endBar; - result = endBar.Init( - symbol, - period, - end - 1 // - ); - if (!result) - { - return result; - } - - // - // End Bar Must be InDirect by Specified Bar ... - result = - isBullishDirection - ? endBar.IsBearish() - : endBar.IsBullish(); - - // - // Check Loopback for Directional Bars ... - - // - return result; - } - - /** - * Check Specified Bar Has Bullish CHOCH or not ... - * - * @param bar: XOHCL instance, Speciied Bar ... - * @param loopback: Integer, loopback Length ... - * @param forceBody: Boolean, Specified Choch Happens only by Bar's Body ... - * - * @return ( bool ) - */ - bool HasBullishCHOCH( - XOHCL &bar, - int loopback = 2, - bool forceBody = false // - ) - { - // - bool result = false; - - // - ENUM_X_DIRECTION dir; - result = HasCHOCH( - dir, - bar, - loopback, - forceBody // - ); - result = - result && - dir == X_DIRECTION_BULLISH; - - // - return result; - } - - /** - * Check Specified Bar Has Bearish CHOCH or not ... - * - * @param bar: XOHCL instance, Speciied Bar ... - * @param loopback: Integer, loopback Length ... - * @param forceBody: Boolean, Specified Choch Happens only by Bar's Body ... - * - * @return ( bool ) - */ - bool HasBearishCHOCH( - XOHCL &bar, - int loopback = 2, - bool forceBody = false // - ) - { - // - bool result = false; - - // - ENUM_X_DIRECTION dir; - result = HasCHOCH( - dir, - bar, - loopback, - forceBody // - ); - result = - result && - dir == X_DIRECTION_BEARISH; - - // - return result; - } - - // - // Directions ... - - /** - * Check Specified Bar Possible Direction Pressure ... - * - * @param dir: ENUM_X_DIRECTION member ... - * @param bar: XOHCL instance, Specified Bar ... - * - * @return ( bool ) - */ - bool HasDirection( - ENUM_X_DIRECTION &dir, - XOHCL &bar // - ) - { - // - bool result = false; - - // - dir = X_DIRECTION_NONE; - - // - result = bar.IsValid(); - if (!result) - { - return result; - } - - // - // Check Bar isExtended or not ... - bool isExtended = IsExtended( - bar, - 3 // - ); - - // - // Check Rejection ... - ENUM_X_DIRECTION rejectionDir; - bool isRejection = IsRejectionBar(rejectionDir, bar, 40); - bool isBullishRejection = isRejection && - rejectionDir == X_DIRECTION_BULLISH; - bool isBearishRejection = isRejection && - rejectionDir == X_DIRECTION_BEARISH; - - // - // Check Momentum ... - ENUM_X_DIRECTION momentumDir; - bool isMomentum = IsMomentumBar(momentumDir, bar, 40); - bool isBullisMomentumn = isMomentum && - momentumDir == X_DIRECTION_BULLISH; - bool isBearishMomentum = isMomentum && - momentumDir == X_DIRECTION_BEARISH; - - // - // Check Engulfing ... - ENUM_X_DIRECTION engulfDir; - bool isEngulfed = IsEngulfed( - engulfDir, - bar, - 2 // - ); - bool isBullishEngulfed = isEngulfed && - engulfDir == X_DIRECTION_BULLISH; - bool isBearishEngulfed = isEngulfed && - engulfDir == X_DIRECTION_BEARISH; - - // - // Check CHOCH ... - ENUM_X_DIRECTION chochDir; - bool hasCHOCH = HasCHOCH( - chochDir, - bar, - 2, - false // - ); - bool hasBullishCHOCH = hasCHOCH && - chochDir == X_DIRECTION_BULLISH; - bool hasBearishCHOCH = hasCHOCH && - chochDir == X_DIRECTION_BEARISH; - - // - bool hasBullishDirection = - // - isExtended && - (hasBullishCHOCH || - isBullishEngulfed) && - (isBullisMomentumn || - isBullishRejection) - // - ; - - // - bool hasBearishDirection = - // - isExtended && - (hasBearishCHOCH || - isBearishEngulfed) && - (isBearishMomentum || - isBearishRejection) - // - ; - - // - result = hasBullishDirection || - hasBearishDirection; - if (result) - { - // - dir = hasBullishDirection - ? X_DIRECTION_BULLISH - : X_DIRECTION_BEARISH; - } - - // - return result; - } - - /** - * Check Specified Bar has Possibly Bullish Direction ... - * - * @param bar: XOHCL instance, Specified Bar ... - * - * @return ( virtual bool ) - */ - virtual bool HasBullishDirection( - XOHCL &bar // - ) - { - // - bool result = false; - - // - ENUM_X_DIRECTION dir; - result = HasDirection(dir, bar); - result = - result && - dir == X_DIRECTION_BULLISH; - - // - return result; - } - - /** - * Check Specified Bar has Possibly Bearish Direction ... - * - * @param bar: XOHCL instance, Specified Bar ... - * - * @return ( virtual bool ) - */ - virtual bool HasBearishhDirection( - XOHCL &bar // - ) - { - // - bool result = false; - - // - ENUM_X_DIRECTION dir; - result = HasDirection(dir, bar); - result = - result && - dir == X_DIRECTION_BEARISH; - - // - return result; - } - - // - protected: - // - - // - // Actions ... - - /** - * Calculate Loopback Data for Specific Bar ... - * - * @param index: Integer, Bar Current Index ... - * @param start: Integer, Start of Loopback ... - * @param end: Integer, End of Loopback ... - * @param count: Integer, Number of Calculating Bars ... - * @param bar: XOHCL instance, Specified Bar ... - * @param loopback: Integer, Loopback Length ... - * @return ( bool ) - */ - bool CalculateLoopBackData( - int &index, - int &start, - int &end, - int &count, - XOHCL &bar, - int loopback = 1 // - ) - { - // - bool result = false; - - // - if (loopback < 1) - { - loopback = 1; - } - - // - index = -1; - start = -1; - end = -1; - count = -1; - - // - result = bar.IsValid(); - if (!result) - { - return result; - } - - // - index = bar.Index(); - start = index + 1; - end = start + loopback; - count = end - start; - result = count >= 1; - if (!result) - { - return result; - } - - // - return result; - } - - /** - * Retrieve Loopback HH & LL Data ... - * - * @param hhIDX: Integer, HH Index ... - * @param hh: Double, HH Value ... - * @param llIDX: Integer, LL Index ... - * @param ll: Double, LL Value ... - * @param bar: XOHCL instance ... - * @param loopback: Integer, Loopback Length ... - * - * @return ( bool ) - */ - bool CalculateLoopbackHLData( - int &hhIDX, - double &hh, - int &llIDX, - double &ll, - XOHCL &bar, - int loopback // - ) - { - // - bool result = false; - - // - if (loopback < 1) - { - loopback = 1; - } - - // - int index = -1; - int start = -1; - int end = -1; - int count = -1; - result = CalculateLoopBackData( - index, - start, - end, - count, - bar, - loopback // - ); - if (!result) - { - return result; - } - - // - hhIDX = iHighest( - bar.symbol, - bar.period, - MODE_HIGH, - count, - start // - ); - result = IsValidIndex(hhIDX); - if (!result) - { - return result; - } - - // - llIDX = iLowest( - bar.symbol, - bar.period, - MODE_LOW, - count, - start // - ); - result = IsValidIndex(llIDX); - if (!result) - { - return result; - } - - // - hh = iHigh( - bar.symbol, - bar.period, - hhIDX // - ); - ll = iLow( - bar.symbol, - bar.period, - llIDX // - ); - - // - return result; - } - - /** - * Calculate Bar Range ... - * - * @param bar: XOHCL instance ... - * - * @return ( double ) - */ - double GetBarRangePercent(XOHCL &bar) - { - // - double result = 0; - - // - result = bar.GetRange() / 100; - - // - return result; - } - - // - private: - // - - // - // Props ... - - // - // Actions ... - - // -}; - -// \ No newline at end of file diff --git a/Documents/BKP/14030820/14030820.7z b/Documents/BKP/14030820/14030820.7z new file mode 100644 index 00000000..ac03021b Binary files /dev/null and b/Documents/BKP/14030820/14030820.7z differ diff --git a/Helpers/x-saherelm.xchche.helper.mq5 b/Helpers/x-saherelm.xchche.helper.mq5 deleted file mode 100644 index 7ab733af..00000000 --- a/Helpers/x-saherelm.xchche.helper.mq5 +++ /dev/null @@ -1,4743 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Helper Class Library -// ---------------------------------------------- -// Name: XSCXCHCHEHelper -// 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_XCHCHE_BUFFERS -{ - // - // Current ... - XCHCHE_CLE1_LINE = 0, - XCHCHE_CSE1_LINE = 1, - XCHCHE_CLE2_LINE = 2, - XCHCHE_CSE2_LINE = 3, - // - // Short ... - XCHCHE_SLE1_LINE = 4, - XCHCHE_SSE1_LINE = 5, - XCHCHE_SLE2_LINE = 6, - XCHCHE_SSE2_LINE = 7, - // - // Medium ... - XCHCHE_MLE1_LINE = 8, - XCHCHE_MSE1_LINE = 9, - XCHCHE_MLE2_LINE = 10, - XCHCHE_MSE2_LINE = 11, - // - // Long ... - XCHCHE_LLE1_LINE = 12, - XCHCHE_LSE1_LINE = 13, - XCHCHE_LLE2_LINE = 14, - XCHCHE_LSE2_LINE = 15, - // - // Hind ... - XCHCHE_HLE1_LINE = 16, - XCHCHE_HSE1_LINE = 17, - XCHCHE_HLE2_LINE = 18, - XCHCHE_HSE2_LINE = 19, -}; - -// -// Input Models ... -struct XCHCHEInputs -{ - // - // 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 - - // - // Cycles ... - - // - // Short ... - ENUM_X_PERIOD_METHOD scMethod; // How to Find Period - ENUM_TIMEFRAMES scPeriod; // Time Period - - // - // Medium ... - ENUM_X_PERIOD_METHOD mcMethod; // How to Find Period - ENUM_TIMEFRAMES mcPeriod; // Time Period - - // - // Long ... - ENUM_X_PERIOD_METHOD lcMethod; // How to Find Period - ENUM_TIMEFRAMES lcPeriod; // Time Period - - // - // Hind ... - ENUM_X_PERIOD_METHOD hcMethod; // How to Find Period - ENUM_TIMEFRAMES hcPeriod; // Time Period - - // - // Presentation ... - - // - bool showLE1; // Show Long Exit 1 - bool showLE2; // Show Long Exit 2 - bool showSE1; // Show Short Exit 1 - bool showSE2; // Show Short Exit 2 - - // - bool showCurrent; // Show Current Cycle - bool showShort; // Show Short Cycle - bool showMedium; // Show Medium Cycle - bool showLong; // Show Long Cycle - bool showHind; // Show Hind Cycle - - // - // Constructor(s) ... - XCHCHEInputs() - { - // - Clean(); - } - - // - // Tools ... - - // - // Clean ... - void Clean() - { - // - length = 0; - loopback = 0; - multiplier1 = 0; - multiplier2 = 0; - - // - upAppliedTo = PRICE_HIGH; - downAppliedTo = PRICE_LOW; - - // - scMethod = X_PERIOD_AUTO; - scPeriod = NULL; - mcMethod = X_PERIOD_AUTO; - mcPeriod = NULL; - lcMethod = X_PERIOD_AUTO; - lcPeriod = NULL; - hcMethod = X_PERIOD_AUTO; - hcPeriod = NULL; - - // - showLE1 = false; - showLE2 = false; - showSE1 = false; - showSE2 = false; - - // - showCurrent = false; - showShort = false; - showMedium = false; - showLong = false; - showHind = false; - } - - // - // Default ... - void Default() - { - // - length = 35; - loopback = 26; - multiplier1 = 3.0; - multiplier2 = 3.5; - - // - upAppliedTo = PRICE_HIGH; - downAppliedTo = PRICE_LOW; - - // - scMethod = X_PERIOD_AUTO; - scPeriod = NULL; - mcMethod = X_PERIOD_AUTO; - mcPeriod = NULL; - lcMethod = X_PERIOD_AUTO; - lcPeriod = NULL; - hcMethod = X_PERIOD_AUTO; - hcPeriod = NULL; - - // - showLE1 = true; - showLE2 = true; - showSE1 = true; - showSE2 = true; - - // - showCurrent = true; - showShort = true; - showMedium = true; - showLong = true; - showHind = true; - } - - // - // Validate ... - bool IsValid() - { - // - bool result = false; - - // - result = - // - length >= 2 && - loopback >= 0 && - // - (IsValid(scMethod, scPeriod) && - IsValid(mcMethod, mcPeriod) && - IsValid(lcMethod, lcPeriod) && - IsValid(hcMethod, hcPeriod)) - // - ; - - // - return result; - } - - // - // Retrieve MAx Length ... - int Max() - { - // - int result = 0; - - // - result = - // - MathMax(0, length) - // - ; - - // - return result; - } -}; - -// -// Define Conditions ... -struct XCHCHEConditions -{ - // - // Common ... - string symbol; - ENUM_TIMEFRAMES period; - datetime time; - - // - // Buffers ... - - // - // Current ... - double cLE1[]; - double cLE2[]; - double cSE1[]; - double cSE2[]; - - // - // Short ... - double sLE1[]; - double sLE2[]; - double sSE1[]; - double sSE2[]; - - // - // Medium ... - double mLE1[]; - double mLE2[]; - double mSE1[]; - double mSE2[]; - - // - // Long ... - double lLE1[]; - double lLE2[]; - double lSE1[]; - double lSE2[]; - - // - // Hind ... - double hLE1[]; - double hLE2[]; - double hSE1[]; - double hSE2[]; - - // - // Conditions ... - - // - // Power ... - bool hasBullishPower; - bool hasBearishPower; - bool isBullishPowerUp; - bool isBearishPowerUp; - bool isBullishPowerIncreasing; - bool isBullishPowerDecreasing; - bool isBearishPowerIncreasing; - bool isBearishPowerDecreasing; - - // - // Current ... - bool isCBullish; - bool isCBearish; - bool isCStrongBullish; - bool isCStrongBearish; - bool isCSwitchedToBullish; - bool isCSwitchedToBearish; - bool isCStrongSwitchedToBullish; - bool isCStrongSwitchedToBearish; - - // - // Short ... - bool isSBullish; - bool isSBearish; - bool isSStrongBullish; - bool isSStrongBearish; - bool isSSwitchedToBullish; - bool isSSwitchedToBearish; - bool isSStrongSwitchedToBullish; - bool isSStrongSwitchedToBearish; - - // - // Medium ... - bool isMBullish; - bool isMBearish; - bool isMStrongBullish; - bool isMStrongBearish; - bool isMSwitchedToBullish; - bool isMSwitchedToBearish; - bool isMStrongSwitchedToBullish; - bool isMStrongSwitchedToBearish; - - // - // Long ... - bool isLBullish; - bool isLBearish; - bool isLStrongBullish; - bool isLStrongBearish; - bool isLSwitchedToBullish; - bool isLSwitchedToBearish; - bool isLStrongSwitchedToBullish; - bool isLStrongSwitchedToBearish; - - // - // Hind ... - bool isHBullish; - bool isHBearish; - bool isHStrongBullish; - bool isHStrongBearish; - bool isHSwitchedToBullish; - bool isHSwitchedToBearish; - bool isHStrongSwitchedToBullish; - bool isHStrongSwitchedToBearish; - - // - void Clean() - { - // - Clean(cLE1); - Clean(cLE2); - Clean(cSE1); - Clean(cSE2); - Clean(sLE1); - Clean(sLE2); - Clean(sSE1); - Clean(sSE2); - Clean(mLE1); - Clean(mLE2); - Clean(mSE1); - Clean(mSE2); - Clean(lLE1); - Clean(lLE2); - Clean(lSE1); - Clean(lSE2); - Clean(hLE1); - Clean(hLE2); - Clean(hSE1); - Clean(hSE2); - - // - ArraySetAsSeries(cLE1, true); - ArraySetAsSeries(cLE2, true); - ArraySetAsSeries(cSE1, true); - ArraySetAsSeries(cSE2, true); - ArraySetAsSeries(sLE1, true); - ArraySetAsSeries(sLE2, true); - ArraySetAsSeries(sSE1, true); - ArraySetAsSeries(sSE2, true); - ArraySetAsSeries(mLE1, true); - ArraySetAsSeries(mLE2, true); - ArraySetAsSeries(mSE1, true); - ArraySetAsSeries(mSE2, true); - ArraySetAsSeries(lLE1, true); - ArraySetAsSeries(lLE2, true); - ArraySetAsSeries(lSE1, true); - ArraySetAsSeries(lSE2, true); - ArraySetAsSeries(hLE1, true); - ArraySetAsSeries(hLE2, true); - ArraySetAsSeries(hSE1, true); - ArraySetAsSeries(hSE2, true); - - // - // Conditions ... - - // - // Power ... - hasBullishPower = false; - hasBearishPower = false; - isBullishPowerUp = false; - isBearishPowerUp = false; - isBullishPowerIncreasing = false; - isBullishPowerDecreasing = false; - isBearishPowerIncreasing = false; - isBearishPowerDecreasing = false; - - // - // Current ... - isCBullish = false; - isCBearish = false; - isCStrongBullish = false; - isCStrongBearish = false; - isCSwitchedToBullish = false; - isCSwitchedToBearish = false; - isCStrongSwitchedToBullish = false; - isCStrongSwitchedToBearish = false; - - // - // Short ... - isSBullish = false; - isSBearish = false; - isSStrongBullish = false; - isSStrongBearish = false; - isSSwitchedToBullish = false; - isSSwitchedToBearish = false; - isSStrongSwitchedToBullish = false; - isSStrongSwitchedToBearish = false; - - // - // Medium ... - isMBullish = false; - isMBearish = false; - isMStrongBullish = false; - isMStrongBearish = false; - isMSwitchedToBullish = false; - isMSwitchedToBearish = false; - isMStrongSwitchedToBullish = false; - isMStrongSwitchedToBearish = false; - - // - // Long ... - isLBullish = false; - isLBearish = false; - isLStrongBullish = false; - isLStrongBearish = false; - isLSwitchedToBullish = false; - isLSwitchedToBearish = false; - isLStrongSwitchedToBullish = false; - isLStrongSwitchedToBearish = false; - - // - // Hind ... - isHBullish = false; - isHBearish = false; - isHStrongBullish = false; - isHStrongBearish = false; - isHSwitchedToBullish = false; - isHSwitchedToBearish = false; - isHStrongSwitchedToBullish = false; - isHStrongSwitchedToBearish = false; - } - - // - void GenerateScore( - double &bullishScore, - double &bearishScore // - ) - { - // - bullishScore = 0; - bearishScore = 0; - - // - // Since We have to Use this - // Only for Filtering Signals ... - // We Can Ignore Scoring ... - // or Complete this later ... - - // - // Conditions ... - - // - // Power ... - if (hasBullishPower) - { - bullishScore++; - } - if (hasBearishPower) - { - bearishScore++; - } - if (isBullishPowerUp) - { - bullishScore++; - } - if (isBearishPowerUp) - { - bearishScore++; - } - if (isBullishPowerIncreasing) - { - bullishScore++; - } - if (isBullishPowerDecreasing) - { - bearishScore++; - } - if (isBearishPowerIncreasing) - { - bearishScore++; - } - if (isBearishPowerDecreasing) - { - bullishScore++; - } - - // - // Current ... - - // - if (isCBullish) - { - bullishScore++; - } - if (isCStrongBullish) - { - bullishScore++; - } - if (isCSwitchedToBullish) - { - bullishScore++; - } - if (isCStrongSwitchedToBullish) - { - bullishScore++; - } - - // - if (isCBearish) - { - bearishScore++; - } - if (isCStrongBearish) - { - bearishScore++; - } - if (isCSwitchedToBearish) - { - bearishScore++; - } - if (isCStrongSwitchedToBearish) - { - bearishScore++; - } - - // - // Short ... - - // - if (isSBullish) - { - bullishScore++; - } - if (isSStrongBullish) - { - bullishScore++; - } - if (isSSwitchedToBullish) - { - bullishScore++; - } - if (isSStrongSwitchedToBullish) - { - bullishScore++; - } - - // - if (isSBearish) - { - bearishScore++; - } - if (isSStrongBearish) - { - bearishScore++; - } - if (isSSwitchedToBearish) - { - bearishScore++; - } - if (isSStrongSwitchedToBearish) - { - bearishScore++; - } - - // - // Medium ... - - // - if (isMBullish) - { - bullishScore++; - } - if (isMStrongBullish) - { - bullishScore++; - } - if (isMSwitchedToBullish) - { - bullishScore++; - } - if (isMStrongSwitchedToBullish) - { - bullishScore++; - } - - // - if (isMBearish) - { - bearishScore++; - } - if (isMStrongBearish) - { - bearishScore++; - } - if (isMSwitchedToBearish) - { - bearishScore++; - } - if (isMStrongSwitchedToBearish) - { - bearishScore++; - } - - // - // Long ... - - // - if (isLBullish) - { - bullishScore++; - } - if (isLStrongBullish) - { - bullishScore++; - } - if (isLSwitchedToBullish) - { - bullishScore++; - } - if (isLStrongSwitchedToBullish) - { - bullishScore++; - } - - // - if (isLBearish) - { - bearishScore++; - } - if (isLStrongBearish) - { - bearishScore++; - } - if (isLSwitchedToBearish) - { - bearishScore++; - } - if (isLStrongSwitchedToBearish) - { - bearishScore++; - } - - // - // Hind ... - - // - if (isHBullish) - { - bullishScore++; - } - if (isHStrongBullish) - { - bullishScore++; - } - if (isHSwitchedToBullish) - { - bullishScore++; - } - if (isHStrongSwitchedToBullish) - { - bullishScore++; - } - - // - if (isHBearish) - { - bearishScore++; - } - if (isHStrongBearish) - { - bearishScore++; - } - if (isHSwitchedToBearish) - { - bearishScore++; - } - if (isHStrongSwitchedToBearish) - { - bearishScore++; - } - } - - // - string GenerateSummary( - bool onlyCommons = false, - bool onlyConditions = false, - bool includeScores = true, - bool ignoreFalseConditions = true, - string separator = "\n" // - ) - { - // - string result = NULL; - - // - double bullishScore = 0; - double bearishScore = 0; - GenerateScore( - bullishScore, - bearishScore // - ); - - // - string scoresStr = - // - "Scores: " + separator + - "---------------" + separator + - "Bullish: " + ToString(bullishScore) + separator + - "Bearish: " + ToString(bearishScore) + separator + - "" - // - ; - - // - string commonStr = GenerateSpecifiedCommonSummary( - this, - separator, - includeScores // - ); - - // - string conditionsStr = - // - // Power ... - ToString("hasBullishPower", hasBullishPower, ignoreFalseConditions, separator) + - ToString("hasBearishPower", hasBearishPower, ignoreFalseConditions, separator) + - ToString("isBullishPowerUp", isBullishPowerUp, ignoreFalseConditions, separator) + - ToString("isBearishPowerUp", isBearishPowerUp, ignoreFalseConditions, separator) + - ToString("isBullishPowerIncreasing", isBullishPowerIncreasing, ignoreFalseConditions, separator) + - ToString("isBullishPowerDecreasing", isBullishPowerDecreasing, ignoreFalseConditions, separator) + - ToString("isBearishPowerIncreasing", isBearishPowerIncreasing, ignoreFalseConditions, separator) + - ToString("isBearishPowerDecreasing", isBearishPowerDecreasing, ignoreFalseConditions, separator) + - // - // Current ... - ToString("isCBullish", isCBullish, ignoreFalseConditions, separator) + - ToString("isCBearish", isCBearish, ignoreFalseConditions, separator) + - ToString("isCStrongBullish", isCStrongBullish, ignoreFalseConditions, separator) + - ToString("isCStrongBearish", isCStrongBearish, ignoreFalseConditions, separator) + - ToString("isCSwitchedToBullish", isCSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isCSwitchedToBearish", isCSwitchedToBearish, ignoreFalseConditions, separator) + - ToString("isCStrongSwitchedToBullish", isCStrongSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isCStrongSwitchedToBearish", isCStrongSwitchedToBearish, ignoreFalseConditions, separator) + - // - // Short ... - ToString("isSBullish", isSBullish, ignoreFalseConditions, separator) + - ToString("isSBearish", isSBearish, ignoreFalseConditions, separator) + - ToString("isSStrongBullish", isSStrongBullish, ignoreFalseConditions, separator) + - ToString("isSStrongBearish", isSStrongBearish, ignoreFalseConditions, separator) + - ToString("isSSwitchedToBullish", isSSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isSSwitchedToBearish", isSSwitchedToBearish, ignoreFalseConditions, separator) + - ToString("isSStrongSwitchedToBullish", isSStrongSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isSStrongSwitchedToBearish", isSStrongSwitchedToBearish, ignoreFalseConditions, separator) + - // - // Medium ... - ToString("isMBullish", isMBullish, ignoreFalseConditions, separator) + - ToString("isMBearish", isMBearish, ignoreFalseConditions, separator) + - ToString("isMStrongBullish", isMStrongBullish, ignoreFalseConditions, separator) + - ToString("isMStrongBearish", isMStrongBearish, ignoreFalseConditions, separator) + - ToString("isMSwitchedToBullish", isMSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isMSwitchedToBearish", isMSwitchedToBearish, ignoreFalseConditions, separator) + - ToString("isMStrongSwitchedToBullish", isMStrongSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isMStrongSwitchedToBearish", isMStrongSwitchedToBearish, ignoreFalseConditions, separator) + - // - // Long ... - ToString("isLBullish", isLBullish, ignoreFalseConditions, separator) + - ToString("isLBearish", isLBearish, ignoreFalseConditions, separator) + - ToString("isLStrongBullish", isLStrongBullish, ignoreFalseConditions, separator) + - ToString("isLStrongBearish", isLStrongBearish, ignoreFalseConditions, separator) + - ToString("isLSwitchedToBullish", isLSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isLSwitchedToBearish", isLSwitchedToBearish, ignoreFalseConditions, separator) + - ToString("isLStrongSwitchedToBullish", isLStrongSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isLStrongSwitchedToBearish", isLStrongSwitchedToBearish, ignoreFalseConditions, separator) + - // - // Hind ... - ToString("isHBullish", isHBullish, ignoreFalseConditions, separator) + - ToString("isHBearish", isHBearish, ignoreFalseConditions, separator) + - ToString("isHStrongBullish", isHStrongBullish, ignoreFalseConditions, separator) + - ToString("isHStrongBearish", isHStrongBearish, ignoreFalseConditions, separator) + - ToString("isHSwitchedToBullish", isHSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isHSwitchedToBearish", isHSwitchedToBearish, ignoreFalseConditions, separator) + - ToString("isHStrongSwitchedToBullish", isHStrongSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isHStrongSwitchedToBearish", isHStrongSwitchedToBearish, ignoreFalseConditions, separator) + - // - "" - // - ; - - // - result = - // - "[" + GetTag() + "]" + separator + - (onlyConditions - ? "" - : commonStr) + - (!includeScores - ? "" - : scoresStr) + - " " + separator + - (onlyCommons - ? "" - : conditionsStr) + - "" - // - ; - - // - return result; - } - - // - string GetTag() - { - return "XCHCHE"; - } -}; - -// -// Class ... -class XSCXCHCHEHelper : public XSCBaseHelper -{ - // - // Public ... -public: - // - // Props ... - - // - // Constructors ... - XSCXCHCHEHelper() : XSCBaseHelper(_Symbol, _Period) - { - } - - // - // Deconstructor ... - ~XSCXCHCHEHelper() - { - // - Clean(cLE1Buffer); - Clean(cLE2Buffer); - Clean(cSE1Buffer); - Clean(cSE2Buffer); - Clean(sLE1Buffer); - Clean(sLE2Buffer); - Clean(sSE1Buffer); - Clean(sSE2Buffer); - Clean(mLE1Buffer); - Clean(mLE2Buffer); - Clean(mSE1Buffer); - Clean(mSE2Buffer); - Clean(lLE1Buffer); - Clean(lLE2Buffer); - Clean(lSE1Buffer); - Clean(lSE2Buffer); - Clean(hLE1Buffer); - Clean(hLE2Buffer); - Clean(hSE1Buffer); - Clean(hSE2Buffer); - } - - // - // Tools ... - bool Init( - string symbol, // Trading Symbol - ENUM_TIMEFRAMES period, // Trading Period - XCHCHEInputs &inputs // Inputs - ) - { - // - bool result = false; - - // - mSymbol = symbol; - mPeriod = period; - - // - result = inputs.IsValid(); - if (!result) - { - return result; - } - - // - mInputs = inputs; - - // - ArraySetAsSeries(cLE1Buffer, true); - ArraySetAsSeries(cLE2Buffer, true); - ArraySetAsSeries(cSE1Buffer, true); - ArraySetAsSeries(cSE2Buffer, true); - ArraySetAsSeries(sLE1Buffer, true); - ArraySetAsSeries(sLE2Buffer, true); - ArraySetAsSeries(sSE1Buffer, true); - ArraySetAsSeries(sSE2Buffer, true); - ArraySetAsSeries(mLE1Buffer, true); - ArraySetAsSeries(mLE2Buffer, true); - ArraySetAsSeries(mSE1Buffer, true); - ArraySetAsSeries(mSE2Buffer, true); - ArraySetAsSeries(lLE1Buffer, true); - ArraySetAsSeries(lLE2Buffer, true); - ArraySetAsSeries(lSE1Buffer, true); - ArraySetAsSeries(lSE2Buffer, true); - ArraySetAsSeries(hLE1Buffer, true); - ArraySetAsSeries(hLE2Buffer, true); - ArraySetAsSeries(hSE1Buffer, true); - ArraySetAsSeries(hSE2Buffer, true); - - // - mHandler = iCustom( - mSymbol, - mPeriod, - "x-saherelm.xchche", - // - // Inputs ... - // - // Market ... - "", - mInputs.length, - mInputs.loopback, - mInputs.multiplier1, - mInputs.multiplier2, - // - // Calculations ... - "", - mInputs.upAppliedTo, - mInputs.downAppliedTo, - // - // Cycles ... - "", - // - // Short ... - "", - mInputs.scMethod, - mInputs.scPeriod, - // - // Medium ... - "", - mInputs.mcMethod, - mInputs.mcPeriod, - // - // Long ... - "", - mInputs.lcMethod, - mInputs.lcPeriod, - // - // Hind ... - "", - mInputs.hcMethod, - mInputs.hcPeriod, - // - // Presentation ... - "", - // - mInputs.showLE1, - mInputs.showLE2, - mInputs.showSE1, - mInputs.showSE2, - // - mInputs.showCurrent, - mInputs.showShort, - mInputs.showMedium, - mInputs.showLong, - mInputs.showHind - // - ); - result = mHandler != INVALID_HANDLE; - if (!result) - { - return result; - } - - // - return result; - } - - // - // Inputs ... - - // - XCHCHEInputs GetInputs() - { - return mInputs; - } - - // - bool SetInputs( - XCHCHEInputs &inputs // Configs - ) - { - // - return Init( - mSymbol, - mPeriod, - inputs - // - ); - } - - // - // Buffers ... - - // - // Current ... - - // - double GetCLE1( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(cLE1Buffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return cLE1Buffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyCLE1( - 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, - cLE1Buffer, - buffer, - forceClean - // - ); - } - - // - double GetCLE2( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(cLE2Buffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return cLE2Buffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyCLE2( - 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, - cLE2Buffer, - buffer, - forceClean - // - ); - } - - // - double GetCSE1( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(cSE1Buffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return cSE1Buffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyCSE1( - 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, - cSE1Buffer, - buffer, - forceClean - // - ); - } - - // - double GetCSE2( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(cSE2Buffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return cSE2Buffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyCSE2( - 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, - cSE2Buffer, - buffer, - forceClean - // - ); - } - - // - // Short ... - - // - double GetSLE1( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(sLE1Buffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return sLE1Buffer[barIndex]; - } - - // - // Copy Required Items ... - int CopySLE1( - 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, - sLE1Buffer, - buffer, - forceClean - // - ); - } - - // - double GetSLE2( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(sLE2Buffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return sLE2Buffer[barIndex]; - } - - // - // Copy Required Items ... - int CopySLE2( - 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, - sLE2Buffer, - buffer, - forceClean - // - ); - } - - // - double GetSSE1( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(sSE1Buffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return sSE1Buffer[barIndex]; - } - - // - // Copy Required Items ... - int CopySSE1( - 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, - sSE1Buffer, - buffer, - forceClean - // - ); - } - - // - double GetSSE2( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(sSE2Buffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return sSE2Buffer[barIndex]; - } - - // - // Copy Required Items ... - int CopySSE2( - 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, - sSE2Buffer, - buffer, - forceClean - // - ); - } - - // - // Medium ... - - // - double GetMLE1( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(mLE1Buffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return mLE1Buffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyMLE1( - 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, - mLE1Buffer, - buffer, - forceClean - // - ); - } - - // - double GetMLE2( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(mLE2Buffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return mLE2Buffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyMLE2( - 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, - mLE2Buffer, - buffer, - forceClean - // - ); - } - - // - double GetMSE1( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(mSE1Buffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return mSE1Buffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyMSE1( - 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, - mSE1Buffer, - buffer, - forceClean - // - ); - } - - // - double GetMSE2( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(mSE2Buffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return mSE2Buffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyMSE2( - 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, - mSE2Buffer, - buffer, - forceClean - // - ); - } - - // - // Long ... - - // - double GetLLE1( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(lLE1Buffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return lLE1Buffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyLLE1( - 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, - lLE1Buffer, - buffer, - forceClean - // - ); - } - - // - double GetLLE2( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(lLE2Buffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return lLE2Buffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyLLE2( - 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, - lLE2Buffer, - buffer, - forceClean - // - ); - } - - // - double GetLSE1( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(lSE1Buffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return lSE1Buffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyLSE1( - 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, - lSE1Buffer, - buffer, - forceClean - // - ); - } - - // - double GetLSE2( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(lSE2Buffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return lSE2Buffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyLSE2( - 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, - lSE2Buffer, - buffer, - forceClean - // - ); - } - - // - // Hind ... - - // - double GetHLE1( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(hLE1Buffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return hLE1Buffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyHLE1( - 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, - hLE1Buffer, - buffer, - forceClean - // - ); - } - - // - double GetHLE2( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(hLE2Buffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return hLE2Buffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyHLE2( - 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, - hLE2Buffer, - buffer, - forceClean - // - ); - } - - // - double GetHSE1( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(hSE1Buffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return hSE1Buffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyHSE1( - 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, - hSE1Buffer, - buffer, - forceClean - // - ); - } - - // - double GetHSE2( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(hSE2Buffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return hSE2Buffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyHSE2( - 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, - hSE2Buffer, - buffer, - forceClean - // - ); - } - - // - // Tools ... - - // - bool IsCycleBullish( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle // - ) - { - // - bool result = false; - - // - double le1 = 0; - - // - switch (cycle) - { - // - // CURRENT ... - case X_MARKET_CYCLE_UNKNOWN: - le1 = GetCLE1(barIndex); - break; - - // - // SHORT ... - case X_MARKET_CYCLE_SHORT: - le1 = GetSLE1(barIndex); - break; - - // - // MEDIUM ... - case X_MARKET_CYCLE_MEDIUM: - le1 = GetMLE1(barIndex); - break; - - // - // LONG ... - case X_MARKET_CYCLE_LONG: - le1 = GetLLE1(barIndex); - break; - - // - // HIND ... - case X_MARKET_CYCLE_HIND: - le1 = GetHLE1(barIndex); - break; - } - - // - result = le1 != EMPTY_VALUE && - le1 > 0; - - // - return result; - } - - // - bool IsCycleStrongBullish( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle // - ) - { - // - bool result = false; - - // - double le1 = 0; - double le2 = 0; - - // - switch (cycle) - { - // - // CURRENT ... - case X_MARKET_CYCLE_UNKNOWN: - le1 = GetCLE1(barIndex); - le2 = GetCLE2(barIndex); - break; - - // - // SHORT ... - case X_MARKET_CYCLE_SHORT: - le1 = GetSLE1(barIndex); - le2 = GetSLE2(barIndex); - break; - - // - // MEDIUM ... - case X_MARKET_CYCLE_MEDIUM: - le1 = GetMLE1(barIndex); - le2 = GetMLE2(barIndex); - break; - - // - // LONG ... - case X_MARKET_CYCLE_LONG: - le1 = GetLLE1(barIndex); - le2 = GetLLE2(barIndex); - break; - - // - // HIND ... - case X_MARKET_CYCLE_HIND: - le1 = GetHLE1(barIndex); - le2 = GetHLE2(barIndex); - break; - } - - // - result = le1 != EMPTY_VALUE && - le1 > 0 && - le2 != EMPTY_VALUE && - le2 > 0; - - // - return result; - } - - // - bool IsCycleBearish( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle // - ) - { - // - bool result = false; - - // - double se1 = 0; - - // - switch (cycle) - { - // - // CURRENT ... - case X_MARKET_CYCLE_UNKNOWN: - se1 = GetCSE1(barIndex); - break; - - // - // SHORT ... - case X_MARKET_CYCLE_SHORT: - se1 = GetSSE1(barIndex); - break; - - // - // MEDIUM ... - case X_MARKET_CYCLE_MEDIUM: - se1 = GetMSE1(barIndex); - break; - - // - // LONG ... - case X_MARKET_CYCLE_LONG: - se1 = GetLSE1(barIndex); - break; - - // - // HIND ... - case X_MARKET_CYCLE_HIND: - se1 = GetHSE1(barIndex); - break; - } - - // - result = se1 != EMPTY_VALUE && - se1 > 0; - - // - return result; - } - - // - bool IsCycleStrongBearish( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle // - ) - { - // - bool result = false; - - // - double se1 = 0; - double se2 = 0; - - // - switch (cycle) - { - // - // CURRENT ... - case X_MARKET_CYCLE_UNKNOWN: - se1 = GetCSE1(barIndex); - se2 = GetCSE2(barIndex); - break; - - // - // SHORT ... - case X_MARKET_CYCLE_SHORT: - se1 = GetSSE1(barIndex); - se2 = GetSSE2(barIndex); - break; - - // - // MEDIUM ... - case X_MARKET_CYCLE_MEDIUM: - se1 = GetMSE1(barIndex); - se2 = GetMSE2(barIndex); - break; - - // - // LONG ... - case X_MARKET_CYCLE_LONG: - se1 = GetLSE1(barIndex); - se2 = GetLSE2(barIndex); - break; - - // - // HIND ... - case X_MARKET_CYCLE_HIND: - se1 = GetHSE1(barIndex); - se2 = GetHSE2(barIndex); - break; - } - - // - result = se1 != EMPTY_VALUE && - se1 > 0 && - se2 != EMPTY_VALUE && - se2 > 0; - - // - return result; - } - - // - int GetCycleValues( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle, - double &values[] // - ) - { - // - int result = 0; - - // - Clean(values); - - // - double le1 = 0; - double le2 = 0; - double se1 = 0; - double se2 = 0; - - // - switch (cycle) - { - // - // CURRENT ... - case X_MARKET_CYCLE_UNKNOWN: - // - le1 = GetCLE1(barIndex); - le2 = GetCLE2(barIndex); - se1 = GetCSE1(barIndex); - se2 = GetCSE2(barIndex); - break; - - // - // SHORT ... - case X_MARKET_CYCLE_SHORT: - // - le1 = GetSLE1(barIndex); - le2 = GetSLE2(barIndex); - se1 = GetSSE1(barIndex); - se2 = GetSSE2(barIndex); - break; - - // - // MEDIUM ... - case X_MARKET_CYCLE_MEDIUM: - // - le1 = GetMLE1(barIndex); - le2 = GetMLE2(barIndex); - se1 = GetMSE1(barIndex); - se2 = GetMSE2(barIndex); - break; - - // - // LONG ... - case X_MARKET_CYCLE_LONG: - // - le1 = GetLLE1(barIndex); - le2 = GetLLE2(barIndex); - se1 = GetLSE1(barIndex); - se2 = GetLSE2(barIndex); - break; - - // - // HIND ... - case X_MARKET_CYCLE_HIND: - // - le1 = GetHLE1(barIndex); - le2 = GetHLE2(barIndex); - se1 = GetHSE1(barIndex); - se2 = GetHSE2(barIndex); - break; - } - - // - if (le1 > 0 && le1 != EMPTY_VALUE) - { - // - Add( - le1, - values // - ); - } - - // - if (le2 > 0 && le2 != EMPTY_VALUE) - { - // - Add( - le2, - values // - ); - } - - // - if (se1 > 0 && se1 != EMPTY_VALUE) - { - // - Add( - se1, - values // - ); - } - - // - if (se2 > 0 && se2 != EMPTY_VALUE) - { - // - Add( - se2, - values // - ); - } - - // - result = ArraySize(values); - - // - return result; - } - - // - int GetCycleBullishValues( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle, - double &values[] // - ) - { - // - int result = 0; - - // - Clean(values); - - // - double le1 = 0; - double le2 = 0; - - // - switch (cycle) - { - // - // CURRENT ... - case X_MARKET_CYCLE_UNKNOWN: - // - le1 = GetCLE1(barIndex); - le2 = GetCLE2(barIndex); - break; - - // - // SHORT ... - case X_MARKET_CYCLE_SHORT: - // - le1 = GetSLE1(barIndex); - le2 = GetSLE2(barIndex); - break; - - // - // MEDIUM ... - case X_MARKET_CYCLE_MEDIUM: - // - le1 = GetMLE1(barIndex); - le2 = GetMLE2(barIndex); - break; - - // - // LONG ... - case X_MARKET_CYCLE_LONG: - // - le1 = GetLLE1(barIndex); - le2 = GetLLE2(barIndex); - break; - - // - // HIND ... - case X_MARKET_CYCLE_HIND: - // - le1 = GetHLE1(barIndex); - le2 = GetHLE2(barIndex); - break; - } - - // - if (le1 > 0 && le1 != EMPTY_VALUE) - { - // - Add( - le1, - values // - ); - } - - // - if (le2 > 0 && le2 != EMPTY_VALUE) - { - // - Add( - le2, - values // - ); - } - - // - result = ArraySize(values); - - // - return result; - } - - // - int GetCycleBearishValues( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle, - double &values[] // - ) - { - // - int result = 0; - - // - Clean(values); - - // - double se1 = 0; - double se2 = 0; - - // - switch (cycle) - { - // - // CURRENT ... - case X_MARKET_CYCLE_UNKNOWN: - // - se1 = GetCSE1(barIndex); - se2 = GetCSE2(barIndex); - break; - - // - // SHORT ... - case X_MARKET_CYCLE_SHORT: - // - se1 = GetSSE1(barIndex); - se2 = GetSSE2(barIndex); - break; - - // - // MEDIUM ... - case X_MARKET_CYCLE_MEDIUM: - // - se1 = GetMSE1(barIndex); - se2 = GetMSE2(barIndex); - break; - - // - // LONG ... - case X_MARKET_CYCLE_LONG: - // - se1 = GetLSE1(barIndex); - se2 = GetLSE2(barIndex); - break; - - // - // HIND ... - case X_MARKET_CYCLE_HIND: - // - se1 = GetHSE1(barIndex); - se2 = GetHSE2(barIndex); - break; - } - - // - if (se1 > 0 && se1 != EMPTY_VALUE) - { - // - Add( - se1, - values // - ); - } - - // - if (se2 > 0 && se2 != EMPTY_VALUE) - { - // - Add( - se2, - values // - ); - } - - // - result = ArraySize(values); - - // - return result; - } - - // - double GetCycleMax( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle // - ) - { - // - double result = 0; - - // - double values[]; - int valuesCount = GetCycleValues( - barIndex, - cycle, - values // - ); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetCycleMin( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle // - ) - { - // - double result = 0; - - // - double values[]; - int valuesCount = GetCycleValues( - barIndex, - cycle, - values // - ); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetCyclePower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle // - ) - { - // - double result = 0; - - // - double values[]; - int count = GetCycleValues( - barIndex, - cycle, - values // - ); - - // - double max = GetSpecifiedMax(values); - double min = GetSpecifiedMin(values); - - // - result = MathAbs(max - min); - - // - return result; - } - - // - int GetBullishCycles( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - int result = 0; - - // - Clean(cycles); - - // - ENUM_X_MARKET_CYCLES allCycles[]; - int allCyclesCount = GetAllMarketCycles(allCycles); - if (!IsValidSize(allCyclesCount)) - { - return result; - } - - // - for (int i = 0; i < allCyclesCount; i++) - { - // - bool isBullish = IsCycleBullish( - barIndex, - allCycles[i] // - ); - if (isBullish) - { - // - Add( - allCycles[i], - cycles // - ); - } - } - - // - result = ArraySize(cycles); - - // - return result; - } - - // - int GetStrongBullishCycles( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - int result = 0; - - // - Clean(cycles); - - // - ENUM_X_MARKET_CYCLES allCycles[]; - int allCyclesCount = GetAllMarketCycles(allCycles); - if (!IsValidSize(allCyclesCount)) - { - return result; - } - - // - for (int i = 0; i < allCyclesCount; i++) - { - // - bool isBullish = IsCycleStrongBullish( - barIndex, - allCycles[i] // - ); - if (isBullish) - { - // - Add( - allCycles[i], - cycles // - ); - } - } - - // - result = ArraySize(cycles); - - // - return result; - } - - // - int GetBearishCycles( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - int result = 0; - - // - Clean(cycles); - - // - ENUM_X_MARKET_CYCLES allCycles[]; - int allCyclesCount = GetAllMarketCycles(allCycles); - if (!IsValidSize(allCyclesCount)) - { - return result; - } - - // - for (int i = 0; i < allCyclesCount; i++) - { - // - bool isBearish = IsCycleBearish( - barIndex, - allCycles[i] // - ); - if (isBearish) - { - // - Add( - allCycles[i], - cycles // - ); - } - } - - // - result = ArraySize(cycles); - - // - return result; - } - - // - int GetStrongBearishCycles( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - int result = 0; - - // - Clean(cycles); - - // - ENUM_X_MARKET_CYCLES allCycles[]; - int allCyclesCount = GetAllMarketCycles(allCycles); - if (!IsValidSize(allCyclesCount)) - { - return result; - } - - // - for (int i = 0; i < allCyclesCount; i++) - { - // - bool isBearish = IsCycleStrongBearish( - barIndex, - allCycles[i] // - ); - if (isBearish) - { - // - Add( - allCycles[i], - cycles // - ); - } - } - - // - result = ArraySize(cycles); - - // - return result; - } - - // - double GetMax( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - double values[]; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int count = GetAllMarketCycles(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - double iValues[]; - int iValuesCount = GetCycleValues( - barIndex, - cycles[i], - iValues // - ); - if (IsValidSize(iValuesCount)) - { - // - Copy( - iValues, - values, - false // - ); - } - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetMin( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - double values[]; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int count = GetAllMarketCycles(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - double iValues[]; - int iValuesCount = GetCycleValues( - barIndex, - cycles[i], - iValues // - ); - if (IsValidSize(iValuesCount)) - { - // - Copy( - iValues, - values, - false // - ); - } - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetBullishMax( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - double values[]; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int count = GetBullishCycles( - barIndex, - cycles // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - double iValues[]; - int iValuesCount = GetCycleValues( - barIndex, - cycles[i], - iValues // - ); - if (IsValidSize(iValuesCount)) - { - // - Copy( - iValues, - values, - false // - ); - } - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetBullishMin( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - double values[]; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int count = GetBullishCycles( - barIndex, - cycles // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - double iValues[]; - int iValuesCount = GetCycleValues( - barIndex, - cycles[i], - iValues // - ); - if (IsValidSize(iValuesCount)) - { - // - Copy( - iValues, - values, - false // - ); - } - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetBearishMax( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - double values[]; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int count = GetBearishCycles( - barIndex, - cycles // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - double iValues[]; - int iValuesCount = GetCycleValues( - barIndex, - cycles[i], - iValues // - ); - if (IsValidSize(iValuesCount)) - { - // - Copy( - iValues, - values, - false // - ); - } - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetBearishMin( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - double values[]; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int count = GetBearishCycles( - barIndex, - cycles // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - double iValues[]; - int iValuesCount = GetCycleValues( - barIndex, - cycles[i], - iValues // - ); - if (IsValidSize(iValuesCount)) - { - // - Copy( - iValues, - values, - false // - ); - } - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetCycleBullishMax( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle // Cycle - ) - { - // - double result = 0; - - // - bool isBullish = IsCycleBullish( - barIndex, - cycle // - ); - if (!isBullish) - { - return result; - } - - // - double values[]; - int count = GetCycleBullishValues( - barIndex, - cycle, - values // - ); - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetCycleBullishMin( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle // Cycle - ) - { - // - double result = 0; - - // - bool isBullish = IsCycleBullish( - barIndex, - cycle // - ); - if (!isBullish) - { - return result; - } - - // - double values[]; - int count = GetCycleBullishValues( - barIndex, - cycle, - values // - ); - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetCycleBearishMax( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle // Cycle - ) - { - // - double result = 0; - - // - bool isBearish = IsCycleBearish( - barIndex, - cycle // - ); - if (!isBearish) - { - return result; - } - - // - double values[]; - int count = GetCycleBearishValues( - barIndex, - cycle, - values // - ); - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetCycleBearishMin( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle // Cycle - ) - { - // - double result = 0; - - // - bool isBearish = IsCycleBearish( - barIndex, - cycle // - ); - if (!isBearish) - { - return result; - } - - // - double values[]; - int count = GetCycleBearishValues( - barIndex, - cycle, - values // - ); - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetBullishPower( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int count = GetBullishCycles( - barIndex, - cycles // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - result += GetCyclePower( - barIndex, - cycles[i] // - ); - } - - // - return result; - } - - // - double GetBearishPower( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int count = GetBearishCycles( - barIndex, - cycles // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - result += GetCyclePower( - barIndex, - cycles[i] // - ); - } - - // - return result; - } - - // - double GetCyclesBullishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - bool isBullish = IsCycleBullish( - barIndex, - cycles[i] // - ); - - // - if (isBullish) - { - // - result += GetCyclePower( - barIndex, - cycles[i] // - ); - } - } - - // - return result; - } - - // - double GetCyclesBearishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - bool isBearish = IsCycleBearish( - barIndex, - cycles[i] // - ); - - // - if (isBearish) - { - // - result += GetCyclePower( - barIndex, - cycles[i] // - ); - } - } - - // - return result; - } - - // - bool HasBullishPower( - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - double bullishPower = GetBullishPower(barIndex); - double bearishPower = GetBearishPower(barIndex); - - // - result = - // - bearishPower >= 0 && - bullishPower > bearishPower - // - ; - - // - return result; - } - - // - bool HasBearishPower( - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - double bullishPower = GetBullishPower(barIndex); - double bearishPower = GetBearishPower(barIndex); - - // - result = - // - bullishPower >= 0 && - bearishPower > bullishPower - // - ; - - // - return result; - } - - // - bool HasCyclesBullishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - bool result = false; - - // - double bullishPower = GetCyclesBullishPower(barIndex, cycles); - double bearishPower = GetCyclesBearishPower(barIndex, cycles); - - // - result = - // - bearishPower >= 0 && - bullishPower > bearishPower - // - ; - - // - return result; - } - - // - bool HasCyclesBearishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - bool result = false; - - // - double bullishPower = GetCyclesBullishPower(barIndex, cycles); - double bearishPower = GetCyclesBearishPower(barIndex, cycles); - - // - result = - // - bullishPower >= 0 && - bearishPower > bullishPower - // - ; - - // - return result; - } - - // - // Check Bullish Power Increasing ... - bool IsBullishPowerIncreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBullishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBullishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bullish Power Decreasing ... - bool IsBullishPowerDecreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBullishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBullishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Increasing ... - bool IsBearishPowerIncreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBearishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBearishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Decreasing ... - bool IsBearishPowerDecreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBearishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBearishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Check Bullish Power Increasing ... - bool IsCyclesBullishPowerIncreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBullishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBullishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bullish Power Decreasing ... - bool IsCyclesBullishPowerDecreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBullishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBullishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Increasing ... - bool IsCyclesBearishPowerIncreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBearishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBearishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Decreasing ... - bool IsCyclesBearishPowerDecreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBearishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBearishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Conditions ... - - // - bool GetConditions( - XCHCHEConditions &conditions, // - int barIndex = 0, // - int loopback = 5 // - ) - { - // - bool result = true; - - // - if (loopback < 5) - { - loopback = 5; - } - - // - conditions.Clean(); - - // - conditions.symbol = mSymbol; - conditions.period = mPeriod; - conditions.time = TimeCurrent(); - - // - int zIndex = barIndex; - int cIndex = zIndex + 1; - int pIndex = cIndex + 1; - int ppIndex = pIndex + 1; - - // - // Buffers ... - - // - // CURRENT ... - - // - CopyCLE1( - zIndex, - loopback, - conditions.cLE1 // - ); - - // - CopyCLE2( - zIndex, - loopback, - conditions.cLE2 // - ); - - // - CopyCSE1( - zIndex, - loopback, - conditions.cSE1 // - ); - - // - CopyCSE2( - zIndex, - loopback, - conditions.cSE2 // - ); - - // - // SHORT ... - - // - CopySLE1( - zIndex, - loopback, - conditions.sLE1 // - ); - - // - CopySLE2( - zIndex, - loopback, - conditions.sLE2 // - ); - - // - CopySSE1( - zIndex, - loopback, - conditions.sSE1 // - ); - - // - CopySSE2( - zIndex, - loopback, - conditions.sSE2 // - ); - - // - // MEDIUM ... - - // - CopyMLE1( - zIndex, - loopback, - conditions.mLE1 // - ); - - // - CopyMLE2( - zIndex, - loopback, - conditions.mLE2 // - ); - - // - CopyMSE1( - zIndex, - loopback, - conditions.mSE1 // - ); - - // - CopyMSE2( - zIndex, - loopback, - conditions.mSE2 // - ); - - // - // LONG ... - - // - CopyLLE1( - zIndex, - loopback, - conditions.lLE1 // - ); - - // - CopyLLE2( - zIndex, - loopback, - conditions.lLE2 // - ); - - // - CopyLSE1( - zIndex, - loopback, - conditions.lSE1 // - ); - - // - CopyLSE2( - zIndex, - loopback, - conditions.lSE2 // - ); - - // - // HIND ... - - // - CopyHLE1( - zIndex, - loopback, - conditions.hLE1 // - ); - - // - CopyHLE2( - zIndex, - loopback, - conditions.hLE2 // - ); - - // - CopyHSE1( - zIndex, - loopback, - conditions.hSE1 // - ); - - // - CopyHSE2( - zIndex, - loopback, - conditions.hSE2 // - ); - - // - // Power ... - - // - bool hasBullishPower = HasBullishPower(cIndex); - bool hasBullishPowerPrev = HasBullishPower(pIndex); - - // - bool hasBearishPower = HasBearishPower(cIndex); - bool hasBearishPowerPrev = HasBearishPower(pIndex); - - // - bool isBullishPowerUp = hasBullishPower && - !hasBullishPowerPrev; - bool isBearishPowerUp = hasBearishPower && - !hasBearishPowerPrev; - - // - bool isBullishPowerIncreasing = IsBullishPowerIncreasing(cIndex); - bool isBullishPowerDecreasing = IsBullishPowerDecreasing(cIndex); - bool isBearishPowerIncreasing = IsBearishPowerIncreasing(cIndex); - bool isBearishPowerDecreasing = IsBearishPowerDecreasing(cIndex); - - // - conditions.hasBullishPower = hasBullishPower; - conditions.hasBearishPower = hasBearishPower; - conditions.isBullishPowerUp = isBullishPowerUp; - conditions.isBearishPowerUp = isBearishPowerUp; - conditions.isBullishPowerIncreasing = isBullishPowerIncreasing; - conditions.isBullishPowerDecreasing = isBullishPowerDecreasing; - conditions.isBearishPowerIncreasing = isBearishPowerIncreasing; - conditions.isBearishPowerDecreasing = isBearishPowerDecreasing; - - // - // Current ... - - // - bool isCBullish = NotEmptyZero(conditions.cLE1[cIndex]); - bool isCBearish = NotEmptyZero(conditions.cSE1[cIndex]); - - // - bool isCBullishPrev = NotEmptyZero(conditions.cLE1[pIndex]); - bool isCBearishPrev = NotEmptyZero(conditions.cSE1[pIndex]); - - // - bool isCStrongBullish = isCBullish && - NotEmptyZero(conditions.cLE2[cIndex]); - bool isCStrongBearish = isCBearish && - NotEmptyZero(conditions.cSE2[cIndex]); - - // - bool isCStrongBullishPrev = isCBullishPrev && - NotEmptyZero(conditions.cLE2[pIndex]); - bool isCStrongBearishPrev = isCBearishPrev && - NotEmptyZero(conditions.cSE2[pIndex]); - - // - bool isCSwitchedToBullish = isCBullish && - !isCBullishPrev; - bool isCSwitchedToBearish = isCBearish && - !isCBearishPrev; - - // - bool isCStrongSwitchedToBullish = isCStrongBullish && - !isCStrongBullishPrev; - bool isCStrongSwitchedToBearish = isCStrongBearish && - !isCStrongBearishPrev; - - // - conditions.isCBullish = isCBullish; - conditions.isCBearish = isCBearish; - conditions.isCStrongBullish = isCStrongBullish; - conditions.isCStrongBearish = isCStrongBearish; - conditions.isCSwitchedToBullish = isCSwitchedToBullish; - conditions.isCSwitchedToBearish = isCSwitchedToBearish; - conditions.isCStrongSwitchedToBullish = isCStrongSwitchedToBullish; - conditions.isCStrongSwitchedToBearish = isCStrongSwitchedToBearish; - - // - // Short ... - - // - bool isSBullish = NotEmptyZero(conditions.sLE1[cIndex]); - bool isSBearish = NotEmptyZero(conditions.sSE1[cIndex]); - - // - bool isSBullishPrev = NotEmptyZero(conditions.sLE1[pIndex]); - bool isSBearishPrev = NotEmptyZero(conditions.sSE1[pIndex]); - - // - bool isSStrongBullish = isSBullish && - NotEmptyZero(conditions.sLE2[cIndex]); - bool isSStrongBearish = isSBearish && - NotEmptyZero(conditions.sSE2[cIndex]); - - // - bool isSStrongBullishPrev = isSBullishPrev && - NotEmptyZero(conditions.sLE2[pIndex]); - bool isSStrongBearishPrev = isSBearishPrev && - NotEmptyZero(conditions.sSE2[pIndex]); - - // - bool isSSwitchedToBullish = isSBullish && - !isSBullishPrev; - bool isSSwitchedToBearish = isSBearish && - !isSBearishPrev; - - // - bool isSStrongSwitchedToBullish = isSStrongBullish && - !isSStrongBullishPrev; - bool isSStrongSwitchedToBearish = isSStrongBearish && - !isSStrongBearishPrev; - - // - conditions.isSBullish = isSBullish; - conditions.isSBearish = isSBearish; - conditions.isSStrongBullish = isSStrongBullish; - conditions.isSStrongBearish = isSStrongBearish; - conditions.isSSwitchedToBullish = isSSwitchedToBullish; - conditions.isSSwitchedToBearish = isSSwitchedToBearish; - conditions.isSStrongSwitchedToBullish = isSStrongSwitchedToBullish; - conditions.isSStrongSwitchedToBearish = isSStrongSwitchedToBearish; - - // - // Medium ... - - // - bool isMBullish = NotEmptyZero(conditions.mLE1[cIndex]); - bool isMBearish = NotEmptyZero(conditions.mSE1[cIndex]); - - // - bool isMBullishPrev = NotEmptyZero(conditions.mLE1[pIndex]); - bool isMBearishPrev = NotEmptyZero(conditions.mSE1[pIndex]); - - // - bool isMStrongBullish = isMBullish && - NotEmptyZero(conditions.mLE2[cIndex]); - bool isMStrongBearish = isMBearish && - NotEmptyZero(conditions.mSE2[cIndex]); - - // - bool isMStrongBullishPrev = isMBullishPrev && - NotEmptyZero(conditions.mLE2[pIndex]); - bool isMStrongBearishPrev = isMBearishPrev && - NotEmptyZero(conditions.mSE2[pIndex]); - - // - bool isMSwitchedToBullish = isMBullish && - !isMBullishPrev; - bool isMSwitchedToBearish = isMBearish && - !isMBearishPrev; - - // - bool isMStrongSwitchedToBullish = isMStrongBullish && - !isMStrongBullishPrev; - bool isMStrongSwitchedToBearish = isMStrongBearish && - !isMStrongBearishPrev; - - // - conditions.isMBullish = isMBullish; - conditions.isMBearish = isMBearish; - conditions.isMStrongBullish = isMStrongBullish; - conditions.isMStrongBearish = isMStrongBearish; - conditions.isMSwitchedToBullish = isMSwitchedToBullish; - conditions.isMSwitchedToBearish = isMSwitchedToBearish; - conditions.isMStrongSwitchedToBullish = isMStrongSwitchedToBullish; - conditions.isMStrongSwitchedToBearish = isMStrongSwitchedToBearish; - - // - // Long ... - - // - bool isLBullish = NotEmptyZero(conditions.lLE1[cIndex]); - bool isLBearish = NotEmptyZero(conditions.lSE1[cIndex]); - - // - bool isLBullishPrev = NotEmptyZero(conditions.lLE1[pIndex]); - bool isLBearishPrev = NotEmptyZero(conditions.lSE1[pIndex]); - - // - bool isLStrongBullish = isLBullish && - NotEmptyZero(conditions.lLE2[cIndex]); - bool isLStrongBearish = isLBearish && - NotEmptyZero(conditions.lSE2[cIndex]); - - // - bool isLStrongBullishPrev = isLBullishPrev && - NotEmptyZero(conditions.lLE2[pIndex]); - bool isLStrongBearishPrev = isLBearishPrev && - NotEmptyZero(conditions.lSE2[pIndex]); - - // - bool isLSwitchedToBullish = isLBullish && - !isLBullishPrev; - bool isLSwitchedToBearish = isLBearish && - !isLBearishPrev; - - // - bool isLStrongSwitchedToBullish = isLStrongBullish && - !isLStrongBullishPrev; - bool isLStrongSwitchedToBearish = isLStrongBearish && - !isLStrongBearishPrev; - - // - conditions.isLBullish = isLBullish; - conditions.isLBearish = isLBearish; - conditions.isLStrongBullish = isLStrongBullish; - conditions.isLStrongBearish = isLStrongBearish; - conditions.isLSwitchedToBullish = isLSwitchedToBullish; - conditions.isLSwitchedToBearish = isLSwitchedToBearish; - conditions.isLStrongSwitchedToBullish = isLStrongSwitchedToBullish; - conditions.isLStrongSwitchedToBearish = isLStrongSwitchedToBearish; - - // - // Hind ... - - // - bool isHBullish = NotEmptyZero(conditions.hLE1[cIndex]); - bool isHBearish = NotEmptyZero(conditions.hSE1[cIndex]); - - // - bool isHBullishPrev = NotEmptyZero(conditions.hLE1[pIndex]); - bool isHBearishPrev = NotEmptyZero(conditions.hSE1[pIndex]); - - // - bool isHStrongBullish = isHBullish && - NotEmptyZero(conditions.hLE2[cIndex]); - bool isHStrongBearish = isHBearish && - NotEmptyZero(conditions.hSE2[cIndex]); - - // - bool isHStrongBullishPrev = isHBullishPrev && - NotEmptyZero(conditions.hLE2[pIndex]); - bool isHStrongBearishPrev = isHBearishPrev && - NotEmptyZero(conditions.hSE2[pIndex]); - - // - bool isHSwitchedToBullish = isHBullish && - !isHBullishPrev; - bool isHSwitchedToBearish = isHBearish && - !isHBearishPrev; - - // - bool isHStrongSwitchedToBullish = isHStrongBullish && - !isHStrongBullishPrev; - bool isHStrongSwitchedToBearish = isHStrongBearish && - !isHStrongBearishPrev; - - // - conditions.isHBullish = isHBullish; - conditions.isHBearish = isHBearish; - conditions.isHStrongBullish = isHStrongBullish; - conditions.isHStrongBearish = isHStrongBearish; - conditions.isHSwitchedToBullish = isHSwitchedToBullish; - conditions.isHSwitchedToBearish = isHSwitchedToBearish; - conditions.isHStrongSwitchedToBullish = isHStrongSwitchedToBullish; - conditions.isHStrongSwitchedToBearish = isHStrongSwitchedToBearish; - - // - return result; - } - - // - // Protected ... -protected: - // - // Private ... -private: - // - // Props ... - XCHCHEInputs mInputs; // Inputs ... - - // - // Buffers ... - - // - // Current ... - double cLE1Buffer[]; - double cLE2Buffer[]; - double cSE1Buffer[]; - double cSE2Buffer[]; - - // - // Short ... - double sLE1Buffer[]; - double sLE2Buffer[]; - double sSE1Buffer[]; - double sSE2Buffer[]; - - // - // Medium ... - double mLE1Buffer[]; - double mLE2Buffer[]; - double mSE1Buffer[]; - double mSE2Buffer[]; - - // - // Long ... - double lLE1Buffer[]; - double lLE2Buffer[]; - double lSE1Buffer[]; - double lSE2Buffer[]; - - // - // Hind ... - double hLE1Buffer[]; - double hLE2Buffer[]; - double hSE1Buffer[]; - double hSE2Buffer[]; - - // - // Tools ... - - // - // Calculate Values Until Now ... - void Calculate() - { - // - int totalBars = CountBars(); - if (totalBars > 1000) - { - totalBars = 1000; - } - - // - // Current ... - - // - // LE1 ... - CopyBuffer( - mHandler, - XCHCHE_CLE1_LINE, - 0, - totalBars, - cLE1Buffer - // - ); - - // - // LE2 ... - CopyBuffer( - mHandler, - XCHCHE_CLE2_LINE, - 0, - totalBars, - cLE2Buffer - // - ); - - // - // SE1 ... - CopyBuffer( - mHandler, - XCHCHE_CSE1_LINE, - 0, - totalBars, - cSE1Buffer - // - ); - - // - // SE2 ... - CopyBuffer( - mHandler, - XCHCHE_CSE2_LINE, - 0, - totalBars, - cSE2Buffer - // - ); - - // - // Short ... - - // - // LE1 ... - CopyBuffer( - mHandler, - XCHCHE_SLE1_LINE, - 0, - totalBars, - sLE1Buffer - // - ); - - // - // LE2 ... - CopyBuffer( - mHandler, - XCHCHE_SLE2_LINE, - 0, - totalBars, - sLE2Buffer - // - ); - - // - // SE1 ... - CopyBuffer( - mHandler, - XCHCHE_SSE1_LINE, - 0, - totalBars, - sSE1Buffer - // - ); - - // - // SE2 ... - CopyBuffer( - mHandler, - XCHCHE_SSE2_LINE, - 0, - totalBars, - sSE2Buffer - // - ); - - // - // Medium ... - - // - // LE1 ... - CopyBuffer( - mHandler, - XCHCHE_MLE1_LINE, - 0, - totalBars, - mLE1Buffer - // - ); - - // - // LE2 ... - CopyBuffer( - mHandler, - XCHCHE_MLE2_LINE, - 0, - totalBars, - mLE2Buffer - // - ); - - // - // SE1 ... - CopyBuffer( - mHandler, - XCHCHE_MSE1_LINE, - 0, - totalBars, - mSE1Buffer - // - ); - - // - // SE2 ... - CopyBuffer( - mHandler, - XCHCHE_MSE2_LINE, - 0, - totalBars, - mSE2Buffer - // - ); - - // - // Long ... - - // - // LE1 ... - CopyBuffer( - mHandler, - XCHCHE_LLE1_LINE, - 0, - totalBars, - lLE1Buffer - // - ); - - // - // LE2 ... - CopyBuffer( - mHandler, - XCHCHE_LLE2_LINE, - 0, - totalBars, - lLE2Buffer - // - ); - - // - // SE1 ... - CopyBuffer( - mHandler, - XCHCHE_LSE1_LINE, - 0, - totalBars, - lSE1Buffer - // - ); - - // - // SE2 ... - CopyBuffer( - mHandler, - XCHCHE_LSE2_LINE, - 0, - totalBars, - lSE2Buffer - // - ); - - // - // Hind ... - - // - // LE1 ... - CopyBuffer( - mHandler, - XCHCHE_HLE1_LINE, - 0, - totalBars, - hLE1Buffer - // - ); - - // - // LE2 ... - CopyBuffer( - mHandler, - XCHCHE_HLE2_LINE, - 0, - totalBars, - hLE2Buffer - // - ); - - // - // SE1 ... - CopyBuffer( - mHandler, - XCHCHE_HSE1_LINE, - 0, - totalBars, - hSE1Buffer - // - ); - - // - // SE2 ... - CopyBuffer( - mHandler, - XCHCHE_HSE2_LINE, - 0, - totalBars, - hSE2Buffer - // - ); - }; -}; - -// \ No newline at end of file diff --git a/Helpers/x-saherelm.xchdon.helper.mq5 b/Helpers/x-saherelm.xchdon.helper.mq5 deleted file mode 100644 index 2b054736..00000000 --- a/Helpers/x-saherelm.xchdon.helper.mq5 +++ /dev/null @@ -1,3887 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Helper Class Library -// ---------------------------------------------- -// Name: XSCXCHDONHelper -// 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" - -// -enum ENUM_XCHDON_BUFFERS -{ - // - // Current ... - // - XCHDON_C_OPEN_UPPER_LINE = 0, - XCHDON_C_OPEN_LOWER_LINE = 1, - // - XCHDON_C_HIGH_UPPER_LINE = 2, - XCHDON_C_HIGH_LOWER_LINE = 3, - // - XCHDON_C_LOW_UPPER_LINE = 4, - XCHDON_C_LOW_LOWER_LINE = 5, - // - XCHDON_C_CLOSE_UPPER_LINE = 6, - XCHDON_C_CLOSE_LOWER_LINE = 7, - // - // Short ... - // - XCHDON_S_OPEN_UPPER_LINE = 8, - XCHDON_S_OPEN_LOWER_LINE = 9, - // - XCHDON_S_HIGH_UPPER_LINE = 10, - XCHDON_S_HIGH_LOWER_LINE = 11, - // - XCHDON_S_LOW_UPPER_LINE = 12, - XCHDON_S_LOW_LOWER_LINE = 13, - // - XCHDON_S_CLOSE_UPPER_LINE = 14, - XCHDON_S_CLOSE_LOWER_LINE = 15, - // - // Medium ... - // - XCHDON_M_OPEN_UPPER_LINE = 16, - XCHDON_M_OPEN_LOWER_LINE = 17, - // - XCHDON_M_HIGH_UPPER_LINE = 18, - XCHDON_M_HIGH_LOWER_LINE = 19, - // - XCHDON_M_LOW_UPPER_LINE = 20, - XCHDON_M_LOW_LOWER_LINE = 21, - // - XCHDON_M_CLOSE_UPPER_LINE = 22, - XCHDON_M_CLOSE_LOWER_LINE = 23, - // - // Long ... - // - XCHDON_L_OPEN_UPPER_LINE = 24, - XCHDON_L_OPEN_LOWER_LINE = 25, - // - XCHDON_L_HIGH_UPPER_LINE = 26, - XCHDON_L_HIGH_LOWER_LINE = 27, - // - XCHDON_L_LOW_UPPER_LINE = 28, - XCHDON_L_LOW_LOWER_LINE = 29, - // - XCHDON_L_CLOSE_UPPER_LINE = 30, - XCHDON_L_CLOSE_LOWER_LINE = 31, - // - // Hind ... - // - XCHDON_H_OPEN_UPPER_LINE = 32, - XCHDON_H_OPEN_LOWER_LINE = 33, - // - XCHDON_H_HIGH_UPPER_LINE = 34, - XCHDON_H_HIGH_LOWER_LINE = 35, - // - XCHDON_H_LOW_UPPER_LINE = 36, - XCHDON_H_LOW_LOWER_LINE = 37, - // - XCHDON_H_CLOSE_UPPER_LINE = 38, - XCHDON_H_CLOSE_LOWER_LINE = 39, -}; - -// -// Input Models ... -struct XCHDONInputs -{ - // - // Props ... - - // - // Market ... - int length; // Market Length - - // - // Cycles ... - - // - // Short ... - ENUM_X_PERIOD_METHOD scMethod; // How to Find Period - ENUM_TIMEFRAMES scPeriod; // Time Period - - // - // Medium ... - ENUM_X_PERIOD_METHOD mcMethod; // How to Find Period - ENUM_TIMEFRAMES mcPeriod; // Time Period - - // - // Long ... - ENUM_X_PERIOD_METHOD lcMethod; // How to Find Period - ENUM_TIMEFRAMES lcPeriod; // Time Period - - // - // Hind ... - ENUM_X_PERIOD_METHOD hcMethod; // How to Find Period - ENUM_TIMEFRAMES hcPeriod; // Time Period - - // - // Presentation ... - - // - bool showUpper; // Show Upper Band - bool showLower; // Show Lower Band - - // - bool showOpen; // Show Open - bool showHigh; // Show High - bool showClose; // Show Close - bool showLow; // Show Low - - // - bool showCurrent; // Show Current Cycle - bool showShort; // Show Short Cycle - bool showMedium; // Show Medium Cycle - bool showLong; // Show Long Cycle - bool showHind; // Show Hind Cycle - - // - // Constructor(s) ... - XCHDONInputs() - { - // - Clean(); - } - - // - // Tools ... - - // - // Clean ... - void Clean() - { - // - length = 0; - - // - scMethod = X_PERIOD_AUTO; - scPeriod = NULL; - mcMethod = X_PERIOD_AUTO; - mcPeriod = NULL; - lcMethod = X_PERIOD_AUTO; - lcPeriod = NULL; - hcMethod = X_PERIOD_AUTO; - hcPeriod = NULL; - - // - showUpper = false; - showLower = false; - - // - showOpen = false; - showHigh = false; - showClose = false; - showLow = false; - - // - showCurrent = false; - showShort = false; - showMedium = false; - showLong = false; - showHind = false; - } - - // - // Default ... - void Default() - { - // - length = 52; - - // - scMethod = X_PERIOD_AUTO; - scPeriod = NULL; - mcMethod = X_PERIOD_AUTO; - mcPeriod = NULL; - lcMethod = X_PERIOD_AUTO; - lcPeriod = NULL; - hcMethod = X_PERIOD_AUTO; - hcPeriod = NULL; - - // - showUpper = true; - showLower = true; - - // - showOpen = true; - showHigh = true; - showClose = true; - showLow = true; - - // - showCurrent = true; - showShort = true; - showMedium = true; - showLong = true; - showHind = true; - } - - // - // Validate ... - bool IsValid() - { - // - bool result = false; - - // - result = - // - length > 2 - // - && - // - (IsValid(scMethod, scPeriod) && - IsValid(mcMethod, mcPeriod) && - IsValid(lcMethod, lcPeriod) && - IsValid(hcMethod, hcPeriod)) - // - ; - - // - return result; - } - - // - // Retrieve MAx Length ... - int Max() - { - // - int result = 0; - - // - result = MathMax(result, length); - - // - return result; - } -}; - -// -// Define Conditions ... -struct XCHDONConditions -{ - // - // Common ... - string symbol; - ENUM_TIMEFRAMES period; - datetime time; - - // - // Buffers ... - - // - // Current ... - double cOpenUpper[]; - double cOpenLower[]; - double cHighUpper[]; - double cHighLower[]; - double cLowUpper[]; - double cLowLower[]; - double cCloseUpper[]; - double cCloseLower[]; - - // - // Short ... - double sOpenUpper[]; - double sOpenLower[]; - double sHighUpper[]; - double sHighLower[]; - double sLowUpper[]; - double sLowLower[]; - double sCloseUpper[]; - double sCloseLower[]; - - // - // Medium ... - double mOpenUpper[]; - double mOpenLower[]; - double mHighUpper[]; - double mHighLower[]; - double mLowUpper[]; - double mLowLower[]; - double mCloseUpper[]; - double mCloseLower[]; - - // - // Long ... - double lOpenUpper[]; - double lOpenLower[]; - double lHighUpper[]; - double lHighLower[]; - double lLowUpper[]; - double lLowLower[]; - double lCloseUpper[]; - double lCloseLower[]; - - // - // Hind ... - double hOpenUpper[]; - double hOpenLower[]; - double hHighUpper[]; - double hHighLower[]; - double hLowUpper[]; - double hLowLower[]; - double hCloseUpper[]; - double hCloseLower[]; - - // - // Conditions ... - - // - // Current ... - - // - // Short ... - - // - // Medium ... - - // - // Long ... - - // - // Hind ... - - // - void Clean() - { - // - // Buffers ... - - // - Clean(cOpenUpper); - Clean(cOpenLower); - Clean(cHighUpper); - Clean(cHighLower); - Clean(cLowUpper); - Clean(cLowLower); - Clean(cCloseUpper); - Clean(cCloseLower); - Clean(sOpenUpper); - Clean(sOpenLower); - Clean(sHighUpper); - Clean(sHighLower); - Clean(sLowUpper); - Clean(sLowLower); - Clean(sCloseUpper); - Clean(sCloseLower); - Clean(mOpenUpper); - Clean(mOpenLower); - Clean(mHighUpper); - Clean(mHighLower); - Clean(mLowUpper); - Clean(mLowLower); - Clean(mCloseUpper); - Clean(mCloseLower); - Clean(lOpenUpper); - Clean(lOpenLower); - Clean(lHighUpper); - Clean(lHighLower); - Clean(lLowUpper); - Clean(lLowLower); - Clean(lCloseUpper); - Clean(lCloseLower); - Clean(hOpenUpper); - Clean(hOpenLower); - Clean(hHighUpper); - Clean(hHighLower); - Clean(hLowUpper); - Clean(hLowLower); - Clean(hCloseUpper); - Clean(hCloseLower); - - // - ArraySetAsSeries(cOpenUpper, true); - ArraySetAsSeries(cOpenLower, true); - ArraySetAsSeries(cHighUpper, true); - ArraySetAsSeries(cHighLower, true); - ArraySetAsSeries(cLowUpper, true); - ArraySetAsSeries(cLowLower, true); - ArraySetAsSeries(cCloseUpper, true); - ArraySetAsSeries(cCloseLower, true); - ArraySetAsSeries(sOpenUpper, true); - ArraySetAsSeries(sOpenLower, true); - ArraySetAsSeries(sHighUpper, true); - ArraySetAsSeries(sHighLower, true); - ArraySetAsSeries(sLowUpper, true); - ArraySetAsSeries(sLowLower, true); - ArraySetAsSeries(sCloseUpper, true); - ArraySetAsSeries(sCloseLower, true); - ArraySetAsSeries(mOpenUpper, true); - ArraySetAsSeries(mOpenLower, true); - ArraySetAsSeries(mHighUpper, true); - ArraySetAsSeries(mHighLower, true); - ArraySetAsSeries(mLowUpper, true); - ArraySetAsSeries(mLowLower, true); - ArraySetAsSeries(mCloseUpper, true); - ArraySetAsSeries(mCloseLower, true); - ArraySetAsSeries(lOpenUpper, true); - ArraySetAsSeries(lOpenLower, true); - ArraySetAsSeries(lHighUpper, true); - ArraySetAsSeries(lHighLower, true); - ArraySetAsSeries(lLowUpper, true); - ArraySetAsSeries(lLowLower, true); - ArraySetAsSeries(lCloseUpper, true); - ArraySetAsSeries(lCloseLower, true); - ArraySetAsSeries(hOpenUpper, true); - ArraySetAsSeries(hOpenLower, true); - ArraySetAsSeries(hHighUpper, true); - ArraySetAsSeries(hHighLower, true); - ArraySetAsSeries(hLowUpper, true); - ArraySetAsSeries(hLowLower, true); - ArraySetAsSeries(hCloseUpper, true); - ArraySetAsSeries(hCloseLower, true); - - // - // Current ... - - // - // Short ... - - // - // Medium ... - - // - // Long ... - - // - // Hind ... - } - - // - void GenerateScore( - double &bullishScore, - double &bearishScore // - ) - { - // - bullishScore = 0; - bearishScore = 0; - - // - // Current ... - - // - // Short ... - - // - // Medium ... - - // - // Long ... - - // - // Hind ... - } - - // - string GenerateSummary( - bool onlyCommons = false, - bool onlyConditions = false, - bool includeScores = true, - bool ignoreFalseConditions = true, - string separator = "\n" // - ) - { - // - string result = NULL; - - // - double bullishScore = 0; - double bearishScore = 0; - GenerateScore( - bullishScore, - bearishScore // - ); - - // - string scoresStr = - // - "Scores: " + separator + - "---------------" + separator + - "Bullish: " + ToString(bullishScore) + separator + - "Bearish: " + ToString(bearishScore) + separator + - "" - // - ; - - // - string commonStr = GenerateSpecifiedCommonSummary( - this, - separator, - includeScores // - ); - - // - string conditionsStr = - // - // Current ... - // - // Short ... - // - // Medium ... - // - // Long ... - // - // Hind ... - // - "" - // - ; - - // - result = - // - "[" + GetTag() + "]" + separator + - (onlyConditions - ? "" - : commonStr) + - (!includeScores - ? "" - : scoresStr) + - " " + separator + - (onlyCommons - ? "" - : conditionsStr) + - "" - // - ; - - // - return result; - } - - // - string GetTag() - { - return "XCHDON"; - } -}; - -// -// Class ... -class XSCXCHDONHelper : public XSCBaseHelper -{ - // - // Public ... -public: - // - // Props ... - - // - // Constructors ... - XSCXCHDONHelper() : XSCBaseHelper(_Symbol, _Period) - { - } - - // - // Deconstructor ... - ~XSCXCHDONHelper() - { - // - Clean(cOpenUpperBuffer); - Clean(cOpenLowerBuffer); - Clean(cHighUpperBuffer); - Clean(cHighLowerBuffer); - Clean(cLowUpperBuffer); - Clean(cLowLowerBuffer); - Clean(cCloseUpperBuffer); - Clean(cCloseLowerBuffer); - Clean(sOpenUpperBuffer); - Clean(sOpenLowerBuffer); - Clean(sHighUpperBuffer); - Clean(sHighLowerBuffer); - Clean(sLowUpperBuffer); - Clean(sLowLowerBuffer); - Clean(sCloseUpperBuffer); - Clean(sCloseLowerBuffer); - Clean(mOpenUpperBuffer); - Clean(mOpenLowerBuffer); - Clean(mHighUpperBuffer); - Clean(mHighLowerBuffer); - Clean(mLowUpperBuffer); - Clean(mLowLowerBuffer); - Clean(mCloseUpperBuffer); - Clean(mCloseLowerBuffer); - Clean(lOpenUpperBuffer); - Clean(lOpenLowerBuffer); - Clean(lHighUpperBuffer); - Clean(lHighLowerBuffer); - Clean(lLowUpperBuffer); - Clean(lLowLowerBuffer); - Clean(lCloseUpperBuffer); - Clean(lCloseLowerBuffer); - Clean(hOpenUpperBuffer); - Clean(hOpenLowerBuffer); - Clean(hHighUpperBuffer); - Clean(hHighLowerBuffer); - Clean(hLowUpperBuffer); - Clean(hLowLowerBuffer); - Clean(hCloseUpperBuffer); - Clean(hCloseLowerBuffer); - } - - // - // Tools ... - bool Init( - string symbol, // Trading Symbol - ENUM_TIMEFRAMES period, // Trading Period - XCHDONInputs &inputs // Inputs - ) - { - // - bool result = false; - - // - mSymbol = symbol; - mPeriod = period; - - // - result = inputs.IsValid(); - if (!result) - { - return result; - } - - // - mInputs = inputs; - - // - ArraySetAsSeries(cOpenUpperBuffer, true); - ArraySetAsSeries(cOpenLowerBuffer, true); - ArraySetAsSeries(cHighUpperBuffer, true); - ArraySetAsSeries(cHighLowerBuffer, true); - ArraySetAsSeries(cLowUpperBuffer, true); - ArraySetAsSeries(cLowLowerBuffer, true); - ArraySetAsSeries(cCloseUpperBuffer, true); - ArraySetAsSeries(cCloseLowerBuffer, true); - ArraySetAsSeries(sOpenUpperBuffer, true); - ArraySetAsSeries(sOpenLowerBuffer, true); - ArraySetAsSeries(sHighUpperBuffer, true); - ArraySetAsSeries(sHighLowerBuffer, true); - ArraySetAsSeries(sLowUpperBuffer, true); - ArraySetAsSeries(sLowLowerBuffer, true); - ArraySetAsSeries(sCloseUpperBuffer, true); - ArraySetAsSeries(sCloseLowerBuffer, true); - ArraySetAsSeries(mOpenUpperBuffer, true); - ArraySetAsSeries(mOpenLowerBuffer, true); - ArraySetAsSeries(mHighUpperBuffer, true); - ArraySetAsSeries(mHighLowerBuffer, true); - ArraySetAsSeries(mLowUpperBuffer, true); - ArraySetAsSeries(mLowLowerBuffer, true); - ArraySetAsSeries(mCloseUpperBuffer, true); - ArraySetAsSeries(mCloseLowerBuffer, true); - ArraySetAsSeries(lOpenUpperBuffer, true); - ArraySetAsSeries(lOpenLowerBuffer, true); - ArraySetAsSeries(lHighUpperBuffer, true); - ArraySetAsSeries(lHighLowerBuffer, true); - ArraySetAsSeries(lLowUpperBuffer, true); - ArraySetAsSeries(lLowLowerBuffer, true); - ArraySetAsSeries(lCloseUpperBuffer, true); - ArraySetAsSeries(lCloseLowerBuffer, true); - ArraySetAsSeries(hOpenUpperBuffer, true); - ArraySetAsSeries(hOpenLowerBuffer, true); - ArraySetAsSeries(hHighUpperBuffer, true); - ArraySetAsSeries(hHighLowerBuffer, true); - ArraySetAsSeries(hLowUpperBuffer, true); - ArraySetAsSeries(hLowLowerBuffer, true); - ArraySetAsSeries(hCloseUpperBuffer, true); - ArraySetAsSeries(hCloseLowerBuffer, true); - - // - mHandler = iCustom( - mSymbol, - mPeriod, - "x-saherelm.xchdon", - // - // Inputs ... - // - // Market ... - "", - mInputs.length, - // - // Cycles ... - "", - // - // Short ... - "", - mInputs.scMethod, - mInputs.scPeriod, - // - // Medium ... - "", - mInputs.mcMethod, - mInputs.mcPeriod, - // - // Long ... - "", - mInputs.lcMethod, - mInputs.lcPeriod, - // - // Hind ... - "", - mInputs.hcMethod, - mInputs.hcPeriod, - // - // Presentation ... - "", - // - mInputs.showUpper, // Show Upper Band - mInputs.showLower, // Show Lower Band - // - mInputs.showOpen, // Show Open - mInputs.showHigh, // Show High - mInputs.showClose, // Show Close - mInputs.showLow, // Show Low - // - // Cycles ... - mInputs.showCurrent, // Show Current Cycle - mInputs.showShort, // Show Short Cycle - mInputs.showMedium, // Show Medium Cycle - mInputs.showLong, // Show Long Cycle - mInputs.showHind // Show Hind Cycle - // - ); - result = mHandler != INVALID_HANDLE; - if (!result) - { - return result; - } - - // - return result; - } - - // - // Buffers ... - - // - // Current ... - - // - // Open ... - - // - double GetCOpenUpper( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return cOpenUpperBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyCOpenUpper( - 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, - cOpenUpperBuffer, - buffer, - forceClean - // - ); - } - - // - double GetCOpenLower( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return cOpenLowerBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyCOpenLower( - 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, - cOpenLowerBuffer, - buffer, - forceClean - // - ); - } - - // - // High ... - - // - double GetCHighUpper( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return cHighUpperBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyCHighUpper( - 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, - cHighUpperBuffer, - buffer, - forceClean - // - ); - } - - // - double GetCHighLower( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return cHighLowerBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyCHighLower( - 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, - cHighLowerBuffer, - buffer, - forceClean - // - ); - } - - // - // Low ... - - // - double GetCLowUpper( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return cLowUpperBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyCLowUpper( - 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, - cLowUpperBuffer, - buffer, - forceClean - // - ); - } - - // - double GetCLowLower( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return cLowLowerBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyCLowLower( - 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, - cLowLowerBuffer, - buffer, - forceClean - // - ); - } - - // - // Close ... - - // - double GetCCloseUpper( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return cCloseUpperBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyCCloseUpper( - 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, - cCloseUpperBuffer, - buffer, - forceClean - // - ); - } - - // - double GetCCloseLower( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return cCloseLowerBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyCCloseLower( - 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, - cCloseLowerBuffer, - buffer, - forceClean - // - ); - } - - // - // Short ... - - // - // Open ... - - // - double GetSOpenUpper( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return sOpenUpperBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopySOpenUpper( - 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, - sOpenUpperBuffer, - buffer, - forceClean - // - ); - } - - // - double GetSOpenLower( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return sOpenLowerBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopySOpenLower( - 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, - sOpenLowerBuffer, - buffer, - forceClean - // - ); - } - - // - // High ... - - // - double GetSHighUpper( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return sHighUpperBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopySHighUpper( - 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, - sHighUpperBuffer, - buffer, - forceClean - // - ); - } - - // - double GetSHighLower( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return sHighLowerBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopySHighLower( - 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, - sHighLowerBuffer, - buffer, - forceClean - // - ); - } - - // - // Low ... - - // - double GetSLowUpper( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return sLowUpperBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopySLowUpper( - 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, - sLowUpperBuffer, - buffer, - forceClean - // - ); - } - - // - double GetSLowLower( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return sLowLowerBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopySLowLower( - 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, - sLowLowerBuffer, - buffer, - forceClean - // - ); - } - - // - // Close ... - - // - double GetSCloseUpper( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return sCloseUpperBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopySCloseUpper( - 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, - sCloseUpperBuffer, - buffer, - forceClean - // - ); - } - - // - double GetSCloseLower( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return sCloseLowerBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopySCloseLower( - 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, - sCloseLowerBuffer, - buffer, - forceClean - // - ); - } - - // - // Medium ... - - // - // Open ... - - // - double GetMOpenUpper( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return mOpenUpperBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyMOpenUpper( - 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, - mOpenUpperBuffer, - buffer, - forceClean - // - ); - } - - // - double GetMOpenLower( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return mOpenLowerBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyMOpenLower( - 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, - mOpenLowerBuffer, - buffer, - forceClean - // - ); - } - - // - // High ... - - // - double GetMHighUpper( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return mHighUpperBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyMHighUpper( - 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, - mHighUpperBuffer, - buffer, - forceClean - // - ); - } - - // - double GetMHighLower( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return mHighLowerBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyMHighLower( - 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, - mHighLowerBuffer, - buffer, - forceClean - // - ); - } - - // - // Low ... - - // - double GetMLowUpper( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return mLowUpperBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyMLowUpper( - 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, - mLowUpperBuffer, - buffer, - forceClean - // - ); - } - - // - double GetMLowLower( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return mLowLowerBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyMLowLower( - 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, - mLowLowerBuffer, - buffer, - forceClean - // - ); - } - - // - // Close ... - - // - double GetMCloseUpper( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return mCloseUpperBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyMCloseUpper( - 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, - mCloseUpperBuffer, - buffer, - forceClean - // - ); - } - - // - double GetMCloseLower( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return mCloseLowerBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyMCloseLower( - 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, - mCloseLowerBuffer, - buffer, - forceClean - // - ); - } - - // - // Long ... - - // - // Open ... - - // - double GetLOpenUpper( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return lOpenUpperBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyLOpenUpper( - 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, - lOpenUpperBuffer, - buffer, - forceClean - // - ); - } - - // - double GetLOpenLower( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return lOpenLowerBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyLOpenLower( - 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, - lOpenLowerBuffer, - buffer, - forceClean - // - ); - } - - // - // High ... - - // - double GetLHighUpper( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return lHighUpperBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyLHighUpper( - 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, - lHighUpperBuffer, - buffer, - forceClean - // - ); - } - - // - double GetLHighLower( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return lHighLowerBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyLHighLower( - 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, - lHighLowerBuffer, - buffer, - forceClean - // - ); - } - - // - // Low ... - - // - double GetLLowUpper( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return lLowUpperBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyLLowUpper( - 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, - lLowUpperBuffer, - buffer, - forceClean - // - ); - } - - // - double GetLLowLower( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return lLowLowerBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyLLowLower( - 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, - lLowLowerBuffer, - buffer, - forceClean - // - ); - } - - // - // Close ... - - // - double GetLCloseUpper( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return lCloseUpperBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyLCloseUpper( - 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, - lCloseUpperBuffer, - buffer, - forceClean - // - ); - } - - // - double GetLCloseLower( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return lCloseLowerBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyLCloseLower( - 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, - lCloseLowerBuffer, - buffer, - forceClean - // - ); - } - - // - // Hind ... - - // - // Open ... - - // - double GetHOpenUpper( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return hOpenUpperBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyHOpenUpper( - 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, - hOpenUpperBuffer, - buffer, - forceClean - // - ); - } - - // - double GetHOpenLower( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return hOpenLowerBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyHOpenLower( - 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, - hOpenLowerBuffer, - buffer, - forceClean - // - ); - } - - // - // High ... - - // - double GetHHighUpper( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return hHighUpperBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyHHighUpper( - 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, - hHighUpperBuffer, - buffer, - forceClean - // - ); - } - - // - double GetHHighLower( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return hHighLowerBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyHHighLower( - 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, - hHighLowerBuffer, - buffer, - forceClean - // - ); - } - - // - // Low ... - - // - double GetHLowUpper( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return hLowUpperBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyHLowUpper( - 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, - hLowUpperBuffer, - buffer, - forceClean - // - ); - } - - // - double GetHLowLower( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return hLowLowerBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyHLowLower( - 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, - hLowLowerBuffer, - buffer, - forceClean - // - ); - } - - // - // Close ... - - // - double GetHCloseUpper( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return hCloseUpperBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyHCloseUpper( - 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, - hCloseUpperBuffer, - buffer, - forceClean - // - ); - } - - // - double GetHCloseLower( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return hCloseLowerBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyHCloseLower( - 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, - hCloseLowerBuffer, - buffer, - forceClean - // - ); - } - - // - // Tools ... - - // - void GetCycleValues( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle, // Cycle - // - double &openUpper, - double &openLower, - double &highUpper, - double &highLower, - double &lowUpper, - double &lowLower, - double &closeUpper, - double &closeLower // - ) - { - // - openUpper = 0; - openLower = 0; - highUpper = 0; - highLower = 0; - lowUpper = 0; - lowLower = 0; - closeUpper = 0; - closeLower = 0; - - // - if (barIndex < 0) - { - barIndex = 0; - } - - switch (cycle) - { - // - // Current ... - case X_MARKET_CYCLE_UNKNOWN: - // - openUpper = GetCOpenUpper(barIndex); - openLower = GetCOpenLower(barIndex); - highUpper = GetCHighUpper(barIndex); - highLower = GetCHighLower(barIndex); - lowUpper = GetCLowUpper(barIndex); - lowLower = GetCLowLower(barIndex); - closeUpper = GetCCloseUpper(barIndex); - closeLower = GetCCloseLower(barIndex); - break; - - // - // Short ... - case X_MARKET_CYCLE_SHORT: - // - openUpper = GetSOpenUpper(barIndex); - openLower = GetSOpenLower(barIndex); - highUpper = GetSHighUpper(barIndex); - highLower = GetSHighLower(barIndex); - lowUpper = GetSLowUpper(barIndex); - lowLower = GetSLowLower(barIndex); - closeUpper = GetSCloseUpper(barIndex); - closeLower = GetSCloseLower(barIndex); - break; - - // - // Medium ... - case X_MARKET_CYCLE_MEDIUM: - // - openUpper = GetMOpenUpper(barIndex); - openLower = GetMOpenLower(barIndex); - highUpper = GetMHighUpper(barIndex); - highLower = GetMHighLower(barIndex); - lowUpper = GetMLowUpper(barIndex); - lowLower = GetMLowLower(barIndex); - closeUpper = GetMCloseUpper(barIndex); - closeLower = GetMCloseLower(barIndex); - break; - - // - // Long ... - case X_MARKET_CYCLE_LONG: - // - openUpper = GetLOpenUpper(barIndex); - openLower = GetLOpenLower(barIndex); - highUpper = GetLHighUpper(barIndex); - highLower = GetLHighLower(barIndex); - lowUpper = GetLLowUpper(barIndex); - lowLower = GetLLowLower(barIndex); - closeUpper = GetLCloseUpper(barIndex); - closeLower = GetLCloseLower(barIndex); - break; - - // - // Hind ... - case X_MARKET_CYCLE_HIND: - // - openUpper = GetHOpenUpper(barIndex); - openLower = GetHOpenLower(barIndex); - highUpper = GetHHighUpper(barIndex); - highLower = GetHHighLower(barIndex); - lowUpper = GetHLowUpper(barIndex); - lowLower = GetHLowLower(barIndex); - closeUpper = GetHCloseUpper(barIndex); - closeLower = GetHCloseLower(barIndex); - break; - } - } - - // - int GetCyclesUpperValues( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Cycles - ) - { - // - int result = 0; - - // - double values[]; - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - double iOpenUpper = 0; - double iOpenLower = 0; - double iHighUpper = 0; - double iHighLower = 0; - double iLowUpper = 0; - double iLowLower = 0; - double iCloseUpper = 0; - double iCloseLower = 0; - GetCycleValues( - barIndex, - cycles[i], - iOpenUpper, - iOpenLower, - iHighUpper, - iHighLower, - iLowUpper, - iLowLower, - iCloseUpper, - iCloseLower // - ); - - // - Add( - iOpenUpper, - values // - ); - - // - Add( - iHighUpper, - values // - ); - - // - Add( - iLowUpper, - values // - ); - - // - Add( - iCloseUpper, - values // - ); - } - - // - result = ArraySize(values); - - // - return result; - } - - // - int GetCyclesOpenUpperValues( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Cycles - ) - { - // - int result = 0; - - // - double values[]; - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - double iOpenUpper = 0; - double iOpenLower = 0; - double iHighUpper = 0; - double iHighLower = 0; - double iLowUpper = 0; - double iLowLower = 0; - double iCloseUpper = 0; - double iCloseLower = 0; - GetCycleValues( - barIndex, - cycles[i], - iOpenUpper, - iOpenLower, - iHighUpper, - iHighLower, - iLowUpper, - iLowLower, - iCloseUpper, - iCloseLower // - ); - - // - Add( - iOpenUpper, - values // - ); - } - - // - result = ArraySize(values); - - // - return result; - } - - // - int GetCyclesOpenLowerValues( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Cycles - ) - { - // - int result = 0; - - // - double values[]; - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - double iOpenUpper = 0; - double iOpenLower = 0; - double iHighUpper = 0; - double iHighLower = 0; - double iLowUpper = 0; - double iLowLower = 0; - double iCloseUpper = 0; - double iCloseLower = 0; - GetCycleValues( - barIndex, - cycles[i], - iOpenUpper, - iOpenLower, - iHighUpper, - iHighLower, - iLowUpper, - iLowLower, - iCloseUpper, - iCloseLower // - ); - - // - Add( - iOpenLower, - values // - ); - } - - // - result = ArraySize(values); - - // - return result; - } - - // - int GetCyclesHighUpperValues( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Cycles - ) - { - // - int result = 0; - - // - double values[]; - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - double iOpenUpper = 0; - double iOpenLower = 0; - double iHighUpper = 0; - double iHighLower = 0; - double iLowUpper = 0; - double iLowLower = 0; - double iCloseUpper = 0; - double iCloseLower = 0; - GetCycleValues( - barIndex, - cycles[i], - iOpenUpper, - iOpenLower, - iHighUpper, - iHighLower, - iLowUpper, - iLowLower, - iCloseUpper, - iCloseLower // - ); - - // - Add( - iHighUpper, - values // - ); - } - - // - result = ArraySize(values); - - // - return result; - } - - // - int GetCyclesHighLowerValues( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Cycles - ) - { - // - int result = 0; - - // - double values[]; - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - double iOpenUpper = 0; - double iOpenLower = 0; - double iHighUpper = 0; - double iHighLower = 0; - double iLowUpper = 0; - double iLowLower = 0; - double iCloseUpper = 0; - double iCloseLower = 0; - GetCycleValues( - barIndex, - cycles[i], - iOpenUpper, - iOpenLower, - iHighUpper, - iHighLower, - iLowUpper, - iLowLower, - iCloseUpper, - iCloseLower // - ); - - // - Add( - iHighLower, - values // - ); - } - - // - result = ArraySize(values); - - // - return result; - } - - // - int GetCyclesLowUpperValues( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Cycles - ) - { - // - int result = 0; - - // - double values[]; - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - double iOpenUpper = 0; - double iOpenLower = 0; - double iHighUpper = 0; - double iHighLower = 0; - double iLowUpper = 0; - double iLowLower = 0; - double iCloseUpper = 0; - double iCloseLower = 0; - GetCycleValues( - barIndex, - cycles[i], - iOpenUpper, - iOpenLower, - iHighUpper, - iHighLower, - iLowUpper, - iLowLower, - iCloseUpper, - iCloseLower // - ); - - // - Add( - iLowUpper, - values // - ); - } - - // - result = ArraySize(values); - - // - return result; - } - - // - int GetCyclesLowLowerValues( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Cycles - ) - { - // - int result = 0; - - // - double values[]; - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - double iOpenUpper = 0; - double iOpenLower = 0; - double iHighUpper = 0; - double iHighLower = 0; - double iLowUpper = 0; - double iLowLower = 0; - double iCloseUpper = 0; - double iCloseLower = 0; - GetCycleValues( - barIndex, - cycles[i], - iOpenUpper, - iOpenLower, - iHighUpper, - iHighLower, - iLowUpper, - iLowLower, - iCloseUpper, - iCloseLower // - ); - - // - Add( - iLowLower, - values // - ); - } - - // - result = ArraySize(values); - - // - return result; - } - - // - int GetCyclesCloseUpperValues( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Cycles - ) - { - // - int result = 0; - - // - double values[]; - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - double iOpenUpper = 0; - double iOpenLower = 0; - double iHighUpper = 0; - double iHighLower = 0; - double iLowUpper = 0; - double iLowLower = 0; - double iCloseUpper = 0; - double iCloseLower = 0; - GetCycleValues( - barIndex, - cycles[i], - iOpenUpper, - iOpenLower, - iHighUpper, - iHighLower, - iLowUpper, - iLowLower, - iCloseUpper, - iCloseLower // - ); - - // - Add( - iCloseUpper, - values // - ); - } - - // - result = ArraySize(values); - - // - return result; - } - - // - int GetCyclesCloseLowerValues( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Cycles - ) - { - // - int result = 0; - - // - double values[]; - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - double iOpenUpper = 0; - double iOpenLower = 0; - double iHighUpper = 0; - double iHighLower = 0; - double iLowUpper = 0; - double iLowLower = 0; - double iCloseUpper = 0; - double iCloseLower = 0; - GetCycleValues( - barIndex, - cycles[i], - iOpenUpper, - iOpenLower, - iHighUpper, - iHighLower, - iLowUpper, - iLowLower, - iCloseUpper, - iCloseLower // - ); - - // - Add( - iCloseLower, - values // - ); - } - - // - result = ArraySize(values); - - // - return result; - } - - // - int GetCyclesLowerValues( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Cycles - ) - { - // - int result = 0; - - // - double values[]; - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - double iOpenUpper = 0; - double iOpenLower = 0; - double iHighUpper = 0; - double iHighLower = 0; - double iLowUpper = 0; - double iLowLower = 0; - double iCloseUpper = 0; - double iCloseLower = 0; - GetCycleValues( - barIndex, - cycles[i], - iOpenUpper, - iOpenLower, - iHighUpper, - iHighLower, - iLowUpper, - iLowLower, - iCloseUpper, - iCloseLower // - ); - - // - Add( - iOpenLower, - values // - ); - - // - Add( - iHighLower, - values // - ); - - // - Add( - iLowLower, - values // - ); - - // - Add( - iCloseLower, - values // - ); - } - - // - result = ArraySize(values); - - // - return result; - } - - // - double GetCyclesUpperMax( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Cycles - ) - { - // - double result = 0; - - // - double values[]; - int count = GetCyclesUpperValues( - barIndex, - cycles // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetCyclesUpperMin( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Cycles - ) - { - // - double result = 0; - - // - double values[]; - int count = GetCyclesUpperValues( - barIndex, - cycles // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetCyclesLowerMax( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Cycles - ) - { - // - double result = 0; - - // - double values[]; - int count = GetCyclesLowerValues( - barIndex, - cycles // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetCyclesLowerMin( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Cycles - ) - { - // - double result = 0; - - // - double values[]; - int count = GetCyclesLowerValues( - barIndex, - cycles // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - // Conditions ... - - // - bool GetConditions( - XCHDONConditions &conditions, // - int barIndex = 0, // - int loopback = 5 // - ) - { - // - bool result = true; - - // - if (loopback < 5) - { - loopback = 5; - } - - // - conditions.Clean(); - - // - conditions.symbol = mSymbol; - conditions.period = mPeriod; - conditions.time = TimeCurrent(); - - // - int zIndex = barIndex; - int cIndex = zIndex + 1; - int pIndex = cIndex + 1; - int ppIndex = pIndex + 1; - - // - // Buffers ... - - // - // Current ... - // CopyCTenkanSen( - // zIndex, - // loopback, - // conditions.cTK // - // ); - - // - // Short ... - - // - // Medium ... - - // - // Long ... - - // - // Hind ... - - // - // Conditions ... - - // - XOHCL cBar; - result = cBar.Init( - mSymbol, - mPeriod, - cIndex // - ); - if (!result) - { - return result; - } - - // - XOHCL pBar; - result = pBar.Init( - mSymbol, - mPeriod, - pIndex // - ); - if (!result) - { - return result; - } - - // - // Conditions ... - - // - // Current ... - - // - // Short ... - - // - // Medium ... - - // - // Long ... - - // - // Hind ... - - // - return result; - } - - // - // Protected ... -protected: - // - // Private ... -private: - // - // Props ... - XCHDONInputs mInputs; // Inputs ... - - // - // Buffers ... - - // - // Current ... - double cOpenUpperBuffer[]; - double cOpenLowerBuffer[]; - double cHighUpperBuffer[]; - double cHighLowerBuffer[]; - double cLowUpperBuffer[]; - double cLowLowerBuffer[]; - double cCloseUpperBuffer[]; - double cCloseLowerBuffer[]; - - // - // Short ... - double sOpenUpperBuffer[]; - double sOpenLowerBuffer[]; - double sHighUpperBuffer[]; - double sHighLowerBuffer[]; - double sLowUpperBuffer[]; - double sLowLowerBuffer[]; - double sCloseUpperBuffer[]; - double sCloseLowerBuffer[]; - - // - // Medium ... - double mOpenUpperBuffer[]; - double mOpenLowerBuffer[]; - double mHighUpperBuffer[]; - double mHighLowerBuffer[]; - double mLowUpperBuffer[]; - double mLowLowerBuffer[]; - double mCloseUpperBuffer[]; - double mCloseLowerBuffer[]; - - // - // Long ... - double lOpenUpperBuffer[]; - double lOpenLowerBuffer[]; - double lHighUpperBuffer[]; - double lHighLowerBuffer[]; - double lLowUpperBuffer[]; - double lLowLowerBuffer[]; - double lCloseUpperBuffer[]; - double lCloseLowerBuffer[]; - - // - // Hind ... - double hOpenUpperBuffer[]; - double hOpenLowerBuffer[]; - double hHighUpperBuffer[]; - double hHighLowerBuffer[]; - double hLowUpperBuffer[]; - double hLowLowerBuffer[]; - double hCloseUpperBuffer[]; - double hCloseLowerBuffer[]; - - // - // Tools ... - - // - // Calculate Values Until Now ... - void Calculate() - { - // - int totalBars = CountBars(); - if (totalBars > 1000) - { - totalBars = 1000; - } - - // - // Current ... - CopyBuffer( - mHandler, - XCHDON_C_OPEN_UPPER_LINE, - 0, - totalBars, - cOpenUpperBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_C_OPEN_LOWER_LINE, - 0, - totalBars, - cOpenLowerBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_C_HIGH_UPPER_LINE, - 0, - totalBars, - cHighUpperBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_C_HIGH_LOWER_LINE, - 0, - totalBars, - cHighLowerBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_C_LOW_UPPER_LINE, - 0, - totalBars, - cLowUpperBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_C_LOW_LOWER_LINE, - 0, - totalBars, - cLowLowerBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_C_CLOSE_UPPER_LINE, - 0, - totalBars, - cCloseUpperBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_C_CLOSE_LOWER_LINE, - 0, - totalBars, - cCloseLowerBuffer // - ); - - // - // Short ... - CopyBuffer( - mHandler, - XCHDON_S_OPEN_UPPER_LINE, - 0, - totalBars, - sOpenUpperBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_S_OPEN_LOWER_LINE, - 0, - totalBars, - sOpenLowerBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_S_HIGH_UPPER_LINE, - 0, - totalBars, - sHighUpperBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_S_HIGH_LOWER_LINE, - 0, - totalBars, - sHighLowerBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_S_LOW_UPPER_LINE, - 0, - totalBars, - sLowUpperBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_S_LOW_LOWER_LINE, - 0, - totalBars, - sLowLowerBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_S_CLOSE_UPPER_LINE, - 0, - totalBars, - sCloseUpperBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_S_CLOSE_LOWER_LINE, - 0, - totalBars, - sCloseLowerBuffer // - ); - - // - // Medium ... - CopyBuffer( - mHandler, - XCHDON_M_OPEN_UPPER_LINE, - 0, - totalBars, - mOpenUpperBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_M_OPEN_LOWER_LINE, - 0, - totalBars, - mOpenLowerBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_M_HIGH_UPPER_LINE, - 0, - totalBars, - mHighUpperBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_M_HIGH_LOWER_LINE, - 0, - totalBars, - mHighLowerBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_M_LOW_UPPER_LINE, - 0, - totalBars, - mLowUpperBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_M_LOW_LOWER_LINE, - 0, - totalBars, - mLowLowerBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_M_CLOSE_UPPER_LINE, - 0, - totalBars, - mCloseUpperBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_M_CLOSE_LOWER_LINE, - 0, - totalBars, - mCloseLowerBuffer // - ); - - // - // Long ... - CopyBuffer( - mHandler, - XCHDON_L_OPEN_UPPER_LINE, - 0, - totalBars, - lOpenUpperBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_L_OPEN_LOWER_LINE, - 0, - totalBars, - lOpenLowerBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_L_HIGH_UPPER_LINE, - 0, - totalBars, - lHighUpperBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_L_HIGH_LOWER_LINE, - 0, - totalBars, - lHighLowerBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_L_LOW_UPPER_LINE, - 0, - totalBars, - lLowUpperBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_L_LOW_LOWER_LINE, - 0, - totalBars, - lLowLowerBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_L_CLOSE_UPPER_LINE, - 0, - totalBars, - lCloseUpperBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_L_CLOSE_LOWER_LINE, - 0, - totalBars, - lCloseLowerBuffer // - ); - - // - // Hind ... - CopyBuffer( - mHandler, - XCHDON_H_OPEN_UPPER_LINE, - 0, - totalBars, - hOpenUpperBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_H_OPEN_LOWER_LINE, - 0, - totalBars, - hOpenLowerBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_H_HIGH_UPPER_LINE, - 0, - totalBars, - hHighUpperBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_H_HIGH_LOWER_LINE, - 0, - totalBars, - hHighLowerBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_H_LOW_UPPER_LINE, - 0, - totalBars, - hLowUpperBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_H_LOW_LOWER_LINE, - 0, - totalBars, - hLowLowerBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_H_CLOSE_UPPER_LINE, - 0, - totalBars, - hCloseUpperBuffer // - ); - CopyBuffer( - mHandler, - XCHDON_H_CLOSE_LOWER_LINE, - 0, - totalBars, - hCloseLowerBuffer // - ); - }; -}; - -// \ No newline at end of file diff --git a/Helpers/x-saherelm.xchhk.helper.mq5 b/Helpers/x-saherelm.xchhk.helper.mq5 deleted file mode 100644 index 1291254f..00000000 --- a/Helpers/x-saherelm.xchhk.helper.mq5 +++ /dev/null @@ -1,5980 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Helper Class Library -// ---------------------------------------------- -// Name: XSCXCHHKHelper -// 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_XCHHK_BUFFERS -{ - // - // Current ... - XCHHK_CO_LINE = 0, - XCHHK_CH_LINE = 1, - XCHHK_CL_LINE = 2, - XCHHK_CC_LINE = 3, - // - // Short ... - XCHHK_SO_LINE = 5, - XCHHK_SH_LINE = 6, - XCHHK_SL_LINE = 7, - XCHHK_SC_LINE = 8, - // - // Medium ... - XCHHK_MO_LINE = 10, - XCHHK_MH_LINE = 11, - XCHHK_ML_LINE = 12, - XCHHK_MC_LINE = 13, - // - // Long ... - XCHHK_LO_LINE = 15, - XCHHK_LH_LINE = 16, - XCHHK_LL_LINE = 17, - XCHHK_LC_LINE = 18, - // - // Hind ... - XCHHK_HO_LINE = 20, - XCHHK_HH_LINE = 21, - XCHHK_HL_LINE = 22, - XCHHK_HC_LINE = 23, -}; - -// -// Input Models ... -struct XCHHKInputs -{ - // - // Props ... - - // - // Market ... - int cSmoothingLength; // Smoothing Length - - // - // Cycles ... - - // - // Short ... - ENUM_X_PERIOD_METHOD scMethod; // How to Find Period - ENUM_TIMEFRAMES scPeriod; // Time Period - - // - // Medium ... - ENUM_X_PERIOD_METHOD mcMethod; // How to Find Period - ENUM_TIMEFRAMES mcPeriod; // Time Period - - // - // Long ... - ENUM_X_PERIOD_METHOD lcMethod; // How to Find Period - ENUM_TIMEFRAMES lcPeriod; // Time Period - - // - // Hind ... - ENUM_X_PERIOD_METHOD hcMethod; // How to Find Period - ENUM_TIMEFRAMES hcPeriod; // Time Period - - // - // Presentation ... - bool ignoreShadows; // Ignore Bar Shadows - bool showCurrent; // Show Current Cycle - bool showShort; // Show Short Cycle - bool showMedium; // Show Medium Cycle - bool showLong; // Show Long Cycle - bool showHind; // Show Hind Cycle - - // - // Constructor(s) ... - XCHHKInputs() - { - // - Clean(); - } - - // - // Tools ... - - // - // Clean ... - void Clean() - { - // - cSmoothingLength = 0; - - // - scMethod = X_PERIOD_AUTO; - scPeriod = NULL; - mcMethod = X_PERIOD_AUTO; - mcPeriod = NULL; - lcMethod = X_PERIOD_AUTO; - lcPeriod = NULL; - hcMethod = X_PERIOD_AUTO; - hcPeriod = NULL; - - // - ignoreShadows = false; - showCurrent = false; - showShort = false; - showMedium = false; - showLong = false; - showHind = false; - } - - // - // Default ... - void Default() - { - // - cSmoothingLength = 14; - - // - scMethod = X_PERIOD_AUTO; - scPeriod = NULL; - mcMethod = X_PERIOD_AUTO; - mcPeriod = NULL; - lcMethod = X_PERIOD_AUTO; - lcPeriod = NULL; - hcMethod = X_PERIOD_AUTO; - hcPeriod = NULL; - - // - ignoreShadows = false; - showCurrent = true; - showShort = true; - showMedium = true; - showLong = true; - showHind = true; - } - - // - // Validate ... - bool IsValid() - { - // - bool result = false; - - // - result = - // - cSmoothingLength > 2 && - // - (IsValid(scMethod, scPeriod) && - IsValid(mcMethod, mcPeriod) && - IsValid(lcMethod, lcPeriod) && - IsValid(hcMethod, hcPeriod)) - // - ; - - // - return result; - } - - // - // Retrieve MAx Length ... - int Max() - { - // - int result = 0; - - // - result = - // - MathMax(0, cSmoothingLength) - // - ; - - // - return result; - } -}; - -// -// Define Conditions ... -struct XCHHKConditions -{ - // - // Common ... - string symbol; - ENUM_TIMEFRAMES period; - datetime time; - - // - // Buffers ... - - // - // Current ... - XOHCL cBars[]; - - // - // Short ... - XOHCL sBars[]; - - // - // Medium ... - XOHCL mBars[]; - - // - // Long ... - XOHCL lBars[]; - - // - // Hind ... - XOHCL hBars[]; - - // - // Conditions ... - - // - // Power ... - bool hasBullishPower; - bool hasBearishPower; - bool isBullishPowerUp; - bool isBearishPowerUp; - bool isBullishPowerIncreasing; - bool isBullishPowerDecreasing; - bool isBearishPowerIncreasing; - bool isBearishPowerDecreasing; - - // - // Current ... - - // - bool isCBullish; - bool isCSwitchedToBullish; - bool isCBearish; - bool isCSwitchedToBearish; - - // - bool isCloseOverCHigh; - bool isCloseUnderCLow; - - // - // Short ... - - // - bool isSBullish; - bool isSSwitchedToBullish; - bool isSBearish; - bool isSSwitchedToBearish; - - // - bool isCloseOverSHigh; - bool isCloseUnderSLow; - - // - // Medium ... - - // - bool isMBullish; - bool isMSwitchedToBullish; - bool isMBearish; - bool isMSwitchedToBearish; - - // - bool isCloseOverMHigh; - bool isCloseUnderMLow; - - // - // Long ... - - // - bool isLBullish; - bool isLSwitchedToBullish; - bool isLBearish; - bool isLSwitchedToBearish; - - // - bool isCloseOverLHigh; - bool isCloseUnderLLow; - - // - // Hind ... - - // - bool isHBullish; - bool isHSwitchedToBullish; - bool isHBearish; - bool isHSwitchedToBearish; - - // - bool isCloseOverHHigh; - bool isCloseUnderHLow; - - // - void Clean() - { - // - Clean(cBars); - Clean(sBars); - Clean(mBars); - Clean(lBars); - Clean(hBars); - - // - ArraySetAsSeries(cBars, true); - ArraySetAsSeries(sBars, true); - ArraySetAsSeries(mBars, true); - ArraySetAsSeries(lBars, true); - ArraySetAsSeries(hBars, true); - - // - // Conditions ... - - // - // Power ... - hasBullishPower = false; - hasBearishPower = false; - isBullishPowerUp = false; - isBearishPowerUp = false; - isBullishPowerIncreasing = false; - isBullishPowerDecreasing = false; - isBearishPowerIncreasing = false; - isBearishPowerDecreasing = false; - - // - // Current ... - - // - isCBullish = false; - isCSwitchedToBullish = false; - isCBearish = false; - isCSwitchedToBearish = false; - - // - isCloseOverCHigh = false; - isCloseUnderCLow = false; - - // - // Short ... - - // - isSBullish = false; - isSSwitchedToBullish = false; - isSBearish = false; - isSSwitchedToBearish = false; - - // - isCloseOverSHigh = false; - isCloseUnderSLow = false; - - // - // Medium ... - - // - isMBullish = false; - isMSwitchedToBullish = false; - isMBearish = false; - isMSwitchedToBearish = false; - - // - isCloseOverMHigh = false; - isCloseUnderMLow = false; - - // - // Long ... - - // - isLBullish = false; - isLSwitchedToBullish = false; - isLBearish = false; - isLSwitchedToBearish = false; - - // - isCloseOverLHigh = false; - isCloseUnderLLow = false; - - // - // Hind ... - - // - isHBullish = false; - isHSwitchedToBullish = false; - isHBearish = false; - isHSwitchedToBearish = false; - - // - isCloseOverHHigh = false; - isCloseUnderHLow = false; - } - - // - void GenerateScore( - double &bullishScore, - double &bearishScore // - ) - { - // - bullishScore = 0; - bearishScore = 0; - - // - // Since We have to Use this - // Only for Filtering Signals ... - // We Can Ignore Scoring ... - // or Complete this later ... - - // - // Conditions ... - - // - // Power ... - if (hasBullishPower) - { - bullishScore++; - } - if (hasBearishPower) - { - bearishScore++; - } - if (isBullishPowerUp) - { - bullishScore++; - } - if (isBearishPowerUp) - { - bearishScore++; - } - if (isBullishPowerIncreasing) - { - bullishScore++; - } - if (isBullishPowerDecreasing) - { - bearishScore++; - } - if (isBearishPowerIncreasing) - { - bearishScore++; - } - if (isBearishPowerDecreasing) - { - bullishScore++; - } - - // - // Current ... - if (isCBullish) - { - bullishScore++; - } - if (isCSwitchedToBullish) - { - bullishScore++; - } - if (isCBearish) - { - bearishScore++; - } - if (isCSwitchedToBearish) - { - bearishScore++; - } - if (isCloseOverCHigh) - { - bullishScore++; - } - if (isCloseUnderCLow) - { - bearishScore++; - } - - // - // Short ... - if (isSBullish) - { - bullishScore++; - } - if (isSSwitchedToBullish) - { - bullishScore++; - } - if (isSBearish) - { - bearishScore++; - } - if (isSSwitchedToBearish) - { - bearishScore++; - } - if (isCloseOverSHigh) - { - bullishScore++; - } - if (isCloseUnderSLow) - { - bearishScore++; - } - - // - // Medium ... - if (isMBullish) - { - bullishScore++; - } - if (isMSwitchedToBullish) - { - bullishScore++; - } - if (isMBearish) - { - bearishScore++; - } - if (isMSwitchedToBearish) - { - bearishScore++; - } - if (isCloseOverMHigh) - { - bullishScore++; - } - if (isCloseUnderMLow) - { - bearishScore++; - } - - // - // Long ... - if (isLBullish) - { - bullishScore++; - } - if (isLSwitchedToBullish) - { - bullishScore++; - } - if (isLBearish) - { - bearishScore++; - } - if (isLSwitchedToBearish) - { - bearishScore++; - } - if (isCloseOverLHigh) - { - bullishScore++; - } - if (isCloseUnderLLow) - { - bearishScore++; - } - - // - // Hind ... - if (isHBullish) - { - bullishScore++; - } - if (isHSwitchedToBullish) - { - bullishScore++; - } - if (isHBearish) - { - bearishScore++; - } - if (isHSwitchedToBearish) - { - bearishScore++; - } - if (isCloseOverHHigh) - { - bullishScore++; - } - if (isCloseUnderHLow) - { - bearishScore++; - } - } - - // - string GenerateSummary( - bool onlyCommons = false, - bool onlyConditions = false, - bool includeScores = true, - bool ignoreFalseConditions = true, - string separator = "\n" // - ) - { - // - string result = NULL; - - // - double bullishScore = 0; - double bearishScore = 0; - GenerateScore( - bullishScore, - bearishScore // - ); - - // - string scoresStr = - // - "Scores: " + separator + - "---------------" + separator + - "Bullish: " + ToString(bullishScore) + separator + - "Bearish: " + ToString(bearishScore) + separator + - "" - // - ; - - // - string commonStr = GenerateSpecifiedCommonSummary( - this, - separator, - includeScores // - ); - - // - string conditionsStr = - // - // Power ... - ToString("hasBullishPower", hasBullishPower, ignoreFalseConditions, separator) + - ToString("hasBearishPower", hasBearishPower, ignoreFalseConditions, separator) + - ToString("isBullishPowerUp", isBullishPowerUp, ignoreFalseConditions, separator) + - ToString("isBearishPowerUp", isBearishPowerUp, ignoreFalseConditions, separator) + - ToString("isBullishPowerIncreasing", isBullishPowerIncreasing, ignoreFalseConditions, separator) + - ToString("isBullishPowerDecreasing", isBullishPowerDecreasing, ignoreFalseConditions, separator) + - ToString("isBearishPowerIncreasing", isBearishPowerIncreasing, ignoreFalseConditions, separator) + - ToString("isBearishPowerDecreasing", isBearishPowerDecreasing, ignoreFalseConditions, separator) + - // - // Current ... - ToString("isCBullish", isCBullish, ignoreFalseConditions, separator) + - ToString("isCSwitchedToBullish", isCSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isCBearish", isCBearish, ignoreFalseConditions, separator) + - ToString("isCSwitchedToBearish", isCSwitchedToBearish, ignoreFalseConditions, separator) + - ToString("isCloseOverCHigh", isCloseOverCHigh, ignoreFalseConditions, separator) + - ToString("isCloseUnderCLow", isCloseUnderCLow, ignoreFalseConditions, separator) + - // - // Short ... - ToString("isSBullish", isSBullish, ignoreFalseConditions, separator) + - ToString("isSSwitchedToBullish", isSSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isSBearish", isSBearish, ignoreFalseConditions, separator) + - ToString("isSSwitchedToBearish", isSSwitchedToBearish, ignoreFalseConditions, separator) + - ToString("isCloseOverSHigh", isCloseOverSHigh, ignoreFalseConditions, separator) + - ToString("isCloseUnderSLow", isCloseUnderSLow, ignoreFalseConditions, separator) + - // - // Medium ... - ToString("isMBullish", isMBullish, ignoreFalseConditions, separator) + - ToString("isMSwitchedToBullish", isMSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isMBearish", isMBearish, ignoreFalseConditions, separator) + - ToString("isMSwitchedToBearish", isMSwitchedToBearish, ignoreFalseConditions, separator) + - ToString("isCloseOverMHigh", isCloseOverMHigh, ignoreFalseConditions, separator) + - ToString("isCloseUnderMLow", isCloseUnderMLow, ignoreFalseConditions, separator) + - // - // Long ... - ToString("isLBullish", isLBullish, ignoreFalseConditions, separator) + - ToString("isLSwitchedToBullish", isLSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isLBearish", isLBearish, ignoreFalseConditions, separator) + - ToString("isLSwitchedToBearish", isLSwitchedToBearish, ignoreFalseConditions, separator) + - ToString("isCloseOverLHigh", isCloseOverLHigh, ignoreFalseConditions, separator) + - ToString("isCloseUnderLLow", isCloseUnderLLow, ignoreFalseConditions, separator) + - // - // Hind ... - ToString("isHBullish", isHBullish, ignoreFalseConditions, separator) + - ToString("isHSwitchedToBullish", isHSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isHBearish", isHBearish, ignoreFalseConditions, separator) + - ToString("isHSwitchedToBearish", isHSwitchedToBearish, ignoreFalseConditions, separator) + - ToString("isCloseOverHHigh", isCloseOverHHigh, ignoreFalseConditions, separator) + - ToString("isCloseUnderHLow", isCloseUnderHLow, ignoreFalseConditions, separator) + - // - "" - // - ; - - // - result = - // - "[" + GetTag() + "]" + separator + - (onlyConditions - ? "" - : commonStr) + - (!includeScores - ? "" - : scoresStr) + - " " + separator + - (onlyCommons - ? "" - : conditionsStr) + - "" - // - ; - - // - return result; - } - - // - string GetTag() - { - return "XCHHK"; - } -}; - -// -// Class ... -class XSCXCHHKHelper : public XSCBaseHelper -{ - // - // Public ... -public: - // - // Props ... - - // - // Constructors ... - XSCXCHHKHelper() : XSCBaseHelper(_Symbol, _Period) - { - } - - // - // Deconstructor ... - ~XSCXCHHKHelper() - { - // - Clean(cOpenBuffer); - Clean(cHighBuffer); - Clean(cLowBuffer); - Clean(cCloseBuffer); - Clean(sOpenBuffer); - Clean(sHighBuffer); - Clean(sLowBuffer); - Clean(sCloseBuffer); - Clean(mOpenBuffer); - Clean(mHighBuffer); - Clean(mLowBuffer); - Clean(mCloseBuffer); - Clean(lOpenBuffer); - Clean(lHighBuffer); - Clean(lLowBuffer); - Clean(lCloseBuffer); - Clean(hOpenBuffer); - Clean(hHighBuffer); - Clean(hLowBuffer); - Clean(hCloseBuffer); - } - - // - // Tools ... - bool Init( - string symbol, // Trading Symbol - ENUM_TIMEFRAMES period, // Trading Period - XCHHKInputs &inputs // Inputs - ) - { - // - bool result = false; - - // - mSymbol = symbol; - mPeriod = period; - - // - result = inputs.IsValid(); - if (!result) - { - return result; - } - - // - mInputs = inputs; - - // - ArraySetAsSeries(cOpenBuffer, true); - ArraySetAsSeries(cHighBuffer, true); - ArraySetAsSeries(cLowBuffer, true); - ArraySetAsSeries(cCloseBuffer, true); - ArraySetAsSeries(sOpenBuffer, true); - ArraySetAsSeries(sHighBuffer, true); - ArraySetAsSeries(sLowBuffer, true); - ArraySetAsSeries(sCloseBuffer, true); - ArraySetAsSeries(mOpenBuffer, true); - ArraySetAsSeries(mHighBuffer, true); - ArraySetAsSeries(mLowBuffer, true); - ArraySetAsSeries(mCloseBuffer, true); - ArraySetAsSeries(lOpenBuffer, true); - ArraySetAsSeries(lHighBuffer, true); - ArraySetAsSeries(lLowBuffer, true); - ArraySetAsSeries(lCloseBuffer, true); - ArraySetAsSeries(hOpenBuffer, true); - ArraySetAsSeries(hHighBuffer, true); - ArraySetAsSeries(hLowBuffer, true); - ArraySetAsSeries(hCloseBuffer, true); - - // - mHandler = iCustom( - mSymbol, - mPeriod, - "x-saherelm.xchhk", - // - // Inputs ... - // - // Market ... - "", - mInputs.cSmoothingLength, - // - // Cycles ... - "", - // - // Short ... - "", - mInputs.scMethod, - mInputs.scPeriod, - // - // Medium ... - "", - mInputs.mcMethod, - mInputs.mcPeriod, - // - // Long ... - "", - mInputs.lcMethod, - mInputs.lcPeriod, - // - // Hind ... - "", - mInputs.hcMethod, - mInputs.hcPeriod, - // - // Presentation ... - "", - mInputs.ignoreShadows, - mInputs.showCurrent, - mInputs.showShort, - mInputs.showMedium, - mInputs.showLong, - mInputs.showHind - // - ); - result = mHandler != INVALID_HANDLE; - if (!result) - { - return result; - } - - // - return result; - } - - // - // Inputs ... - - // - XCHHKInputs GetInputs() - { - return mInputs; - } - - // - bool SetInputs( - XCHHKInputs &inputs // Configs - ) - { - // - return Init( - mSymbol, - mPeriod, - inputs - // - ); - } - - // - // Buffers ... - - // - // Current ... - - // - double GetCOpen( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(cOpenBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return cOpenBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyCOpen( - 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, - cOpenBuffer, - buffer, - forceClean - // - ); - } - - // - double GetCHigh( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(cHighBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return cHighBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyCHigh( - 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, - cHighBuffer, - buffer, - forceClean - // - ); - } - - // - double GetCLow( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(cLowBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return cLowBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyCLow( - 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, - cLowBuffer, - buffer, - forceClean - // - ); - } - - // - double GetCClose( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(cCloseBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return cCloseBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyCClose( - 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, - cCloseBuffer, - buffer, - forceClean - // - ); - } - - // - // Get XOHCL ... - bool CAsOHCL( - XOHCL &bar, // Holds Result - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(cOpenBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - double open = GetCOpen(barIndex); - double high = GetCHigh(barIndex); - double close = GetCClose(barIndex); - double low = GetCLow(barIndex); - - // - result = bar.Init( - mSymbol, - mPeriod, - open, - high, - close, - low, - barIndex - // - ); - - // - return result; - } - - // - // Copy Required Items ... - int CopyCAsOHCL( - int start, // Start - int count, // Number of Items for read - XOHCL &buffer[], // Dest Buffer - bool forceClean = true // Force To Clean buffer - ) - { - // - int result = 0; - - // - // Update Calculations ... - Calculate(); - - // - if (forceClean) - { - Clean(buffer); - } - - // - int before = ArraySize(buffer); - - // - if (start < 0) - { - start = 0; - } - - // - if (start >= ArraySize(cOpenBuffer)) - { - start = ArraySize(cOpenBuffer) - 1; - } - - // - bool asSeriesBuffer = ArrayGetAsSeries(buffer); - ArraySetAsSeries(buffer, true); - - // - for (int i = start; i < start + count; i++) - { - // - XOHCL iBar; - bool isInit = CAsOHCL(iBar, i); - - // - if (isInit) - { - // - AddRef( - iBar, - buffer - // - ); - } - } - - // - ArraySetAsSeries(buffer, asSeriesBuffer); - - // - int after = ArraySize(buffer); - - // - result = after - before; - - // - return result; - } - - // - // Short ... - - // - double GetSOpen( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(sOpenBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return sOpenBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopySOpen( - 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, - sOpenBuffer, - buffer, - forceClean - // - ); - } - - // - double GetSHigh( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(sHighBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return sHighBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopySHigh( - 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, - sHighBuffer, - buffer, - forceClean - // - ); - } - - // - double GetSLow( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(sLowBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return sLowBuffer[barIndex]; - } - - // - // Copy Required Items ... - 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 - // - ); - } - - // - double GetSClose( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(sCloseBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return sCloseBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopySClose( - 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, - sCloseBuffer, - buffer, - forceClean - // - ); - } - - // - // Get XOHCL ... - bool SAsOHCL( - XOHCL &bar, // Holds Result - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(sOpenBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - double open = GetSOpen(barIndex); - double high = GetSHigh(barIndex); - double close = GetSClose(barIndex); - double low = GetSLow(barIndex); - - // - result = bar.Init( - mSymbol, - mPeriod, - open, - high, - close, - low, - barIndex - // - ); - - // - return result; - } - - // - // Copy Required Items ... - int CopySAsOHCL( - int start, // Start - int count, // Number of Items for read - XOHCL &buffer[], // Dest Buffer - bool forceClean = true // Force To Clean buffer - ) - { - // - int result = 0; - - // - // Update Calculations ... - Calculate(); - - // - if (forceClean) - { - Clean(buffer); - } - - // - int before = ArraySize(buffer); - - // - if (start < 0) - { - start = 0; - } - - // - if (start >= ArraySize(sOpenBuffer)) - { - start = ArraySize(sOpenBuffer) - 1; - } - - // - bool asSeriesBuffer = ArrayGetAsSeries(buffer); - ArraySetAsSeries(buffer, true); - - // - for (int i = start; i < start + count; i++) - { - // - XOHCL iBar; - bool isInit = SAsOHCL(iBar, i); - - // - if (isInit) - { - // - AddRef( - iBar, - buffer - // - ); - } - } - - // - ArraySetAsSeries(buffer, asSeriesBuffer); - - // - int after = ArraySize(buffer); - - // - result = after - before; - - // - return result; - } - - // - // Medium ... - - // - double GetMOpen( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(mOpenBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return mOpenBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyMOpen( - 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, - mOpenBuffer, - buffer, - forceClean - // - ); - } - - // - double GetMHigh( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(mHighBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return mHighBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyMHigh( - 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, - mHighBuffer, - buffer, - forceClean - // - ); - } - - // - double GetMLow( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(mLowBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return mLowBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyMLow( - 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, - mLowBuffer, - buffer, - forceClean - // - ); - } - - // - double GetMClose( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(mCloseBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return mCloseBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyMClose( - 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, - mCloseBuffer, - buffer, - forceClean - // - ); - } - - // - // Get XOHCL ... - bool MAsOHCL( - XOHCL &bar, // Holds Result - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(mOpenBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - double open = GetMOpen(barIndex); - double high = GetMHigh(barIndex); - double close = GetMClose(barIndex); - double low = GetMLow(barIndex); - - // - result = bar.Init( - mSymbol, - mPeriod, - open, - high, - close, - low, - barIndex - // - ); - - // - return result; - } - - // - // Copy Required Items ... - int CopyMAsOHCL( - int start, // Start - int count, // Number of Items for read - XOHCL &buffer[], // Dest Buffer - bool forceClean = true // Force To Clean buffer - ) - { - // - int result = 0; - - // - // Update Calculations ... - Calculate(); - - // - if (forceClean) - { - Clean(buffer); - } - - // - int before = ArraySize(buffer); - - // - if (start < 0) - { - start = 0; - } - - // - if (start >= ArraySize(mOpenBuffer)) - { - start = ArraySize(mOpenBuffer) - 1; - } - - // - bool asSeriesBuffer = ArrayGetAsSeries(buffer); - ArraySetAsSeries(buffer, true); - - // - for (int i = start; i < start + count; i++) - { - // - XOHCL iBar; - bool isInit = MAsOHCL(iBar, i); - - // - if (isInit) - { - // - AddRef( - iBar, - buffer - // - ); - } - } - - // - ArraySetAsSeries(buffer, asSeriesBuffer); - - // - int after = ArraySize(buffer); - - // - result = after - before; - - // - return result; - } - - // - // Long ... - - // - double GetLOpen( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(lOpenBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return lOpenBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyLOpen( - 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, - lOpenBuffer, - buffer, - forceClean - // - ); - } - - // - double GetLHigh( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(lHighBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return lHighBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyLHigh( - 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, - lHighBuffer, - buffer, - forceClean - // - ); - } - - // - double GetLLow( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(lLowBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return lLowBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyLLow( - 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, - lLowBuffer, - buffer, - forceClean - // - ); - } - - // - double GetLClose( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(lCloseBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return lCloseBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyLClose( - 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, - lCloseBuffer, - buffer, - forceClean - // - ); - } - - // - // Get XOHCL ... - bool LAsOHCL( - XOHCL &bar, // Holds Result - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(lOpenBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - double open = GetLOpen(barIndex); - double high = GetLHigh(barIndex); - double close = GetLClose(barIndex); - double low = GetLLow(barIndex); - - // - result = bar.Init( - mSymbol, - mPeriod, - open, - high, - close, - low, - barIndex - // - ); - - // - return result; - } - - // - // Copy Required Items ... - int CopyLAsOHCL( - int start, // Start - int count, // Number of Items for read - XOHCL &buffer[], // Dest Buffer - bool forceClean = true // Force To Clean buffer - ) - { - // - int result = 0; - - // - // Update Calculations ... - Calculate(); - - // - if (forceClean) - { - Clean(buffer); - } - - // - int before = ArraySize(buffer); - - // - if (start < 0) - { - start = 0; - } - - // - if (start >= ArraySize(lOpenBuffer)) - { - start = ArraySize(lOpenBuffer) - 1; - } - - // - bool asSeriesBuffer = ArrayGetAsSeries(buffer); - ArraySetAsSeries(buffer, true); - - // - for (int i = start; i < start + count; i++) - { - // - XOHCL iBar; - bool isInit = LAsOHCL(iBar, i); - - // - if (isInit) - { - // - AddRef( - iBar, - buffer - // - ); - } - } - - // - ArraySetAsSeries(buffer, asSeriesBuffer); - - // - int after = ArraySize(buffer); - - // - result = after - before; - - // - return result; - } - - // - // Hind ... - - // - double GetHOpen( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(hOpenBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return hOpenBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyHOpen( - 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, - hOpenBuffer, - buffer, - forceClean - // - ); - } - - // - double GetHHigh( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(hHighBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return hHighBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyHHigh( - 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, - hHighBuffer, - buffer, - forceClean - // - ); - } - - // - double GetHLow( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(hLowBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return hLowBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyHLow( - 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, - hLowBuffer, - buffer, - forceClean - // - ); - } - - // - double GetHClose( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(hCloseBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return hCloseBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyHClose( - 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, - hCloseBuffer, - buffer, - forceClean - // - ); - } - - // - // Get XOHCL ... - bool HAsOHCL( - XOHCL &bar, // Holds Result - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(hOpenBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - double open = GetHOpen(barIndex); - double high = GetHHigh(barIndex); - double close = GetHClose(barIndex); - double low = GetHLow(barIndex); - - // - result = bar.Init( - mSymbol, - mPeriod, - open, - high, - close, - low, - barIndex - // - ); - - // - return result; - } - - // - // Copy Required Items ... - int CopyHAsOHCL( - int start, // Start - int count, // Number of Items for read - XOHCL &buffer[], // Dest Buffer - bool forceClean = true // Force To Clean buffer - ) - { - // - int result = 0; - - // - // Update Calculations ... - Calculate(); - - // - if (forceClean) - { - Clean(buffer); - } - - // - int before = ArraySize(buffer); - - // - if (start < 0) - { - start = 0; - } - - // - if (start >= ArraySize(hOpenBuffer)) - { - start = ArraySize(hOpenBuffer) - 1; - } - - // - bool asSeriesBuffer = ArrayGetAsSeries(buffer); - ArraySetAsSeries(buffer, true); - - // - for (int i = start; i < start + count; i++) - { - // - XOHCL iBar; - bool isInit = HAsOHCL(iBar, i); - - // - if (isInit) - { - // - AddRef( - iBar, - buffer - // - ); - } - } - - // - ArraySetAsSeries(buffer, asSeriesBuffer); - - // - int after = ArraySize(buffer); - - // - result = after - before; - - // - return result; - } - - // - // Tools ... - - // - int GetBars( - XOHCL &bars[], - int barIndex // Bar Index - ) - { - // - int result = 0; - - // - Clean(bars); - - // - XOHCL bar; - bool hasBar = false; - - // - // CURRENT ... - bar.Clean(); - hasBar = CAsOHCL( - bar, - barIndex // - ); - if (hasBar && bar.IsValid()) - { - // - AddRef( - bar, - bars // - ); - - // - hasBar = false; - bar.Clean(); - } - - // - // SHORT ... - bar.Clean(); - hasBar = SAsOHCL( - bar, - barIndex // - ); - if (hasBar && bar.IsValid()) - { - // - AddRef( - bar, - bars // - ); - - // - hasBar = false; - bar.Clean(); - } - - // - // MEDIUM ... - bar.Clean(); - hasBar = MAsOHCL( - bar, - barIndex // - ); - if (hasBar && bar.IsValid()) - { - // - AddRef( - bar, - bars // - ); - - // - hasBar = false; - bar.Clean(); - } - - // - // LONG ... - bar.Clean(); - hasBar = LAsOHCL( - bar, - barIndex // - ); - if (hasBar && bar.IsValid()) - { - // - AddRef( - bar, - bars // - ); - - // - hasBar = false; - bar.Clean(); - } - - // - // HIND ... - bar.Clean(); - hasBar = HAsOHCL( - bar, - barIndex // - ); - if (hasBar && bar.IsValid()) - { - // - AddRef( - bar, - bars // - ); - - // - hasBar = false; - bar.Clean(); - } - - // - result = ArraySize(bars); - - // - return result; - } - - // - int GetBullishBars( - XOHCL &bars[], - int barIndex // Bar Index - ) - { - // - int result = 0; - - // - Clean(bars); - - // - XOHCL bar; - bool hasBar = false; - - // - // CURRENT ... - bar.Clean(); - hasBar = CAsOHCL( - bar, - barIndex // - ); - if (hasBar && - bar.IsValid() && - bar.IsBullish()) - { - // - AddRef( - bar, - bars // - ); - - // - hasBar = false; - bar.Clean(); - } - - // - // SHORT ... - bar.Clean(); - hasBar = SAsOHCL( - bar, - barIndex // - ); - if (hasBar && - bar.IsValid() && - bar.IsBullish()) - { - // - AddRef( - bar, - bars // - ); - - // - hasBar = false; - bar.Clean(); - } - - // - // MEDIUM ... - bar.Clean(); - hasBar = MAsOHCL( - bar, - barIndex // - ); - if (hasBar && - bar.IsValid() && - bar.IsBullish()) - { - // - AddRef( - bar, - bars // - ); - - // - hasBar = false; - bar.Clean(); - } - - // - // LONG ... - bar.Clean(); - hasBar = LAsOHCL( - bar, - barIndex // - ); - if (hasBar && - bar.IsValid() && - bar.IsBullish()) - { - // - AddRef( - bar, - bars // - ); - - // - hasBar = false; - bar.Clean(); - } - - // - // HIND ... - bar.Clean(); - hasBar = HAsOHCL( - bar, - barIndex // - ); - if (hasBar && - bar.IsValid() && - bar.IsBullish()) - { - // - AddRef( - bar, - bars // - ); - - // - hasBar = false; - bar.Clean(); - } - - // - result = ArraySize(bars); - - // - return result; - } - - // - int GetBearishBars( - XOHCL &bars[], - int barIndex // Bar Index - ) - { - // - int result = 0; - - // - Clean(bars); - - // - XOHCL bar; - bool hasBar = false; - - // - // CURRENT ... - bar.Clean(); - hasBar = CAsOHCL( - bar, - barIndex // - ); - if (hasBar && - bar.IsValid() && - bar.IsBearish()) - { - // - AddRef( - bar, - bars // - ); - - // - hasBar = false; - bar.Clean(); - } - - // - // SHORT ... - bar.Clean(); - hasBar = SAsOHCL( - bar, - barIndex // - ); - if (hasBar && - bar.IsValid() && - bar.IsBearish()) - { - // - AddRef( - bar, - bars // - ); - - // - hasBar = false; - bar.Clean(); - } - - // - // MEDIUM ... - bar.Clean(); - hasBar = MAsOHCL( - bar, - barIndex // - ); - if (hasBar && - bar.IsValid() && - bar.IsBearish()) - { - // - AddRef( - bar, - bars // - ); - - // - hasBar = false; - bar.Clean(); - } - - // - // LONG ... - bar.Clean(); - hasBar = LAsOHCL( - bar, - barIndex // - ); - if (hasBar && - bar.IsValid() && - bar.IsBearish()) - { - // - AddRef( - bar, - bars // - ); - - // - hasBar = false; - bar.Clean(); - } - - // - // HIND ... - bar.Clean(); - hasBar = HAsOHCL( - bar, - barIndex // - ); - if (hasBar && - bar.IsValid() && - bar.IsBearish()) - { - // - AddRef( - bar, - bars // - ); - - // - hasBar = false; - bar.Clean(); - } - - // - result = ArraySize(bars); - - // - return result; - } - - // - int GetCyclesBars( - XOHCL &bars[], - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - int result = 0; - - // - Clean(bars); - - // - int cyclesCount = ArraySize(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - XOHCL iBar; - bool hasBar = false; - - // - switch (cycles[i]) - { - // - // CURRENT ... - case X_MARKET_CYCLE_UNKNOWN: - hasBar = CAsOHCL(iBar, barIndex); - break; - // - // SHORT ... - case X_MARKET_CYCLE_SHORT: - hasBar = SAsOHCL(iBar, barIndex); - break; - // - // MEDIUM ... - case X_MARKET_CYCLE_MEDIUM: - hasBar = MAsOHCL(iBar, barIndex); - break; - // - // LONG ... - case X_MARKET_CYCLE_LONG: - hasBar = LAsOHCL(iBar, barIndex); - break; - // - // HIND ... - case X_MARKET_CYCLE_HIND: - hasBar = HAsOHCL(iBar, barIndex); - break; - } - - // - if (hasBar && iBar.IsValid()) - { - // - AddRef( - iBar, - bars // - ); - } - } - - // - result = ArraySize(bars); - - // - return result; - } - - // - int GetCyclesBullishBars( - XOHCL &bars[], - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - int result = 0; - - // - Clean(bars); - - // - int cyclesCount = ArraySize(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - XOHCL iBar; - bool hasBar = false; - - // - switch (cycles[i]) - { - // - // CURRENT ... - case X_MARKET_CYCLE_UNKNOWN: - hasBar = CAsOHCL(iBar, barIndex); - break; - // - // SHORT ... - case X_MARKET_CYCLE_SHORT: - hasBar = SAsOHCL(iBar, barIndex); - break; - // - // MEDIUM ... - case X_MARKET_CYCLE_MEDIUM: - hasBar = MAsOHCL(iBar, barIndex); - break; - // - // LONG ... - case X_MARKET_CYCLE_LONG: - hasBar = LAsOHCL(iBar, barIndex); - break; - // - // HIND ... - case X_MARKET_CYCLE_HIND: - hasBar = HAsOHCL(iBar, barIndex); - break; - } - - // - if (hasBar && - iBar.IsValid() && - iBar.IsBullish()) - { - // - AddRef( - iBar, - bars // - ); - } - } - - // - result = ArraySize(bars); - - // - return result; - } - - // - int GetCyclesBearishBars( - XOHCL &bars[], - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - int result = 0; - - // - Clean(bars); - - // - int cyclesCount = ArraySize(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - XOHCL iBar; - bool hasBar = false; - - // - switch (cycles[i]) - { - // - // CURRENT ... - case X_MARKET_CYCLE_UNKNOWN: - hasBar = CAsOHCL(iBar, barIndex); - break; - // - // SHORT ... - case X_MARKET_CYCLE_SHORT: - hasBar = SAsOHCL(iBar, barIndex); - break; - // - // MEDIUM ... - case X_MARKET_CYCLE_MEDIUM: - hasBar = MAsOHCL(iBar, barIndex); - break; - // - // LONG ... - case X_MARKET_CYCLE_LONG: - hasBar = LAsOHCL(iBar, barIndex); - break; - // - // HIND ... - case X_MARKET_CYCLE_HIND: - hasBar = HAsOHCL(iBar, barIndex); - break; - } - - // - if (hasBar && - iBar.IsValid() && - iBar.IsBearish()) - { - // - AddRef( - iBar, - bars // - ); - } - } - - // - result = ArraySize(bars); - - // - return result; - } - - // - double GetMaxHigh( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - XOHCL bars[]; - int barsCount = GetBars( - bars, - barIndex // - ); - if (!IsValidSize(barsCount)) - { - return result; - } - - // - double values[]; - for (int i = 0; i < barsCount; i++) - { - // - Add( - bars[i].high, - values); - } - - // - int valuesCount = ArraySize(values); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetMax(values); - - // - return result; - } - - // - double GetMinHigh( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - XOHCL bars[]; - int barsCount = GetBars( - bars, - barIndex // - ); - if (!IsValidSize(barsCount)) - { - return result; - } - - // - double values[]; - for (int i = 0; i < barsCount; i++) - { - // - Add( - bars[i].high, - values); - } - - // - int valuesCount = ArraySize(values); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetMin(values); - - // - return result; - } - - // - double GetMaxLow( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - XOHCL bars[]; - int barsCount = GetBars( - bars, - barIndex // - ); - if (!IsValidSize(barsCount)) - { - return result; - } - - // - double values[]; - for (int i = 0; i < barsCount; i++) - { - // - Add( - bars[i].low, - values); - } - - // - int valuesCount = ArraySize(values); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetMax(values); - - // - return result; - } - - // - double GetMinLow( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - XOHCL bars[]; - int barsCount = GetBars( - bars, - barIndex // - ); - if (!IsValidSize(barsCount)) - { - return result; - } - - // - double values[]; - for (int i = 0; i < barsCount; i++) - { - // - Add( - bars[i].low, - values); - } - - // - int valuesCount = ArraySize(values); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetMin(values); - - // - return result; - } - - // - // Bullish ... - - // - double GetMaxBullishHigh( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - XOHCL bars[]; - int barsCount = GetBullishBars( - bars, - barIndex // - ); - if (!IsValidSize(barsCount)) - { - return result; - } - - // - double values[]; - for (int i = 0; i < barsCount; i++) - { - // - Add( - bars[i].high, - values); - } - - // - int valuesCount = ArraySize(values); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetMax(values); - - // - return result; - } - - // - double GetMinBullishHigh( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - XOHCL bars[]; - int barsCount = GetBullishBars( - bars, - barIndex // - ); - if (!IsValidSize(barsCount)) - { - return result; - } - - // - double values[]; - for (int i = 0; i < barsCount; i++) - { - // - Add( - bars[i].high, - values); - } - - // - int valuesCount = ArraySize(values); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetMin(values); - - // - return result; - } - - // - double GetMaxBullishLow( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - XOHCL bars[]; - int barsCount = GetBullishBars( - bars, - barIndex // - ); - if (!IsValidSize(barsCount)) - { - return result; - } - - // - double values[]; - for (int i = 0; i < barsCount; i++) - { - // - Add( - bars[i].low, - values); - } - - // - int valuesCount = ArraySize(values); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetMax(values); - - // - return result; - } - - // - double GetMinBullishLow( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - XOHCL bars[]; - int barsCount = GetBullishBars( - bars, - barIndex // - ); - if (!IsValidSize(barsCount)) - { - return result; - } - - // - double values[]; - for (int i = 0; i < barsCount; i++) - { - // - Add( - bars[i].low, - values); - } - - // - int valuesCount = ArraySize(values); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetMin(values); - - // - return result; - } - - // - // Bearish ... - - // - double GetMaxBearishHigh( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - XOHCL bars[]; - int barsCount = GetBearishBars( - bars, - barIndex // - ); - if (!IsValidSize(barsCount)) - { - return result; - } - - // - double values[]; - for (int i = 0; i < barsCount; i++) - { - // - Add( - bars[i].high, - values); - } - - // - int valuesCount = ArraySize(values); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetMax(values); - - // - return result; - } - - // - double GetMinBearishHigh( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - XOHCL bars[]; - int barsCount = GetBearishBars( - bars, - barIndex // - ); - if (!IsValidSize(barsCount)) - { - return result; - } - - // - double values[]; - for (int i = 0; i < barsCount; i++) - { - // - Add( - bars[i].high, - values); - } - - // - int valuesCount = ArraySize(values); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetMin(values); - - // - return result; - } - - // - double GetMaxBearishLow( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - XOHCL bars[]; - int barsCount = GetBearishBars( - bars, - barIndex // - ); - if (!IsValidSize(barsCount)) - { - return result; - } - - // - double values[]; - for (int i = 0; i < barsCount; i++) - { - // - Add( - bars[i].low, - values); - } - - // - int valuesCount = ArraySize(values); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetMax(values); - - // - return result; - } - - // - double GetMinBearishLow( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - XOHCL bars[]; - int barsCount = GetBearishBars( - bars, - barIndex // - ); - if (!IsValidSize(barsCount)) - { - return result; - } - - // - double values[]; - for (int i = 0; i < barsCount; i++) - { - // - Add( - bars[i].low, - values); - } - - // - int valuesCount = ArraySize(values); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetMin(values); - - // - return result; - } - - // - // Cycles Bullish ... - - // - double GetMaxCyclesBullishHigh( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - XOHCL bars[]; - int barsCount = GetCyclesBullishBars( - bars, - barIndex, - cycles // - ); - if (!IsValidSize(barsCount)) - { - return result; - } - - // - double values[]; - for (int i = 0; i < barsCount; i++) - { - // - Add( - bars[i].high, - values); - } - - // - int valuesCount = ArraySize(values); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetMax(values); - - // - return result; - } - - // - double GetMinCyclesBullishHigh( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - XOHCL bars[]; - int barsCount = GetCyclesBullishBars( - bars, - barIndex, - cycles // - ); - if (!IsValidSize(barsCount)) - { - return result; - } - - // - double values[]; - for (int i = 0; i < barsCount; i++) - { - // - Add( - bars[i].high, - values); - } - - // - int valuesCount = ArraySize(values); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetMin(values); - - // - return result; - } - - // - double GetMaxCyclesBullishLow( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - XOHCL bars[]; - int barsCount = GetCyclesBullishBars( - bars, - barIndex, - cycles // - ); - if (!IsValidSize(barsCount)) - { - return result; - } - - // - double values[]; - for (int i = 0; i < barsCount; i++) - { - // - Add( - bars[i].low, - values); - } - - // - int valuesCount = ArraySize(values); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetMax(values); - - // - return result; - } - - // - double GetMinCyclesBullishLow( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - XOHCL bars[]; - int barsCount = GetCyclesBullishBars( - bars, - barIndex, - cycles // - ); - if (!IsValidSize(barsCount)) - { - return result; - } - - // - double values[]; - for (int i = 0; i < barsCount; i++) - { - // - Add( - bars[i].low, - values); - } - - // - int valuesCount = ArraySize(values); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetMin(values); - - // - return result; - } - - // - // Cycles Bearish ... - - // - double GetMaxCyclesBearishHigh( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - XOHCL bars[]; - int barsCount = GetCyclesBearishBars( - bars, - barIndex, - cycles // - ); - if (!IsValidSize(barsCount)) - { - return result; - } - - // - double values[]; - for (int i = 0; i < barsCount; i++) - { - // - Add( - bars[i].high, - values); - } - - // - int valuesCount = ArraySize(values); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetMax(values); - - // - return result; - } - - // - double GetMinCyclesBearishHigh( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - XOHCL bars[]; - int barsCount = GetCyclesBearishBars( - bars, - barIndex, - cycles // - ); - if (!IsValidSize(barsCount)) - { - return result; - } - - // - double values[]; - for (int i = 0; i < barsCount; i++) - { - // - Add( - bars[i].high, - values); - } - - // - int valuesCount = ArraySize(values); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetMin(values); - - // - return result; - } - - // - double GetMaxCyclesBearishLow( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - XOHCL bars[]; - int barsCount = GetCyclesBearishBars( - bars, - barIndex, - cycles // - ); - if (!IsValidSize(barsCount)) - { - return result; - } - - // - double values[]; - for (int i = 0; i < barsCount; i++) - { - // - Add( - bars[i].low, - values); - } - - // - int valuesCount = ArraySize(values); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetMax(values); - - // - return result; - } - - // - double GetMinCyclesBearishLow( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - XOHCL bars[]; - int barsCount = GetCyclesBearishBars( - bars, - barIndex, - cycles // - ); - if (!IsValidSize(barsCount)) - { - return result; - } - - // - double values[]; - for (int i = 0; i < barsCount; i++) - { - // - Add( - bars[i].low, - values); - } - - // - int valuesCount = ArraySize(values); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetMin(values); - - // - return result; - } - - // - double GetBullishPower( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - XOHCL bars[]; - int barsCount = GetBullishBars( - bars, - barIndex // - ); - if (!IsValidSize(barsCount)) - { - return result; - } - - // - for (int i = 0; i < barsCount; i++) - { - result += bars[i].GetBody(); - } - - // - return result; - } - - // - double GetBearishPower( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - XOHCL bars[]; - int barsCount = GetBearishBars( - bars, - barIndex // - ); - if (!IsValidSize(barsCount)) - { - return result; - } - - // - for (int i = 0; i < barsCount; i++) - { - result += bars[i].GetBody(); - } - - // - return result; - } - - // - double GetCyclesBullishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - XOHCL bars[]; - int barsCount = GetCyclesBullishBars( - bars, - barIndex, - cycles // - ); - if (!IsValidSize(barsCount)) - { - return result; - } - - // - for (int i = 0; i < barsCount; i++) - { - result += bars[i].GetBody(); - } - - // - return result; - } - - // - double GetCyclesBearishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - XOHCL bars[]; - int barsCount = GetCyclesBearishBars( - bars, - barIndex, - cycles // - ); - if (!IsValidSize(barsCount)) - { - return result; - } - - // - for (int i = 0; i < barsCount; i++) - { - result += bars[i].GetBody(); - } - - // - return result; - } - - // - bool HasBullishPower( - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - double bullishPower = GetBullishPower(barIndex); - double bearishPower = GetBearishPower(barIndex); - - // - result = - // - bearishPower >= 0 && - bullishPower > bearishPower - // - ; - - // - return result; - } - - // - bool HasBearishPower( - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - double bullishPower = GetBullishPower(barIndex); - double bearishPower = GetBearishPower(barIndex); - - // - result = - // - bullishPower >= 0 && - bearishPower > bullishPower - // - ; - - // - return result; - } - - // - bool HasCyclesBullishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - bool result = false; - - // - double bullishPower = GetCyclesBullishPower(barIndex, cycles); - double bearishPower = GetCyclesBearishPower(barIndex, cycles); - - // - result = - // - bearishPower >= 0 && - bullishPower > bearishPower - // - ; - - // - return result; - } - - // - bool HasCyclesBearishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - bool result = false; - - // - double bullishPower = GetCyclesBullishPower(barIndex, cycles); - double bearishPower = GetCyclesBearishPower(barIndex, cycles); - - // - result = - // - bullishPower >= 0 && - bearishPower > bullishPower - // - ; - - // - return result; - } - - // - // Check Bullish Power Increasing ... - bool IsBullishPowerIncreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBullishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBullishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bullish Power Decreasing ... - bool IsBullishPowerDecreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBullishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBullishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Increasing ... - bool IsBearishPowerIncreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBearishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBearishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Decreasing ... - bool IsBearishPowerDecreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBearishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBearishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Check Bullish Power Increasing ... - bool IsCyclesBullishPowerIncreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBullishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBullishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bullish Power Decreasing ... - bool IsCyclesBullishPowerDecreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBullishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBullishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Increasing ... - bool IsCyclesBearishPowerIncreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBearishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBearishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Decreasing ... - bool IsCyclesBearishPowerDecreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBearishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBearishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Check Cycles Switched to Bullish or not ... - bool IsCyclesSwitchedToBullish( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - bool result = false; - - // - int cyclesCount = ArraySize(cycles); - result = IsValidSize(cyclesCount); - if (!result) - { - return result; - } - - // - int cIndex = barIndex; - int pIndex = cIndex + 1; - - // - XOHCL cBars[]; - XOHCL pBars[]; - for (int i = 0; i < cyclesCount; i++) - { - // - XOHCL iCBar; - XOHCL iPBar; - - // - switch (cycles[i]) - { - // - // CURRENT ... - case X_MARKET_CYCLE_UNKNOWN: - result = CAsOHCL(iCBar, cIndex); - break; - // - // SHORT ... - case X_MARKET_CYCLE_SHORT: - result = SAsOHCL(iCBar, cIndex); - break; - // - // MEDIUM ... - case X_MARKET_CYCLE_MEDIUM: - result = MAsOHCL(iCBar, cIndex); - break; - // - // LONG ... - case X_MARKET_CYCLE_LONG: - result = LAsOHCL(iCBar, cIndex); - break; - // - // HIND ... - case X_MARKET_CYCLE_HIND: - result = HAsOHCL(iCBar, cIndex); - break; - } - if (!result) - { - break; - } - AddRef( - iCBar, - cBars // - ); - - // - switch (cycles[i]) - { - // - // CURRENT ... - case X_MARKET_CYCLE_UNKNOWN: - result = CAsOHCL(iPBar, pIndex); - break; - // - // SHORT ... - case X_MARKET_CYCLE_SHORT: - result = SAsOHCL(iPBar, pIndex); - break; - // - // MEDIUM ... - case X_MARKET_CYCLE_MEDIUM: - result = MAsOHCL(iPBar, pIndex); - break; - // - // LONG ... - case X_MARKET_CYCLE_LONG: - result = LAsOHCL(iPBar, pIndex); - break; - // - // HIND ... - case X_MARKET_CYCLE_HIND: - result = HAsOHCL(iPBar, pIndex); - break; - } - if (!result) - { - break; - } - AddRef( - iPBar, - pBars // - ); - } - - // - int cBarsCount = ArraySize(cBars); - int pBarsCount = ArraySize(pBars); - result = - // - IsValidSize(cBarsCount) && - cBarsCount == cyclesCount && - // - IsValidSize(pBarsCount) && - pBarsCount == cyclesCount - // - ; - if (!result) - { - return result; - } - - // - bool isCIndexBullish = true; - for (int i = 0; i < cBarsCount; i++) - { - isCIndexBullish = isCIndexBullish && cBars[i].IsBullish(); - } - - // - bool isPIndexBullish = true; - for (int i = 0; i < pBarsCount; i++) - { - isPIndexBullish = isPIndexBullish && pBars[i].IsBullish(); - } - - // - result = isCIndexBullish && - !isPIndexBullish; - - // - return result; - } - - // - // Check Cycles Switched to Bearish or not ... - bool IsCyclesSwitchedToBearish( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - bool result = false; - - // - int cyclesCount = ArraySize(cycles); - result = IsValidSize(cyclesCount); - if (!result) - { - return result; - } - - // - int cIndex = barIndex; - int pIndex = cIndex + 1; - - // - XOHCL cBars[]; - XOHCL pBars[]; - for (int i = 0; i < cyclesCount; i++) - { - // - XOHCL iCBar; - XOHCL iPBar; - - // - switch (cycles[i]) - { - // - // CURRENT ... - case X_MARKET_CYCLE_UNKNOWN: - result = CAsOHCL(iCBar, cIndex); - break; - // - // SHORT ... - case X_MARKET_CYCLE_SHORT: - result = SAsOHCL(iCBar, cIndex); - break; - // - // MEDIUM ... - case X_MARKET_CYCLE_MEDIUM: - result = MAsOHCL(iCBar, cIndex); - break; - // - // LONG ... - case X_MARKET_CYCLE_LONG: - result = LAsOHCL(iCBar, cIndex); - break; - // - // HIND ... - case X_MARKET_CYCLE_HIND: - result = HAsOHCL(iCBar, cIndex); - break; - } - if (!result) - { - break; - } - AddRef( - iCBar, - cBars // - ); - - // - switch (cycles[i]) - { - // - // CURRENT ... - case X_MARKET_CYCLE_UNKNOWN: - result = CAsOHCL(iPBar, pIndex); - break; - // - // SHORT ... - case X_MARKET_CYCLE_SHORT: - result = SAsOHCL(iPBar, pIndex); - break; - // - // MEDIUM ... - case X_MARKET_CYCLE_MEDIUM: - result = MAsOHCL(iPBar, pIndex); - break; - // - // LONG ... - case X_MARKET_CYCLE_LONG: - result = LAsOHCL(iPBar, pIndex); - break; - // - // HIND ... - case X_MARKET_CYCLE_HIND: - result = HAsOHCL(iPBar, pIndex); - break; - } - if (!result) - { - break; - } - AddRef( - iPBar, - pBars // - ); - } - - // - int cBarsCount = ArraySize(cBars); - int pBarsCount = ArraySize(pBars); - result = - // - IsValidSize(cBarsCount) && - cBarsCount == cyclesCount && - // - IsValidSize(pBarsCount) && - pBarsCount == cyclesCount - // - ; - if (!result) - { - return result; - } - - // - bool isCIndexBearish = true; - for (int i = 0; i < cBarsCount; i++) - { - isCIndexBearish = isCIndexBearish && cBars[i].IsBearish(); - } - - // - bool isPIndexBearish = true; - for (int i = 0; i < pBarsCount; i++) - { - isPIndexBearish = isPIndexBearish && pBars[i].IsBearish(); - } - - // - result = isCIndexBearish && - !isPIndexBearish; - - // - return result; - } - - // - bool IsBullishSorted( - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - int cIndex = barIndex; - int pIndex = cIndex + 1; - - // - // Current ... - - // - XOHCL cCBar; - result = CAsOHCL(cCBar, cIndex); - if (!result) - { - return result; - } - - // - XOHCL cPBar; - result = CAsOHCL(cPBar, pIndex); - if (!result) - { - return result; - } - - // - // Short ... - - // - XOHCL sCBar; - result = SAsOHCL(sCBar, cIndex); - if (!result) - { - return result; - } - - // - XOHCL sPBar; - result = SAsOHCL(sPBar, pIndex); - if (!result) - { - return result; - } - - // - // Medium ... - - // - XOHCL mCBar; - result = MAsOHCL(mCBar, cIndex); - if (!result) - { - return result; - } - - // - XOHCL mPBar; - result = MAsOHCL(mPBar, pIndex); - if (!result) - { - return result; - } - - // - // Long ... - - // - XOHCL lCBar; - result = LAsOHCL(lCBar, cIndex); - if (!result) - { - return result; - } - - // - XOHCL lPBar; - result = LAsOHCL(lPBar, pIndex); - if (!result) - { - return result; - } - - // - // Hind ... - - // - XOHCL hCBar; - result = HAsOHCL(hCBar, cIndex); - if (!result) - { - return result; - } - - // - XOHCL hPBar; - result = HAsOHCL(hPBar, pIndex); - if (!result) - { - return result; - } - - // - bool isCBullish = - // - cCBar.IsBullish() && - sCBar.IsBullish() && - mCBar.IsBullish() && - lCBar.IsBullish() && - hCBar.IsBullish() - // - ; - - // - bool isCSorted = - // - cCBar.high > sCBar.high && - sCBar.high > mCBar.high && - mCBar.high > lCBar.high && - lCBar.high > hCBar.high - // - ; - - // - bool isCPrepred = isCBullish && - isCSorted; - - // - bool isPBullish = - // - cPBar.IsBullish() && - sPBar.IsBullish() && - mPBar.IsBullish() && - lPBar.IsBullish() && - hPBar.IsBullish() - // - ; - - // - bool isPSorted = - // - cPBar.high > sPBar.high && - sPBar.high > mPBar.high && - mPBar.high > lPBar.high && - lPBar.high > hPBar.high - // - ; - - // - bool isPPrepred = isPBullish && - isPSorted; - - // - result = isCPrepred && - !isPPrepred; - - // - return result; - } - - // - bool IsBearishSorted( - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - int cIndex = barIndex; - int pIndex = cIndex + 1; - - // - // Current ... - - // - XOHCL cCBar; - result = CAsOHCL(cCBar, cIndex); - if (!result) - { - return result; - } - - // - XOHCL cPBar; - result = CAsOHCL(cPBar, pIndex); - if (!result) - { - return result; - } - - // - // Short ... - - // - XOHCL sCBar; - result = SAsOHCL(sCBar, cIndex); - if (!result) - { - return result; - } - - // - XOHCL sPBar; - result = SAsOHCL(sPBar, pIndex); - if (!result) - { - return result; - } - - // - // Medium ... - - // - XOHCL mCBar; - result = MAsOHCL(mCBar, cIndex); - if (!result) - { - return result; - } - - // - XOHCL mPBar; - result = MAsOHCL(mPBar, pIndex); - if (!result) - { - return result; - } - - // - // Long ... - - // - XOHCL lCBar; - result = LAsOHCL(lCBar, cIndex); - if (!result) - { - return result; - } - - // - XOHCL lPBar; - result = LAsOHCL(lPBar, pIndex); - if (!result) - { - return result; - } - - // - // Hind ... - - // - XOHCL hCBar; - result = HAsOHCL(hCBar, cIndex); - if (!result) - { - return result; - } - - // - XOHCL hPBar; - result = HAsOHCL(hPBar, pIndex); - if (!result) - { - return result; - } - - // - bool isCBearish = - // - cCBar.IsBearish() && - sCBar.IsBearish() && - mCBar.IsBearish() && - lCBar.IsBearish() && - hCBar.IsBearish() - // - ; - - // - bool isCSorted = - // - cCBar.low < sCBar.low && - sCBar.low < mCBar.low && - mCBar.low < lCBar.low && - lCBar.low < hCBar.low - // - ; - - // - bool isCPrepred = isCBearish && - isCSorted; - - // - bool isPBearish = - // - cPBar.IsBearish() && - sPBar.IsBearish() && - mPBar.IsBearish() && - lPBar.IsBearish() && - hPBar.IsBearish() - // - ; - - // - bool isPSorted = - // - cPBar.low < sPBar.low && - sPBar.low < mPBar.low && - mPBar.low < lPBar.low && - lPBar.low < hPBar.low - // - ; - - // - bool isPPrepred = isPBearish && - isPSorted; - - // - result = isCPrepred && - !isPPrepred; - - // - return result; - } - - // - // Check All Cycles Switched to Bullish or not ... - bool IsSwitchedToBullish( - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetAllMarketCycles(cycles); - result = IsValidSize(cyclesCount); - if (!result) - { - return result; - } - - // - result = IsCyclesSwitchedToBullish( - barIndex, - cycles // - ); - - // - return result; - } - - // - // Check All Cycles Switched to Bearish or not ... - bool IsSwitchedToBearish( - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetAllMarketCycles(cycles); - result = IsValidSize(cyclesCount); - if (!result) - { - return result; - } - - // - result = IsCyclesSwitchedToBearish( - barIndex, - cycles // - ); - - // - return result; - } - - // - // Conditions ... - - // - bool GetConditions( - XCHHKConditions &conditions, // - int barIndex = 0, // - int loopback = 5 // - ) - { - // - bool result = true; - - // - if (loopback < 5) - { - loopback = 5; - } - - // - conditions.Clean(); - - // - conditions.symbol = mSymbol; - conditions.period = mPeriod; - conditions.time = TimeCurrent(); - - // - int zIndex = barIndex; - int cIndex = zIndex + 1; - int pIndex = cIndex + 1; - int ppIndex = pIndex + 1; - - // - // Buffers ... - - // - // Current ... - CopyCAsOHCL( - zIndex, - loopback, - conditions.cBars // - ); - - // - // Short ... - CopySAsOHCL( - zIndex, - loopback, - conditions.sBars // - ); - - // - // Medium ... - CopyMAsOHCL( - zIndex, - loopback, - conditions.mBars // - ); - - // - // Long ... - CopyLAsOHCL( - zIndex, - loopback, - conditions.lBars // - ); - - // - // Hind ... - CopyHAsOHCL( - zIndex, - loopback, - conditions.hBars // - ); - - // - // Conditions ... - - // - XOHCL cBar; - result = cBar.Init( - mSymbol, - mPeriod, - cIndex // - ); - if (!result) - { - return result; - } - - // - XOHCL pBar; - result = pBar.Init( - mSymbol, - mPeriod, - pIndex // - ); - if (!result) - { - return result; - } - - // - // Power ... - - // - bool hasBullishPower = HasBullishPower(cIndex); - bool hasBullishPowerPrev = HasBullishPower(pIndex); - - // - bool hasBearishPower = HasBearishPower(cIndex); - bool hasBearishPowerPrev = HasBearishPower(pIndex); - - // - bool isBullishPowerUp = hasBullishPower && - !hasBullishPowerPrev; - bool isBearishPowerUp = hasBearishPower && - !hasBearishPowerPrev; - - // - bool isBullishPowerIncreasing = IsBullishPowerIncreasing(cIndex); - bool isBullishPowerDecreasing = IsBullishPowerDecreasing(cIndex); - bool isBearishPowerIncreasing = IsBearishPowerIncreasing(cIndex); - bool isBearishPowerDecreasing = IsBearishPowerDecreasing(cIndex); - - // - conditions.hasBullishPower = hasBullishPower; - conditions.hasBearishPower = hasBearishPower; - conditions.isBullishPowerUp = isBullishPowerUp; - conditions.isBearishPowerUp = isBearishPowerUp; - conditions.isBullishPowerIncreasing = isBullishPowerIncreasing; - conditions.isBullishPowerDecreasing = isBullishPowerDecreasing; - conditions.isBearishPowerIncreasing = isBearishPowerIncreasing; - conditions.isBearishPowerDecreasing = isBearishPowerDecreasing; - - // - // Current ... - - // - bool isCBullish = conditions.cBars[cIndex].IsBullish(); - bool isCBullishPrev = conditions.cBars[pIndex].IsBullish(); - - // - bool isCBearish = conditions.cBars[cIndex].IsBearish(); - bool isCBearishPrev = conditions.cBars[pIndex].IsBearish(); - - // - bool isCSwitchedToBullish = isCBullish && - !isCBullishPrev; - bool isCSwitchedToBearish = isCBearish && - !isCBearishPrev; - - // - bool isCloseOverCHigh = cBar.close > conditions.cBars[cIndex].high; - bool isCloseUnderCLow = cBar.close < conditions.cBars[cIndex].low; - - // - conditions.isCBullish = isCBullish; - conditions.isCSwitchedToBullish = isCSwitchedToBullish; - conditions.isCBearish = isCBearish; - conditions.isCSwitchedToBearish = isCSwitchedToBearish; - - // - conditions.isCloseOverCHigh = isCloseOverCHigh; - conditions.isCloseUnderCLow = isCloseUnderCLow; - - // - // Short ... - - // - bool isSBullish = conditions.sBars[cIndex].IsBullish(); - bool isSBullishPrev = conditions.sBars[pIndex].IsBullish(); - - // - bool isSBearish = conditions.sBars[cIndex].IsBearish(); - bool isSBearishPrev = conditions.sBars[pIndex].IsBearish(); - - // - bool isSSwitchedToBullish = isSBullish && - !isSBullishPrev; - bool isSSwitchedToBearish = isSBearish && - !isSBearishPrev; - - // - bool isCloseOverSHigh = cBar.close > conditions.sBars[cIndex].high; - bool isCloseUnderSLow = cBar.close < conditions.sBars[cIndex].low; - - // - conditions.isSBullish = isSBullish; - conditions.isSSwitchedToBullish = isSSwitchedToBullish; - conditions.isSBearish = isSBearish; - conditions.isSSwitchedToBearish = isSSwitchedToBearish; - - // - conditions.isCloseOverSHigh = isCloseOverSHigh; - conditions.isCloseUnderSLow = isCloseUnderSLow; - - // - // Medium ... - - // - bool isMBullish = conditions.mBars[cIndex].IsBullish(); - bool isMBullishPrev = conditions.mBars[pIndex].IsBullish(); - - // - bool isMBearish = conditions.mBars[cIndex].IsBearish(); - bool isMBearishPrev = conditions.mBars[pIndex].IsBearish(); - - // - bool isMSwitchedToBullish = isMBullish && - !isMBullishPrev; - bool isMSwitchedToBearish = isMBearish && - !isMBearishPrev; - - // - bool isCloseOverMHigh = cBar.close > conditions.mBars[cIndex].high; - bool isCloseUnderMLow = cBar.close < conditions.mBars[cIndex].low; - - // - conditions.isMBullish = isMBullish; - conditions.isMSwitchedToBullish = isMSwitchedToBullish; - conditions.isMBearish = isMBearish; - conditions.isMSwitchedToBearish = isMSwitchedToBearish; - - // - conditions.isCloseOverMHigh = isCloseOverMHigh; - conditions.isCloseUnderMLow = isCloseUnderMLow; - - // - // Long ... - - // - bool isLBullish = conditions.lBars[cIndex].IsBullish(); - bool isLBullishPrev = conditions.lBars[pIndex].IsBullish(); - - // - bool isLBearish = conditions.lBars[cIndex].IsBearish(); - bool isLBearishPrev = conditions.lBars[pIndex].IsBearish(); - - // - bool isLSwitchedToBullish = isLBullish && - !isLBullishPrev; - bool isLSwitchedToBearish = isLBearish && - !isLBearishPrev; - - // - bool isCloseOverLHigh = cBar.close > conditions.lBars[cIndex].high; - bool isCloseUnderLLow = cBar.close < conditions.lBars[cIndex].low; - - // - conditions.isLBullish = isLBullish; - conditions.isLSwitchedToBullish = isLSwitchedToBullish; - conditions.isLBearish = isLBearish; - conditions.isLSwitchedToBearish = isLSwitchedToBearish; - - // - conditions.isCloseOverLHigh = isCloseOverLHigh; - conditions.isCloseUnderLLow = isCloseUnderLLow; - - // - // Hind ... - - // - bool isHBullish = conditions.hBars[cIndex].IsBullish(); - bool isHBullishPrev = conditions.hBars[pIndex].IsBullish(); - - // - bool isHBearish = conditions.hBars[cIndex].IsBearish(); - bool isHBearishPrev = conditions.hBars[pIndex].IsBearish(); - - // - bool isHSwitchedToBullish = isHBullish && - !isHBullishPrev; - bool isHSwitchedToBearish = isHBearish && - !isHBearishPrev; - - // - bool isCloseOverHHigh = cBar.close > conditions.hBars[cIndex].high; - bool isCloseUnderHLow = cBar.close < conditions.hBars[cIndex].low; - - // - conditions.isHBullish = isHBullish; - conditions.isHSwitchedToBullish = isHSwitchedToBullish; - conditions.isHBearish = isHBearish; - conditions.isHSwitchedToBearish = isHSwitchedToBearish; - - // - conditions.isCloseOverHHigh = isCloseOverHHigh; - conditions.isCloseUnderHLow = isCloseUnderHLow; - - // - return result; - } - - // - // Protected ... -protected: - // - // Private ... -private: - // - // Props ... - XCHHKInputs mInputs; // Inputs ... - - // - // Buffers ... - - // - // Current ... - double cOpenBuffer[]; - double cHighBuffer[]; - double cLowBuffer[]; - double cCloseBuffer[]; - - // - // Short ... - double sOpenBuffer[]; - double sHighBuffer[]; - double sLowBuffer[]; - double sCloseBuffer[]; - - // - // Medium ... - double mOpenBuffer[]; - double mHighBuffer[]; - double mLowBuffer[]; - double mCloseBuffer[]; - - // - // Long ... - double lOpenBuffer[]; - double lHighBuffer[]; - double lLowBuffer[]; - double lCloseBuffer[]; - - // - // Hind ... - double hOpenBuffer[]; - double hHighBuffer[]; - double hLowBuffer[]; - double hCloseBuffer[]; - - // - // Tools ... - - // - // Calculate Values Until Now ... - void Calculate() - { - // - int totalBars = CountBars(); - if (totalBars > 1000) - { - totalBars = 1000; - } - - // - // Current ... - - // - // Open ... - CopyBuffer( - mHandler, - XCHHK_CO_LINE, - 0, - totalBars, - cOpenBuffer - // - ); - - // - // High ... - CopyBuffer( - mHandler, - XCHHK_CH_LINE, - 0, - totalBars, - cHighBuffer - // - ); - - // - // Low ... - CopyBuffer( - mHandler, - XCHHK_CL_LINE, - 0, - totalBars, - cLowBuffer - // - ); - - // - // Close ... - CopyBuffer( - mHandler, - XCHHK_CC_LINE, - 0, - totalBars, - cCloseBuffer - // - ); - - // - // Short ... - - // - // Open ... - CopyBuffer( - mHandler, - XCHHK_SO_LINE, - 0, - totalBars, - sOpenBuffer - // - ); - - // - // High ... - CopyBuffer( - mHandler, - XCHHK_SH_LINE, - 0, - totalBars, - sHighBuffer - // - ); - - // - // Low ... - CopyBuffer( - mHandler, - XCHHK_SL_LINE, - 0, - totalBars, - sLowBuffer - // - ); - - // - // Close ... - CopyBuffer( - mHandler, - XCHHK_SC_LINE, - 0, - totalBars, - sCloseBuffer - // - ); - - // - // Medium ... - - // - // Open ... - CopyBuffer( - mHandler, - XCHHK_MO_LINE, - 0, - totalBars, - mOpenBuffer - // - ); - - // - // High ... - CopyBuffer( - mHandler, - XCHHK_MH_LINE, - 0, - totalBars, - mHighBuffer - // - ); - - // - // Low ... - CopyBuffer( - mHandler, - XCHHK_ML_LINE, - 0, - totalBars, - mLowBuffer - // - ); - - // - // Close ... - CopyBuffer( - mHandler, - XCHHK_MC_LINE, - 0, - totalBars, - mCloseBuffer - // - ); - - // - // Long ... - - // - // Open ... - CopyBuffer( - mHandler, - XCHHK_LO_LINE, - 0, - totalBars, - lOpenBuffer - // - ); - - // - // High ... - CopyBuffer( - mHandler, - XCHHK_LH_LINE, - 0, - totalBars, - lHighBuffer - // - ); - - // - // Low ... - CopyBuffer( - mHandler, - XCHHK_LL_LINE, - 0, - totalBars, - lLowBuffer - // - ); - - // - // Close ... - CopyBuffer( - mHandler, - XCHHK_LC_LINE, - 0, - totalBars, - lCloseBuffer - // - ); - - // - // Hind ... - - // - // Open ... - CopyBuffer( - mHandler, - XCHHK_HO_LINE, - 0, - totalBars, - hOpenBuffer - // - ); - - // - // High ... - CopyBuffer( - mHandler, - XCHHK_HH_LINE, - 0, - totalBars, - hHighBuffer - // - ); - - // - // Low ... - CopyBuffer( - mHandler, - XCHHK_HL_LINE, - 0, - totalBars, - hLowBuffer - // - ); - - // - // Close ... - CopyBuffer( - mHandler, - XCHHK_HC_LINE, - 0, - totalBars, - hCloseBuffer - // - ); - }; -}; - -// \ No newline at end of file diff --git a/Helpers/x-saherelm.xchich.helper.mq5 b/Helpers/x-saherelm.xchich.helper.mq5 deleted file mode 100644 index e12bb338..00000000 --- a/Helpers/x-saherelm.xchich.helper.mq5 +++ /dev/null @@ -1,5718 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Helper Class Library -// ---------------------------------------------- -// Name: XSCXCHICHHelper -// 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" - -// -// Ichimoku Lines Calculator Mode ... -enum ENUM_X_ICHIMOKU_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_XCHICH_BUFFERS -{ - // - // Current ... - XCHICH_C_TK_LINE = 0, - XCHICH_C_KJ_LINE = 1, - XCHICH_C_CH_LINE = 2, - XCHICH_C_SSA_LINE = 3, - XCHICH_C_SSB_LINE = 4, - // - // Short ... - XCHICH_S_TK_LINE = 5, - XCHICH_S_KJ_LINE = 6, - XCHICH_S_CH_LINE = 7, - XCHICH_S_SSA_LINE = 8, - XCHICH_S_SSB_LINE = 9, - // - // Medium ... - XCHICH_M_TK_LINE = 10, - XCHICH_M_KJ_LINE = 11, - XCHICH_M_CH_LINE = 12, - XCHICH_M_SSA_LINE = 13, - XCHICH_M_SSB_LINE = 14, - // - // Long ... - XCHICH_L_TK_LINE = 15, - XCHICH_L_KJ_LINE = 16, - XCHICH_L_CH_LINE = 17, - XCHICH_L_SSA_LINE = 18, - XCHICH_L_SSB_LINE = 19, - // - // Hind ... - XCHICH_H_TK_LINE = 20, - XCHICH_H_KJ_LINE = 21, - XCHICH_H_CH_LINE = 22, - XCHICH_H_SSA_LINE = 23, - XCHICH_H_SSB_LINE = 24, -}; - -// -// Input Models ... -struct XCHICHInputs -{ - // - // Props ... - - // - // Market ... - - // - // TENKANSEN ... - - // - // Tenkan Sen ... - int tenkanSenLength; // Length - ENUM_X_ICHIMOKU_CALCULATION_MODE tenkanSenMode; // Calculation Mode - - // - // KIJUNSEN ... - - // - // Kijun Sen ... - int kijunSenLength; // Length - ENUM_X_ICHIMOKU_CALCULATION_MODE kijunSenMode; // Calculation Mode - - // - // SENKOUSPANB ... - - // - // Senkou Span B ... - int senkouSpanBLength; // Length - ENUM_X_ICHIMOKU_CALCULATION_MODE senkouSpanBMode; // Calculation Mode - - // - // CHIKOUSPAN ... - - // - // Chikou Span ... - ENUM_APPLIED_PRICE chikuoSpanAppliedTo; // Price Type - - // - // Cycles ... - - // - // Short ... - ENUM_X_PERIOD_METHOD scMethod; // How to Find Period - ENUM_TIMEFRAMES scPeriod; // Time Period - - // - // Medium ... - ENUM_X_PERIOD_METHOD mcMethod; // How to Find Period - ENUM_TIMEFRAMES mcPeriod; // Time Period - - // - // Long ... - ENUM_X_PERIOD_METHOD lcMethod; // How to Find Period - ENUM_TIMEFRAMES lcPeriod; // Time Period - - // - // Hind ... - ENUM_X_PERIOD_METHOD hcMethod; // How to Find Period - ENUM_TIMEFRAMES hcPeriod; // Time Period - - // - // Presentation ... - - // - // Ichimoku ... - bool showTenkanSen; // Show Tenkan Sen - bool showKijunSen; // 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 - - // - bool showCurrent; // Show Current Cycle - bool showShort; // Show Short Cycle - bool showMedium; // Show Medium Cycle - bool showLong; // Show Long Cycle - bool showHind; // Show Hind Cycle - - // - // Constructor(s) ... - XCHICHInputs() - { - // - Clean(); - } - - // - // Tools ... - - // - // Clean ... - void Clean() - { - // - kijunSenLength = 0; - tenkanSenLength = 0; - senkouSpanBLength = 0; - kijunSenMode = X_XICH_HH_LL_MODE; - tenkanSenMode = X_XICH_HH_LL_MODE; - chikuoSpanAppliedTo = PRICE_CLOSE; - senkouSpanBMode = X_XICH_HH_LL_MODE; - - // - scMethod = X_PERIOD_AUTO; - scPeriod = NULL; - mcMethod = X_PERIOD_AUTO; - mcPeriod = NULL; - lcMethod = X_PERIOD_AUTO; - lcPeriod = NULL; - hcMethod = X_PERIOD_AUTO; - hcPeriod = NULL; - - // - showTenkanSen = false; - showKijunSen = false; - showChikouSpan = false; - showSenkouSpanA = false; - showSenkouSpanB = false; - showKumo = false; - shiftKumo = true; - - // - showCurrent = false; - showShort = false; - showMedium = false; - showLong = false; - showHind = false; - } - - // - // Default ... - void Default() - { - // - kijunSenLength = 26; - tenkanSenLength = 9; - senkouSpanBLength = 52; - kijunSenMode = X_XICH_HH_LL_MODE; - tenkanSenMode = X_XICH_HH_LL_MODE; - chikuoSpanAppliedTo = PRICE_CLOSE; - senkouSpanBMode = X_XICH_HH_LL_MODE; - - // - scMethod = X_PERIOD_AUTO; - scPeriod = NULL; - mcMethod = X_PERIOD_AUTO; - mcPeriod = NULL; - lcMethod = X_PERIOD_AUTO; - lcPeriod = NULL; - hcMethod = X_PERIOD_AUTO; - hcPeriod = NULL; - - // - showTenkanSen = true; - showKijunSen = true; - showChikouSpan = true; - showSenkouSpanA = true; - showSenkouSpanB = true; - showKumo = true; - shiftKumo = true; - - // - showCurrent = true; - showShort = true; - showMedium = true; - showLong = true; - showHind = true; - } - - // - // Validate ... - bool IsValid() - { - // - bool result = false; - - // - result = - // - (tenkanSenLength > 2 && - kijunSenLength > tenkanSenLength && - senkouSpanBLength > kijunSenLength) - // - && - // - (IsValid(scMethod, scPeriod) && - IsValid(mcMethod, mcPeriod) && - IsValid(lcMethod, lcPeriod) && - IsValid(hcMethod, hcPeriod)) - // - ; - - // - return result; - } - - // - // Retrieve MAx Length ... - int Max() - { - // - int result = 0; - - // - result = MathMax(tenkanSenLength, kijunSenLength); - result = MathMax(result, senkouSpanBLength); - - // - return result; - } -}; - -// -// Define Conditions ... -struct XCHICHConditions -{ - // - // Common ... - string symbol; - ENUM_TIMEFRAMES period; - datetime time; - - // - // Buffers ... - - // - // Current ... - double cTK[]; - double cKJ[]; - double cChik[]; - double cSSA[]; - double cSSB[]; - double cFSSA[]; - double cFSSB[]; - - // - // Short ... - double sTK[]; - double sKJ[]; - double sChik[]; - double sSSA[]; - double sSSB[]; - double sFSSA[]; - double sFSSB[]; - - // - // Medium ... - double mTK[]; - double mKJ[]; - double mChik[]; - double mSSA[]; - double mSSB[]; - double mFSSA[]; - double mFSSB[]; - - // - // Long ... - double lTK[]; - double lKJ[]; - double lChik[]; - double lSSA[]; - double lSSB[]; - double lFSSA[]; - double lFSSB[]; - - // - // Hind ... - double hTK[]; - double hKJ[]; - double hChik[]; - double hSSA[]; - double hSSB[]; - double hFSSA[]; - double hFSSB[]; - - // - // Conditions ... - - // - // Current ... - - // - bool isCClosedOverKijunSen; - bool isCClosedUnderKijunSen; - bool isCTenkanSenOverKijunSen; - bool isCTenkanSenUnderKijunSen; - bool isCTenkanSenCrossedOverKijunSen; - bool isCTenkanSenCrossedUnderKijunSen; - - // - bool isCSenkouSpanAOverB; - bool isCSenkouSpanAUnderB; - bool isCSenkouSpanAOverLast; - bool isCSenkouSpanAUnderLast; - bool isCFutureSenkouSpanAOverB; - bool isCFutureSenkouSpanAUnderB; - bool isCFutureSenkouSpanAOverLast; - bool isCFutureSenkouSpanAUnderLast; - - // - bool isCSenkouSpanACrossedOverB; - bool isCSenkouSpanACrossedUnderB; - bool isCSenkouSpanACrossedOverLast; - bool isCSenkouSpanACrossedUnderLast; - bool isCFutureSenkouSpanACrossedOverB; - bool isCFutureSenkouSpanACrossedUnderB; - bool isCFutureSenkouSpanACrossedOverLast; - bool isCFutureSenkouSpanACrossedUnderLast; - - // - // Short ... - - // - bool isSClosedOverKijunSen; - bool isSClosedUnderKijunSen; - bool isSTenkanSenOverKijunSen; - bool isSTenkanSenUnderKijunSen; - bool isSTenkanSenCrossedOverKijunSen; - bool isSTenkanSenCrossedUnderKijunSen; - - // - bool isSSenkouSpanAOverB; - bool isSSenkouSpanAUnderB; - bool isSSenkouSpanAOverLast; - bool isSSenkouSpanAUnderLast; - bool isSFutureSenkouSpanAOverB; - bool isSFutureSenkouSpanAUnderB; - bool isSFutureSenkouSpanAOverLast; - bool isSFutureSenkouSpanAUnderLast; - - // - bool isSSenkouSpanACrossedOverB; - bool isSSenkouSpanACrossedUnderB; - bool isSSenkouSpanACrossedOverLast; - bool isSSenkouSpanACrossedUnderLast; - bool isSFutureSenkouSpanACrossedOverB; - bool isSFutureSenkouSpanACrossedUnderB; - bool isSFutureSenkouSpanACrossedOverLast; - bool isSFutureSenkouSpanACrossedUnderLast; - - // - // Medium ... - - // - bool isMClosedOverKijunSen; - bool isMClosedUnderKijunSen; - bool isMTenkanSenOverKijunSen; - bool isMTenkanSenUnderKijunSen; - bool isMTenkanSenCrossedOverKijunSen; - bool isMTenkanSenCrossedUnderKijunSen; - - // - bool isMSenkouSpanAOverB; - bool isMSenkouSpanAUnderB; - bool isMSenkouSpanAOverLast; - bool isMSenkouSpanAUnderLast; - bool isMFutureSenkouSpanAOverB; - bool isMFutureSenkouSpanAUnderB; - bool isMFutureSenkouSpanAOverLast; - bool isMFutureSenkouSpanAUnderLast; - - // - bool isMSenkouSpanACrossedOverB; - bool isMSenkouSpanACrossedUnderB; - bool isMSenkouSpanACrossedOverLast; - bool isMSenkouSpanACrossedUnderLast; - bool isMFutureSenkouSpanACrossedOverB; - bool isMFutureSenkouSpanACrossedUnderB; - bool isMFutureSenkouSpanACrossedOverLast; - bool isMFutureSenkouSpanACrossedUnderLast; - - // - // Long ... - - // - bool isLClosedOverKijunSen; - bool isLClosedUnderKijunSen; - bool isLTenkanSenOverKijunSen; - bool isLTenkanSenUnderKijunSen; - bool isLTenkanSenCrossedOverKijunSen; - bool isLTenkanSenCrossedUnderKijunSen; - - // - bool isLSenkouSpanAOverB; - bool isLSenkouSpanAUnderB; - bool isLSenkouSpanAOverLast; - bool isLSenkouSpanAUnderLast; - bool isLFutureSenkouSpanAOverB; - bool isLFutureSenkouSpanAUnderB; - bool isLFutureSenkouSpanAOverLast; - bool isLFutureSenkouSpanAUnderLast; - - // - bool isLSenkouSpanACrossedOverB; - bool isLSenkouSpanACrossedUnderB; - bool isLSenkouSpanACrossedOverLast; - bool isLSenkouSpanACrossedUnderLast; - bool isLFutureSenkouSpanACrossedOverB; - bool isLFutureSenkouSpanACrossedUnderB; - bool isLFutureSenkouSpanACrossedOverLast; - bool isLFutureSenkouSpanACrossedUnderLast; - - // - // Hind ... - - // - bool isHClosedOverKijunSen; - bool isHClosedUnderKijunSen; - bool isHTenkanSenOverKijunSen; - bool isHTenkanSenUnderKijunSen; - bool isHTenkanSenCrossedOverKijunSen; - bool isHTenkanSenCrossedUnderKijunSen; - - // - bool isHSenkouSpanAOverB; - bool isHSenkouSpanAUnderB; - bool isHSenkouSpanAOverLast; - bool isHSenkouSpanAUnderLast; - bool isHFutureSenkouSpanAOverB; - bool isHFutureSenkouSpanAUnderB; - bool isHFutureSenkouSpanAOverLast; - bool isHFutureSenkouSpanAUnderLast; - - // - bool isHSenkouSpanACrossedOverB; - bool isHSenkouSpanACrossedUnderB; - bool isHSenkouSpanACrossedOverLast; - bool isHSenkouSpanACrossedUnderLast; - bool isHFutureSenkouSpanACrossedOverB; - bool isHFutureSenkouSpanACrossedUnderB; - bool isHFutureSenkouSpanACrossedOverLast; - bool isHFutureSenkouSpanACrossedUnderLast; - - // - void Clean() - { - // - // Buffers ... - Clean(cTK); - Clean(cKJ); - Clean(cChik); - Clean(cSSA); - Clean(cSSB); - Clean(cFSSA); - Clean(cFSSB); - Clean(sTK); - Clean(sKJ); - Clean(sChik); - Clean(sSSA); - Clean(sSSB); - Clean(sFSSA); - Clean(sFSSB); - Clean(mTK); - Clean(mKJ); - Clean(mChik); - Clean(mSSA); - Clean(mSSB); - Clean(mFSSA); - Clean(mFSSB); - Clean(lTK); - Clean(lKJ); - Clean(lChik); - Clean(lSSA); - Clean(lSSB); - Clean(lFSSA); - Clean(lFSSB); - Clean(hTK); - Clean(hKJ); - Clean(hChik); - Clean(hSSA); - Clean(hSSB); - Clean(hFSSA); - Clean(hFSSB); - - // - ArraySetAsSeries(cTK, true); - ArraySetAsSeries(cKJ, true); - ArraySetAsSeries(cChik, true); - ArraySetAsSeries(cSSA, true); - ArraySetAsSeries(cSSB, true); - ArraySetAsSeries(cFSSA, true); - ArraySetAsSeries(cFSSB, true); - ArraySetAsSeries(sTK, true); - ArraySetAsSeries(sKJ, true); - ArraySetAsSeries(sChik, true); - ArraySetAsSeries(sSSA, true); - ArraySetAsSeries(sSSB, true); - ArraySetAsSeries(sFSSA, true); - ArraySetAsSeries(sFSSB, true); - ArraySetAsSeries(mTK, true); - ArraySetAsSeries(mKJ, true); - ArraySetAsSeries(mChik, true); - ArraySetAsSeries(mSSA, true); - ArraySetAsSeries(mSSB, true); - ArraySetAsSeries(mFSSA, true); - ArraySetAsSeries(mFSSB, true); - ArraySetAsSeries(lTK, true); - ArraySetAsSeries(lKJ, true); - ArraySetAsSeries(lChik, true); - ArraySetAsSeries(lSSA, true); - ArraySetAsSeries(lSSB, true); - ArraySetAsSeries(lFSSA, true); - ArraySetAsSeries(lFSSB, true); - ArraySetAsSeries(hTK, true); - ArraySetAsSeries(hKJ, true); - ArraySetAsSeries(hChik, true); - ArraySetAsSeries(hSSA, true); - ArraySetAsSeries(hSSB, true); - ArraySetAsSeries(hFSSA, true); - ArraySetAsSeries(hFSSB, true); - - // - // Current ... - - // - isCClosedOverKijunSen = false; - isCClosedUnderKijunSen = false; - isCTenkanSenOverKijunSen = false; - isCTenkanSenUnderKijunSen = false; - isCTenkanSenCrossedOverKijunSen = false; - isCTenkanSenCrossedUnderKijunSen = false; - isCSenkouSpanAOverB = false; - isCSenkouSpanAUnderB = false; - isCSenkouSpanAOverLast = false; - isCSenkouSpanAUnderLast = false; - isCFutureSenkouSpanAOverB = false; - isCFutureSenkouSpanAUnderB = false; - isCFutureSenkouSpanAOverLast = false; - isCFutureSenkouSpanAUnderLast = false; - isCSenkouSpanACrossedOverB = false; - isCSenkouSpanACrossedUnderB = false; - isCSenkouSpanACrossedOverLast = false; - isCSenkouSpanACrossedUnderLast = false; - isCFutureSenkouSpanACrossedOverB = false; - isCFutureSenkouSpanACrossedUnderB = false; - isCFutureSenkouSpanACrossedOverLast = false; - isCFutureSenkouSpanACrossedUnderLast = false; - - // - // Short ... - - // - isSClosedOverKijunSen = false; - isSClosedUnderKijunSen = false; - isSTenkanSenOverKijunSen = false; - isSTenkanSenUnderKijunSen = false; - isSTenkanSenCrossedOverKijunSen = false; - isSTenkanSenCrossedUnderKijunSen = false; - isSSenkouSpanAOverB = false; - isSSenkouSpanAUnderB = false; - isSSenkouSpanAOverLast = false; - isSSenkouSpanAUnderLast = false; - isSFutureSenkouSpanAOverB = false; - isSFutureSenkouSpanAUnderB = false; - isSFutureSenkouSpanAOverLast = false; - isSFutureSenkouSpanAUnderLast = false; - isSSenkouSpanACrossedOverB = false; - isSSenkouSpanACrossedUnderB = false; - isSSenkouSpanACrossedOverLast = false; - isSSenkouSpanACrossedUnderLast = false; - isSFutureSenkouSpanACrossedOverB = false; - isSFutureSenkouSpanACrossedUnderB = false; - isSFutureSenkouSpanACrossedOverLast = false; - isSFutureSenkouSpanACrossedUnderLast = false; - - // - // Medium ... - - // - isMClosedOverKijunSen = false; - isMClosedUnderKijunSen = false; - isMTenkanSenOverKijunSen = false; - isMTenkanSenUnderKijunSen = false; - isMTenkanSenCrossedOverKijunSen = false; - isMTenkanSenCrossedUnderKijunSen = false; - isMSenkouSpanAOverB = false; - isMSenkouSpanAUnderB = false; - isMSenkouSpanAOverLast = false; - isMSenkouSpanAUnderLast = false; - isMFutureSenkouSpanAOverB = false; - isMFutureSenkouSpanAUnderB = false; - isMFutureSenkouSpanAOverLast = false; - isMFutureSenkouSpanAUnderLast = false; - isMSenkouSpanACrossedOverB = false; - isMSenkouSpanACrossedUnderB = false; - isMSenkouSpanACrossedOverLast = false; - isMSenkouSpanACrossedUnderLast = false; - isMFutureSenkouSpanACrossedOverB = false; - isMFutureSenkouSpanACrossedUnderB = false; - isMFutureSenkouSpanACrossedOverLast = false; - isMFutureSenkouSpanACrossedUnderLast = false; - - // - // Long ... - - // - isLClosedOverKijunSen = false; - isLClosedUnderKijunSen = false; - isLTenkanSenOverKijunSen = false; - isLTenkanSenUnderKijunSen = false; - isLTenkanSenCrossedOverKijunSen = false; - isLTenkanSenCrossedUnderKijunSen = false; - isLSenkouSpanAOverB = false; - isLSenkouSpanAUnderB = false; - isLSenkouSpanAOverLast = false; - isLSenkouSpanAUnderLast = false; - isLFutureSenkouSpanAOverB = false; - isLFutureSenkouSpanAUnderB = false; - isLFutureSenkouSpanAOverLast = false; - isLFutureSenkouSpanAUnderLast = false; - isLSenkouSpanACrossedOverB = false; - isLSenkouSpanACrossedUnderB = false; - isLSenkouSpanACrossedOverLast = false; - isLSenkouSpanACrossedUnderLast = false; - isLFutureSenkouSpanACrossedOverB = false; - isLFutureSenkouSpanACrossedUnderB = false; - isLFutureSenkouSpanACrossedOverLast = false; - isLFutureSenkouSpanACrossedUnderLast = false; - - // - // Hind ... - - // - isHClosedOverKijunSen = false; - isHClosedUnderKijunSen = false; - isHTenkanSenOverKijunSen = false; - isHTenkanSenUnderKijunSen = false; - isHTenkanSenCrossedOverKijunSen = false; - isHTenkanSenCrossedUnderKijunSen = false; - isHSenkouSpanAOverB = false; - isHSenkouSpanAUnderB = false; - isHSenkouSpanAOverLast = false; - isHSenkouSpanAUnderLast = false; - isHFutureSenkouSpanAOverB = false; - isHFutureSenkouSpanAUnderB = false; - isHFutureSenkouSpanAOverLast = false; - isHFutureSenkouSpanAUnderLast = false; - isHSenkouSpanACrossedOverB = false; - isHSenkouSpanACrossedUnderB = false; - isHSenkouSpanACrossedOverLast = false; - isHSenkouSpanACrossedUnderLast = false; - isHFutureSenkouSpanACrossedOverB = false; - isHFutureSenkouSpanACrossedUnderB = false; - isHFutureSenkouSpanACrossedOverLast = false; - isHFutureSenkouSpanACrossedUnderLast = false; - } - - // - void GenerateScore( - double &bullishScore, - double &bearishScore // - ) - { - // - bullishScore = 0; - bearishScore = 0; - - // - // Current ... - - // - if (isCClosedOverKijunSen) - { - bullishScore++; - } - if (isCTenkanSenOverKijunSen) - { - bullishScore++; - } - if (isCTenkanSenCrossedOverKijunSen) - { - bullishScore++; - } - if (isCSenkouSpanAOverB) - { - bullishScore++; - } - if (isCSenkouSpanAOverLast) - { - bullishScore++; - } - if (isCFutureSenkouSpanAOverB) - { - bullishScore++; - } - if (isCFutureSenkouSpanAOverLast) - { - bullishScore++; - } - if (isCSenkouSpanACrossedOverB) - { - bullishScore++; - } - if (isCSenkouSpanACrossedOverLast) - { - bullishScore++; - } - if (isCFutureSenkouSpanACrossedOverB) - { - bullishScore++; - } - if (isCFutureSenkouSpanACrossedOverLast) - { - bullishScore++; - } - - // - if (isCClosedUnderKijunSen) - { - bearishScore++; - } - if (isCTenkanSenUnderKijunSen) - { - bearishScore++; - } - if (isCTenkanSenCrossedUnderKijunSen) - { - bearishScore++; - } - if (isCSenkouSpanAUnderB) - { - bearishScore++; - } - if (isCSenkouSpanAUnderLast) - { - bearishScore++; - } - if (isCFutureSenkouSpanAUnderB) - { - bearishScore++; - } - if (isCFutureSenkouSpanAUnderLast) - { - bearishScore++; - } - if (isCSenkouSpanACrossedUnderB) - { - bearishScore++; - } - if (isCSenkouSpanACrossedUnderLast) - { - bearishScore++; - } - if (isCFutureSenkouSpanACrossedUnderB) - { - bearishScore++; - } - if (isCFutureSenkouSpanACrossedUnderLast) - { - bearishScore++; - } - - // - // Short ... - - // - if (isSClosedOverKijunSen) - { - bullishScore++; - } - if (isSTenkanSenOverKijunSen) - { - bullishScore++; - } - if (isSTenkanSenCrossedOverKijunSen) - { - bullishScore++; - } - if (isSSenkouSpanAOverB) - { - bullishScore++; - } - if (isSSenkouSpanAOverLast) - { - bullishScore++; - } - if (isSFutureSenkouSpanAOverB) - { - bullishScore++; - } - if (isSFutureSenkouSpanAOverLast) - { - bullishScore++; - } - if (isSSenkouSpanACrossedOverB) - { - bullishScore++; - } - if (isSSenkouSpanACrossedOverLast) - { - bullishScore++; - } - if (isSFutureSenkouSpanACrossedOverB) - { - bullishScore++; - } - if (isSFutureSenkouSpanACrossedOverLast) - { - bullishScore++; - } - - // - if (isSClosedUnderKijunSen) - { - bearishScore++; - } - if (isSTenkanSenUnderKijunSen) - { - bearishScore++; - } - if (isSTenkanSenCrossedUnderKijunSen) - { - bearishScore++; - } - if (isSSenkouSpanAUnderB) - { - bearishScore++; - } - if (isSSenkouSpanAUnderLast) - { - bearishScore++; - } - if (isSFutureSenkouSpanAUnderB) - { - bearishScore++; - } - if (isSFutureSenkouSpanAUnderLast) - { - bearishScore++; - } - if (isSSenkouSpanACrossedUnderB) - { - bearishScore++; - } - if (isSSenkouSpanACrossedUnderLast) - { - bearishScore++; - } - if (isSFutureSenkouSpanACrossedUnderB) - { - bearishScore++; - } - if (isSFutureSenkouSpanACrossedUnderLast) - { - bearishScore++; - } - - // - // Medium ... - - // - if (isMClosedOverKijunSen) - { - bullishScore++; - } - if (isMTenkanSenOverKijunSen) - { - bullishScore++; - } - if (isMTenkanSenCrossedOverKijunSen) - { - bullishScore++; - } - if (isMSenkouSpanAOverB) - { - bullishScore++; - } - if (isMSenkouSpanAOverLast) - { - bullishScore++; - } - if (isMFutureSenkouSpanAOverB) - { - bullishScore++; - } - if (isMFutureSenkouSpanAOverLast) - { - bullishScore++; - } - if (isMSenkouSpanACrossedOverB) - { - bullishScore++; - } - if (isMSenkouSpanACrossedOverLast) - { - bullishScore++; - } - if (isMFutureSenkouSpanACrossedOverB) - { - bullishScore++; - } - if (isMFutureSenkouSpanACrossedOverLast) - { - bullishScore++; - } - - // - if (isMClosedUnderKijunSen) - { - bearishScore++; - } - if (isMTenkanSenUnderKijunSen) - { - bearishScore++; - } - if (isMTenkanSenCrossedUnderKijunSen) - { - bearishScore++; - } - if (isMSenkouSpanAUnderB) - { - bearishScore++; - } - if (isMSenkouSpanAUnderLast) - { - bearishScore++; - } - if (isMFutureSenkouSpanAUnderB) - { - bearishScore++; - } - if (isMFutureSenkouSpanAUnderLast) - { - bearishScore++; - } - if (isMSenkouSpanACrossedUnderB) - { - bearishScore++; - } - if (isMSenkouSpanACrossedUnderLast) - { - bearishScore++; - } - if (isMFutureSenkouSpanACrossedUnderB) - { - bearishScore++; - } - if (isMFutureSenkouSpanACrossedUnderLast) - { - bearishScore++; - } - - // - // Long ... - - // - if (isLClosedOverKijunSen) - { - bullishScore++; - } - if (isLTenkanSenOverKijunSen) - { - bullishScore++; - } - if (isLTenkanSenCrossedOverKijunSen) - { - bullishScore++; - } - if (isLSenkouSpanAOverB) - { - bullishScore++; - } - if (isLSenkouSpanAOverLast) - { - bullishScore++; - } - if (isLFutureSenkouSpanAOverB) - { - bullishScore++; - } - if (isLFutureSenkouSpanAOverLast) - { - bullishScore++; - } - if (isLSenkouSpanACrossedOverB) - { - bullishScore++; - } - if (isLSenkouSpanACrossedOverLast) - { - bullishScore++; - } - if (isLFutureSenkouSpanACrossedOverB) - { - bullishScore++; - } - if (isLFutureSenkouSpanACrossedOverLast) - { - bullishScore++; - } - - // - if (isLClosedUnderKijunSen) - { - bearishScore++; - } - if (isLTenkanSenUnderKijunSen) - { - bearishScore++; - } - if (isLTenkanSenCrossedUnderKijunSen) - { - bearishScore++; - } - if (isLSenkouSpanAUnderB) - { - bearishScore++; - } - if (isLSenkouSpanAUnderLast) - { - bearishScore++; - } - if (isLFutureSenkouSpanAUnderB) - { - bearishScore++; - } - if (isLFutureSenkouSpanAUnderLast) - { - bearishScore++; - } - if (isLSenkouSpanACrossedUnderB) - { - bearishScore++; - } - if (isLSenkouSpanACrossedUnderLast) - { - bearishScore++; - } - if (isLFutureSenkouSpanACrossedUnderB) - { - bearishScore++; - } - if (isLFutureSenkouSpanACrossedUnderLast) - { - bearishScore++; - } - - // - // Hind ... - - // - if (isHClosedOverKijunSen) - { - bullishScore++; - } - if (isHTenkanSenOverKijunSen) - { - bullishScore++; - } - if (isHTenkanSenCrossedOverKijunSen) - { - bullishScore++; - } - if (isHSenkouSpanAOverB) - { - bullishScore++; - } - if (isHSenkouSpanAOverLast) - { - bullishScore++; - } - if (isHFutureSenkouSpanAOverB) - { - bullishScore++; - } - if (isHFutureSenkouSpanAOverLast) - { - bullishScore++; - } - if (isHSenkouSpanACrossedOverB) - { - bullishScore++; - } - if (isHSenkouSpanACrossedOverLast) - { - bullishScore++; - } - if (isHFutureSenkouSpanACrossedOverB) - { - bullishScore++; - } - if (isHFutureSenkouSpanACrossedOverLast) - { - bullishScore++; - } - - // - if (isHClosedUnderKijunSen) - { - bearishScore++; - } - if (isHTenkanSenUnderKijunSen) - { - bearishScore++; - } - if (isHTenkanSenCrossedUnderKijunSen) - { - bearishScore++; - } - if (isHSenkouSpanAUnderB) - { - bearishScore++; - } - if (isHSenkouSpanAUnderLast) - { - bearishScore++; - } - if (isHFutureSenkouSpanAUnderB) - { - bearishScore++; - } - if (isHFutureSenkouSpanAUnderLast) - { - bearishScore++; - } - if (isHSenkouSpanACrossedUnderB) - { - bearishScore++; - } - if (isHSenkouSpanACrossedUnderLast) - { - bearishScore++; - } - if (isHFutureSenkouSpanACrossedUnderB) - { - bearishScore++; - } - if (isHFutureSenkouSpanACrossedUnderLast) - { - bearishScore++; - } - } - - // - string GenerateSummary( - bool onlyCommons = false, - bool onlyConditions = false, - bool includeScores = true, - bool ignoreFalseConditions = true, - string separator = "\n" // - ) - { - // - string result = NULL; - - // - double bullishScore = 0; - double bearishScore = 0; - GenerateScore( - bullishScore, - bearishScore // - ); - - // - string scoresStr = - // - "Scores: " + separator + - "---------------" + separator + - "Bullish: " + ToString(bullishScore) + separator + - "Bearish: " + ToString(bearishScore) + separator + - "" - // - ; - - // - string commonStr = GenerateSpecifiedCommonSummary( - this, - separator, - includeScores // - ); - - // - string conditionsStr = - // - // Current ... - ToString("isCClosedOverKijunSen", isCClosedOverKijunSen, ignoreFalseConditions, separator) + - ToString("isCClosedUnderKijunSen", isCClosedUnderKijunSen, ignoreFalseConditions, separator) + - ToString("isCTenkanSenOverKijunSen", isCTenkanSenOverKijunSen, ignoreFalseConditions, separator) + - ToString("isCTenkanSenUnderKijunSen", isCTenkanSenUnderKijunSen, ignoreFalseConditions, separator) + - ToString("isCTenkanSenCrossedOverKijunSen", isCTenkanSenCrossedOverKijunSen, ignoreFalseConditions, separator) + - ToString("isCTenkanSenCrossedUnderKijunSen", isCTenkanSenCrossedUnderKijunSen, ignoreFalseConditions, separator) + - ToString("isCSenkouSpanAOverB", isCSenkouSpanAOverB, ignoreFalseConditions, separator) + - ToString("isCSenkouSpanAUnderB", isCSenkouSpanAUnderB, ignoreFalseConditions, separator) + - ToString("isCSenkouSpanAOverLast", isCSenkouSpanAOverLast, ignoreFalseConditions, separator) + - ToString("isCSenkouSpanAUnderLast", isCSenkouSpanAUnderLast, ignoreFalseConditions, separator) + - ToString("isCFutureSenkouSpanAOverB", isCFutureSenkouSpanAOverB, ignoreFalseConditions, separator) + - ToString("isCFutureSenkouSpanAUnderB", isCFutureSenkouSpanAUnderB, ignoreFalseConditions, separator) + - ToString("isCFutureSenkouSpanAOverLast", isCFutureSenkouSpanAOverLast, ignoreFalseConditions, separator) + - ToString("isCFutureSenkouSpanAUnderLast", isCFutureSenkouSpanAUnderLast, ignoreFalseConditions, separator) + - ToString("isCSenkouSpanACrossedOverB", isCSenkouSpanACrossedOverB, ignoreFalseConditions, separator) + - ToString("isCSenkouSpanACrossedUnderB", isCSenkouSpanACrossedUnderB, ignoreFalseConditions, separator) + - ToString("isCSenkouSpanACrossedOverLast", isCSenkouSpanACrossedOverLast, ignoreFalseConditions, separator) + - ToString("isCSenkouSpanACrossedUnderLast", isCSenkouSpanACrossedUnderLast, ignoreFalseConditions, separator) + - ToString("isCFutureSenkouSpanACrossedOverB", isCFutureSenkouSpanACrossedOverB, ignoreFalseConditions, separator) + - ToString("isCFutureSenkouSpanACrossedUnderB", isCFutureSenkouSpanACrossedUnderB, ignoreFalseConditions, separator) + - ToString("isCFutureSenkouSpanACrossedOverLast", isCFutureSenkouSpanACrossedOverLast, ignoreFalseConditions, separator) + - ToString("isCFutureSenkouSpanACrossedUnderLast", isCFutureSenkouSpanACrossedUnderLast, ignoreFalseConditions, separator) + - // - // Short ... - ToString("isSClosedOverKijunSen", isSClosedOverKijunSen, ignoreFalseConditions, separator) + - ToString("isSClosedUnderKijunSen", isSClosedUnderKijunSen, ignoreFalseConditions, separator) + - ToString("isSTenkanSenOverKijunSen", isSTenkanSenOverKijunSen, ignoreFalseConditions, separator) + - ToString("isSTenkanSenUnderKijunSen", isSTenkanSenUnderKijunSen, ignoreFalseConditions, separator) + - ToString("isSTenkanSenCrossedOverKijunSen", isSTenkanSenCrossedOverKijunSen, ignoreFalseConditions, separator) + - ToString("isSTenkanSenCrossedUnderKijunSen", isSTenkanSenCrossedUnderKijunSen, ignoreFalseConditions, separator) + - ToString("isSSenkouSpanAOverB", isSSenkouSpanAOverB, ignoreFalseConditions, separator) + - ToString("isSSenkouSpanAUnderB", isSSenkouSpanAUnderB, ignoreFalseConditions, separator) + - ToString("isSSenkouSpanAOverLast", isSSenkouSpanAOverLast, ignoreFalseConditions, separator) + - ToString("isSSenkouSpanAUnderLast", isSSenkouSpanAUnderLast, ignoreFalseConditions, separator) + - ToString("isSFutureSenkouSpanAOverB", isSFutureSenkouSpanAOverB, ignoreFalseConditions, separator) + - ToString("isSFutureSenkouSpanAUnderB", isSFutureSenkouSpanAUnderB, ignoreFalseConditions, separator) + - ToString("isSFutureSenkouSpanAOverLast", isSFutureSenkouSpanAOverLast, ignoreFalseConditions, separator) + - ToString("isSFutureSenkouSpanAUnderLast", isSFutureSenkouSpanAUnderLast, ignoreFalseConditions, separator) + - ToString("isSSenkouSpanACrossedOverB", isSSenkouSpanACrossedOverB, ignoreFalseConditions, separator) + - ToString("isSSenkouSpanACrossedUnderB", isSSenkouSpanACrossedUnderB, ignoreFalseConditions, separator) + - ToString("isSSenkouSpanACrossedOverLast", isSSenkouSpanACrossedOverLast, ignoreFalseConditions, separator) + - ToString("isSSenkouSpanACrossedUnderLast", isSSenkouSpanACrossedUnderLast, ignoreFalseConditions, separator) + - ToString("isSFutureSenkouSpanACrossedOverB", isSFutureSenkouSpanACrossedOverB, ignoreFalseConditions, separator) + - ToString("isSFutureSenkouSpanACrossedUnderB", isSFutureSenkouSpanACrossedUnderB, ignoreFalseConditions, separator) + - ToString("isSFutureSenkouSpanACrossedOverLast", isSFutureSenkouSpanACrossedOverLast, ignoreFalseConditions, separator) + - ToString("isSFutureSenkouSpanACrossedUnderLast", isSFutureSenkouSpanACrossedUnderLast, ignoreFalseConditions, separator) + - // - // Medium ... - ToString("isMClosedOverKijunSen", isMClosedOverKijunSen, ignoreFalseConditions, separator) + - ToString("isMClosedUnderKijunSen", isMClosedUnderKijunSen, ignoreFalseConditions, separator) + - ToString("isMTenkanSenOverKijunSen", isMTenkanSenOverKijunSen, ignoreFalseConditions, separator) + - ToString("isMTenkanSenUnderKijunSen", isMTenkanSenUnderKijunSen, ignoreFalseConditions, separator) + - ToString("isMTenkanSenCrossedOverKijunSen", isMTenkanSenCrossedOverKijunSen, ignoreFalseConditions, separator) + - ToString("isMTenkanSenCrossedUnderKijunSen", isMTenkanSenCrossedUnderKijunSen, ignoreFalseConditions, separator) + - ToString("isMSenkouSpanAOverB", isMSenkouSpanAOverB, ignoreFalseConditions, separator) + - ToString("isMSenkouSpanAUnderB", isMSenkouSpanAUnderB, ignoreFalseConditions, separator) + - ToString("isMSenkouSpanAOverLast", isMSenkouSpanAOverLast, ignoreFalseConditions, separator) + - ToString("isMSenkouSpanAUnderLast", isMSenkouSpanAUnderLast, ignoreFalseConditions, separator) + - ToString("isMFutureSenkouSpanAOverB", isMFutureSenkouSpanAOverB, ignoreFalseConditions, separator) + - ToString("isMFutureSenkouSpanAUnderB", isMFutureSenkouSpanAUnderB, ignoreFalseConditions, separator) + - ToString("isMFutureSenkouSpanAOverLast", isMFutureSenkouSpanAOverLast, ignoreFalseConditions, separator) + - ToString("isMFutureSenkouSpanAUnderLast", isMFutureSenkouSpanAUnderLast, ignoreFalseConditions, separator) + - ToString("isMSenkouSpanACrossedOverB", isMSenkouSpanACrossedOverB, ignoreFalseConditions, separator) + - ToString("isMSenkouSpanACrossedUnderB", isMSenkouSpanACrossedUnderB, ignoreFalseConditions, separator) + - ToString("isMSenkouSpanACrossedOverLast", isMSenkouSpanACrossedOverLast, ignoreFalseConditions, separator) + - ToString("isMSenkouSpanACrossedUnderLast", isMSenkouSpanACrossedUnderLast, ignoreFalseConditions, separator) + - ToString("isMFutureSenkouSpanACrossedOverB", isMFutureSenkouSpanACrossedOverB, ignoreFalseConditions, separator) + - ToString("isMFutureSenkouSpanACrossedUnderB", isMFutureSenkouSpanACrossedUnderB, ignoreFalseConditions, separator) + - ToString("isMFutureSenkouSpanACrossedOverLast", isMFutureSenkouSpanACrossedOverLast, ignoreFalseConditions, separator) + - ToString("isMFutureSenkouSpanACrossedUnderLast", isMFutureSenkouSpanACrossedUnderLast, ignoreFalseConditions, separator) + - // - // Long ... - ToString("isLClosedOverKijunSen", isLClosedOverKijunSen, ignoreFalseConditions, separator) + - ToString("isLClosedUnderKijunSen", isLClosedUnderKijunSen, ignoreFalseConditions, separator) + - ToString("isLTenkanSenOverKijunSen", isLTenkanSenOverKijunSen, ignoreFalseConditions, separator) + - ToString("isLTenkanSenUnderKijunSen", isLTenkanSenUnderKijunSen, ignoreFalseConditions, separator) + - ToString("isLTenkanSenCrossedOverKijunSen", isLTenkanSenCrossedOverKijunSen, ignoreFalseConditions, separator) + - ToString("isLTenkanSenCrossedUnderKijunSen", isLTenkanSenCrossedUnderKijunSen, ignoreFalseConditions, separator) + - ToString("isLSenkouSpanAOverB", isLSenkouSpanAOverB, ignoreFalseConditions, separator) + - ToString("isLSenkouSpanAUnderB", isLSenkouSpanAUnderB, ignoreFalseConditions, separator) + - ToString("isLSenkouSpanAOverLast", isLSenkouSpanAOverLast, ignoreFalseConditions, separator) + - ToString("isLSenkouSpanAUnderLast", isLSenkouSpanAUnderLast, ignoreFalseConditions, separator) + - ToString("isLFutureSenkouSpanAOverB", isLFutureSenkouSpanAOverB, ignoreFalseConditions, separator) + - ToString("isLFutureSenkouSpanAUnderB", isLFutureSenkouSpanAUnderB, ignoreFalseConditions, separator) + - ToString("isLFutureSenkouSpanAOverLast", isLFutureSenkouSpanAOverLast, ignoreFalseConditions, separator) + - ToString("isLFutureSenkouSpanAUnderLast", isLFutureSenkouSpanAUnderLast, ignoreFalseConditions, separator) + - ToString("isLSenkouSpanACrossedOverB", isLSenkouSpanACrossedOverB, ignoreFalseConditions, separator) + - ToString("isLSenkouSpanACrossedUnderB", isLSenkouSpanACrossedUnderB, ignoreFalseConditions, separator) + - ToString("isLSenkouSpanACrossedOverLast", isLSenkouSpanACrossedOverLast, ignoreFalseConditions, separator) + - ToString("isLSenkouSpanACrossedUnderLast", isLSenkouSpanACrossedUnderLast, ignoreFalseConditions, separator) + - ToString("isLFutureSenkouSpanACrossedOverB", isLFutureSenkouSpanACrossedOverB, ignoreFalseConditions, separator) + - ToString("isLFutureSenkouSpanACrossedUnderB", isLFutureSenkouSpanACrossedUnderB, ignoreFalseConditions, separator) + - ToString("isLFutureSenkouSpanACrossedOverLast", isLFutureSenkouSpanACrossedOverLast, ignoreFalseConditions, separator) + - ToString("isLFutureSenkouSpanACrossedUnderLast", isLFutureSenkouSpanACrossedUnderLast, ignoreFalseConditions, separator) + - // - // Hind ... - ToString("isHClosedOverKijunSen", isHClosedOverKijunSen, ignoreFalseConditions, separator) + - ToString("isHClosedUnderKijunSen", isHClosedUnderKijunSen, ignoreFalseConditions, separator) + - ToString("isHTenkanSenOverKijunSen", isHTenkanSenOverKijunSen, ignoreFalseConditions, separator) + - ToString("isHTenkanSenUnderKijunSen", isHTenkanSenUnderKijunSen, ignoreFalseConditions, separator) + - ToString("isHTenkanSenCrossedOverKijunSen", isHTenkanSenCrossedOverKijunSen, ignoreFalseConditions, separator) + - ToString("isHTenkanSenCrossedUnderKijunSen", isHTenkanSenCrossedUnderKijunSen, ignoreFalseConditions, separator) + - ToString("isHSenkouSpanAOverB", isHSenkouSpanAOverB, ignoreFalseConditions, separator) + - ToString("isHSenkouSpanAUnderB", isHSenkouSpanAUnderB, ignoreFalseConditions, separator) + - ToString("isHSenkouSpanAOverLast", isHSenkouSpanAOverLast, ignoreFalseConditions, separator) + - ToString("isHSenkouSpanAUnderLast", isHSenkouSpanAUnderLast, ignoreFalseConditions, separator) + - ToString("isHFutureSenkouSpanAOverB", isHFutureSenkouSpanAOverB, ignoreFalseConditions, separator) + - ToString("isHFutureSenkouSpanAUnderB", isHFutureSenkouSpanAUnderB, ignoreFalseConditions, separator) + - ToString("isHFutureSenkouSpanAOverLast", isHFutureSenkouSpanAOverLast, ignoreFalseConditions, separator) + - ToString("isHFutureSenkouSpanAUnderLast", isHFutureSenkouSpanAUnderLast, ignoreFalseConditions, separator) + - ToString("isHSenkouSpanACrossedOverB", isHSenkouSpanACrossedOverB, ignoreFalseConditions, separator) + - ToString("isHSenkouSpanACrossedUnderB", isHSenkouSpanACrossedUnderB, ignoreFalseConditions, separator) + - ToString("isHSenkouSpanACrossedOverLast", isHSenkouSpanACrossedOverLast, ignoreFalseConditions, separator) + - ToString("isHSenkouSpanACrossedUnderLast", isHSenkouSpanACrossedUnderLast, ignoreFalseConditions, separator) + - ToString("isHFutureSenkouSpanACrossedOverB", isHFutureSenkouSpanACrossedOverB, ignoreFalseConditions, separator) + - ToString("isHFutureSenkouSpanACrossedUnderB", isHFutureSenkouSpanACrossedUnderB, ignoreFalseConditions, separator) + - ToString("isHFutureSenkouSpanACrossedOverLast", isHFutureSenkouSpanACrossedOverLast, ignoreFalseConditions, separator) + - ToString("isHFutureSenkouSpanACrossedUnderLast", isHFutureSenkouSpanACrossedUnderLast, ignoreFalseConditions, separator) + - // - "" - // - ; - - // - result = - // - "[" + GetTag() + "]" + separator + - (onlyConditions - ? "" - : commonStr) + - (!includeScores - ? "" - : scoresStr) + - " " + separator + - (onlyCommons - ? "" - : conditionsStr) + - "" - // - ; - - // - return result; - } - - // - string GetTag() - { - return "XCHICH"; - } -}; - -// -// Class ... -class XSCXCHICHHelper : public XSCBaseHelper -{ - // - // Public ... -public: - // - // Props ... - - // - // Constructors ... - XSCXCHICHHelper() : XSCBaseHelper(_Symbol, _Period) - { - } - - // - // Deconstructor ... - ~XSCXCHICHHelper() - { - // - Clean(cTKBuffer); - Clean(cKJBuffer); - Clean(cChikBuffer); - Clean(cSSABuffer); - Clean(cSSBBuffer); - Clean(sTKBuffer); - Clean(sKJBuffer); - Clean(sChikBuffer); - Clean(sSSABuffer); - Clean(sSSBBuffer); - Clean(mTKBuffer); - Clean(mKJBuffer); - Clean(mChikBuffer); - Clean(mSSABuffer); - Clean(mSSBBuffer); - Clean(lTKBuffer); - Clean(lKJBuffer); - Clean(lChikBuffer); - Clean(lSSABuffer); - Clean(lSSBBuffer); - Clean(hTKBuffer); - Clean(hKJBuffer); - Clean(hChikBuffer); - Clean(hSSABuffer); - Clean(hSSBBuffer); - } - - // - // Tools ... - bool Init( - string symbol, // Trading Symbol - ENUM_TIMEFRAMES period, // Trading Period - XCHICHInputs &inputs // Inputs - ) - { - // - bool result = false; - - // - mSymbol = symbol; - mPeriod = period; - - // - result = inputs.IsValid(); - if (!result) - { - return result; - } - - // - mInputs = inputs; - - // - ArraySetAsSeries(cTKBuffer, true); - ArraySetAsSeries(cKJBuffer, true); - ArraySetAsSeries(cChikBuffer, true); - ArraySetAsSeries(cSSABuffer, true); - ArraySetAsSeries(cSSBBuffer, true); - ArraySetAsSeries(sTKBuffer, true); - ArraySetAsSeries(sKJBuffer, true); - ArraySetAsSeries(sChikBuffer, true); - ArraySetAsSeries(sSSABuffer, true); - ArraySetAsSeries(sSSBBuffer, true); - ArraySetAsSeries(mTKBuffer, true); - ArraySetAsSeries(mKJBuffer, true); - ArraySetAsSeries(mChikBuffer, true); - ArraySetAsSeries(mSSABuffer, true); - ArraySetAsSeries(mSSBBuffer, true); - ArraySetAsSeries(lTKBuffer, true); - ArraySetAsSeries(lKJBuffer, true); - ArraySetAsSeries(lChikBuffer, true); - ArraySetAsSeries(lSSABuffer, true); - ArraySetAsSeries(lSSBBuffer, true); - ArraySetAsSeries(hTKBuffer, true); - ArraySetAsSeries(hKJBuffer, true); - ArraySetAsSeries(hChikBuffer, true); - ArraySetAsSeries(hSSABuffer, true); - ArraySetAsSeries(hSSBBuffer, true); - - // - mHandler = iCustom( - mSymbol, - mPeriod, - "x-saherelm.xchich", - // - // Inputs ... - // - // Market ... - "", - // - // TENKANSEN ... - "", - mInputs.tenkanSenLength, // Length - mInputs.tenkanSenMode, // Calculation Mode - // - // KIJUNSEN ... - "", - mInputs.kijunSenLength, // Length - mInputs.kijunSenMode, // Calculation Mode - // - // SENKOUSPANB ... - "", - mInputs.senkouSpanBLength, // Length - mInputs.senkouSpanBMode, // Calculation Mode - // - // CHIKOUSPAN ... - "", - mInputs.chikuoSpanAppliedTo, // Price Type - // - // Cycles ... - "", - // - // Short ... - "", - mInputs.scMethod, - mInputs.scPeriod, - // - // Medium ... - "", - mInputs.mcMethod, - mInputs.mcPeriod, - // - // Long ... - "", - mInputs.lcMethod, - mInputs.lcPeriod, - // - // Hind ... - "", - mInputs.hcMethod, - mInputs.hcPeriod, - // - // Presentation ... - "", - // - // Ichimoku ... - mInputs.showTenkanSen, // Show Tenkan Sen - mInputs.showKijunSen, // 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 - // - // Cycles ... - mInputs.showCurrent, // Show Current Cycle - mInputs.showShort, // Show Short Cycle - mInputs.showMedium, // Show Medium Cycle - mInputs.showLong, // Show Long Cycle - mInputs.showHind // Show Hind Cycle - // - ); - result = mHandler != INVALID_HANDLE; - if (!result) - { - return result; - } - - // - return result; - } - - // - // Buffers ... - - // - // Current ... - - // - // TENKANSEN ... - - // - double GetCTenkanSen( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return cTKBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyCTenkanSen( - 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, - cTKBuffer, - buffer, - forceClean - // - ); - } - - // - // KIJUNSEN ... - - // - double GetCKijunSen( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return cKJBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyCKijunSen( - 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, - cKJBuffer, - buffer, - forceClean - // - ); - } - - // - // CHIKOUSPAN ... - - // - double GetCChikouSpan( - int barIndex // Bar Index - ) - { - // - barIndex -= mInputs.kijunSenLength; - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return cChikBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyCChikouSpan( - 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, - cChikBuffer, - buffer, - forceClean - // - ); - } - - // - // SENKOUSPANA ... - - // - double GetCSenkouSpanA( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return cSSABuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyCSenkouSpanA( - 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, - cSSABuffer, - buffer, - forceClean - // - ); - } - - // - // SENKOUSPANB ... - - // - double GetCSenkouSpanB( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return cSSBBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyCSenkouSpanB( - 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, - cSSBBuffer, - buffer, - forceClean - // - ); - } - - // - // FUTURESENKOUSPANA ... - - // - double GetCFutureSenkouSpanA( - int barIndex // Bar Index - ) - { - // - barIndex -= mInputs.kijunSenLength; - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return cSSABuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyCFutureSenkouSpanA( - 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, - cSSABuffer, - buffer, - forceClean - // - ); - } - - // - // FUTURESENKOUSPANB ... - - // - double GetCFutureSenkouSpanB( - int barIndex // Bar Index - ) - { - // - barIndex -= mInputs.kijunSenLength; - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return cSSBBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyCFutureSenkouSpanB( - 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, - cSSBBuffer, - buffer, - forceClean - // - ); - } - - // - // Short ... - - // - // TENKANSEN ... - - // - double GetSTenkanSen( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return sTKBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopySTenkanSen( - 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, - sTKBuffer, - buffer, - forceClean - // - ); - } - - // - // KIJUNSEN ... - - // - double GetSKijunSen( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return sKJBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopySKijunSen( - 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, - sKJBuffer, - buffer, - forceClean - // - ); - } - - // - // CHIKOUSPAN ... - - // - double GetSChikouSpan( - int barIndex // Bar Index - ) - { - // - int cycleLength = GetCycleLengthOn( - mPeriod, // Host - X_MARKET_CYCLE_SHORT, // Cycle - mInputs.scMethod, // Method - mInputs.scPeriod // Period - ); - if (cycleLength <= 0) - { - cycleLength = 1; - } - - // - barIndex -= (mInputs.kijunSenLength * cycleLength); - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return sChikBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopySChikouSpan( - int start, // Start - int count, // Number of Items for read - double &buffer[], // Dest Buffer - bool forceClean = true // Force To Clean buffer - ) - { - - // - int cycleLength = GetCycleLengthOn( - mPeriod, // Host - X_MARKET_CYCLE_SHORT, // Cycle - mInputs.scMethod, // Method - mInputs.scPeriod // Period - ); - if (cycleLength <= 0) - { - cycleLength = 1; - } - - // - // Update Calculations ... - Calculate(); - - // - // Copy Items ... - return Copy( - start - (mInputs.kijunSenLength * cycleLength), - count, - sChikBuffer, - buffer, - forceClean - // - ); - } - - // - // SENKOUSPANA ... - - // - double GetSSenkouSpanA( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return sSSABuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopySSenkouSpanA( - 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, - sSSABuffer, - buffer, - forceClean - // - ); - } - - // - // SENKOUSPANB ... - - // - double GetSSenkouSpanB( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return sSSBBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopySSenkouSpanB( - 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, - sSSBBuffer, - buffer, - forceClean - // - ); - } - - // - // FUTURESENKOUSPANA ... - - // - double GetSFutureSenkouSpanA( - int barIndex // Bar Index - ) - { - // - int cycleLength = GetCycleLengthOn( - mPeriod, // Host - X_MARKET_CYCLE_SHORT, // Cycle - mInputs.scMethod, // Method - mInputs.scPeriod // Period - ); - if (cycleLength <= 0) - { - cycleLength = 1; - } - - // - barIndex -= (mInputs.kijunSenLength * cycleLength); - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return sSSABuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopySFutureSenkouSpanA( - int start, // Start - int count, // Number of Items for read - double &buffer[], // Dest Buffer - bool forceClean = true // Force To Clean buffer - ) - { - // - int cycleLength = GetCycleLengthOn( - mPeriod, // Host - X_MARKET_CYCLE_SHORT, // Cycle - mInputs.scMethod, // Method - mInputs.scPeriod // Period - ); - if (cycleLength <= 0) - { - cycleLength = 1; - } - - // - // Update Calculations ... - Calculate(); - - // - // Copy Items ... - return Copy( - start - (mInputs.kijunSenLength * cycleLength), - count, - sSSABuffer, - buffer, - forceClean - // - ); - } - - // - // FUTURESENKOUSPANB ... - - // - double GetSFutureSenkouSpanB( - int barIndex // Bar Index - ) - { - // - int cycleLength = GetCycleLengthOn( - mPeriod, // Host - X_MARKET_CYCLE_SHORT, // Cycle - mInputs.scMethod, // Method - mInputs.scPeriod // Period - ); - if (cycleLength <= 0) - { - cycleLength = 1; - } - - // - barIndex -= (mInputs.kijunSenLength * cycleLength); - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return sSSBBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopySFutureSenkouSpanB( - int start, // Start - int count, // Number of Items for read - double &buffer[], // Dest Buffer - bool forceClean = true // Force To Clean buffer - ) - { - // - int cycleLength = GetCycleLengthOn( - mPeriod, // Host - X_MARKET_CYCLE_SHORT, // Cycle - mInputs.scMethod, // Method - mInputs.scPeriod // Period - ); - if (cycleLength <= 0) - { - cycleLength = 1; - } - - // - // Update Calculations ... - Calculate(); - - // - // Copy Items ... - return Copy( - start - (mInputs.kijunSenLength * cycleLength), - count, - sSSBBuffer, - buffer, - forceClean - // - ); - } - - // - // Medium ... - - // - // TENKANSEN ... - - // - double GetMTenkanSen( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return mTKBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyMTenkanSen( - 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, - mTKBuffer, - buffer, - forceClean - // - ); - } - - // - // KIJUNSEN ... - - // - double GetMKijunSen( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return mKJBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyMKijunSen( - 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, - mKJBuffer, - buffer, - forceClean - // - ); - } - - // - // CHIKOUSPAN ... - - // - double GetMChikouSpan( - int barIndex // Bar Index - ) - { - // - int cycleLength = GetCycleLengthOn( - mPeriod, // Host - X_MARKET_CYCLE_MEDIUM, // Cycle - mInputs.scMethod, // Method - mInputs.scPeriod // Period - ); - if (cycleLength <= 0) - { - cycleLength = 1; - } - - // - barIndex -= (mInputs.kijunSenLength * cycleLength); - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return mChikBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyMChikouSpan( - int start, // Start - int count, // Number of Items for read - double &buffer[], // Dest Buffer - bool forceClean = true // Force To Clean buffer - ) - { - - // - int cycleLength = GetCycleLengthOn( - mPeriod, // Host - X_MARKET_CYCLE_MEDIUM, // Cycle - mInputs.scMethod, // Method - mInputs.scPeriod // Period - ); - if (cycleLength <= 0) - { - cycleLength = 1; - } - - // - // Update Calculations ... - Calculate(); - - // - // Copy Items ... - return Copy( - start - (mInputs.kijunSenLength * cycleLength), - count, - mChikBuffer, - buffer, - forceClean - // - ); - } - - // - // SENKOUSPANA ... - - // - double GetMSenkouSpanA( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return mSSABuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyMSenkouSpanA( - 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, - mSSABuffer, - buffer, - forceClean - // - ); - } - - // - // SENKOUSPANB ... - - // - double GetMSenkouSpanB( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return mSSBBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyMSenkouSpanB( - 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, - mSSBBuffer, - buffer, - forceClean - // - ); - } - - // - // FUTURESENKOUSPANA ... - - // - double GetMFutureSenkouSpanA( - int barIndex // Bar Index - ) - { - // - int cycleLength = GetCycleLengthOn( - mPeriod, // Host - X_MARKET_CYCLE_MEDIUM, // Cycle - mInputs.scMethod, // Method - mInputs.scPeriod // Period - ); - if (cycleLength <= 0) - { - cycleLength = 1; - } - - // - barIndex -= (mInputs.kijunSenLength * cycleLength); - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return mSSABuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyMFutureSenkouSpanA( - int start, // Start - int count, // Number of Items for read - double &buffer[], // Dest Buffer - bool forceClean = true // Force To Clean buffer - ) - { - // - int cycleLength = GetCycleLengthOn( - mPeriod, // Host - X_MARKET_CYCLE_MEDIUM, // Cycle - mInputs.scMethod, // Method - mInputs.scPeriod // Period - ); - if (cycleLength <= 0) - { - cycleLength = 1; - } - - // - // Update Calculations ... - Calculate(); - - // - // Copy Items ... - return Copy( - start - (mInputs.kijunSenLength * cycleLength), - count, - mSSABuffer, - buffer, - forceClean - // - ); - } - - // - // FUTURESENKOUSPANB ... - - // - double GetMFutureSenkouSpanB( - int barIndex // Bar Index - ) - { - // - int cycleLength = GetCycleLengthOn( - mPeriod, // Host - X_MARKET_CYCLE_MEDIUM, // Cycle - mInputs.scMethod, // Method - mInputs.scPeriod // Period - ); - if (cycleLength <= 0) - { - cycleLength = 1; - } - - // - barIndex -= (mInputs.kijunSenLength * cycleLength); - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return mSSBBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyMFutureSenkouSpanB( - int start, // Start - int count, // Number of Items for read - double &buffer[], // Dest Buffer - bool forceClean = true // Force To Clean buffer - ) - { - // - int cycleLength = GetCycleLengthOn( - mPeriod, // Host - X_MARKET_CYCLE_MEDIUM, // Cycle - mInputs.scMethod, // Method - mInputs.scPeriod // Period - ); - if (cycleLength <= 0) - { - cycleLength = 1; - } - - // - // Update Calculations ... - Calculate(); - - // - // Copy Items ... - return Copy( - start - (mInputs.kijunSenLength * cycleLength), - count, - mSSBBuffer, - buffer, - forceClean - // - ); - } - - // - // Long ... - - // - // TENKANSEN ... - - // - double GetLTenkanSen( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return lTKBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyLTenkanSen( - 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, - lTKBuffer, - buffer, - forceClean - // - ); - } - - // - // KIJUNSEN ... - - // - double GetLKijunSen( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return lKJBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyLKijunSen( - 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, - lKJBuffer, - buffer, - forceClean - // - ); - } - - // - // CHIKOUSPAN ... - - // - double GetLChikouSpan( - int barIndex // Bar Index - ) - { - // - int cycleLength = GetCycleLengthOn( - mPeriod, // Host - X_MARKET_CYCLE_LONG, // Cycle - mInputs.scMethod, // Method - mInputs.scPeriod // Period - ); - if (cycleLength <= 0) - { - cycleLength = 1; - } - - // - barIndex -= (mInputs.kijunSenLength * cycleLength); - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return lChikBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyLChikouSpan( - int start, // Start - int count, // Number of Items for read - double &buffer[], // Dest Buffer - bool forceClean = true // Force To Clean buffer - ) - { - - // - int cycleLength = GetCycleLengthOn( - mPeriod, // Host - X_MARKET_CYCLE_LONG, // Cycle - mInputs.scMethod, // Method - mInputs.scPeriod // Period - ); - if (cycleLength <= 0) - { - cycleLength = 1; - } - - // - // Update Calculations ... - Calculate(); - - // - // Copy Items ... - return Copy( - start - (mInputs.kijunSenLength * cycleLength), - count, - lChikBuffer, - buffer, - forceClean - // - ); - } - - // - // SENKOUSPANA ... - - // - double GetLSenkouSpanA( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return lSSABuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyLSenkouSpanA( - 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, - lSSABuffer, - buffer, - forceClean - // - ); - } - - // - // SENKOUSPANB ... - - // - double GetLSenkouSpanB( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return lSSBBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyLSenkouSpanB( - 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, - lSSBBuffer, - buffer, - forceClean - // - ); - } - - // - // FUTURESENKOUSPANA ... - - // - double GetLFutureSenkouSpanA( - int barIndex // Bar Index - ) - { - // - int cycleLength = GetCycleLengthOn( - mPeriod, // Host - X_MARKET_CYCLE_LONG, // Cycle - mInputs.scMethod, // Method - mInputs.scPeriod // Period - ); - if (cycleLength <= 0) - { - cycleLength = 1; - } - - // - barIndex -= (mInputs.kijunSenLength * cycleLength); - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return lSSABuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyLFutureSenkouSpanA( - int start, // Start - int count, // Number of Items for read - double &buffer[], // Dest Buffer - bool forceClean = true // Force To Clean buffer - ) - { - // - int cycleLength = GetCycleLengthOn( - mPeriod, // Host - X_MARKET_CYCLE_LONG, // Cycle - mInputs.scMethod, // Method - mInputs.scPeriod // Period - ); - if (cycleLength <= 0) - { - cycleLength = 1; - } - - // - // Update Calculations ... - Calculate(); - - // - // Copy Items ... - return Copy( - start - (mInputs.kijunSenLength * cycleLength), - count, - lSSABuffer, - buffer, - forceClean - // - ); - } - - // - // FUTURESENKOUSPANB ... - - // - double GetLFutureSenkouSpanB( - int barIndex // Bar Index - ) - { - // - int cycleLength = GetCycleLengthOn( - mPeriod, // Host - X_MARKET_CYCLE_LONG, // Cycle - mInputs.scMethod, // Method - mInputs.scPeriod // Period - ); - if (cycleLength <= 0) - { - cycleLength = 1; - } - - // - barIndex -= (mInputs.kijunSenLength * cycleLength); - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return lSSBBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyLFutureSenkouSpanB( - int start, // Start - int count, // Number of Items for read - double &buffer[], // Dest Buffer - bool forceClean = true // Force To Clean buffer - ) - { - // - int cycleLength = GetCycleLengthOn( - mPeriod, // Host - X_MARKET_CYCLE_LONG, // Cycle - mInputs.scMethod, // Method - mInputs.scPeriod // Period - ); - if (cycleLength <= 0) - { - cycleLength = 1; - } - - // - // Update Calculations ... - Calculate(); - - // - // Copy Items ... - return Copy( - start - (mInputs.kijunSenLength * cycleLength), - count, - lSSBBuffer, - buffer, - forceClean - // - ); - } - - // - // Hind ... - - // - // TENKANSEN ... - - // - double GetHTenkanSen( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return hTKBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyHTenkanSen( - 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, - hTKBuffer, - buffer, - forceClean - // - ); - } - - // - // KIJUNSEN ... - - // - double GetHKijunSen( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return hKJBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyHKijunSen( - 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, - hKJBuffer, - buffer, - forceClean - // - ); - } - - // - // CHIKOUSPAN ... - - // - double GetHChikouSpan( - int barIndex // Bar Index - ) - { - // - int cycleLength = GetCycleLengthOn( - mPeriod, // Host - X_MARKET_CYCLE_HIND, // Cycle - mInputs.scMethod, // Method - mInputs.scPeriod // Period - ); - if (cycleLength <= 0) - { - cycleLength = 1; - } - - // - barIndex -= (mInputs.kijunSenLength * cycleLength); - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return hChikBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyHChikouSpan( - int start, // Start - int count, // Number of Items for read - double &buffer[], // Dest Buffer - bool forceClean = true // Force To Clean buffer - ) - { - - // - int cycleLength = GetCycleLengthOn( - mPeriod, // Host - X_MARKET_CYCLE_HIND, // Cycle - mInputs.scMethod, // Method - mInputs.scPeriod // Period - ); - if (cycleLength <= 0) - { - cycleLength = 1; - } - - // - // Update Calculations ... - Calculate(); - - // - // Copy Items ... - return Copy( - start - (mInputs.kijunSenLength * cycleLength), - count, - hChikBuffer, - buffer, - forceClean - // - ); - } - - // - // SENKOUSPANA ... - - // - double GetHSenkouSpanA( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return hSSABuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyHSenkouSpanA( - 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, - hSSABuffer, - buffer, - forceClean - // - ); - } - - // - // SENKOUSPANB ... - - // - double GetHSenkouSpanB( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return hSSBBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyHSenkouSpanB( - 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, - hSSBBuffer, - buffer, - forceClean - // - ); - } - - // - // FUTURESENKOUSPANA ... - - // - double GetHFutureSenkouSpanA( - int barIndex // Bar Index - ) - { - // - int cycleLength = GetCycleLengthOn( - mPeriod, // Host - X_MARKET_CYCLE_HIND, // Cycle - mInputs.scMethod, // Method - mInputs.scPeriod // Period - ); - if (cycleLength <= 0) - { - cycleLength = 1; - } - - // - barIndex -= (mInputs.kijunSenLength * cycleLength); - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return hSSABuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyHFutureSenkouSpanA( - int start, // Start - int count, // Number of Items for read - double &buffer[], // Dest Buffer - bool forceClean = true // Force To Clean buffer - ) - { - // - int cycleLength = GetCycleLengthOn( - mPeriod, // Host - X_MARKET_CYCLE_HIND, // Cycle - mInputs.scMethod, // Method - mInputs.scPeriod // Period - ); - if (cycleLength <= 0) - { - cycleLength = 1; - } - - // - // Update Calculations ... - Calculate(); - - // - // Copy Items ... - return Copy( - start - (mInputs.kijunSenLength * cycleLength), - count, - hSSABuffer, - buffer, - forceClean - // - ); - } - - // - // FUTURESENKOUSPANB ... - - // - double GetHFutureSenkouSpanB( - int barIndex // Bar Index - ) - { - // - int cycleLength = GetCycleLengthOn( - mPeriod, // Host - X_MARKET_CYCLE_HIND, // Cycle - mInputs.scMethod, // Method - mInputs.scPeriod // Period - ); - if (cycleLength <= 0) - { - cycleLength = 1; - } - - // - barIndex -= (mInputs.kijunSenLength * cycleLength); - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return hSSBBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyHFutureSenkouSpanB( - int start, // Start - int count, // Number of Items for read - double &buffer[], // Dest Buffer - bool forceClean = true // Force To Clean buffer - ) - { - // - int cycleLength = GetCycleLengthOn( - mPeriod, // Host - X_MARKET_CYCLE_HIND, // Cycle - mInputs.scMethod, // Method - mInputs.scPeriod // Period - ); - if (cycleLength <= 0) - { - cycleLength = 1; - } - - // - // Update Calculations ... - Calculate(); - - // - // Copy Items ... - return Copy( - start - (mInputs.kijunSenLength * cycleLength), - count, - hSSBBuffer, - buffer, - forceClean - // - ); - } - - // - // Tools ... - - // - void GetCycleValues( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle, // Cycle - // - double &tenkanSen, - double &kijunSen, - double &chikouSpan, - double &senkouSpanA, - double &senkouSpanB, - double &futureSenkouSpanA, - double &futureSenkouSpanB // - ) - { - // - tenkanSen = 0; - kijunSen = 0; - chikouSpan = 0; - senkouSpanA = 0; - senkouSpanB = 0; - futureSenkouSpanA = 0; - futureSenkouSpanB = 0; - - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - switch (cycle) - { - // - // Current ... - case X_MARKET_CYCLE_UNKNOWN: - // - tenkanSen = GetCTenkanSen(barIndex); - kijunSen = GetCKijunSen(barIndex); - chikouSpan = GetCChikouSpan(barIndex); - senkouSpanA = GetCSenkouSpanA(barIndex); - senkouSpanB = GetCSenkouSpanB(barIndex); - futureSenkouSpanA = GetCFutureSenkouSpanA(barIndex); - futureSenkouSpanB = GetCFutureSenkouSpanB(barIndex); - break; - - // - // Short ... - case X_MARKET_CYCLE_SHORT: - // - tenkanSen = GetSTenkanSen(barIndex); - kijunSen = GetSKijunSen(barIndex); - chikouSpan = GetSChikouSpan(barIndex); - senkouSpanA = GetSSenkouSpanA(barIndex); - senkouSpanB = GetSSenkouSpanB(barIndex); - futureSenkouSpanA = GetSFutureSenkouSpanA(barIndex); - futureSenkouSpanB = GetSFutureSenkouSpanB(barIndex); - break; - - // - // Medium ... - case X_MARKET_CYCLE_MEDIUM: - // - tenkanSen = GetMTenkanSen(barIndex); - kijunSen = GetMKijunSen(barIndex); - chikouSpan = GetMChikouSpan(barIndex); - senkouSpanA = GetMSenkouSpanA(barIndex); - senkouSpanB = GetMSenkouSpanB(barIndex); - futureSenkouSpanA = GetMFutureSenkouSpanA(barIndex); - futureSenkouSpanB = GetMFutureSenkouSpanB(barIndex); - break; - - // - // Long ... - case X_MARKET_CYCLE_LONG: - // - tenkanSen = GetLTenkanSen(barIndex); - kijunSen = GetLKijunSen(barIndex); - chikouSpan = GetLChikouSpan(barIndex); - senkouSpanA = GetLSenkouSpanA(barIndex); - senkouSpanB = GetLSenkouSpanB(barIndex); - futureSenkouSpanA = GetLFutureSenkouSpanA(barIndex); - futureSenkouSpanB = GetLFutureSenkouSpanB(barIndex); - break; - - // - // Hind ... - case X_MARKET_CYCLE_HIND: - // - tenkanSen = GetHTenkanSen(barIndex); - kijunSen = GetHKijunSen(barIndex); - chikouSpan = GetHChikouSpan(barIndex); - senkouSpanA = GetHSenkouSpanA(barIndex); - senkouSpanB = GetHSenkouSpanB(barIndex); - futureSenkouSpanA = GetHFutureSenkouSpanA(barIndex); - futureSenkouSpanB = GetHFutureSenkouSpanB(barIndex); - break; - } - } - - // - int GetTenkanSenOverKijunSenCycles( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - int result = 0; - - // - Clean(cycles); - - // - ENUM_X_MARKET_CYCLES allCycles[]; - int allCyclesCount = GetAllMarketCycles(allCycles); - if (!IsValidSize(allCyclesCount)) - { - return result; - } - - // - for (int i = 0; i < allCyclesCount; i++) - { - // - double iTenkanSen = 0; - double iKijunSen = 0; - double iChikouSpan = 0; - double iSenkouSpanA = 0; - double iSenkouSpanB = 0; - double iFutureSenkouSpanA = 0; - double iFutureSenkouSpanB = 0; - GetCycleValues( - barIndex, - allCycles[i], - iTenkanSen, - iKijunSen, - iChikouSpan, - iSenkouSpanA, - iSenkouSpanB, - iFutureSenkouSpanA, - iFutureSenkouSpanB // - ); - - // - bool isPassed = - iTenkanSen > iKijunSen; - if (isPassed) - { - // - Add( - allCycles[i], - cycles // - ); - } - } - - // - result = ArraySize(cycles); - - // - return result; - } - - // - int GetTenkanSenUnderKijunSenCycles( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - int result = 0; - - // - Clean(cycles); - - // - ENUM_X_MARKET_CYCLES allCycles[]; - int allCyclesCount = GetAllMarketCycles(allCycles); - if (!IsValidSize(allCyclesCount)) - { - return result; - } - - // - for (int i = 0; i < allCyclesCount; i++) - { - // - double iTenkanSen = 0; - double iKijunSen = 0; - double iChikouSpan = 0; - double iSenkouSpanA = 0; - double iSenkouSpanB = 0; - double iFutureSenkouSpanA = 0; - double iFutureSenkouSpanB = 0; - GetCycleValues( - barIndex, - allCycles[i], - iTenkanSen, - iKijunSen, - iChikouSpan, - iSenkouSpanA, - iSenkouSpanB, - iFutureSenkouSpanA, - iFutureSenkouSpanB // - ); - - // - bool isPassed = - iTenkanSen < iKijunSen; - if (isPassed) - { - // - Add( - allCycles[i], - cycles // - ); - } - } - - // - result = ArraySize(cycles); - - // - return result; - } - - // - int GetSenkouSpanAOverBCycles( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - int result = 0; - - // - Clean(cycles); - - // - ENUM_X_MARKET_CYCLES allCycles[]; - int allCyclesCount = GetAllMarketCycles(allCycles); - if (!IsValidSize(allCyclesCount)) - { - return result; - } - - // - for (int i = 0; i < allCyclesCount; i++) - { - // - double iTenkanSen = 0; - double iKijunSen = 0; - double iChikouSpan = 0; - double iSenkouSpanA = 0; - double iSenkouSpanB = 0; - double iFutureSenkouSpanA = 0; - double iFutureSenkouSpanB = 0; - GetCycleValues( - barIndex, - allCycles[i], - iTenkanSen, - iKijunSen, - iChikouSpan, - iSenkouSpanA, - iSenkouSpanB, - iFutureSenkouSpanA, - iFutureSenkouSpanB // - ); - - // - bool isPassed = - iSenkouSpanA > iSenkouSpanB; - if (isPassed) - { - // - Add( - allCycles[i], - cycles // - ); - } - } - - // - result = ArraySize(cycles); - - // - return result; - } - - // - int GetSenkouSpanAUnderBCycles( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - int result = 0; - - // - Clean(cycles); - - // - ENUM_X_MARKET_CYCLES allCycles[]; - int allCyclesCount = GetAllMarketCycles(allCycles); - if (!IsValidSize(allCyclesCount)) - { - return result; - } - - // - for (int i = 0; i < allCyclesCount; i++) - { - // - double iTenkanSen = 0; - double iKijunSen = 0; - double iChikouSpan = 0; - double iSenkouSpanA = 0; - double iSenkouSpanB = 0; - double iFutureSenkouSpanA = 0; - double iFutureSenkouSpanB = 0; - GetCycleValues( - barIndex, - allCycles[i], - iTenkanSen, - iKijunSen, - iChikouSpan, - iSenkouSpanA, - iSenkouSpanB, - iFutureSenkouSpanA, - iFutureSenkouSpanB // - ); - - // - bool isPassed = - iSenkouSpanA < iSenkouSpanB; - if (isPassed) - { - // - Add( - allCycles[i], - cycles // - ); - } - } - - // - result = ArraySize(cycles); - - // - return result; - } - - // - int GetFutureSenkouSpanAOverBCycles( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - int result = 0; - - // - Clean(cycles); - - // - ENUM_X_MARKET_CYCLES allCycles[]; - int allCyclesCount = GetAllMarketCycles(allCycles); - if (!IsValidSize(allCyclesCount)) - { - return result; - } - - // - for (int i = 0; i < allCyclesCount; i++) - { - // - double iTenkanSen = 0; - double iKijunSen = 0; - double iChikouSpan = 0; - double iSenkouSpanA = 0; - double iSenkouSpanB = 0; - double iFutureSenkouSpanA = 0; - double iFutureSenkouSpanB = 0; - GetCycleValues( - barIndex, - allCycles[i], - iTenkanSen, - iKijunSen, - iChikouSpan, - iSenkouSpanA, - iSenkouSpanB, - iFutureSenkouSpanA, - iFutureSenkouSpanB // - ); - - // - bool isPassed = - iFutureSenkouSpanA > iFutureSenkouSpanB; - if (isPassed) - { - // - Add( - allCycles[i], - cycles // - ); - } - } - - // - result = ArraySize(cycles); - - // - return result; - } - - // - int GetFutureSenkouSpanAUnderBCycles( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - int result = 0; - - // - Clean(cycles); - - // - ENUM_X_MARKET_CYCLES allCycles[]; - int allCyclesCount = GetAllMarketCycles(allCycles); - if (!IsValidSize(allCyclesCount)) - { - return result; - } - - // - for (int i = 0; i < allCyclesCount; i++) - { - // - double iTenkanSen = 0; - double iKijunSen = 0; - double iChikouSpan = 0; - double iSenkouSpanA = 0; - double iSenkouSpanB = 0; - double iFutureSenkouSpanA = 0; - double iFutureSenkouSpanB = 0; - GetCycleValues( - barIndex, - allCycles[i], - iTenkanSen, - iKijunSen, - iChikouSpan, - iSenkouSpanA, - iSenkouSpanB, - iFutureSenkouSpanA, - iFutureSenkouSpanB // - ); - - // - bool isPassed = - iFutureSenkouSpanA < iFutureSenkouSpanB; - if (isPassed) - { - // - Add( - allCycles[i], - cycles // - ); - } - } - - // - result = ArraySize(cycles); - - // - return result; - } - - // - double GetCyclesTenkanSensMax( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - double result = 0; - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - double values[]; - - // - for (int i = 0; i < count; i++) - { - // - double iTenkanSen = 0; - double iKijunSen = 0; - double iChikouSpan = 0; - double iSenkouSpanA = 0; - double iSenkouSpanB = 0; - double iFutureSenkouSpanA = 0; - double iFutureSenkouSpanB = 0; - GetCycleValues( - barIndex, - cycles[i], - iTenkanSen, - iKijunSen, - iChikouSpan, - iSenkouSpanA, - iSenkouSpanB, - iFutureSenkouSpanA, - iFutureSenkouSpanB // - ); - - // - Add( - iTenkanSen, - values // - ); - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetCyclesTenkanSensMin( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - double result = 0; - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - double values[]; - - // - for (int i = 0; i < count; i++) - { - // - double iTenkanSen = 0; - double iKijunSen = 0; - double iChikouSpan = 0; - double iSenkouSpanA = 0; - double iSenkouSpanB = 0; - double iFutureSenkouSpanA = 0; - double iFutureSenkouSpanB = 0; - GetCycleValues( - barIndex, - cycles[i], - iTenkanSen, - iKijunSen, - iChikouSpan, - iSenkouSpanA, - iSenkouSpanB, - iFutureSenkouSpanA, - iFutureSenkouSpanB // - ); - - // - Add( - iTenkanSen, - values // - ); - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetCyclesKijunSensMax( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - double result = 0; - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - double values[]; - - // - for (int i = 0; i < count; i++) - { - // - double iTenkanSen = 0; - double iKijunSen = 0; - double iChikouSpan = 0; - double iSenkouSpanA = 0; - double iSenkouSpanB = 0; - double iFutureSenkouSpanA = 0; - double iFutureSenkouSpanB = 0; - GetCycleValues( - barIndex, - cycles[i], - iTenkanSen, - iKijunSen, - iChikouSpan, - iSenkouSpanA, - iSenkouSpanB, - iFutureSenkouSpanA, - iFutureSenkouSpanB // - ); - - // - Add( - iKijunSen, - values // - ); - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetCyclesKijunSensMin( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - double result = 0; - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - double values[]; - - // - for (int i = 0; i < count; i++) - { - // - double iTenkanSen = 0; - double iKijunSen = 0; - double iChikouSpan = 0; - double iSenkouSpanA = 0; - double iSenkouSpanB = 0; - double iFutureSenkouSpanA = 0; - double iFutureSenkouSpanB = 0; - GetCycleValues( - barIndex, - cycles[i], - iTenkanSen, - iKijunSen, - iChikouSpan, - iSenkouSpanA, - iSenkouSpanB, - iFutureSenkouSpanA, - iFutureSenkouSpanB // - ); - - // - Add( - iKijunSen, - values // - ); - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetCyclesSenkouSpanAMax( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - double result = 0; - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - double values[]; - - // - for (int i = 0; i < count; i++) - { - // - double iTenkanSen = 0; - double iKijunSen = 0; - double iChikouSpan = 0; - double iSenkouSpanA = 0; - double iSenkouSpanB = 0; - double iFutureSenkouSpanA = 0; - double iFutureSenkouSpanB = 0; - GetCycleValues( - barIndex, - cycles[i], - iTenkanSen, - iKijunSen, - iChikouSpan, - iSenkouSpanA, - iSenkouSpanB, - iFutureSenkouSpanA, - iFutureSenkouSpanB // - ); - - // - Add( - iSenkouSpanA, - values // - ); - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetCyclesSenkouSpanAMin( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - double result = 0; - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - double values[]; - - // - for (int i = 0; i < count; i++) - { - // - double iTenkanSen = 0; - double iKijunSen = 0; - double iChikouSpan = 0; - double iSenkouSpanA = 0; - double iSenkouSpanB = 0; - double iFutureSenkouSpanA = 0; - double iFutureSenkouSpanB = 0; - GetCycleValues( - barIndex, - cycles[i], - iTenkanSen, - iKijunSen, - iChikouSpan, - iSenkouSpanA, - iSenkouSpanB, - iFutureSenkouSpanA, - iFutureSenkouSpanB // - ); - - // - Add( - iSenkouSpanA, - values // - ); - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetCyclesSenkouSpanBMax( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - double result = 0; - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - double values[]; - - // - for (int i = 0; i < count; i++) - { - // - double iTenkanSen = 0; - double iKijunSen = 0; - double iChikouSpan = 0; - double iSenkouSpanA = 0; - double iSenkouSpanB = 0; - double iFutureSenkouSpanA = 0; - double iFutureSenkouSpanB = 0; - GetCycleValues( - barIndex, - cycles[i], - iTenkanSen, - iKijunSen, - iChikouSpan, - iSenkouSpanA, - iSenkouSpanB, - iFutureSenkouSpanA, - iFutureSenkouSpanB // - ); - - // - Add( - iSenkouSpanB, - values // - ); - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetCyclesSenkouSpanBMin( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - double result = 0; - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - double values[]; - - // - for (int i = 0; i < count; i++) - { - // - double iTenkanSen = 0; - double iKijunSen = 0; - double iChikouSpan = 0; - double iSenkouSpanA = 0; - double iSenkouSpanB = 0; - double iFutureSenkouSpanA = 0; - double iFutureSenkouSpanB = 0; - GetCycleValues( - barIndex, - cycles[i], - iTenkanSen, - iKijunSen, - iChikouSpan, - iSenkouSpanA, - iSenkouSpanB, - iFutureSenkouSpanA, - iFutureSenkouSpanB // - ); - - // - Add( - iSenkouSpanB, - values // - ); - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetCyclesFutureSenkouSpanAMax( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - double result = 0; - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - double values[]; - - // - for (int i = 0; i < count; i++) - { - // - double iTenkanSen = 0; - double iKijunSen = 0; - double iChikouSpan = 0; - double iSenkouSpanA = 0; - double iSenkouSpanB = 0; - double iFutureSenkouSpanA = 0; - double iFutureSenkouSpanB = 0; - GetCycleValues( - barIndex, - cycles[i], - iTenkanSen, - iKijunSen, - iChikouSpan, - iSenkouSpanA, - iSenkouSpanB, - iFutureSenkouSpanA, - iFutureSenkouSpanB // - ); - - // - Add( - iFutureSenkouSpanA, - values // - ); - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetCyclesFutureSenkouSpanAMin( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - double result = 0; - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - double values[]; - - // - for (int i = 0; i < count; i++) - { - // - double iTenkanSen = 0; - double iKijunSen = 0; - double iChikouSpan = 0; - double iSenkouSpanA = 0; - double iSenkouSpanB = 0; - double iFutureSenkouSpanA = 0; - double iFutureSenkouSpanB = 0; - GetCycleValues( - barIndex, - cycles[i], - iTenkanSen, - iKijunSen, - iChikouSpan, - iSenkouSpanA, - iSenkouSpanB, - iFutureSenkouSpanA, - iFutureSenkouSpanB // - ); - - // - Add( - iFutureSenkouSpanA, - values // - ); - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetCyclesFutureSenkouSpanBMax( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - double result = 0; - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - double values[]; - - // - for (int i = 0; i < count; i++) - { - // - double iTenkanSen = 0; - double iKijunSen = 0; - double iChikouSpan = 0; - double iSenkouSpanA = 0; - double iSenkouSpanB = 0; - double iFutureSenkouSpanA = 0; - double iFutureSenkouSpanB = 0; - GetCycleValues( - barIndex, - cycles[i], - iTenkanSen, - iKijunSen, - iChikouSpan, - iSenkouSpanA, - iSenkouSpanB, - iFutureSenkouSpanA, - iFutureSenkouSpanB // - ); - - // - Add( - iFutureSenkouSpanB, - values // - ); - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetCyclesFutureSenkouSpanBMin( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - double result = 0; - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - double values[]; - - // - for (int i = 0; i < count; i++) - { - // - double iTenkanSen = 0; - double iKijunSen = 0; - double iChikouSpan = 0; - double iSenkouSpanA = 0; - double iSenkouSpanB = 0; - double iFutureSenkouSpanA = 0; - double iFutureSenkouSpanB = 0; - GetCycleValues( - barIndex, - cycles[i], - iTenkanSen, - iKijunSen, - iChikouSpan, - iSenkouSpanA, - iSenkouSpanB, - iFutureSenkouSpanA, - iFutureSenkouSpanB // - ); - - // - Add( - iFutureSenkouSpanB, - values // - ); - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - // Conditions ... - - // - bool GetConditions( - XCHICHConditions &conditions, // - int barIndex = 0, // - int loopback = 5 // - ) - { - // - bool result = true; - - // - if (loopback < 5) - { - loopback = 5; - } - - // - conditions.Clean(); - - // - conditions.symbol = mSymbol; - conditions.period = mPeriod; - conditions.time = TimeCurrent(); - - // - int zIndex = barIndex; - int cIndex = zIndex + 1; - int pIndex = cIndex + 1; - int ppIndex = pIndex + 1; - - // - // Buffers ... - - // - // Current ... - CopyCTenkanSen( - zIndex, - loopback, - conditions.cTK // - ); - CopyCKijunSen( - zIndex, - loopback, - conditions.cKJ // - ); - CopyCChikouSpan( - zIndex, - loopback, - conditions.cChik // - ); - CopyCSenkouSpanA( - zIndex, - loopback, - conditions.cSSA // - ); - CopyCSenkouSpanB( - zIndex, - loopback, - conditions.cSSB // - ); - CopyCFutureSenkouSpanA( - zIndex, - loopback, - conditions.cFSSA // - ); - CopyCFutureSenkouSpanB( - zIndex, - loopback, - conditions.cFSSB // - ); - - // - // Short ... - CopySTenkanSen( - zIndex, - loopback, - conditions.sTK // - ); - CopySKijunSen( - zIndex, - loopback, - conditions.sKJ // - ); - CopySChikouSpan( - zIndex, - loopback, - conditions.sChik // - ); - CopySSenkouSpanA( - zIndex, - loopback, - conditions.sSSA // - ); - CopySSenkouSpanB( - zIndex, - loopback, - conditions.sSSB // - ); - CopySFutureSenkouSpanA( - zIndex, - loopback, - conditions.sFSSA // - ); - CopySFutureSenkouSpanB( - zIndex, - loopback, - conditions.sFSSB // - ); - - // - // Medium ... - CopyMTenkanSen( - zIndex, - loopback, - conditions.mTK // - ); - CopyMKijunSen( - zIndex, - loopback, - conditions.mKJ // - ); - CopyMChikouSpan( - zIndex, - loopback, - conditions.mChik // - ); - CopyMSenkouSpanA( - zIndex, - loopback, - conditions.mSSA // - ); - CopyMSenkouSpanB( - zIndex, - loopback, - conditions.mSSB // - ); - CopyMFutureSenkouSpanA( - zIndex, - loopback, - conditions.mFSSA // - ); - CopyMFutureSenkouSpanB( - zIndex, - loopback, - conditions.mFSSB // - ); - - // - // Long ... - CopyLTenkanSen( - zIndex, - loopback, - conditions.lTK // - ); - CopyLKijunSen( - zIndex, - loopback, - conditions.lKJ // - ); - CopyLChikouSpan( - zIndex, - loopback, - conditions.lChik // - ); - CopyLSenkouSpanA( - zIndex, - loopback, - conditions.lSSA // - ); - CopyLSenkouSpanB( - zIndex, - loopback, - conditions.lSSB // - ); - CopyLFutureSenkouSpanA( - zIndex, - loopback, - conditions.lFSSA // - ); - CopyLFutureSenkouSpanB( - zIndex, - loopback, - conditions.lFSSB // - ); - - // - // Hind ... - CopyHTenkanSen( - zIndex, - loopback, - conditions.hTK // - ); - CopyHKijunSen( - zIndex, - loopback, - conditions.hKJ // - ); - CopyHChikouSpan( - zIndex, - loopback, - conditions.hChik // - ); - CopyHSenkouSpanA( - zIndex, - loopback, - conditions.hSSA // - ); - CopyHSenkouSpanB( - zIndex, - loopback, - conditions.hSSB // - ); - CopyHFutureSenkouSpanA( - zIndex, - loopback, - conditions.hFSSA // - ); - CopyHFutureSenkouSpanB( - zIndex, - loopback, - conditions.hFSSB // - ); - - // - // Conditions ... - - // - XOHCL cBar; - result = cBar.Init( - mSymbol, - mPeriod, - cIndex // - ); - if (!result) - { - return result; - } - - // - XOHCL pBar; - result = pBar.Init( - mSymbol, - mPeriod, - pIndex // - ); - if (!result) - { - return result; - } - - // - // Conditions ... - - // - // Current ... - - // - bool isCClosedOverKijunSen = cBar.low > conditions.cTK[cIndex]; - bool isCClosedUnderKijunSen = cBar.high < conditions.cTK[cIndex]; - - // - bool isCTenkanSenOverKijunSen = conditions.cTK[cIndex] > conditions.cKJ[cIndex]; - bool isCTenkanSenOverKijunSenPrev = conditions.cTK[pIndex] > conditions.cKJ[pIndex]; - - // - bool isCTenkanSenUnderKijunSen = conditions.cTK[cIndex] < conditions.cKJ[cIndex]; - bool isCTenkanSenUnderKijunSenPrev = conditions.cTK[pIndex] < conditions.cKJ[pIndex]; - - // - bool isCTenkanSenCrossedOverKijunSen = isCTenkanSenOverKijunSen && - !isCTenkanSenOverKijunSenPrev; - bool isCTenkanSenCrossedUnderKijunSen = isCTenkanSenUnderKijunSen && - !isCTenkanSenUnderKijunSenPrev; - - // - bool isCSenkouSpanAOverB = conditions.cSSA[cIndex] > conditions.cSSB[cIndex]; - bool isCSenkouSpanAOverBPrev = conditions.cSSA[pIndex] > conditions.cSSB[pIndex]; - - // - bool isCSenkouSpanAUnderB = conditions.cSSA[cIndex] < conditions.cSSB[cIndex]; - bool isCSenkouSpanAUnderBPrev = conditions.cSSA[pIndex] < conditions.cSSB[pIndex]; - - // - bool isCSenkouSpanAOverLast = conditions.cSSA[cIndex] > conditions.cSSA[pIndex]; - bool isCSenkouSpanAOverLastPrev = conditions.cSSA[pIndex] > conditions.cSSA[ppIndex]; - - // - bool isCSenkouSpanAUnderLast = conditions.cSSA[cIndex] < conditions.cSSA[pIndex]; - bool isCSenkouSpanAUnderLastPrev = conditions.cSSA[pIndex] < conditions.cSSA[ppIndex]; - - // - bool isCFutureSenkouSpanAOverB = conditions.cFSSA[cIndex] > conditions.cFSSB[cIndex]; - bool isCFutureSenkouSpanAOverBPrev = conditions.cFSSA[pIndex] > conditions.cFSSB[pIndex]; - - // - bool isCFutureSenkouSpanAUnderB = conditions.cFSSA[cIndex] < conditions.cFSSB[cIndex]; - bool isCFutureSenkouSpanAUnderBPrev = conditions.cFSSA[pIndex] < conditions.cFSSB[pIndex]; - - // - bool isCFutureSenkouSpanAOverLast = conditions.cFSSA[cIndex] > conditions.cFSSA[pIndex]; - bool isCFutureSenkouSpanAOverLastPrev = conditions.cFSSA[pIndex] > conditions.cFSSA[ppIndex]; - - // - bool isCFutureSenkouSpanAUnderLast = conditions.cFSSA[cIndex] < conditions.cFSSA[pIndex]; - bool isCFutureSenkouSpanAUnderLastPrev = conditions.cFSSA[pIndex] < conditions.cFSSA[ppIndex]; - - // - bool isCSenkouSpanACrossedOverB = isCSenkouSpanAOverB && - !isCSenkouSpanAOverBPrev; - bool isCSenkouSpanACrossedUnderB = isCSenkouSpanAUnderB && - !isCSenkouSpanAUnderBPrev; - bool isCSenkouSpanACrossedOverLast = isCSenkouSpanAOverLast && - !isCSenkouSpanAOverLastPrev; - bool isCSenkouSpanACrossedUnderLast = isCSenkouSpanAUnderLast && - !isCSenkouSpanAUnderLastPrev; - bool isCFutureSenkouSpanACrossedOverB = isCFutureSenkouSpanAOverB && - !isCFutureSenkouSpanAOverBPrev; - bool isCFutureSenkouSpanACrossedUnderB = isCFutureSenkouSpanAUnderB && - !isCFutureSenkouSpanAUnderBPrev; - bool isCFutureSenkouSpanACrossedOverLast = isCFutureSenkouSpanAOverLast && - !isCFutureSenkouSpanAOverLastPrev; - bool isCFutureSenkouSpanACrossedUnderLast = isCFutureSenkouSpanAUnderLast && - !isCFutureSenkouSpanAUnderLastPrev; - - // - conditions.isCClosedOverKijunSen = isCClosedOverKijunSen; - conditions.isCClosedUnderKijunSen = isCClosedUnderKijunSen; - conditions.isCTenkanSenOverKijunSen = isCTenkanSenOverKijunSen; - conditions.isCTenkanSenUnderKijunSen = isCTenkanSenUnderKijunSen; - conditions.isCTenkanSenCrossedOverKijunSen = isCTenkanSenCrossedOverKijunSen; - conditions.isCTenkanSenCrossedUnderKijunSen = isCTenkanSenCrossedUnderKijunSen; - - // - conditions.isCSenkouSpanAOverB = isCSenkouSpanAOverB; - conditions.isCSenkouSpanAUnderB = isCSenkouSpanAUnderB; - conditions.isCSenkouSpanAOverLast = isCSenkouSpanAOverLast; - conditions.isCSenkouSpanAUnderLast = isCSenkouSpanAUnderLast; - conditions.isCFutureSenkouSpanAOverB = isCFutureSenkouSpanAOverB; - conditions.isCFutureSenkouSpanAUnderB = isCFutureSenkouSpanAUnderB; - conditions.isCFutureSenkouSpanAOverLast = isCFutureSenkouSpanAOverLast; - conditions.isCFutureSenkouSpanAUnderLast = isCFutureSenkouSpanAUnderLast; - - // - conditions.isCSenkouSpanACrossedOverB = isCSenkouSpanACrossedOverB; - conditions.isCSenkouSpanACrossedUnderB = isCSenkouSpanACrossedUnderB; - conditions.isCSenkouSpanACrossedOverLast = isCSenkouSpanACrossedOverLast; - conditions.isCSenkouSpanACrossedUnderLast = isCSenkouSpanACrossedUnderLast; - conditions.isCFutureSenkouSpanACrossedOverB = isCFutureSenkouSpanACrossedOverB; - conditions.isCFutureSenkouSpanACrossedUnderB = isCFutureSenkouSpanACrossedUnderB; - conditions.isCFutureSenkouSpanACrossedOverLast = isCFutureSenkouSpanACrossedOverLast; - conditions.isCFutureSenkouSpanACrossedUnderLast = isCFutureSenkouSpanACrossedUnderLast; - - // - // Short ... - - // - bool isSClosedOverKijunSen = cBar.low > conditions.sTK[cIndex]; - bool isSClosedUnderKijunSen = cBar.high < conditions.sTK[cIndex]; - - // - bool isSTenkanSenOverKijunSen = conditions.sTK[cIndex] > conditions.sKJ[cIndex]; - bool isSTenkanSenOverKijunSenPrev = conditions.sTK[pIndex] > conditions.sKJ[pIndex]; - - // - bool isSTenkanSenUnderKijunSen = conditions.sTK[cIndex] < conditions.sKJ[cIndex]; - bool isSTenkanSenUnderKijunSenPrev = conditions.sTK[pIndex] < conditions.sKJ[pIndex]; - - // - bool isSTenkanSenCrossedOverKijunSen = isSTenkanSenOverKijunSen && - !isSTenkanSenOverKijunSenPrev; - bool isSTenkanSenCrossedUnderKijunSen = isSTenkanSenUnderKijunSen && - !isSTenkanSenUnderKijunSenPrev; - - // - bool isSSenkouSpanAOverB = conditions.sSSA[cIndex] > conditions.sSSB[cIndex]; - bool isSSenkouSpanAOverBPrev = conditions.sSSA[pIndex] > conditions.sSSB[pIndex]; - - // - bool isSSenkouSpanAUnderB = conditions.sSSA[cIndex] < conditions.sSSB[cIndex]; - bool isSSenkouSpanAUnderBPrev = conditions.sSSA[pIndex] < conditions.sSSB[pIndex]; - - // - bool isSSenkouSpanAOverLast = conditions.sSSA[cIndex] > conditions.sSSA[pIndex]; - bool isSSenkouSpanAOverLastPrev = conditions.sSSA[pIndex] > conditions.sSSA[ppIndex]; - - // - bool isSSenkouSpanAUnderLast = conditions.sSSA[cIndex] < conditions.sSSA[pIndex]; - bool isSSenkouSpanAUnderLastPrev = conditions.sSSA[pIndex] < conditions.sSSA[ppIndex]; - - // - bool isSFutureSenkouSpanAOverB = conditions.sFSSA[cIndex] > conditions.sFSSB[cIndex]; - bool isSFutureSenkouSpanAOverBPrev = conditions.sFSSA[pIndex] > conditions.sFSSB[pIndex]; - - // - bool isSFutureSenkouSpanAUnderB = conditions.sFSSA[cIndex] < conditions.sFSSB[cIndex]; - bool isSFutureSenkouSpanAUnderBPrev = conditions.sFSSA[pIndex] < conditions.sFSSB[pIndex]; - - // - bool isSFutureSenkouSpanAOverLast = conditions.sFSSA[cIndex] > conditions.sFSSA[pIndex]; - bool isSFutureSenkouSpanAOverLastPrev = conditions.sFSSA[pIndex] > conditions.sFSSA[ppIndex]; - - // - bool isSFutureSenkouSpanAUnderLast = conditions.sFSSA[cIndex] < conditions.sFSSA[pIndex]; - bool isSFutureSenkouSpanAUnderLastPrev = conditions.sFSSA[pIndex] < conditions.sFSSA[ppIndex]; - - // - bool isSSenkouSpanACrossedOverB = isSSenkouSpanAOverB && - !isSSenkouSpanAOverBPrev; - bool isSSenkouSpanACrossedUnderB = isSSenkouSpanAUnderB && - !isSSenkouSpanAUnderBPrev; - bool isSSenkouSpanACrossedOverLast = isSSenkouSpanAOverLast && - !isSSenkouSpanAOverLastPrev; - bool isSSenkouSpanACrossedUnderLast = isSSenkouSpanAUnderLast && - !isSSenkouSpanAUnderLastPrev; - bool isSFutureSenkouSpanACrossedOverB = isSFutureSenkouSpanAOverB && - !isSFutureSenkouSpanAOverBPrev; - bool isSFutureSenkouSpanACrossedUnderB = isSFutureSenkouSpanAUnderB && - !isSFutureSenkouSpanAUnderBPrev; - bool isSFutureSenkouSpanACrossedOverLast = isSFutureSenkouSpanAOverLast && - !isSFutureSenkouSpanAOverLastPrev; - bool isSFutureSenkouSpanACrossedUnderLast = isSFutureSenkouSpanAUnderLast && - !isSFutureSenkouSpanAUnderLastPrev; - - // - conditions.isSClosedOverKijunSen = isSClosedOverKijunSen; - conditions.isSClosedUnderKijunSen = isSClosedUnderKijunSen; - conditions.isSTenkanSenOverKijunSen = isSTenkanSenOverKijunSen; - conditions.isSTenkanSenUnderKijunSen = isSTenkanSenUnderKijunSen; - conditions.isSTenkanSenCrossedOverKijunSen = isSTenkanSenCrossedOverKijunSen; - conditions.isSTenkanSenCrossedUnderKijunSen = isSTenkanSenCrossedUnderKijunSen; - - // - conditions.isSSenkouSpanAOverB = isSSenkouSpanAOverB; - conditions.isSSenkouSpanAUnderB = isSSenkouSpanAUnderB; - conditions.isSSenkouSpanAOverLast = isSSenkouSpanAOverLast; - conditions.isSSenkouSpanAUnderLast = isSSenkouSpanAUnderLast; - conditions.isSFutureSenkouSpanAOverB = isSFutureSenkouSpanAOverB; - conditions.isSFutureSenkouSpanAUnderB = isSFutureSenkouSpanAUnderB; - conditions.isSFutureSenkouSpanAOverLast = isSFutureSenkouSpanAOverLast; - conditions.isSFutureSenkouSpanAUnderLast = isSFutureSenkouSpanAUnderLast; - - // - conditions.isSSenkouSpanACrossedOverB = isSSenkouSpanACrossedOverB; - conditions.isSSenkouSpanACrossedUnderB = isSSenkouSpanACrossedUnderB; - conditions.isSSenkouSpanACrossedOverLast = isSSenkouSpanACrossedOverLast; - conditions.isSSenkouSpanACrossedUnderLast = isSSenkouSpanACrossedUnderLast; - conditions.isSFutureSenkouSpanACrossedOverB = isSFutureSenkouSpanACrossedOverB; - conditions.isSFutureSenkouSpanACrossedUnderB = isSFutureSenkouSpanACrossedUnderB; - conditions.isSFutureSenkouSpanACrossedOverLast = isSFutureSenkouSpanACrossedOverLast; - conditions.isSFutureSenkouSpanACrossedUnderLast = isSFutureSenkouSpanACrossedUnderLast; - - // - // Medium ... - - // - bool isMClosedOverKijunSen = cBar.low > conditions.mTK[cIndex]; - bool isMClosedUnderKijunSen = cBar.high < conditions.mTK[cIndex]; - - // - bool isMTenkanSenOverKijunSen = conditions.mTK[cIndex] > conditions.mKJ[cIndex]; - bool isMTenkanSenOverKijunSenPrev = conditions.mTK[pIndex] > conditions.mKJ[pIndex]; - - // - bool isMTenkanSenUnderKijunSen = conditions.mTK[cIndex] < conditions.mKJ[cIndex]; - bool isMTenkanSenUnderKijunSenPrev = conditions.mTK[pIndex] < conditions.mKJ[pIndex]; - - // - bool isMTenkanSenCrossedOverKijunSen = isMTenkanSenOverKijunSen && - !isMTenkanSenOverKijunSenPrev; - bool isMTenkanSenCrossedUnderKijunSen = isMTenkanSenUnderKijunSen && - !isMTenkanSenUnderKijunSenPrev; - - // - bool isMSenkouSpanAOverB = conditions.mSSA[cIndex] > conditions.mSSB[cIndex]; - bool isMSenkouSpanAOverBPrev = conditions.mSSA[pIndex] > conditions.mSSB[pIndex]; - - // - bool isMSenkouSpanAUnderB = conditions.mSSA[cIndex] < conditions.mSSB[cIndex]; - bool isMSenkouSpanAUnderBPrev = conditions.mSSA[pIndex] < conditions.mSSB[pIndex]; - - // - bool isMSenkouSpanAOverLast = conditions.mSSA[cIndex] > conditions.mSSA[pIndex]; - bool isMSenkouSpanAOverLastPrev = conditions.mSSA[pIndex] > conditions.mSSA[ppIndex]; - - // - bool isMSenkouSpanAUnderLast = conditions.mSSA[cIndex] < conditions.mSSA[pIndex]; - bool isMSenkouSpanAUnderLastPrev = conditions.mSSA[pIndex] < conditions.mSSA[ppIndex]; - - // - bool isMFutureSenkouSpanAOverB = conditions.mFSSA[cIndex] > conditions.mFSSB[cIndex]; - bool isMFutureSenkouSpanAOverBPrev = conditions.mFSSA[pIndex] > conditions.mFSSB[pIndex]; - - // - bool isMFutureSenkouSpanAUnderB = conditions.mFSSA[cIndex] < conditions.mFSSB[cIndex]; - bool isMFutureSenkouSpanAUnderBPrev = conditions.mFSSA[pIndex] < conditions.mFSSB[pIndex]; - - // - bool isMFutureSenkouSpanAOverLast = conditions.mFSSA[cIndex] > conditions.mFSSA[pIndex]; - bool isMFutureSenkouSpanAOverLastPrev = conditions.mFSSA[pIndex] > conditions.mFSSA[ppIndex]; - - // - bool isMFutureSenkouSpanAUnderLast = conditions.mFSSA[cIndex] < conditions.mFSSA[pIndex]; - bool isMFutureSenkouSpanAUnderLastPrev = conditions.mFSSA[pIndex] < conditions.mFSSA[ppIndex]; - - // - bool isMSenkouSpanACrossedOverB = isMSenkouSpanAOverB && - !isMSenkouSpanAOverBPrev; - bool isMSenkouSpanACrossedUnderB = isMSenkouSpanAUnderB && - !isMSenkouSpanAUnderBPrev; - bool isMSenkouSpanACrossedOverLast = isMSenkouSpanAOverLast && - !isMSenkouSpanAOverLastPrev; - bool isMSenkouSpanACrossedUnderLast = isMSenkouSpanAUnderLast && - !isMSenkouSpanAUnderLastPrev; - bool isMFutureSenkouSpanACrossedOverB = isMFutureSenkouSpanAOverB && - !isMFutureSenkouSpanAOverBPrev; - bool isMFutureSenkouSpanACrossedUnderB = isMFutureSenkouSpanAUnderB && - !isMFutureSenkouSpanAUnderBPrev; - bool isMFutureSenkouSpanACrossedOverLast = isMFutureSenkouSpanAOverLast && - !isMFutureSenkouSpanAOverLastPrev; - bool isMFutureSenkouSpanACrossedUnderLast = isMFutureSenkouSpanAUnderLast && - !isMFutureSenkouSpanAUnderLastPrev; - - // - conditions.isMClosedOverKijunSen = isMClosedOverKijunSen; - conditions.isMClosedUnderKijunSen = isMClosedUnderKijunSen; - conditions.isMTenkanSenOverKijunSen = isMTenkanSenOverKijunSen; - conditions.isMTenkanSenUnderKijunSen = isMTenkanSenUnderKijunSen; - conditions.isMTenkanSenCrossedOverKijunSen = isMTenkanSenCrossedOverKijunSen; - conditions.isMTenkanSenCrossedUnderKijunSen = isMTenkanSenCrossedUnderKijunSen; - - // - conditions.isMSenkouSpanAOverB = isMSenkouSpanAOverB; - conditions.isMSenkouSpanAUnderB = isMSenkouSpanAUnderB; - conditions.isMSenkouSpanAOverLast = isMSenkouSpanAOverLast; - conditions.isMSenkouSpanAUnderLast = isMSenkouSpanAUnderLast; - conditions.isMFutureSenkouSpanAOverB = isMFutureSenkouSpanAOverB; - conditions.isMFutureSenkouSpanAUnderB = isMFutureSenkouSpanAUnderB; - conditions.isMFutureSenkouSpanAOverLast = isMFutureSenkouSpanAOverLast; - conditions.isMFutureSenkouSpanAUnderLast = isMFutureSenkouSpanAUnderLast; - - // - conditions.isMSenkouSpanACrossedOverB = isMSenkouSpanACrossedOverB; - conditions.isMSenkouSpanACrossedUnderB = isMSenkouSpanACrossedUnderB; - conditions.isMSenkouSpanACrossedOverLast = isMSenkouSpanACrossedOverLast; - conditions.isMSenkouSpanACrossedUnderLast = isMSenkouSpanACrossedUnderLast; - conditions.isMFutureSenkouSpanACrossedOverB = isMFutureSenkouSpanACrossedOverB; - conditions.isMFutureSenkouSpanACrossedUnderB = isMFutureSenkouSpanACrossedUnderB; - conditions.isMFutureSenkouSpanACrossedOverLast = isMFutureSenkouSpanACrossedOverLast; - conditions.isMFutureSenkouSpanACrossedUnderLast = isMFutureSenkouSpanACrossedUnderLast; - - // - // Long ... - - // - bool isLClosedOverKijunSen = cBar.low > conditions.lTK[cIndex]; - bool isLClosedUnderKijunSen = cBar.high < conditions.lTK[cIndex]; - - // - bool isLTenkanSenOverKijunSen = conditions.lTK[cIndex] > conditions.lKJ[cIndex]; - bool isLTenkanSenOverKijunSenPrev = conditions.lTK[pIndex] > conditions.lKJ[pIndex]; - - // - bool isLTenkanSenUnderKijunSen = conditions.lTK[cIndex] < conditions.lKJ[cIndex]; - bool isLTenkanSenUnderKijunSenPrev = conditions.lTK[pIndex] < conditions.lKJ[pIndex]; - - // - bool isLTenkanSenCrossedOverKijunSen = isLTenkanSenOverKijunSen && - !isLTenkanSenOverKijunSenPrev; - bool isLTenkanSenCrossedUnderKijunSen = isLTenkanSenUnderKijunSen && - !isLTenkanSenUnderKijunSenPrev; - - // - bool isLSenkouSpanAOverB = conditions.lSSA[cIndex] > conditions.lSSB[cIndex]; - bool isLSenkouSpanAOverBPrev = conditions.lSSA[pIndex] > conditions.lSSB[pIndex]; - - // - bool isLSenkouSpanAUnderB = conditions.lSSA[cIndex] < conditions.lSSB[cIndex]; - bool isLSenkouSpanAUnderBPrev = conditions.lSSA[pIndex] < conditions.lSSB[pIndex]; - - // - bool isLSenkouSpanAOverLast = conditions.lSSA[cIndex] > conditions.lSSA[pIndex]; - bool isLSenkouSpanAOverLastPrev = conditions.lSSA[pIndex] > conditions.lSSA[ppIndex]; - - // - bool isLSenkouSpanAUnderLast = conditions.lSSA[cIndex] < conditions.lSSA[pIndex]; - bool isLSenkouSpanAUnderLastPrev = conditions.lSSA[pIndex] < conditions.lSSA[ppIndex]; - - // - bool isLFutureSenkouSpanAOverB = conditions.lFSSA[cIndex] > conditions.lFSSB[cIndex]; - bool isLFutureSenkouSpanAOverBPrev = conditions.lFSSA[pIndex] > conditions.lFSSB[pIndex]; - - // - bool isLFutureSenkouSpanAUnderB = conditions.lFSSA[cIndex] < conditions.lFSSB[cIndex]; - bool isLFutureSenkouSpanAUnderBPrev = conditions.lFSSA[pIndex] < conditions.lFSSB[pIndex]; - - // - bool isLFutureSenkouSpanAOverLast = conditions.lFSSA[cIndex] > conditions.lFSSA[pIndex]; - bool isLFutureSenkouSpanAOverLastPrev = conditions.lFSSA[pIndex] > conditions.lFSSA[ppIndex]; - - // - bool isLFutureSenkouSpanAUnderLast = conditions.lFSSA[cIndex] < conditions.lFSSA[pIndex]; - bool isLFutureSenkouSpanAUnderLastPrev = conditions.lFSSA[pIndex] < conditions.lFSSA[ppIndex]; - - // - bool isLSenkouSpanACrossedOverB = isLSenkouSpanAOverB && - !isLSenkouSpanAOverBPrev; - bool isLSenkouSpanACrossedUnderB = isLSenkouSpanAUnderB && - !isLSenkouSpanAUnderBPrev; - bool isLSenkouSpanACrossedOverLast = isLSenkouSpanAOverLast && - !isLSenkouSpanAOverLastPrev; - bool isLSenkouSpanACrossedUnderLast = isLSenkouSpanAUnderLast && - !isLSenkouSpanAUnderLastPrev; - bool isLFutureSenkouSpanACrossedOverB = isLFutureSenkouSpanAOverB && - !isLFutureSenkouSpanAOverBPrev; - bool isLFutureSenkouSpanACrossedUnderB = isLFutureSenkouSpanAUnderB && - !isLFutureSenkouSpanAUnderBPrev; - bool isLFutureSenkouSpanACrossedOverLast = isLFutureSenkouSpanAOverLast && - !isLFutureSenkouSpanAOverLastPrev; - bool isLFutureSenkouSpanACrossedUnderLast = isLFutureSenkouSpanAUnderLast && - !isLFutureSenkouSpanAUnderLastPrev; - - // - conditions.isLClosedOverKijunSen = isLClosedOverKijunSen; - conditions.isLClosedUnderKijunSen = isLClosedUnderKijunSen; - conditions.isLTenkanSenOverKijunSen = isLTenkanSenOverKijunSen; - conditions.isLTenkanSenUnderKijunSen = isLTenkanSenUnderKijunSen; - conditions.isLTenkanSenCrossedOverKijunSen = isLTenkanSenCrossedOverKijunSen; - conditions.isLTenkanSenCrossedUnderKijunSen = isLTenkanSenCrossedUnderKijunSen; - - // - conditions.isLSenkouSpanAOverB = isLSenkouSpanAOverB; - conditions.isLSenkouSpanAUnderB = isLSenkouSpanAUnderB; - conditions.isLSenkouSpanAOverLast = isLSenkouSpanAOverLast; - conditions.isLSenkouSpanAUnderLast = isLSenkouSpanAUnderLast; - conditions.isLFutureSenkouSpanAOverB = isLFutureSenkouSpanAOverB; - conditions.isLFutureSenkouSpanAUnderB = isLFutureSenkouSpanAUnderB; - conditions.isLFutureSenkouSpanAOverLast = isLFutureSenkouSpanAOverLast; - conditions.isLFutureSenkouSpanAUnderLast = isLFutureSenkouSpanAUnderLast; - - // - conditions.isLSenkouSpanACrossedOverB = isLSenkouSpanACrossedOverB; - conditions.isLSenkouSpanACrossedUnderB = isLSenkouSpanACrossedUnderB; - conditions.isLSenkouSpanACrossedOverLast = isLSenkouSpanACrossedOverLast; - conditions.isLSenkouSpanACrossedUnderLast = isLSenkouSpanACrossedUnderLast; - conditions.isLFutureSenkouSpanACrossedOverB = isLFutureSenkouSpanACrossedOverB; - conditions.isLFutureSenkouSpanACrossedUnderB = isLFutureSenkouSpanACrossedUnderB; - conditions.isLFutureSenkouSpanACrossedOverLast = isLFutureSenkouSpanACrossedOverLast; - conditions.isLFutureSenkouSpanACrossedUnderLast = isLFutureSenkouSpanACrossedUnderLast; - - // - // Hind ... - - // - bool isHClosedOverKijunSen = cBar.low > conditions.hTK[cIndex]; - bool isHClosedUnderKijunSen = cBar.high < conditions.hTK[cIndex]; - - // - bool isHTenkanSenOverKijunSen = conditions.hTK[cIndex] > conditions.hKJ[cIndex]; - bool isHTenkanSenOverKijunSenPrev = conditions.hTK[pIndex] > conditions.hKJ[pIndex]; - - // - bool isHTenkanSenUnderKijunSen = conditions.hTK[cIndex] < conditions.hKJ[cIndex]; - bool isHTenkanSenUnderKijunSenPrev = conditions.hTK[pIndex] < conditions.hKJ[pIndex]; - - // - bool isHTenkanSenCrossedOverKijunSen = isHTenkanSenOverKijunSen && - !isHTenkanSenOverKijunSenPrev; - bool isHTenkanSenCrossedUnderKijunSen = isHTenkanSenUnderKijunSen && - !isHTenkanSenUnderKijunSenPrev; - - // - bool isHSenkouSpanAOverB = conditions.hSSA[cIndex] > conditions.hSSB[cIndex]; - bool isHSenkouSpanAOverBPrev = conditions.hSSA[pIndex] > conditions.hSSB[pIndex]; - - // - bool isHSenkouSpanAUnderB = conditions.hSSA[cIndex] < conditions.hSSB[cIndex]; - bool isHSenkouSpanAUnderBPrev = conditions.hSSA[pIndex] < conditions.hSSB[pIndex]; - - // - bool isHSenkouSpanAOverLast = conditions.hSSA[cIndex] > conditions.hSSA[pIndex]; - bool isHSenkouSpanAOverLastPrev = conditions.hSSA[pIndex] > conditions.hSSA[ppIndex]; - - // - bool isHSenkouSpanAUnderLast = conditions.hSSA[cIndex] < conditions.hSSA[pIndex]; - bool isHSenkouSpanAUnderLastPrev = conditions.hSSA[pIndex] < conditions.hSSA[ppIndex]; - - // - bool isHFutureSenkouSpanAOverB = conditions.hFSSA[cIndex] > conditions.hFSSB[cIndex]; - bool isHFutureSenkouSpanAOverBPrev = conditions.hFSSA[pIndex] > conditions.hFSSB[pIndex]; - - // - bool isHFutureSenkouSpanAUnderB = conditions.hFSSA[cIndex] < conditions.hFSSB[cIndex]; - bool isHFutureSenkouSpanAUnderBPrev = conditions.hFSSA[pIndex] < conditions.hFSSB[pIndex]; - - // - bool isHFutureSenkouSpanAOverLast = conditions.hFSSA[cIndex] > conditions.hFSSA[pIndex]; - bool isHFutureSenkouSpanAOverLastPrev = conditions.hFSSA[pIndex] > conditions.hFSSA[ppIndex]; - - // - bool isHFutureSenkouSpanAUnderLast = conditions.hFSSA[cIndex] < conditions.hFSSA[pIndex]; - bool isHFutureSenkouSpanAUnderLastPrev = conditions.hFSSA[pIndex] < conditions.hFSSA[ppIndex]; - - // - bool isHSenkouSpanACrossedOverB = isHSenkouSpanAOverB && - !isHSenkouSpanAOverBPrev; - bool isHSenkouSpanACrossedUnderB = isHSenkouSpanAUnderB && - !isHSenkouSpanAUnderBPrev; - bool isHSenkouSpanACrossedOverLast = isHSenkouSpanAOverLast && - !isHSenkouSpanAOverLastPrev; - bool isHSenkouSpanACrossedUnderLast = isHSenkouSpanAUnderLast && - !isHSenkouSpanAUnderLastPrev; - bool isHFutureSenkouSpanACrossedOverB = isHFutureSenkouSpanAOverB && - !isHFutureSenkouSpanAOverBPrev; - bool isHFutureSenkouSpanACrossedUnderB = isHFutureSenkouSpanAUnderB && - !isHFutureSenkouSpanAUnderBPrev; - bool isHFutureSenkouSpanACrossedOverLast = isHFutureSenkouSpanAOverLast && - !isHFutureSenkouSpanAOverLastPrev; - bool isHFutureSenkouSpanACrossedUnderLast = isHFutureSenkouSpanAUnderLast && - !isHFutureSenkouSpanAUnderLastPrev; - - // - conditions.isHClosedOverKijunSen = isHClosedOverKijunSen; - conditions.isHClosedUnderKijunSen = isHClosedUnderKijunSen; - conditions.isHTenkanSenOverKijunSen = isHTenkanSenOverKijunSen; - conditions.isHTenkanSenUnderKijunSen = isHTenkanSenUnderKijunSen; - conditions.isHTenkanSenCrossedOverKijunSen = isHTenkanSenCrossedOverKijunSen; - conditions.isHTenkanSenCrossedUnderKijunSen = isHTenkanSenCrossedUnderKijunSen; - - // - conditions.isHSenkouSpanAOverB = isHSenkouSpanAOverB; - conditions.isHSenkouSpanAUnderB = isHSenkouSpanAUnderB; - conditions.isHSenkouSpanAOverLast = isHSenkouSpanAOverLast; - conditions.isHSenkouSpanAUnderLast = isHSenkouSpanAUnderLast; - conditions.isHFutureSenkouSpanAOverB = isHFutureSenkouSpanAOverB; - conditions.isHFutureSenkouSpanAUnderB = isHFutureSenkouSpanAUnderB; - conditions.isHFutureSenkouSpanAOverLast = isHFutureSenkouSpanAOverLast; - conditions.isHFutureSenkouSpanAUnderLast = isHFutureSenkouSpanAUnderLast; - - // - conditions.isHSenkouSpanACrossedOverB = isHSenkouSpanACrossedOverB; - conditions.isHSenkouSpanACrossedUnderB = isHSenkouSpanACrossedUnderB; - conditions.isHSenkouSpanACrossedOverLast = isHSenkouSpanACrossedOverLast; - conditions.isHSenkouSpanACrossedUnderLast = isHSenkouSpanACrossedUnderLast; - conditions.isHFutureSenkouSpanACrossedOverB = isHFutureSenkouSpanACrossedOverB; - conditions.isHFutureSenkouSpanACrossedUnderB = isHFutureSenkouSpanACrossedUnderB; - conditions.isHFutureSenkouSpanACrossedOverLast = isHFutureSenkouSpanACrossedOverLast; - conditions.isHFutureSenkouSpanACrossedUnderLast = isHFutureSenkouSpanACrossedUnderLast; - - // - return result; - } - - // - // Protected ... -protected: - // - // Private ... -private: - // - // Props ... - XCHICHInputs mInputs; // Inputs ... - - // - // Buffers ... - - // - // Current ... - double cTKBuffer[]; - double cKJBuffer[]; - double cChikBuffer[]; - double cSSABuffer[]; - double cSSBBuffer[]; - - // - // Short ... - double sTKBuffer[]; - double sKJBuffer[]; - double sChikBuffer[]; - double sSSABuffer[]; - double sSSBBuffer[]; - - // - // Medium ... - double mTKBuffer[]; - double mKJBuffer[]; - double mChikBuffer[]; - double mSSABuffer[]; - double mSSBBuffer[]; - - // - // Long ... - double lTKBuffer[]; - double lKJBuffer[]; - double lChikBuffer[]; - double lSSABuffer[]; - double lSSBBuffer[]; - - // - // Hind ... - double hTKBuffer[]; - double hKJBuffer[]; - double hChikBuffer[]; - double hSSABuffer[]; - double hSSBBuffer[]; - - // - // Tools ... - - // - // Calculate Values Until Now ... - void Calculate() - { - // - int totalBars = CountBars(); - if (totalBars > 1000) - { - totalBars = 1000; - } - - // - // Current ... - CopyBuffer( - mHandler, - XCHICH_C_TK_LINE, - 0, - totalBars, - cTKBuffer - // - ); - CopyBuffer( - mHandler, - XCHICH_C_KJ_LINE, - 0, - totalBars, - cKJBuffer - // - ); - CopyBuffer( - mHandler, - XCHICH_C_CH_LINE, - 0, - totalBars, - cChikBuffer - // - ); - CopyBuffer( - mHandler, - XCHICH_C_SSA_LINE, - 0, - totalBars, - cSSABuffer - // - ); - CopyBuffer( - mHandler, - XCHICH_C_SSB_LINE, - 0, - totalBars, - cSSBBuffer - // - ); - - // - // Short ... - CopyBuffer( - mHandler, - XCHICH_S_TK_LINE, - 0, - totalBars, - sTKBuffer - // - ); - CopyBuffer( - mHandler, - XCHICH_S_KJ_LINE, - 0, - totalBars, - sKJBuffer - // - ); - CopyBuffer( - mHandler, - XCHICH_S_CH_LINE, - 0, - totalBars, - sChikBuffer - // - ); - CopyBuffer( - mHandler, - XCHICH_S_SSA_LINE, - 0, - totalBars, - sSSABuffer - // - ); - CopyBuffer( - mHandler, - XCHICH_S_SSB_LINE, - 0, - totalBars, - sSSBBuffer - // - ); - - // - // Medium ... - CopyBuffer( - mHandler, - XCHICH_M_TK_LINE, - 0, - totalBars, - mTKBuffer - // - ); - CopyBuffer( - mHandler, - XCHICH_M_KJ_LINE, - 0, - totalBars, - mKJBuffer - // - ); - CopyBuffer( - mHandler, - XCHICH_M_CH_LINE, - 0, - totalBars, - mChikBuffer - // - ); - CopyBuffer( - mHandler, - XCHICH_M_SSA_LINE, - 0, - totalBars, - mSSABuffer - // - ); - CopyBuffer( - mHandler, - XCHICH_M_SSB_LINE, - 0, - totalBars, - mSSBBuffer - // - ); - - // - // Long ... - CopyBuffer( - mHandler, - XCHICH_L_TK_LINE, - 0, - totalBars, - lTKBuffer - // - ); - CopyBuffer( - mHandler, - XCHICH_L_KJ_LINE, - 0, - totalBars, - lKJBuffer - // - ); - CopyBuffer( - mHandler, - XCHICH_L_CH_LINE, - 0, - totalBars, - lChikBuffer - // - ); - CopyBuffer( - mHandler, - XCHICH_L_SSA_LINE, - 0, - totalBars, - lSSABuffer - // - ); - CopyBuffer( - mHandler, - XCHICH_L_SSB_LINE, - 0, - totalBars, - lSSBBuffer - // - ); - - // - // Hind ... - CopyBuffer( - mHandler, - XCHICH_H_TK_LINE, - 0, - totalBars, - hTKBuffer - // - ); - CopyBuffer( - mHandler, - XCHICH_H_KJ_LINE, - 0, - totalBars, - hKJBuffer - // - ); - CopyBuffer( - mHandler, - XCHICH_H_CH_LINE, - 0, - totalBars, - hChikBuffer - // - ); - CopyBuffer( - mHandler, - XCHICH_H_SSA_LINE, - 0, - totalBars, - hSSABuffer - // - ); - CopyBuffer( - mHandler, - XCHICH_H_SSB_LINE, - 0, - totalBars, - hSSBBuffer - // - ); - }; -}; - -// \ No newline at end of file diff --git a/Helpers/x-saherelm.xchm.helper.mq5 b/Helpers/x-saherelm.xchm.helper.mq5 deleted file mode 100644 index a4598fac..00000000 --- a/Helpers/x-saherelm.xchm.helper.mq5 +++ /dev/null @@ -1,4126 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Helper Class Library -// ---------------------------------------------- -// Name: XSCXCHMHelper -// 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_XCHM_BUFFERS -{ - // - // Main ... - XCHM_FAST_LINE = 0, - XCHM_SLOW_LINE = 1, - // - // Current ... - XCHM_CFAST_LINE = 2, - XCHM_CSLOW_LINE = 3, - // - // Short ... - XCHM_SFAST_LINE = 4, - XCHM_SSLOW_LINE = 5, - // - // Medium ... - XCHM_MFAST_LINE = 6, - XCHM_MSLOW_LINE = 7, - // - // Long ... - XCHM_LFAST_LINE = 8, - XCHM_LSLOW_LINE = 9, - // - // Hind ... - XCHM_HFAST_LINE = 10, - XCHM_HSLOW_LINE = 11, -}; - -// -// Input Models ... -struct XCHMInputs -{ - // - // Props ... - - // - // Market ... - int fastLength; // Fast Length - int slowLength; // Slow Length - ENUM_MA_METHOD method; // Mode - ENUM_APPLIED_PRICE appliedTo; // Applied To - - // - // Cycles ... - - // - // Short ... - ENUM_X_PERIOD_METHOD scMethod; // How to Find Period - ENUM_TIMEFRAMES scPeriod; // Time Period - - // - // Medium ... - ENUM_X_PERIOD_METHOD mcMethod; // How to Find Period - ENUM_TIMEFRAMES mcPeriod; // Time Period - - // - // Long ... - ENUM_X_PERIOD_METHOD lcMethod; // How to Find Period - ENUM_TIMEFRAMES lcPeriod; // Time Period - - // - // Hind ... - ENUM_X_PERIOD_METHOD hcMethod; // How to Find Period - ENUM_TIMEFRAMES hcPeriod; // Time Period - - // - // Presentation ... - - // - bool showFast; // Show Fast - bool showSlow; // Show Slow - - // - bool showAVG; // Show Average - - // - bool showCurrent; // Show Current Cycle - bool showShort; // Show Short Cycle - bool showMedium; // Show Medium Cycle - bool showLong; // Show Long Cycle - bool showHind; // Show Hind Cycle - - // - // Constructor(s) ... - XCHMInputs() - { - // - Clean(); - } - - // - // Tools ... - - // - // Clean ... - void Clean() - { - // - fastLength = 0; - slowLength = 0; - method = MODE_EMA; - appliedTo = PRICE_CLOSE; - - // - scMethod = X_PERIOD_AUTO; - scPeriod = NULL; - mcMethod = X_PERIOD_AUTO; - mcPeriod = NULL; - lcMethod = X_PERIOD_AUTO; - lcPeriod = NULL; - hcMethod = X_PERIOD_AUTO; - hcPeriod = NULL; - - // - showFast = false; - showSlow = false; - - // - showAVG = false; - - // - showCurrent = false; - showShort = false; - showMedium = false; - showLong = false; - showHind = false; - } - - // - // Default ... - void Default() - { - // - fastLength = 9; - slowLength = 18; - method = MODE_EMA; - appliedTo = PRICE_CLOSE; - - // - scMethod = X_PERIOD_AUTO; - scPeriod = NULL; - mcMethod = X_PERIOD_AUTO; - mcPeriod = NULL; - lcMethod = X_PERIOD_AUTO; - lcPeriod = NULL; - hcMethod = X_PERIOD_AUTO; - hcPeriod = NULL; - - // - showFast = true; - showSlow = true; - - // - showAVG = true; - - // - showCurrent = true; - showShort = true; - showMedium = true; - showLong = true; - showHind = true; - } - - // - // Validate ... - bool IsValid() - { - // - bool result = false; - - // - result = - // - fastLength > 2 && - slowLength > fastLength && - // - (IsValid(scMethod, scPeriod) && - IsValid(mcMethod, mcPeriod) && - IsValid(lcMethod, lcPeriod) && - IsValid(hcMethod, hcPeriod)) - // - ; - - // - return result; - } - - // - // Retrieve MAx Length ... - int Max() - { - // - int result = 0; - - // - result = - // - MathMax(fastLength, slowLength) - // - ; - - // - return result; - } -}; - -// -// Define Conditions ... -struct XCHMConditions -{ - // - // Common ... - string symbol; - ENUM_TIMEFRAMES period; - datetime time; - - // - // Buffers ... - - // - double fast[]; - double slow[]; - - // - // Current ... - double cFast[]; - double cSlow[]; - - // - // Short ... - double sFast[]; - double sSlow[]; - - // - // Medium ... - double mFast[]; - double mSlow[]; - - // - // Long ... - double lFast[]; - double lSlow[]; - - // - // Hind ... - double hFast[]; - double hSlow[]; - - // - // Conditions ... - - // - // Power ... - bool hasBullishPower; - bool hasBearishPower; - bool isBullishPowerUp; - bool isBearishPowerUp; - bool isBullishPowerIncreasing; - bool isBullishPowerDecreasing; - bool isBearishPowerIncreasing; - bool isBearishPowerDecreasing; - - // - // AVG ... - - // - bool isFastOverSlow; - bool isFastUnderSlow; - - // - bool isFastCrossedOverSlow; - bool isFastCrossedUnderSlow; - - // - bool isClosedOverFast; - bool isClosedUnderFast; - - // - // Current ... - - // - bool isCFastOverSlow; - bool isCFastUnderSlow; - - // - bool isCFastCrossedOverSlow; - bool isCFastCrossedUnderSlow; - - // - bool isClosedOverCFast; - bool isClosedUnderCFast; - - // - // Short ... - - // - bool isSFastOverSlow; - bool isSFastUnderSlow; - - // - bool isSFastCrossedOverSlow; - bool isSFastCrossedUnderSlow; - - // - bool isClosedOverSFast; - bool isClosedUnderSFast; - - // - // Medium ... - - // - bool isMFastOverSlow; - bool isMFastUnderSlow; - - // - bool isMFastCrossedOverSlow; - bool isMFastCrossedUnderSlow; - - // - bool isClosedOverMFast; - bool isClosedUnderMFast; - - // - // Long ... - - // - bool isLFastOverSlow; - bool isLFastUnderSlow; - - // - bool isLFastCrossedOverSlow; - bool isLFastCrossedUnderSlow; - - // - bool isClosedOverLFast; - bool isClosedUnderLFast; - - // - // Hind ... - - // - bool isHFastOverSlow; - bool isHFastUnderSlow; - - // - bool isHFastCrossedOverSlow; - bool isHFastCrossedUnderSlow; - - // - bool isClosedOverHFast; - bool isClosedUnderHFast; - - // - void Clean() - { - // - Clean(fast); - Clean(slow); - Clean(cFast); - Clean(cSlow); - Clean(sFast); - Clean(sSlow); - Clean(mFast); - Clean(mSlow); - Clean(lFast); - Clean(lSlow); - Clean(hFast); - Clean(hSlow); - - // - ArraySetAsSeries(fast, true); - ArraySetAsSeries(slow, true); - ArraySetAsSeries(cFast, true); - ArraySetAsSeries(cSlow, true); - ArraySetAsSeries(sFast, true); - ArraySetAsSeries(sSlow, true); - ArraySetAsSeries(mFast, true); - ArraySetAsSeries(mSlow, true); - ArraySetAsSeries(lFast, true); - ArraySetAsSeries(lSlow, true); - ArraySetAsSeries(hFast, true); - ArraySetAsSeries(hSlow, true); - - // - // Power ... - hasBullishPower = false; - hasBearishPower = false; - isBullishPowerUp = false; - isBearishPowerUp = false; - isBullishPowerIncreasing = false; - isBullishPowerDecreasing = false; - isBearishPowerIncreasing = false; - isBearishPowerDecreasing = false; - - // - // AVG ... - - // - isFastOverSlow = false; - isFastUnderSlow = false; - - // - isFastCrossedOverSlow = false; - isFastCrossedUnderSlow = false; - - // - isClosedOverFast = false; - isClosedUnderFast = false; - - // - // Current ... - - // - isCFastOverSlow = false; - isCFastUnderSlow = false; - - // - isCFastCrossedOverSlow = false; - isCFastCrossedUnderSlow = false; - - // - isClosedOverCFast = false; - isClosedUnderCFast = false; - - // - // Short ... - - // - isSFastOverSlow = false; - isSFastUnderSlow = false; - - // - isSFastCrossedOverSlow = false; - isSFastCrossedUnderSlow = false; - - // - isClosedOverSFast = false; - isClosedUnderSFast = false; - - // - // Medium ... - - // - isMFastOverSlow = false; - isMFastUnderSlow = false; - - // - isMFastCrossedOverSlow = false; - isMFastCrossedUnderSlow = false; - - // - isClosedOverMFast = false; - isClosedUnderMFast = false; - - // - // Long ... - - // - isLFastOverSlow = false; - isLFastUnderSlow = false; - - // - isLFastCrossedOverSlow = false; - isLFastCrossedUnderSlow = false; - - // - isClosedOverLFast = false; - isClosedUnderLFast = false; - - // - // Hind ... - - // - isHFastOverSlow = false; - isHFastUnderSlow = false; - - // - isHFastCrossedOverSlow = false; - isHFastCrossedUnderSlow = false; - - // - isClosedOverHFast = false; - isClosedUnderHFast = false; - } - - // - void GenerateScore( - double &bullishScore, - double &bearishScore // - ) - { - // - bullishScore = 0; - bearishScore = 0; - - // - // Since We have to Use this - // Only for Filtering Signals ... - // We Can Ignore Scoring ... - // or Complete this later ... - - // - // Power ... - if (hasBullishPower) - { - bullishScore++; - } - if (hasBearishPower) - { - bearishScore++; - } - if (isBullishPowerUp) - { - bullishScore++; - } - if (isBearishPowerUp) - { - bearishScore++; - } - if (isBullishPowerIncreasing) - { - bullishScore++; - } - if (isBullishPowerDecreasing) - { - bearishScore++; - } - if (isBearishPowerIncreasing) - { - bearishScore++; - } - if (isBearishPowerDecreasing) - { - bullishScore++; - } - - // - // AVG ... - - // - if (isFastOverSlow) - { - bullishScore++; - } - if (isFastUnderSlow) - { - bearishScore++; - } - if (isFastCrossedOverSlow) - { - bullishScore++; - } - if (isFastCrossedUnderSlow) - { - bearishScore++; - } - if (isClosedOverFast) - { - bullishScore++; - } - if (isClosedUnderFast) - { - bearishScore++; - } - - // - // Current ... - - // - if (isCFastOverSlow) - { - bullishScore++; - } - if (isCFastUnderSlow) - { - bearishScore++; - } - if (isCFastCrossedOverSlow) - { - bullishScore++; - } - if (isCFastCrossedUnderSlow) - { - bearishScore++; - } - if (isClosedOverCFast) - { - bullishScore++; - } - if (isClosedUnderCFast) - { - bearishScore++; - } - - // - // Short ... - - // - if (isSFastOverSlow) - { - bullishScore++; - } - if (isSFastUnderSlow) - { - bearishScore++; - } - if (isSFastCrossedOverSlow) - { - bullishScore++; - } - if (isSFastCrossedUnderSlow) - { - bearishScore++; - } - if (isClosedOverSFast) - { - bullishScore++; - } - if (isClosedUnderSFast) - { - bearishScore++; - } - - // - // Medium ... - - // - if (isMFastOverSlow) - { - bullishScore++; - } - if (isMFastUnderSlow) - { - bearishScore++; - } - if (isMFastCrossedOverSlow) - { - bullishScore++; - } - if (isMFastCrossedUnderSlow) - { - bearishScore++; - } - if (isClosedOverMFast) - { - bullishScore++; - } - if (isClosedUnderMFast) - { - bearishScore++; - } - - // - // Long ... - - // - if (isLFastOverSlow) - { - bullishScore++; - } - if (isLFastUnderSlow) - { - bearishScore++; - } - if (isLFastCrossedOverSlow) - { - bullishScore++; - } - if (isLFastCrossedUnderSlow) - { - bearishScore++; - } - if (isClosedOverLFast) - { - bullishScore++; - } - if (isClosedUnderLFast) - { - bearishScore++; - } - - // - // Hind ... - - // - if (isHFastOverSlow) - { - bullishScore++; - } - if (isHFastUnderSlow) - { - bearishScore++; - } - if (isHFastCrossedOverSlow) - { - bullishScore++; - } - if (isHFastCrossedUnderSlow) - { - bearishScore++; - } - if (isClosedOverHFast) - { - bullishScore++; - } - if (isClosedUnderHFast) - { - bearishScore++; - } - } - - // - string GenerateSummary( - bool onlyCommons = false, - bool onlyConditions = false, - bool includeScores = true, - bool ignoreFalseConditions = true, - string separator = "\n" // - ) - { - // - string result = NULL; - - // - double bullishScore = 0; - double bearishScore = 0; - GenerateScore( - bullishScore, - bearishScore // - ); - - // - string scoresStr = - // - "Scores: " + separator + - "---------------" + separator + - "Bullish: " + ToString(bullishScore) + separator + - "Bearish: " + ToString(bearishScore) + separator + - "" - // - ; - - // - string commonStr = GenerateSpecifiedCommonSummary( - this, - separator, - includeScores // - ); - - // - string conditionsStr = - // - // Power ... - ToString("hasBullishPower", hasBullishPower, ignoreFalseConditions, separator) + - ToString("hasBearishPower", hasBearishPower, ignoreFalseConditions, separator) + - ToString("isBullishPowerUp", isBullishPowerUp, ignoreFalseConditions, separator) + - ToString("isBearishPowerUp", isBearishPowerUp, ignoreFalseConditions, separator) + - ToString("isBullishPowerIncreasing", isBullishPowerIncreasing, ignoreFalseConditions, separator) + - ToString("isBullishPowerDecreasing", isBullishPowerDecreasing, ignoreFalseConditions, separator) + - ToString("isBearishPowerIncreasing", isBearishPowerIncreasing, ignoreFalseConditions, separator) + - ToString("isBearishPowerDecreasing", isBearishPowerDecreasing, ignoreFalseConditions, separator) + - // - // AVG ... - ToString("isFastOverSlow", isFastOverSlow, ignoreFalseConditions, separator) + - ToString("isFastUnderSlow", isFastUnderSlow, ignoreFalseConditions, separator) + - ToString("isFastCrossedOverSlow", isFastCrossedOverSlow, ignoreFalseConditions, separator) + - ToString("isFastCrossedUnderSlow", isFastCrossedUnderSlow, ignoreFalseConditions, separator) + - ToString("isClosedOverFast", isClosedOverFast, ignoreFalseConditions, separator) + - ToString("isClosedUnderFast", isClosedUnderFast, ignoreFalseConditions, separator) + - // - // Current ... - ToString("isCFastOverSlow", isCFastOverSlow, ignoreFalseConditions, separator) + - ToString("isCFastUnderSlow", isCFastUnderSlow, ignoreFalseConditions, separator) + - ToString("isCFastCrossedOverSlow", isCFastCrossedOverSlow, ignoreFalseConditions, separator) + - ToString("isCFastCrossedUnderSlow", isCFastCrossedUnderSlow, ignoreFalseConditions, separator) + - ToString("isClosedOverCFast", isClosedOverCFast, ignoreFalseConditions, separator) + - ToString("isClosedUnderCFast", isClosedUnderCFast, ignoreFalseConditions, separator) + - // - // Short ... - ToString("isSFastOverSlow", isSFastOverSlow, ignoreFalseConditions, separator) + - ToString("isSFastUnderSlow", isSFastUnderSlow, ignoreFalseConditions, separator) + - ToString("isSFastCrossedOverSlow", isSFastCrossedOverSlow, ignoreFalseConditions, separator) + - ToString("isSFastCrossedUnderSlow", isSFastCrossedUnderSlow, ignoreFalseConditions, separator) + - ToString("isClosedOverSFast", isClosedOverSFast, ignoreFalseConditions, separator) + - ToString("isClosedUnderSFast", isClosedUnderSFast, ignoreFalseConditions, separator) + - // - // Medium ... - ToString("isMFastOverSlow", isMFastOverSlow, ignoreFalseConditions, separator) + - ToString("isMFastUnderSlow", isMFastUnderSlow, ignoreFalseConditions, separator) + - ToString("isMFastCrossedOverSlow", isMFastCrossedOverSlow, ignoreFalseConditions, separator) + - ToString("isMFastCrossedUnderSlow", isMFastCrossedUnderSlow, ignoreFalseConditions, separator) + - ToString("isClosedOverMFast", isClosedOverMFast, ignoreFalseConditions, separator) + - ToString("isClosedUnderMFast", isClosedUnderMFast, ignoreFalseConditions, separator) + - // - // Long ... - ToString("isLFastOverSlow", isLFastOverSlow, ignoreFalseConditions, separator) + - ToString("isLFastUnderSlow", isLFastUnderSlow, ignoreFalseConditions, separator) + - ToString("isLFastCrossedOverSlow", isLFastCrossedOverSlow, ignoreFalseConditions, separator) + - ToString("isLFastCrossedUnderSlow", isLFastCrossedUnderSlow, ignoreFalseConditions, separator) + - ToString("isClosedOverLFast", isClosedOverLFast, ignoreFalseConditions, separator) + - ToString("isClosedUnderLFast", isClosedUnderLFast, ignoreFalseConditions, separator) + - // - // Hind ... - ToString("isHFastOverSlow", isHFastOverSlow, ignoreFalseConditions, separator) + - ToString("isHFastUnderSlow", isHFastUnderSlow, ignoreFalseConditions, separator) + - ToString("isHFastCrossedOverSlow", isHFastCrossedOverSlow, ignoreFalseConditions, separator) + - ToString("isHFastCrossedUnderSlow", isHFastCrossedUnderSlow, ignoreFalseConditions, separator) + - ToString("isClosedOverHFast", isClosedOverHFast, ignoreFalseConditions, separator) + - ToString("isClosedUnderHFast", isClosedUnderHFast, ignoreFalseConditions, separator) + - // - "" - // - ; - - // - result = - // - "[" + GetTag() + "]" + separator + - (onlyConditions - ? "" - : commonStr) + - (!includeScores - ? "" - : scoresStr) + - " " + separator + - (onlyCommons - ? "" - : conditionsStr) + - "" - // - ; - - // - return result; - } - - // - string GetTag() - { - return "XCHM"; - } -}; - -// -// Class ... -class XSCXCHMHelper : public XSCBaseHelper -{ - // - // Public ... -public: - // - // Props ... - - // - // Constructors ... - XSCXCHMHelper() : XSCBaseHelper(_Symbol, _Period) - { - } - - // - // Deconstructor ... - ~XSCXCHMHelper() - { - // - Clean(fastBuffer); - Clean(slowBuffer); - Clean(cFastBuffer); - Clean(cSlowBuffer); - Clean(sFastBuffer); - Clean(sSlowBuffer); - Clean(mFastBuffer); - Clean(mSlowBuffer); - Clean(lFastBuffer); - Clean(lSlowBuffer); - Clean(hFastBuffer); - Clean(hSlowBuffer); - } - - // - // Tools ... - bool Init( - string symbol, // Trading Symbol - ENUM_TIMEFRAMES period, // Trading Period - XCHMInputs &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(cFastBuffer, true); - ArraySetAsSeries(cSlowBuffer, true); - ArraySetAsSeries(sFastBuffer, true); - ArraySetAsSeries(sSlowBuffer, true); - ArraySetAsSeries(mFastBuffer, true); - ArraySetAsSeries(mSlowBuffer, true); - ArraySetAsSeries(lFastBuffer, true); - ArraySetAsSeries(lSlowBuffer, true); - ArraySetAsSeries(hFastBuffer, true); - ArraySetAsSeries(hSlowBuffer, true); - - // - mHandler = iCustom( - mSymbol, - mPeriod, - "x-saherelm.xchm", - // - // Inputs ... - // - // Market ... - "", - mInputs.fastLength, - mInputs.slowLength, - mInputs.method, - mInputs.appliedTo, - // - // Cycles ... - "", - // - // Short ... - "", - mInputs.scMethod, - mInputs.scPeriod, - // - // Medium ... - "", - mInputs.mcMethod, - mInputs.mcPeriod, - // - // Long ... - "", - mInputs.lcMethod, - mInputs.lcPeriod, - // - // Hind ... - "", - mInputs.hcMethod, - mInputs.hcPeriod, - // - // Presentation ... - "", - // - mInputs.showFast, - mInputs.showSlow, - // - mInputs.showAVG, - // - mInputs.showCurrent, - mInputs.showShort, - mInputs.showMedium, - mInputs.showLong, - mInputs.showHind - // - ); - result = mHandler != INVALID_HANDLE; - if (!result) - { - return result; - } - - // - return result; - } - - // - // Inputs ... - - // - XCHMInputs GetInputs() - { - return mInputs; - } - - // - bool SetInputs( - XCHMInputs &inputs // Configs - ) - { - // - return Init( - mSymbol, - mPeriod, - inputs - // - ); - } - - // - // Buffers ... - - // - // AVG ... - - // - double GetFast( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(fastBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return fastBuffer[barIndex]; - } - - // - // Copy Required Items ... - 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 - // - ); - } - - // - double GetSlow( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(slowBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return slowBuffer[barIndex]; - } - - // - // Copy Required Items ... - 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 - // - ); - } - - // - // Current ... - - // - double GetCFast( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(cFastBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return cFastBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyCFast( - 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, - cFastBuffer, - buffer, - forceClean - // - ); - } - - // - double GetCSlow( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(cSlowBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return cSlowBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyCSlow( - 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, - cSlowBuffer, - buffer, - forceClean - // - ); - } - - // - // Short ... - - // - double GetSFast( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(sFastBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return sFastBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopySFast( - 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, - sFastBuffer, - buffer, - forceClean - // - ); - } - - // - double GetSSlow( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(sSlowBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return sSlowBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopySSlow( - 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, - sSlowBuffer, - buffer, - forceClean - // - ); - } - - // - // Medium ... - - // - double GetMFast( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(mFastBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return mFastBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyMFast( - 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, - mFastBuffer, - buffer, - forceClean - // - ); - } - - // - double GetMSlow( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(mSlowBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return mSlowBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyMSlow( - 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, - mSlowBuffer, - buffer, - forceClean - // - ); - } - - // - // Long ... - - // - double GetLFast( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(lFastBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return lFastBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyLFast( - 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, - lFastBuffer, - buffer, - forceClean - // - ); - } - - // - double GetLSlow( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(lSlowBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return lSlowBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyLSlow( - 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, - lSlowBuffer, - buffer, - forceClean - // - ); - } - - // - // Hind ... - - // - double GetHFast( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(hFastBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return hFastBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyHFast( - 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, - hFastBuffer, - buffer, - forceClean - // - ); - } - - // - double GetHSlow( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - int count = ArraySize(hSlowBuffer); - if (barIndex >= count) - { - barIndex = count - 1; - } - - // - return hSlowBuffer[barIndex]; - } - - // - // Copy Required Items ... - int CopyHSlow( - 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, - hSlowBuffer, - buffer, - forceClean - // - ); - } - - // - // Tools ... - - // - void GetCycle( - double &fast, - double &slow, - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle // - ) - { - // - fast = 0; - slow = 0; - - // - switch (cycle) - { - // - // CURRENT ... - case X_MARKET_CYCLE_UNKNOWN: - // - fast = GetCFast(barIndex); - slow = GetCSlow(barIndex); - break; - - // - // SHORT ... - case X_MARKET_CYCLE_SHORT: - // - fast = GetSFast(barIndex); - slow = GetSSlow(barIndex); - break; - - // - // MEDIUM ... - case X_MARKET_CYCLE_MEDIUM: - // - fast = GetMFast(barIndex); - slow = GetMSlow(barIndex); - break; - - // - // LONG ... - case X_MARKET_CYCLE_LONG: - // - fast = GetLFast(barIndex); - slow = GetLSlow(barIndex); - break; - - // - // HIND ... - case X_MARKET_CYCLE_HIND: - // - fast = GetHFast(barIndex); - slow = GetHSlow(barIndex); - break; - } - } - - // - double GetCyclePower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle // - ) - { - // - double result = 0; - - // - double fast = 0; - double slow = 0; - GetCycle( - fast, - slow, - barIndex, - cycle // - ); - - // - result = MathAbs(fast - slow); - - // - return result; - } - - // - double GetCycleFast( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle // - ) - { - // - double result = 0; - - // - double fast = 0; - double slow = 0; - GetCycle( - fast, - slow, - barIndex, - cycle // - ); - - // - result = fast; - - // - return result; - } - - // - double GetCycleSlow( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle // - ) - { - // - double result = 0; - - // - double fast = 0; - double slow = 0; - GetCycle( - fast, - slow, - barIndex, - cycle // - ); - - // - result = slow; - - // - return result; - } - - // - double GetCycleMax( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle // - ) - { - // - double result = 0; - - // - double fast = 0; - double slow = 0; - GetCycle( - fast, - slow, - barIndex, - cycle // - ); - - // - result = MathMax(fast, slow); - - // - return result; - } - - // - double GetCycleMin( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle // - ) - { - // - double result = 0; - - // - double fast = 0; - double slow = 0; - GetCycle( - fast, - slow, - barIndex, - cycle // - ); - - // - result = MathMin(fast, slow); - - // - return result; - } - - // - int GetFasts( - double &values[], - int barIndex // Bar Index - ) - { - // - int result = 0; - - // - Clean(values); - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetAllMarketCycles(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double iValue = GetCycleFast( - barIndex, - cycles[i] // - ); - - // - if (iValue > 0) - { - // - Add( - iValue, - values // - ); - } - } - - // - result = ArraySize(values); - - // - return result; - } - - // - int GetSlows( - double &values[], - int barIndex // Bar Index - ) - { - // - int result = 0; - - // - Clean(values); - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetAllMarketCycles(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double iValue = GetCycleSlow( - barIndex, - cycles[i] // - ); - - // - if (iValue > 0) - { - // - Add( - iValue, - values // - ); - } - } - - // - result = ArraySize(values); - - // - return result; - } - - // - int GetCyclesFast( - double &values[], - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - int result = 0; - - // - Clean(values); - - // - int cyclesCount = ArraySize(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double iValue = GetCycleFast( - barIndex, - cycles[i] // - ); - - // - if (iValue > 0) - { - // - Add( - iValue, - values // - ); - } - } - - // - result = ArraySize(values); - - // - return result; - } - - // - int GetCyclesSlow( - double &values[], - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - int result = 0; - - // - Clean(values); - - // - int cyclesCount = ArraySize(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double iValue = GetCycleSlow( - barIndex, - cycles[i] // - ); - - // - if (iValue > 0) - { - // - Add( - iValue, - values // - ); - } - } - - // - result = ArraySize(values); - - // - return result; - } - - // - int GetBullishCycles( - ENUM_X_MARKET_CYCLES &cycles[], // Holds Result - int barIndex // Bar Index - ) - { - // - int result = 0; - - // - Clean(cycles); - - // - ENUM_X_MARKET_CYCLES mCycles[]; - int cyclesCount = GetAllMarketCycles( - mCycles // - ); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double fast = 0; - double slow = 0; - GetCycle( - fast, - slow, - barIndex, - mCycles[i] // - ); - - // - bool isBullish = fast > slow; - if (isBullish) - { - // - Add( - mCycles[i], - cycles // - ); - } - } - - // - result = ArraySize(cycles); - - // - return result; - } - - // - int GetBearishCycles( - ENUM_X_MARKET_CYCLES &cycles[], // Holds Result - int barIndex // Bar Index - ) - { - // - int result = 0; - - // - Clean(cycles); - - // - ENUM_X_MARKET_CYCLES mCycles[]; - int cyclesCount = GetAllMarketCycles( - mCycles // - ); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double fast = 0; - double slow = 0; - GetCycle( - fast, - slow, - barIndex, - mCycles[i] // - ); - - // - bool isBearish = fast < slow; - if (isBearish) - { - // - Add( - mCycles[i], - cycles // - ); - } - } - - // - result = ArraySize(cycles); - - // - return result; - } - - // - double GetMax( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetAllMarketCycles(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double iValue = GetCycleMax( - barIndex, - cycles[i] // - ); - - // - result = - result == 0 || iValue > result - ? iValue - : result; - } - - // - return result; - } - - // - double GetMin( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetAllMarketCycles(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double iValue = GetCycleMin( - barIndex, - cycles[i] // - ); - - // - result = - result == 0 || iValue < result - ? iValue - : result; - } - - // - return result; - } - - // - double GetCyclesMax( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - int cyclesCount = ArraySize(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double iValue = GetCycleMax( - barIndex, - cycles[i] // - ); - - // - result = - result == 0 || iValue > result - ? iValue - : result; - } - - // - return result; - } - - // - double GetCyclesMin( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - int cyclesCount = ArraySize(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double iValue = GetCycleMin( - barIndex, - cycles[i] // - ); - - // - result = - result == 0 || iValue < result - ? iValue - : result; - } - - // - return result; - } - - // - double GetMaxBullish( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetBullishCycles( - cycles, - barIndex // - ); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double iValue = GetCycleMax( - barIndex, - cycles[i] // - ); - - // - result = - result == 0 || iValue > result - ? iValue - : result; - } - - // - return result; - } - - // - double GetMinBullish( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetBullishCycles( - cycles, - barIndex // - ); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double iValue = GetCycleMin( - barIndex, - cycles[i] // - ); - - // - result = - result == 0 || iValue < result - ? iValue - : result; - } - - // - return result; - } - - // - double GetMaxBearish( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetBearishCycles( - cycles, - barIndex // - ); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double iValue = GetCycleMax( - barIndex, - cycles[i] // - ); - - // - result = - result == 0 || iValue > result - ? iValue - : result; - } - - // - return result; - } - - // - double GetMinBearish( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetBearishCycles( - cycles, - barIndex // - ); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double iValue = GetCycleMin( - barIndex, - cycles[i] // - ); - - // - result = - result == 0 || iValue < result - ? iValue - : result; - } - - // - return result; - } - - // - double GetMaxBullishFast( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetBullishCycles( - cycles, - barIndex // - ); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - double values[]; - int valuesCount = GetCyclesFast( - values, - barIndex, - cycles // - ); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetMinBullishFast( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetBullishCycles( - cycles, - barIndex // - ); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - double values[]; - int valuesCount = GetCyclesFast( - values, - barIndex, - cycles // - ); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetMaxBullishSlow( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetBullishCycles( - cycles, - barIndex // - ); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - double values[]; - int valuesCount = GetCyclesSlow( - values, - barIndex, - cycles // - ); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetMinBullishSlow( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetBullishCycles( - cycles, - barIndex // - ); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - double values[]; - int valuesCount = GetCyclesSlow( - values, - barIndex, - cycles // - ); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetMaxBearishFast( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetBearishCycles( - cycles, - barIndex // - ); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - double values[]; - int valuesCount = GetCyclesFast( - values, - barIndex, - cycles // - ); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetMinBearishFast( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetBearishCycles( - cycles, - barIndex // - ); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - double values[]; - int valuesCount = GetCyclesFast( - values, - barIndex, - cycles // - ); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetMaxBearishSlow( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetBearishCycles( - cycles, - barIndex // - ); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - double values[]; - int valuesCount = GetCyclesSlow( - values, - barIndex, - cycles // - ); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetMinBearishSlow( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetBearishCycles( - cycles, - barIndex // - ); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - double values[]; - int valuesCount = GetCyclesSlow( - values, - barIndex, - cycles // - ); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetBullishPower( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetBullishCycles( - cycles, - barIndex // - ); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double iPower = GetCyclePower( - barIndex, - cycles[i] // - ); - - // - if (iPower > 0) - { - result += iPower; - } - } - - // - return result; - } - - // - double GetBearishPower( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetBearishCycles( - cycles, - barIndex // - ); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double iPower = GetCyclePower( - barIndex, - cycles[i] // - ); - - // - if (iPower > 0) - { - result += iPower; - } - } - - // - return result; - } - - // - double GetCyclesBullishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - int cyclesCount = ArraySize(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double fast = 0; - double slow = 0; - GetCycle( - fast, - slow, - barIndex, - cycles[i] // - ); - - // - if (fast > slow) - { - // - double iPower = GetCyclePower( - barIndex, - cycles[i] // - ); - - // - if (iPower > 0) - { - result += iPower; - } - } - } - - // - return result; - } - - // - double GetCyclesBearishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - int cyclesCount = ArraySize(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double fast = 0; - double slow = 0; - GetCycle( - fast, - slow, - barIndex, - cycles[i] // - ); - - // - if (fast < slow) - { - // - double iPower = GetCyclePower( - barIndex, - cycles[i] // - ); - - // - if (iPower > 0) - { - result += iPower; - } - } - } - - // - return result; - } - - // - bool HasBullishPower( - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - double bullishPower = GetBullishPower(barIndex); - double bearishPower = GetBearishPower(barIndex); - - // - result = - // - bearishPower >= 0 && - bullishPower > bearishPower - // - ; - - // - return result; - } - - // - bool HasBearishPower( - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - double bullishPower = GetBullishPower(barIndex); - double bearishPower = GetBearishPower(barIndex); - - // - result = - // - bullishPower >= 0 && - bearishPower > bullishPower - // - ; - - // - return result; - } - - // - bool HasCyclesBullishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - bool result = false; - - // - double bullishPower = GetCyclesBullishPower(barIndex, cycles); - double bearishPower = GetCyclesBearishPower(barIndex, cycles); - - // - result = - // - bearishPower >= 0 && - bullishPower > bearishPower - // - ; - - // - return result; - } - - // - bool HasCyclesBearishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - bool result = false; - - // - double bullishPower = GetCyclesBullishPower(barIndex, cycles); - double bearishPower = GetCyclesBearishPower(barIndex, cycles); - - // - result = - // - bullishPower >= 0 && - bearishPower > bullishPower - // - ; - - // - return result; - } - - // - // Check Bullish Power Increasing ... - bool IsBullishPowerIncreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBullishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBullishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bullish Power Decreasing ... - bool IsBullishPowerDecreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBullishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBullishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Increasing ... - bool IsBearishPowerIncreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBearishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBearishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Decreasing ... - bool IsBearishPowerDecreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBearishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBearishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Check Bullish Power Increasing ... - bool IsCyclesBullishPowerIncreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBullishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBullishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bullish Power Decreasing ... - bool IsCyclesBullishPowerDecreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBullishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBullishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Increasing ... - bool IsCyclesBearishPowerIncreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBearishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBearishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Decreasing ... - bool IsCyclesBearishPowerDecreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBearishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBearishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Conditions ... - - // - bool GetConditions( - XCHMConditions &conditions, // - int barIndex = 0, // - int loopback = 5 // - ) - { - // - bool result = true; - - // - if (loopback < 3) - { - loopback = 3; - } - - // - conditions.Clean(); - - // - conditions.symbol = mSymbol; - conditions.period = mPeriod; - conditions.time = TimeCurrent(); - - // - int zIndex = barIndex; - int cIndex = zIndex + 1; - int pIndex = cIndex + 1; - int ppIndex = pIndex + 1; - - // - // Buffers ... - - // - // AVG ... - - // - // Fast ... - CopyFast( - zIndex, - loopback, - conditions.fast // - ); - - // - // Slow ... - CopySlow( - zIndex, - loopback, - conditions.slow // - ); - - // - // Current ... - - // - // Fast ... - CopyCFast( - zIndex, - loopback, - conditions.cFast // - ); - - // - // Slow ... - CopyCSlow( - zIndex, - loopback, - conditions.cSlow // - ); - - // - // Short ... - - // - // Fast ... - CopySFast( - zIndex, - loopback, - conditions.sFast // - ); - - // - // Slow ... - CopySSlow( - zIndex, - loopback, - conditions.sSlow // - ); - - // - // Medium ... - - // - // Fast ... - CopyMFast( - zIndex, - loopback, - conditions.mFast // - ); - - // - // Slow ... - CopyMSlow( - zIndex, - loopback, - conditions.mSlow // - ); - - // - // Long ... - - // - // Fast ... - CopyLFast( - zIndex, - loopback, - conditions.lFast // - ); - - // - // Slow ... - CopyLSlow( - zIndex, - loopback, - conditions.lSlow // - ); - - // - // Hind ... - - // - // Fast ... - CopyHFast( - zIndex, - loopback, - conditions.hFast // - ); - - // - // Slow ... - CopyHSlow( - zIndex, - loopback, - conditions.hSlow // - ); - - // - // Conditions ... - - // - XOHCL cBar; - result = cBar.Init( - mSymbol, - mPeriod, - cIndex // - ); - if (!result) - { - return result; - } - - // - XOHCL pBar; - result = pBar.Init( - mSymbol, - mPeriod, - pIndex // - ); - if (!result) - { - return result; - } - double hhValue = pBar.FindHighest( - loopback, - MODE_HIGH // - ); - double llValue = pBar.FindLowest( - loopback, - MODE_LOW // - ); - - // - XOHCL ppBar; - result = ppBar.Init( - mSymbol, - mPeriod, - ppIndex // - ); - if (!result) - { - return result; - } - double phhValue = ppBar.FindHighest( - loopback * 2, - MODE_HIGH // - ); - double pllValue = ppBar.FindLowest( - loopback * 2, - MODE_LOW // - ); - - // - double allValues[]; - double maxValue = 0; - double minValue = 0; - double maxValuePrev = 0; - double minValuePrev = 0; - - // - // Power ... - - // - bool hasBullishPower = HasBullishPower(cIndex); - bool hasBullishPowerPrev = HasBullishPower(pIndex); - - // - bool hasBearishPower = HasBearishPower(cIndex); - bool hasBearishPowerPrev = HasBearishPower(pIndex); - - // - bool isBullishPowerUp = hasBullishPower && - !hasBullishPowerPrev; - bool isBearishPowerUp = hasBearishPower && - !hasBearishPowerPrev; - - // - bool isBullishPowerIncreasing = IsBullishPowerIncreasing(cIndex); - bool isBullishPowerDecreasing = IsBullishPowerDecreasing(cIndex); - bool isBearishPowerIncreasing = IsBearishPowerIncreasing(cIndex); - bool isBearishPowerDecreasing = IsBearishPowerDecreasing(cIndex); - - // - conditions.hasBullishPower = hasBullishPower; - conditions.hasBearishPower = hasBearishPower; - conditions.isBullishPowerUp = isBullishPowerUp; - conditions.isBearishPowerUp = isBearishPowerUp; - conditions.isBullishPowerIncreasing = isBullishPowerIncreasing; - conditions.isBullishPowerDecreasing = isBullishPowerDecreasing; - conditions.isBearishPowerIncreasing = isBearishPowerIncreasing; - conditions.isBearishPowerDecreasing = isBearishPowerDecreasing; - - // - // AVG ... - - // - bool isFastOverSlow = conditions.fast[cIndex] > conditions.slow[cIndex]; - bool isFastOverSlowPrev = conditions.fast[pIndex] > conditions.slow[pIndex]; - - // - bool isFastUnderSlow = conditions.fast[cIndex] < conditions.slow[cIndex]; - bool isFastUnderSlowPrev = conditions.fast[pIndex] < conditions.slow[pIndex]; - - // - bool isFastCrossedOverSlow = isFastOverSlow && - !isFastOverSlowPrev; - bool isFastCrossedUnderSlow = isFastUnderSlow && - !isFastUnderSlowPrev; - - // - bool isClosedOverFast = cBar.close > conditions.fast[cIndex]; - bool isClosedUnderFast = cBar.close < conditions.fast[cIndex]; - - // - conditions.isFastOverSlow = isFastOverSlow; - conditions.isFastUnderSlow = isFastUnderSlow; - - // - conditions.isFastCrossedOverSlow = isFastCrossedOverSlow; - conditions.isFastCrossedUnderSlow = isFastCrossedUnderSlow; - - // - conditions.isClosedOverFast = isClosedOverFast; - conditions.isClosedUnderFast = isClosedUnderFast; - - // - // Current ... - - // - bool isCFastOverSlow = conditions.cFast[cIndex] > conditions.cSlow[cIndex]; - bool isCFastOverSlowPrev = conditions.cFast[pIndex] > conditions.cSlow[pIndex]; - - // - bool isCFastUnderSlow = conditions.cFast[cIndex] < conditions.cSlow[cIndex]; - bool isCFastUnderSlowPrev = conditions.cFast[pIndex] < conditions.cSlow[pIndex]; - - // - bool isCFastCrossedOverSlow = isCFastOverSlow && - !isCFastOverSlowPrev; - bool isCFastCrossedUnderSlow = isCFastUnderSlow && - !isCFastUnderSlowPrev; - - // - bool isClosedOverCFast = cBar.close > conditions.cFast[cIndex]; - bool isClosedUnderCFast = cBar.close < conditions.cFast[cIndex]; - - // - conditions.isCFastOverSlow = isCFastOverSlow; - conditions.isCFastUnderSlow = isCFastUnderSlow; - - // - conditions.isCFastCrossedOverSlow = isCFastCrossedOverSlow; - conditions.isCFastCrossedUnderSlow = isCFastCrossedUnderSlow; - - // - conditions.isClosedOverCFast = isClosedOverCFast; - conditions.isClosedUnderCFast = isClosedUnderCFast; - - // - // Short ... - - // - bool isSFastOverSlow = conditions.sFast[cIndex] > conditions.sSlow[cIndex]; - bool isSFastOverSlowPrev = conditions.sFast[pIndex] > conditions.sSlow[pIndex]; - - // - bool isSFastUnderSlow = conditions.sFast[cIndex] < conditions.sSlow[cIndex]; - bool isSFastUnderSlowPrev = conditions.sFast[pIndex] < conditions.sSlow[pIndex]; - - // - bool isSFastCrossedOverSlow = isSFastOverSlow && - !isSFastOverSlowPrev; - bool isSFastCrossedUnderSlow = isSFastUnderSlow && - !isSFastUnderSlowPrev; - - // - bool isClosedOverSFast = cBar.close > conditions.sFast[cIndex]; - bool isClosedUnderSFast = cBar.close < conditions.sFast[cIndex]; - - // - conditions.isSFastOverSlow = isSFastOverSlow; - conditions.isSFastUnderSlow = isSFastUnderSlow; - - // - conditions.isSFastCrossedOverSlow = isSFastCrossedOverSlow; - conditions.isSFastCrossedUnderSlow = isSFastCrossedUnderSlow; - - // - conditions.isClosedOverSFast = isClosedOverSFast; - conditions.isClosedUnderSFast = isClosedUnderSFast; - - // - // Medium ... - - // - bool isMFastOverSlow = conditions.mFast[cIndex] > conditions.mSlow[cIndex]; - bool isMFastOverSlowPrev = conditions.mFast[pIndex] > conditions.mSlow[pIndex]; - - // - bool isMFastUnderSlow = conditions.mFast[cIndex] < conditions.mSlow[cIndex]; - bool isMFastUnderSlowPrev = conditions.mFast[pIndex] < conditions.mSlow[pIndex]; - - // - bool isMFastCrossedOverSlow = isMFastOverSlow && - !isMFastOverSlowPrev; - bool isMFastCrossedUnderSlow = isMFastUnderSlow && - !isMFastUnderSlowPrev; - - // - bool isClosedOverMFast = cBar.close > conditions.mFast[cIndex]; - bool isClosedUnderMFast = cBar.close < conditions.mFast[cIndex]; - - // - conditions.isMFastOverSlow = isMFastOverSlow; - conditions.isMFastUnderSlow = isMFastUnderSlow; - - // - conditions.isMFastCrossedOverSlow = isMFastCrossedOverSlow; - conditions.isMFastCrossedUnderSlow = isMFastCrossedUnderSlow; - - // - conditions.isClosedOverMFast = isClosedOverMFast; - conditions.isClosedUnderMFast = isClosedUnderMFast; - - // - // Long ... - - // - bool isLFastOverSlow = conditions.lFast[cIndex] > conditions.lSlow[cIndex]; - bool isLFastOverSlowPrev = conditions.lFast[pIndex] > conditions.lSlow[pIndex]; - - // - bool isLFastUnderSlow = conditions.lFast[cIndex] < conditions.lSlow[cIndex]; - bool isLFastUnderSlowPrev = conditions.lFast[pIndex] < conditions.lSlow[pIndex]; - - // - bool isLFastCrossedOverSlow = isLFastOverSlow && - !isLFastOverSlowPrev; - bool isLFastCrossedUnderSlow = isLFastUnderSlow && - !isLFastUnderSlowPrev; - - // - bool isClosedOverLFast = cBar.close > conditions.lFast[cIndex]; - bool isClosedUnderLFast = cBar.close < conditions.lFast[cIndex]; - - // - conditions.isLFastOverSlow = isLFastOverSlow; - conditions.isLFastUnderSlow = isLFastUnderSlow; - - // - conditions.isLFastCrossedOverSlow = isLFastCrossedOverSlow; - conditions.isLFastCrossedUnderSlow = isLFastCrossedUnderSlow; - - // - conditions.isClosedOverLFast = isClosedOverLFast; - conditions.isClosedUnderLFast = isClosedUnderLFast; - - // - // Hind ... - - // - bool isHFastOverSlow = conditions.hFast[cIndex] > conditions.hSlow[cIndex]; - bool isHFastOverSlowPrev = conditions.hFast[pIndex] > conditions.hSlow[pIndex]; - - // - bool isHFastUnderSlow = conditions.hFast[cIndex] < conditions.hSlow[cIndex]; - bool isHFastUnderSlowPrev = conditions.hFast[pIndex] < conditions.hSlow[pIndex]; - - // - bool isHFastCrossedOverSlow = isHFastOverSlow && - !isHFastOverSlowPrev; - bool isHFastCrossedUnderSlow = isHFastUnderSlow && - !isHFastUnderSlowPrev; - - // - bool isClosedOverHFast = cBar.close > conditions.hFast[cIndex]; - bool isClosedUnderHFast = cBar.close < conditions.hFast[cIndex]; - - // - conditions.isHFastOverSlow = isHFastOverSlow; - conditions.isHFastUnderSlow = isHFastUnderSlow; - - // - conditions.isHFastCrossedOverSlow = isHFastCrossedOverSlow; - conditions.isHFastCrossedUnderSlow = isHFastCrossedUnderSlow; - - // - conditions.isClosedOverHFast = isClosedOverHFast; - conditions.isClosedUnderHFast = isClosedUnderHFast; - - // - return result; - } - - // - // Protected ... -protected: - // - // Private ... -private: - // - // Props ... - XCHMInputs mInputs; // Inputs ... - - // - // Buffers ... - - // - // AVG ... - double fastBuffer[]; - double slowBuffer[]; - - // - // Current ... - double cFastBuffer[]; - double cSlowBuffer[]; - - // - // Short ... - double sFastBuffer[]; - double sSlowBuffer[]; - - // - // Medium ... - double mFastBuffer[]; - double mSlowBuffer[]; - - // - // Long ... - double lFastBuffer[]; - double lSlowBuffer[]; - - // - // Hind ... - double hFastBuffer[]; - double hSlowBuffer[]; - - // - // Tools ... - - // - // Calculate Values Until Now ... - void Calculate() - { - // - int totalBars = CountBars(); - if (totalBars > 1000) - { - totalBars = 1000; - } - - // - // Fast ... - CopyBuffer( - mHandler, - XCHM_FAST_LINE, - 0, - totalBars, - fastBuffer - // - ); - - // - // Slow ... - CopyBuffer( - mHandler, - XCHM_SLOW_LINE, - 0, - totalBars, - slowBuffer - // - ); - - // - // Current ... - - // - // Fast ... - CopyBuffer( - mHandler, - XCHM_CFAST_LINE, - 0, - totalBars, - cFastBuffer - // - ); - - // - // Slow ... - CopyBuffer( - mHandler, - XCHM_CSLOW_LINE, - 0, - totalBars, - cSlowBuffer - // - ); - - // - // Short ... - - // - // Fast ... - CopyBuffer( - mHandler, - XCHM_SFAST_LINE, - 0, - totalBars, - sFastBuffer - // - ); - - // - // Slow ... - CopyBuffer( - mHandler, - XCHM_SSLOW_LINE, - 0, - totalBars, - sSlowBuffer - // - ); - - // - // Medium ... - - // - // Fast ... - CopyBuffer( - mHandler, - XCHM_MFAST_LINE, - 0, - totalBars, - mFastBuffer - // - ); - - // - // Slow ... - CopyBuffer( - mHandler, - XCHM_MSLOW_LINE, - 0, - totalBars, - mSlowBuffer - // - ); - - // - // Long ... - - // - // Fast ... - CopyBuffer( - mHandler, - XCHM_LFAST_LINE, - 0, - totalBars, - lFastBuffer - // - ); - - // - // Slow ... - CopyBuffer( - mHandler, - XCHM_LSLOW_LINE, - 0, - totalBars, - lSlowBuffer - // - ); - - // - // Hind ... - - // - // Fast ... - CopyBuffer( - mHandler, - XCHM_HFAST_LINE, - 0, - totalBars, - hFastBuffer - // - ); - - // - // Slow ... - CopyBuffer( - mHandler, - XCHM_HSLOW_LINE, - 0, - totalBars, - hSlowBuffer - // - ); - } -}; - -// \ No newline at end of file diff --git a/Helpers/x-saherelm.xchstr.helper.mq5 b/Helpers/x-saherelm.xchstr.helper.mq5 deleted file mode 100644 index 6ccda110..00000000 --- a/Helpers/x-saherelm.xchstr.helper.mq5 +++ /dev/null @@ -1,3240 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Helper Class Library -// ---------------------------------------------- -// Name: XSCXCHSTRHelper -// 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_XCHSTR_BUFFERS -{ - // - XCHSTR_C_LINE = 0, - XCHSTR_C_STATE_LINE = 11, - // - XCHSTR_S_LINE = 2, - XCHSTR_S_STATE_LINE = 16, - // - XCHSTR_M_LINE = 4, - XCHSTR_M_STATE_LINE = 21, - // - XCHSTR_L_LINE = 6, - XCHSTR_L_STATE_LINE = 26, - // - XCHSTR_H_LINE = 8, - XCHSTR_H_STATE_LINE = 31, -}; - -// -enum ENUM_XCHSTR_TREND_STATES -{ - X_STR_BULLISH = 1, // Bullish - X_STR_BEARISH = -1, // Bearish -}; - -// -// Input Models ... -struct XCHSTRInputs -{ - // - // Props ... - - // - // Market ... - int length; // Length - double multiplier; // Multiplier - ENUM_APPLIED_PRICE appliedTo; // Applied To - - // - // Cycles ... - - // - // Short ... - ENUM_X_PERIOD_METHOD scMethod; // How to Find Period - ENUM_TIMEFRAMES scPeriod; // Time Period - - // - // Medium ... - ENUM_X_PERIOD_METHOD mcMethod; // How to Find Period - ENUM_TIMEFRAMES mcPeriod; // Time Period - - // - // Long ... - ENUM_X_PERIOD_METHOD lcMethod; // How to Find Period - ENUM_TIMEFRAMES lcPeriod; // Time Period - - // - // Hind ... - ENUM_X_PERIOD_METHOD hcMethod; // How to Find Period - ENUM_TIMEFRAMES hcPeriod; // Time Period - - // - // Presentation ... - bool showCurrent; // Show Current Cycle - bool showShort; // Show Short Cycle - bool showMedium; // Show Medium Cycle - bool showLong; // Show Long Cycle - bool showHind; // Show Hind Cycle - - // - // Constructor(s) ... - XCHSTRInputs() - { - // - Clean(); - } - - // - // Tools ... - - // - // Clean ... - void Clean() - { - // - length = 0; - multiplier = 0; - appliedTo = PRICE_CLOSE; - - // - scMethod = X_PERIOD_AUTO; - scPeriod = NULL; - mcMethod = X_PERIOD_AUTO; - mcPeriod = NULL; - lcMethod = X_PERIOD_AUTO; - lcPeriod = NULL; - hcMethod = X_PERIOD_AUTO; - hcPeriod = NULL; - - // - showCurrent = false; - showShort = false; - showMedium = false; - showLong = false; - showHind = false; - } - - // - // Default ... - void Default() - { - // - length = 14; - multiplier = 3.5; - appliedTo = PRICE_MEDIAN; - - // - scMethod = X_PERIOD_AUTO; - scPeriod = NULL; - mcMethod = X_PERIOD_AUTO; - mcPeriod = NULL; - lcMethod = X_PERIOD_AUTO; - lcPeriod = NULL; - hcMethod = X_PERIOD_AUTO; - hcPeriod = NULL; - - // - showCurrent = true; - showShort = true; - showMedium = true; - showLong = true; - showHind = true; - } - - // - // Validate ... - bool IsValid() - { - // - bool result = false; - - // - result = - // - length > 0 && - multiplier > 0 && - // - (IsValid(scMethod, scPeriod) && - IsValid(mcMethod, mcPeriod) && - IsValid(lcMethod, lcPeriod) && - IsValid(hcMethod, hcPeriod)) - // - ; - - // - return result; - } - - // - // Retrieve MAx Length ... - int Max() - { - // - int result = 0; - - // - result = - // - MathMax(0, length) - // - ; - - // - return result; - } -}; - -// -// Define Conditions ... -struct XCHSTRConditions -{ - // - // Common ... - string symbol; - ENUM_TIMEFRAMES period; - datetime time; - - // - // Buffers ... - - // - // Current ... - double cTrend[]; - double cState[]; - - // - // Short ... - double sTrend[]; - double sState[]; - - // - // Medium ... - double mTrend[]; - double mState[]; - - // - // Long ... - double lTrend[]; - double lState[]; - - // - // Hind ... - double hTrend[]; - double hState[]; - - // - // Conditions ... - // - // Power ... - bool hasBullishPower; - bool hasBearishPower; - bool isBullishPowerUp; - bool isBearishPowerUp; - bool isBullishPowerIncreasing; - bool isBullishPowerDecreasing; - bool isBearishPowerIncreasing; - bool isBearishPowerDecreasing; - - // - // Current ... - bool isCBullish; - bool isCBearish; - bool isCSwitchedToBullish; - bool isCSwitchedToBearish; - - // - // Short ... - bool isSBullish; - bool isSBearish; - bool isSSwitchedToBullish; - bool isSSwitchedToBearish; - - // - // Medium ... - bool isMBullish; - bool isMBearish; - bool isMSwitchedToBullish; - bool isMSwitchedToBearish; - - // - // Long ... - bool isLBullish; - bool isLBearish; - bool isLSwitchedToBullish; - bool isLSwitchedToBearish; - - // - // Hind ... - bool isHBullish; - bool isHBearish; - bool isHSwitchedToBullish; - bool isHSwitchedToBearish; - - // - void Clean() - { - // - Clean(cTrend); - Clean(cState); - Clean(sTrend); - Clean(sState); - Clean(mTrend); - Clean(mState); - Clean(lTrend); - Clean(lState); - Clean(hTrend); - Clean(hState); - - // - ArraySetAsSeries(cTrend, true); - ArraySetAsSeries(cState, true); - ArraySetAsSeries(sTrend, true); - ArraySetAsSeries(sState, true); - ArraySetAsSeries(mTrend, true); - ArraySetAsSeries(mState, true); - ArraySetAsSeries(lTrend, true); - ArraySetAsSeries(lState, true); - ArraySetAsSeries(hTrend, true); - ArraySetAsSeries(hState, true); - - // - // Conditions ... - - // - // Power ... - hasBullishPower = false; - hasBearishPower = false; - isBullishPowerUp = false; - isBearishPowerUp = false; - isBullishPowerIncreasing = false; - isBullishPowerDecreasing = false; - isBearishPowerIncreasing = false; - isBearishPowerDecreasing = false; - - // - // Current ... - isCBullish = false; - isCBearish = false; - isCSwitchedToBullish = false; - isCSwitchedToBearish = false; - - // - // Short ... - isSBullish = false; - isSBearish = false; - isSSwitchedToBullish = false; - isSSwitchedToBearish = false; - - // - // Medium ... - isMBullish = false; - isMBearish = false; - isMSwitchedToBullish = false; - isMSwitchedToBearish = false; - - // - // Long ... - isLBullish = false; - isLBearish = false; - isLSwitchedToBullish = false; - isLSwitchedToBearish = false; - - // - // Hind ... - isHBullish = false; - isHBearish = false; - isHSwitchedToBullish = false; - isHSwitchedToBearish = false; - } - - // - void GenerateScore( - double &bullishScore, - double &bearishScore // - ) - { - // - bullishScore = 0; - bearishScore = 0; - - // - // Since We have to Use this - // Only for Filtering Signals ... - // We Can Ignore Scoring ... - // or Complete this later ... - - // - // Conditions ... - - // - // Power ... - if (hasBullishPower) - { - bullishScore++; - } - if (hasBearishPower) - { - bearishScore++; - } - if (isBullishPowerUp) - { - bullishScore++; - } - if (isBearishPowerUp) - { - bearishScore++; - } - if (isBullishPowerIncreasing) - { - bullishScore++; - } - if (isBullishPowerDecreasing) - { - bearishScore++; - } - if (isBearishPowerIncreasing) - { - bearishScore++; - } - if (isBearishPowerDecreasing) - { - bullishScore++; - } - - // - // Current ... - if (isCBullish) - { - bullishScore++; - } - if (isCBearish) - { - bearishScore++; - } - if (isCSwitchedToBullish) - { - bullishScore++; - } - if (isCSwitchedToBearish) - { - bearishScore++; - } - - // - // Short ... - if (isSBullish) - { - bullishScore++; - } - if (isSBearish) - { - bearishScore++; - } - if (isSSwitchedToBullish) - { - bullishScore++; - } - if (isSSwitchedToBearish) - { - bearishScore++; - } - - // - // Medium ... - if (isMBullish) - { - bullishScore++; - } - if (isMBearish) - { - bearishScore++; - } - if (isMSwitchedToBullish) - { - bullishScore++; - } - if (isMSwitchedToBearish) - { - bearishScore++; - } - - // - // Long ... - if (isLBullish) - { - bullishScore++; - } - if (isLBearish) - { - bearishScore++; - } - if (isLSwitchedToBullish) - { - bullishScore++; - } - if (isLSwitchedToBearish) - { - bearishScore++; - } - - // - // Hind ... - if (isHBullish) - { - bullishScore++; - } - if (isHBearish) - { - bearishScore++; - } - if (isHSwitchedToBullish) - { - bullishScore++; - } - if (isHSwitchedToBearish) - { - bearishScore++; - } - } - - // - string GenerateSummary( - bool onlyCommons = false, - bool onlyConditions = false, - bool includeScores = true, - bool ignoreFalseConditions = true, - string separator = "\n" // - ) - { - // - string result = NULL; - - // - double bullishScore = 0; - double bearishScore = 0; - GenerateScore( - bullishScore, - bearishScore // - ); - - // - string scoresStr = - // - "Scores: " + separator + - "---------------" + separator + - "Bullish: " + ToString(bullishScore) + separator + - "Bearish: " + ToString(bearishScore) + separator + - "" - // - ; - - // - string commonStr = GenerateSpecifiedCommonSummary( - this, - separator, - includeScores // - ); - - // - string conditionsStr = - // - // Power ... - ToString("hasBullishPower", hasBullishPower, ignoreFalseConditions, separator) + - ToString("hasBearishPower", hasBearishPower, ignoreFalseConditions, separator) + - ToString("isBullishPowerUp", isBullishPowerUp, ignoreFalseConditions, separator) + - ToString("isBearishPowerUp", isBearishPowerUp, ignoreFalseConditions, separator) + - ToString("isBullishPowerIncreasing", isBullishPowerIncreasing, ignoreFalseConditions, separator) + - ToString("isBullishPowerDecreasing", isBullishPowerDecreasing, ignoreFalseConditions, separator) + - ToString("isBearishPowerIncreasing", isBearishPowerIncreasing, ignoreFalseConditions, separator) + - ToString("isBearishPowerDecreasing", isBearishPowerDecreasing, ignoreFalseConditions, separator) + - // - // Current ... - ToString("isCBullish", isCBullish, ignoreFalseConditions, separator) + - ToString("isCBearish", isCBearish, ignoreFalseConditions, separator) + - ToString("isCSwitchedToBullish", isCSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isCSwitchedToBearish", isCSwitchedToBearish, ignoreFalseConditions, separator) + - // - // Short ... - ToString("isSBullish", isSBullish, ignoreFalseConditions, separator) + - ToString("isSBearish", isSBearish, ignoreFalseConditions, separator) + - ToString("isSSwitchedToBullish", isSSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isSSwitchedToBearish", isSSwitchedToBearish, ignoreFalseConditions, separator) + - // - // Medium ... - ToString("isMBullish", isMBullish, ignoreFalseConditions, separator) + - ToString("isMBearish", isMBearish, ignoreFalseConditions, separator) + - ToString("isMSwitchedToBullish", isMSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isMSwitchedToBearish", isMSwitchedToBearish, ignoreFalseConditions, separator) + - // - // Long ... - ToString("isLBullish", isLBullish, ignoreFalseConditions, separator) + - ToString("isLBearish", isLBearish, ignoreFalseConditions, separator) + - ToString("isLSwitchedToBullish", isLSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isLSwitchedToBearish", isLSwitchedToBearish, ignoreFalseConditions, separator) + - // - // Hind ... - ToString("isHBullish", isHBullish, ignoreFalseConditions, separator) + - ToString("isHBearish", isHBearish, ignoreFalseConditions, separator) + - ToString("isHSwitchedToBullish", isHSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isHSwitchedToBearish", isHSwitchedToBearish, ignoreFalseConditions, separator) + - // - "" - // - ; - - // - result = - // - "[" + GetTag() + "]" + separator + - (onlyConditions - ? "" - : commonStr) + - (!includeScores - ? "" - : scoresStr) + - " " + separator + - (onlyCommons - ? "" - : conditionsStr) + - "" - // - ; - - // - return result; - } - - // - string GetTag() - { - return "XCHSTR"; - } -}; - -// -// Class ... -class XSCXCHSTRHelper : public XSCBaseHelper -{ - // - // Public ... -public: - // - // Props ... - - // - // Constructors ... - XSCXCHSTRHelper() : XSCBaseHelper(_Symbol, _Period) - { - } - - // - // Deconstructor ... - ~XSCXCHSTRHelper() - { - // - Clean(cTrendBuffer); - Clean(cStateBuffer); - Clean(sTrendBuffer); - Clean(sStateBuffer); - Clean(mTrendBuffer); - Clean(mStateBuffer); - Clean(lTrendBuffer); - Clean(lStateBuffer); - Clean(hTrendBuffer); - Clean(hStateBuffer); - } - - // - // Tools ... - bool Init( - string symbol, // Trading Symbol - ENUM_TIMEFRAMES period, // Trading Period - XCHSTRInputs &inputs // Inputs - ) - { - // - bool result = false; - - // - mSymbol = symbol; - mPeriod = period; - - // - result = inputs.IsValid(); - if (!result) - { - return result; - } - - // - mInputs = inputs; - - // - ArraySetAsSeries(cTrendBuffer, true); - ArraySetAsSeries(cStateBuffer, true); - ArraySetAsSeries(sTrendBuffer, true); - ArraySetAsSeries(sStateBuffer, true); - ArraySetAsSeries(mTrendBuffer, true); - ArraySetAsSeries(mStateBuffer, true); - ArraySetAsSeries(lTrendBuffer, true); - ArraySetAsSeries(lStateBuffer, true); - ArraySetAsSeries(hTrendBuffer, true); - ArraySetAsSeries(hStateBuffer, true); - - // - mHandler = iCustom( - mSymbol, - mPeriod, - "x-saherelm.xchstr", - // - // Inputs ... - // - // Market ... - "", - mInputs.length, // Length - mInputs.multiplier, // Multiplier - mInputs.appliedTo, // Applied To - // - // Cycles ... - "", - // - // Short ... - "", - mInputs.scMethod, - mInputs.scPeriod, - // - // Medium ... - "", - mInputs.mcMethod, - mInputs.mcPeriod, - // - // Long ... - "", - mInputs.lcMethod, - mInputs.lcPeriod, - // - // Hind ... - "", - mInputs.hcMethod, - mInputs.hcPeriod, - // - // Presentation ... - "", - mInputs.showCurrent, - mInputs.showShort, - mInputs.showMedium, - mInputs.showLong, - mInputs.showHind - // - ); - result = mHandler != INVALID_HANDLE; - if (!result) - { - return result; - } - - // - return result; - } - - // - // Inputs ... - - // - XCHSTRInputs GetInputs() - { - return mInputs; - } - - // - bool SetInputs( - XCHSTRInputs &inputs // Configs - ) - { - // - return Init( - mSymbol, - mPeriod, - inputs - // - ); - } - - // - // Buffers ... - - // - // Current ... - - // - // Trend ... - - // - double GetCTrend( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return cTrendBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyCTrend( - 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, - cTrendBuffer, - buffer, - forceClean - // - ); - } - - // - // State ... - - // - ENUM_XCHSTR_TREND_STATES GetCState( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return (ENUM_XCHSTR_TREND_STATES)((int)cStateBuffer[barIndex]); - } - - // - // Copy Required Buffer ... - int CopyCState( - 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, - cStateBuffer, - buffer, - forceClean - // - ); - } - - // - // Short ... - - // - // Trend ... - - // - double GetSTrend( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return sTrendBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopySTrend( - 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, - sTrendBuffer, - buffer, - forceClean - // - ); - } - - // - // State ... - - // - ENUM_XCHSTR_TREND_STATES GetSState( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return (ENUM_XCHSTR_TREND_STATES)((int)sStateBuffer[barIndex]); - } - - // - // Copy Required Buffer ... - int CopySState( - 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, - sStateBuffer, - buffer, - forceClean - // - ); - } - - // - // Medium ... - - // - // Trend ... - - // - double GetMTrend( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return mTrendBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyMTrend( - 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, - mTrendBuffer, - buffer, - forceClean - // - ); - } - - // - // State ... - - // - ENUM_XCHSTR_TREND_STATES GetMState( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return (ENUM_XCHSTR_TREND_STATES)((int)mStateBuffer[barIndex]); - } - - // - // Copy Required Buffer ... - int CopyMState( - 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, - mStateBuffer, - buffer, - forceClean - // - ); - } - - // - // Long ... - - // - // Trend ... - - // - double GetLTrend( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return lTrendBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyLTrend( - 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, - lTrendBuffer, - buffer, - forceClean - // - ); - } - - // - // State ... - - // - ENUM_XCHSTR_TREND_STATES GetLState( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return (ENUM_XCHSTR_TREND_STATES)((int)lStateBuffer[barIndex]); - } - - // - // Copy Required Buffer ... - int CopyLState( - 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, - lStateBuffer, - buffer, - forceClean - // - ); - } - - // - // Hind ... - - // - // Trend ... - - // - double GetHTrend( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return hTrendBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyHTrend( - 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, - hTrendBuffer, - buffer, - forceClean - // - ); - } - - // - // State ... - - // - ENUM_XCHSTR_TREND_STATES GetHState( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return (ENUM_XCHSTR_TREND_STATES)((int)hStateBuffer[barIndex]); - } - - // - // Copy Required Buffer ... - int CopyHState( - 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, - hStateBuffer, - buffer, - forceClean - // - ); - } - - // - // Tools ... - - // - ENUM_XCHSTR_TREND_STATES ToState(double state) - { - return (ENUM_XCHSTR_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; - } - - // - int GetTrends( - double &values[], - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - int result = 0; - - // - Clean(values); - - // - int cyclesCount = ArraySize(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double iValue = 0; - - // - switch (cycles[i]) - { - // - // CURRENT ... - case X_MARKET_CYCLE_UNKNOWN: - // - iValue = GetCTrend(barIndex); - break; - - // - // SHORT ... - case X_MARKET_CYCLE_SHORT: - // - iValue = GetSTrend(barIndex); - break; - - // - // MEDIUM ... - case X_MARKET_CYCLE_MEDIUM: - // - iValue = GetMTrend(barIndex); - break; - - // - // LONG ... - case X_MARKET_CYCLE_LONG: - // - iValue = GetLTrend(barIndex); - break; - - // - // HIND ... - case X_MARKET_CYCLE_HIND: - // - iValue = GetHTrend(barIndex); - break; - } - - // - if (iValue > 0) - { - // - Add( - iValue, - values // - ); - } - } - - // - result = ArraySize(values); - - // - return result; - } - - // - int GetBullishTrends( - double &values[], - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - int result = 0; - - // - Clean(values); - - // - int cyclesCount = ArraySize(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double iValue = 0; - - // - switch (cycles[i]) - { - // - // CURRENT ... - case X_MARKET_CYCLE_UNKNOWN: - // - if (IsBullish((double)GetCState(barIndex))) - { - iValue = GetCTrend(barIndex); - } - break; - - // - // SHORT ... - case X_MARKET_CYCLE_SHORT: - // - if (IsBullish((double)GetSState(barIndex))) - { - iValue = GetSTrend(barIndex); - } - break; - - // - // MEDIUM ... - case X_MARKET_CYCLE_MEDIUM: - // - if (IsBullish((double)GetMState(barIndex))) - { - iValue = GetMTrend(barIndex); - } - break; - - // - // LONG ... - case X_MARKET_CYCLE_LONG: - // - if (IsBullish((double)GetLState(barIndex))) - { - iValue = GetLTrend(barIndex); - } - break; - - // - // HIND ... - case X_MARKET_CYCLE_HIND: - // - if (IsBullish((double)GetHState(barIndex))) - { - iValue = GetHTrend(barIndex); - } - break; - } - - // - if (iValue > 0) - { - // - Add( - iValue, - values // - ); - } - } - - // - result = ArraySize(values); - - // - return result; - } - - // - int GetBearishTrends( - double &values[], - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - int result = 0; - - // - Clean(values); - - // - int cyclesCount = ArraySize(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double iValue = 0; - - // - switch (cycles[i]) - { - // - // CURRENT ... - case X_MARKET_CYCLE_UNKNOWN: - // - if (IsBearish((double)GetCState(barIndex))) - { - iValue = GetCTrend(barIndex); - } - break; - - // - // SHORT ... - case X_MARKET_CYCLE_SHORT: - // - if (IsBearish((double)GetSState(barIndex))) - { - iValue = GetSTrend(barIndex); - } - break; - - // - // MEDIUM ... - case X_MARKET_CYCLE_MEDIUM: - // - if (IsBearish((double)GetMState(barIndex))) - { - iValue = GetMTrend(barIndex); - } - break; - - // - // LONG ... - case X_MARKET_CYCLE_LONG: - // - if (IsBearish((double)GetLState(barIndex))) - { - iValue = GetLTrend(barIndex); - } - break; - - // - // HIND ... - case X_MARKET_CYCLE_HIND: - // - if (IsBearish((double)GetHState(barIndex))) - { - iValue = GetHTrend(barIndex); - } - break; - } - - // - if (iValue > 0) - { - // - Add( - iValue, - values // - ); - } - } - - // - result = ArraySize(values); - - // - return result; - } - - // - double GetMax( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetAllMarketCycles(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - result = GetCyclesMax( - barIndex, - cycles // - ); - - // - return result; - } - - // - double GetMin( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetAllMarketCycles(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - result = GetCyclesMin( - barIndex, - cycles // - ); - - // - return result; - } - - // - double GetMaxBullish( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetAllMarketCycles(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - double values[]; - int valuesCount = GetBullishTrends( - values, - barIndex, - cycles // - ); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetMinBullish( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetAllMarketCycles(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - double values[]; - int valuesCount = GetBullishTrends( - values, - barIndex, - cycles // - ); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetMaxBearish( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetAllMarketCycles(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - double values[]; - int valuesCount = GetBearishTrends( - values, - barIndex, - cycles // - ); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetMinBearish( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetAllMarketCycles(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - double values[]; - int valuesCount = GetBearishTrends( - values, - barIndex, - cycles // - ); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetCyclesMax( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - double trends[]; - int trendsCount = GetTrends( - trends, - barIndex, - cycles // - ); - if (!IsValidSize(trendsCount)) - { - return result; - } - - // - result = GetSpecifiedMax(trends); - - // - return result; - } - - // - double GetCyclesMin( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - double trends[]; - int trendsCount = GetTrends( - trends, - barIndex, - cycles // - ); - if (!IsValidSize(trendsCount)) - { - return result; - } - - // - result = GetSpecifiedMin(trends); - - // - return result; - } - - // - double GetCyclesMaxBullish( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - double trends[]; - int trendsCount = GetBullishTrends( - trends, - barIndex, - cycles // - ); - if (!IsValidSize(trendsCount)) - { - return result; - } - - // - result = GetSpecifiedMax(trends); - - // - return result; - } - - // - double GetCyclesMinBullish( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - double trends[]; - int trendsCount = GetBullishTrends( - trends, - barIndex, - cycles // - ); - if (!IsValidSize(trendsCount)) - { - return result; - } - - // - result = GetSpecifiedMin(trends); - - // - return result; - } - - // - double GetCyclesMaxBearish( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - double trends[]; - int trendsCount = GetBearishTrends( - trends, - barIndex, - cycles // - ); - if (!IsValidSize(trendsCount)) - { - return result; - } - - // - result = GetSpecifiedMax(trends); - - // - return result; - } - - // - double GetCyclesMinBearish( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - double trends[]; - int trendsCount = GetBearishTrends( - trends, - barIndex, - cycles // - ); - if (!IsValidSize(trendsCount)) - { - return result; - } - - // - result = GetSpecifiedMin(trends); - - // - return result; - } - - // - double GetBullishPower( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - double power = 0; - double state = -100; - - // - // CURRENT ... - power = GetCTrend(barIndex); - state = (double)GetCState(barIndex); - if (IsBullish(state)) - { - result += power; - } - - // - // SHORT ... - power = GetSTrend(barIndex); - state = (double)GetSState(barIndex); - if (IsBullish(state)) - { - result += power; - } - - // - // MEDIUM ... - power = GetMTrend(barIndex); - state = (double)GetMState(barIndex); - if (IsBullish(state)) - { - result += power; - } - - // - // LONG ... - power = GetLTrend(barIndex); - state = (double)GetLState(barIndex); - if (IsBullish(state)) - { - result += power; - } - - // - // HIND ... - power = GetHTrend(barIndex); - state = (double)GetHState(barIndex); - if (IsBullish(state)) - { - result += power; - } - - // - return result; - } - - // - double GetBearishPower( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - double power = 0; - double state = -100; - - // - // CURRENT ... - power = GetCTrend(barIndex); - state = (double)GetCState(barIndex); - if (IsBearish(state)) - { - result += power; - } - - // - // SHORT ... - power = GetSTrend(barIndex); - state = (double)GetSState(barIndex); - if (IsBearish(state)) - { - result += power; - } - - // - // MEDIUM ... - power = GetMTrend(barIndex); - state = (double)GetMState(barIndex); - if (IsBearish(state)) - { - result += power; - } - - // - // LONG ... - power = GetLTrend(barIndex); - state = (double)GetLState(barIndex); - if (IsBearish(state)) - { - result += power; - } - - // - // HIND ... - power = GetHTrend(barIndex); - state = (double)GetHState(barIndex); - if (IsBearish(state)) - { - result += power; - } - - // - return result; - } - - // - double GetCyclesBullishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - int cyclesCount = ArraySize(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double power = 0; - double state = -100; - - // - switch (cycles[i]) - { - // - // CURRENT ... - case X_MARKET_CYCLE_UNKNOWN: - // - power = GetCTrend(barIndex); - state = GetCState(barIndex); - break; - - // - // SHORT ... - case X_MARKET_CYCLE_SHORT: - // - power = GetSTrend(barIndex); - state = GetSState(barIndex); - break; - - // - // MEDIUM ... - case X_MARKET_CYCLE_MEDIUM: - // - power = GetMTrend(barIndex); - state = GetMState(barIndex); - break; - - // - // LONG ... - case X_MARKET_CYCLE_LONG: - // - power = GetLTrend(barIndex); - state = GetLState(barIndex); - break; - - // - // HIND ... - case X_MARKET_CYCLE_HIND: - // - power = GetHTrend(barIndex); - state = GetHState(barIndex); - break; - } - - // - if (power > 0 && state != -100) - { - // - if (IsBullish(state)) - { - result += power; - } - } - } - - // - return result; - } - - // - double GetCyclesBearishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - int cyclesCount = ArraySize(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double power = 0; - double state = -100; - - // - switch (cycles[i]) - { - // - // CURRENT ... - case X_MARKET_CYCLE_UNKNOWN: - // - power = GetCTrend(barIndex); - state = GetCState(barIndex); - break; - - // - // SHORT ... - case X_MARKET_CYCLE_SHORT: - // - power = GetSTrend(barIndex); - state = GetSState(barIndex); - break; - - // - // MEDIUM ... - case X_MARKET_CYCLE_MEDIUM: - // - power = GetMTrend(barIndex); - state = GetMState(barIndex); - break; - - // - // LONG ... - case X_MARKET_CYCLE_LONG: - // - power = GetLTrend(barIndex); - state = GetLState(barIndex); - break; - - // - // HIND ... - case X_MARKET_CYCLE_HIND: - // - power = GetHTrend(barIndex); - state = GetHState(barIndex); - break; - } - - // - if (power > 0 && state != -100) - { - // - if (IsBearish(state)) - { - result += power; - } - } - } - - // - return result; - } - - // - bool HasBullishPower( - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - double bullishPower = GetBullishPower(barIndex); - double bearishPower = GetBearishPower(barIndex); - - // - result = - // - bearishPower >= 0 && - bullishPower > bearishPower - // - ; - - // - return result; - } - - // - bool HasBearishPower( - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - double bullishPower = GetBullishPower(barIndex); - double bearishPower = GetBearishPower(barIndex); - - // - result = - // - bullishPower >= 0 && - bearishPower > bullishPower - // - ; - - // - return result; - } - - // - bool HasCyclesBullishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - bool result = false; - - // - double bullishPower = GetCyclesBullishPower(barIndex, cycles); - double bearishPower = GetCyclesBearishPower(barIndex, cycles); - - // - result = - // - bearishPower >= 0 && - bullishPower > bearishPower - // - ; - - // - return result; - } - - // - bool HasCyclesBearishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - bool result = false; - - // - double bullishPower = GetCyclesBullishPower(barIndex, cycles); - double bearishPower = GetCyclesBearishPower(barIndex, cycles); - - // - result = - // - bullishPower >= 0 && - bearishPower > bullishPower - // - ; - - // - return result; - } - - // - // Check Bullish Power Increasing ... - bool IsBullishPowerIncreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBullishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBullishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bullish Power Decreasing ... - bool IsBullishPowerDecreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBullishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBullishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Increasing ... - bool IsBearishPowerIncreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBearishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBearishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Decreasing ... - bool IsBearishPowerDecreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBearishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBearishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Check Bullish Power Increasing ... - bool IsCyclesBullishPowerIncreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBullishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBullishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bullish Power Decreasing ... - bool IsCyclesBullishPowerDecreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBullishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBullishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Increasing ... - bool IsCyclesBearishPowerIncreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBearishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBearishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Decreasing ... - bool IsCyclesBearishPowerDecreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBearishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBearishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Conditions ... - - // - bool GetConditions( - XCHSTRConditions &conditions, // - int barIndex = 0, // - int loopback = 5 // - ) - { - // - bool result = true; - - // - if (loopback < 5) - { - loopback = 5; - } - - // - conditions.Clean(); - - // - conditions.symbol = mSymbol; - conditions.period = mPeriod; - conditions.time = TimeCurrent(); - - // - int zIndex = barIndex; - int cIndex = zIndex + 1; - int pIndex = cIndex + 1; - int ppIndex = pIndex + 1; - - // - // Buffers ... - - // - // Current ... - CopyCTrend( - zIndex, - loopback, - conditions.cTrend // - ); - CopyCState( - zIndex, - loopback, - conditions.cState // - ); - - // - // Short ... - CopySTrend( - zIndex, - loopback, - conditions.sTrend // - ); - CopySState( - zIndex, - loopback, - conditions.sState // - ); - - // - // Medium ... - CopyMTrend( - zIndex, - loopback, - conditions.mTrend // - ); - CopyMState( - zIndex, - loopback, - conditions.mState // - ); - - // - // Long ... - CopyLTrend( - zIndex, - loopback, - conditions.lTrend // - ); - CopyLState( - zIndex, - loopback, - conditions.lState // - ); - - // - // Hind ... - CopyHTrend( - zIndex, - loopback, - conditions.hTrend // - ); - CopyHState( - zIndex, - loopback, - conditions.hState // - ); - - // - // Conditions ... - - // - XOHCL cBar; - result = cBar.Init( - mSymbol, - mPeriod, - cIndex // - ); - if (!result) - { - return result; - } - - // - XOHCL pBar; - result = pBar.Init( - mSymbol, - mPeriod, - pIndex // - ); - if (!result) - { - return result; - } - - // - // Power ... - - // - bool hasBullishPower = HasBullishPower(cIndex); - bool hasBullishPowerPrev = HasBullishPower(pIndex); - - // - bool hasBearishPower = HasBearishPower(cIndex); - bool hasBearishPowerPrev = HasBearishPower(pIndex); - - // - bool isBullishPowerUp = hasBullishPower && - !hasBullishPowerPrev; - bool isBearishPowerUp = hasBearishPower && - !hasBearishPowerPrev; - - // - bool isBullishPowerIncreasing = IsBullishPowerIncreasing(cIndex); - bool isBullishPowerDecreasing = IsBullishPowerDecreasing(cIndex); - bool isBearishPowerIncreasing = IsBearishPowerIncreasing(cIndex); - bool isBearishPowerDecreasing = IsBearishPowerDecreasing(cIndex); - - // - conditions.hasBullishPower = hasBullishPower; - conditions.hasBearishPower = hasBearishPower; - conditions.isBullishPowerUp = isBullishPowerUp; - conditions.isBearishPowerUp = isBearishPowerUp; - conditions.isBullishPowerIncreasing = isBullishPowerIncreasing; - conditions.isBullishPowerDecreasing = isBullishPowerDecreasing; - conditions.isBearishPowerIncreasing = isBearishPowerIncreasing; - conditions.isBearishPowerDecreasing = isBearishPowerDecreasing; - - // - // Current ... - - // - bool isCBullish = IsBullish(conditions.cState[cIndex]); - bool isCBullishPrev = IsBullish(conditions.cState[pIndex]); - - // - bool isCBearish = IsBearish(conditions.cState[cIndex]); - bool isCBearishPrev = IsBearish(conditions.cState[pIndex]); - - // - bool isCSwitchedToBullish = isCBullish && - !isCBullishPrev; - bool isCSwitchedToBearish = isCBearish && - !isCBearishPrev; - - // - conditions.isCBullish = isCBullish; - conditions.isCBearish = isCBearish; - conditions.isCSwitchedToBullish = isCSwitchedToBullish; - conditions.isCSwitchedToBearish = isCSwitchedToBearish; - - // - // Short ... - - // - bool isSBullish = IsBullish(conditions.sState[cIndex]); - bool isSBullishPrev = IsBullish(conditions.sState[pIndex]); - - // - bool isSBearish = IsBearish(conditions.sState[cIndex]); - bool isSBearishPrev = IsBearish(conditions.sState[pIndex]); - - // - bool isSSwitchedToBullish = isSBullish && - !isSBullishPrev; - bool isSSwitchedToBearish = isSBearish && - !isSBearishPrev; - - // - conditions.isSBullish = isSBullish; - conditions.isSBearish = isSBearish; - conditions.isSSwitchedToBullish = isSSwitchedToBullish; - conditions.isSSwitchedToBearish = isSSwitchedToBearish; - - // - // Medium ... - - // - bool isMBullish = IsBullish(conditions.mState[cIndex]); - bool isMBullishPrev = IsBullish(conditions.mState[pIndex]); - - // - bool isMBearish = IsBearish(conditions.mState[cIndex]); - bool isMBearishPrev = IsBearish(conditions.mState[pIndex]); - - // - bool isMSwitchedToBullish = isMBullish && - !isMBullishPrev; - bool isMSwitchedToBearish = isMBearish && - !isMBearishPrev; - - // - conditions.isMBullish = isMBullish; - conditions.isMBearish = isMBearish; - conditions.isMSwitchedToBullish = isMSwitchedToBullish; - conditions.isMSwitchedToBearish = isMSwitchedToBearish; - - // - // Long ... - - // - bool isLBullish = IsBullish(conditions.lState[cIndex]); - bool isLBullishPrev = IsBullish(conditions.lState[pIndex]); - - // - bool isLBearish = IsBearish(conditions.lState[cIndex]); - bool isLBearishPrev = IsBearish(conditions.lState[pIndex]); - - // - bool isLSwitchedToBullish = isLBullish && - !isLBullishPrev; - bool isLSwitchedToBearish = isLBearish && - !isLBearishPrev; - - // - conditions.isLBullish = isLBullish; - conditions.isLBearish = isLBearish; - conditions.isLSwitchedToBullish = isLSwitchedToBullish; - conditions.isLSwitchedToBearish = isLSwitchedToBearish; - - // - // Hind ... - - // - bool isHBullish = IsBullish(conditions.hState[cIndex]); - bool isHBullishPrev = IsBullish(conditions.hState[pIndex]); - - // - bool isHBearish = IsBearish(conditions.hState[cIndex]); - bool isHBearishPrev = IsBearish(conditions.hState[pIndex]); - - // - bool isHSwitchedToBullish = isHBullish && - !isHBullishPrev; - bool isHSwitchedToBearish = isHBearish && - !isHBearishPrev; - - // - conditions.isHBullish = isHBullish; - conditions.isHBearish = isHBearish; - conditions.isHSwitchedToBullish = isHSwitchedToBullish; - conditions.isHSwitchedToBearish = isHSwitchedToBearish; - - // - return result; - } - - // - // Protected ... -protected: - // - // Private ... -private: - // - // Props ... - XCHSTRInputs mInputs; // Inputs ... - - // - // Buffers ... - - // - // Current ... - double cTrendBuffer[]; - double cStateBuffer[]; - - // - // Short ... - double sTrendBuffer[]; - double sStateBuffer[]; - - // - // Medium ... - double mTrendBuffer[]; - double mStateBuffer[]; - - // - // Long ... - double lTrendBuffer[]; - double lStateBuffer[]; - - // - // Hind ... - double hTrendBuffer[]; - double hStateBuffer[]; - - // - // Tools ... - - // - // Calculate Values Until Now ... - void Calculate() - { - // - int totalBars = CountBars(); - if (totalBars > 1000) - { - totalBars = 1000; - } - - // - // Current ... - - // - // Trend ... - CopyBuffer( - mHandler, - XCHSTR_C_LINE, - 0, - totalBars, - cTrendBuffer - // - ); - - // - // State ... - CopyBuffer( - mHandler, - XCHSTR_C_STATE_LINE, - 0, - totalBars, - cStateBuffer - // - ); - - // - // Short ... - - // - // Trend ... - CopyBuffer( - mHandler, - XCHSTR_S_LINE, - 0, - totalBars, - sTrendBuffer - // - ); - - // - // State ... - CopyBuffer( - mHandler, - XCHSTR_S_STATE_LINE, - 0, - totalBars, - sStateBuffer - // - ); - - // - // Medium ... - - // - // Trend ... - CopyBuffer( - mHandler, - XCHSTR_M_LINE, - 0, - totalBars, - mTrendBuffer - // - ); - - // - // State ... - CopyBuffer( - mHandler, - XCHSTR_M_STATE_LINE, - 0, - totalBars, - mStateBuffer - // - ); - - // - // Long ... - - // - // Trend ... - CopyBuffer( - mHandler, - XCHSTR_L_LINE, - 0, - totalBars, - lTrendBuffer - // - ); - - // - // State ... - CopyBuffer( - mHandler, - XCHSTR_L_STATE_LINE, - 0, - totalBars, - lStateBuffer - // - ); - - // - // Hind ... - - // - // Trend ... - CopyBuffer( - mHandler, - XCHSTR_H_LINE, - 0, - totalBars, - hTrendBuffer - // - ); - - // - // State ... - CopyBuffer( - mHandler, - XCHSTR_H_STATE_LINE, - 0, - totalBars, - hStateBuffer - // - ); - }; -}; - -// \ No newline at end of file diff --git a/Helpers/x-saherelm.xchswings.helper.mq5 b/Helpers/x-saherelm.xchswings.helper.mq5 deleted file mode 100644 index 7fb79949..00000000 --- a/Helpers/x-saherelm.xchswings.helper.mq5 +++ /dev/null @@ -1,1423 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Helper Class Library -// ---------------------------------------------- -// Name: XSCXCHSwingsHelper -// 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_XCHSwings_BUFFERS -{ - // - // Current ... - XCHSwings_C_SH_LINE = 0, - XCHSwings_C_SL_LINE = 1, - // - // Short ... - XCHSwings_S_SH_LINE = 2, - XCHSwings_S_SL_LINE = 3, - // - // Medium ... - XCHSwings_M_SH_LINE = 4, - XCHSwings_M_SL_LINE = 5, - // - // Long ... - XCHSwings_L_SH_LINE = 6, - XCHSwings_L_SL_LINE = 7, - // - // Hind ... - XCHSwings_H_SH_LINE = 8, - XCHSwings_H_SL_LINE = 9, -}; - -// -// Input Models ... -struct XCHSwingsInputs -{ - // - // Props ... - - // - // Market ... - int length; // Length - - // - // Cycles ... - - // - // Short ... - ENUM_X_PERIOD_METHOD scMethod; // How to Find Period - ENUM_TIMEFRAMES scPeriod; // Time Period - - // - // Medium ... - ENUM_X_PERIOD_METHOD mcMethod; // How to Find Period - ENUM_TIMEFRAMES mcPeriod; // Time Period - - // - // Long ... - ENUM_X_PERIOD_METHOD lcMethod; // How to Find Period - ENUM_TIMEFRAMES lcPeriod; // Time Period - - // - // Hind ... - ENUM_X_PERIOD_METHOD hcMethod; // How to Find Period - ENUM_TIMEFRAMES hcPeriod; // Time Period - - // - // Presentation ... - bool showSwingHighs; // Show Swing Highs - bool showSwingLows; // Show Swing Lows - bool showCurrent; // Show Current Cycle - bool showShort; // Show Short Cycle - bool showMedium; // Show Medium Cycle - bool showLong; // Show Long Cycle - bool showHind; // Show Hind Cycle - - // - // Constructor(s) ... - XCHSwingsInputs() - { - // - Clean(); - } - - // - // Tools ... - - // - // Clean ... - void Clean() - { - // - length = 0; - - // - scMethod = X_PERIOD_AUTO; - scPeriod = NULL; - mcMethod = X_PERIOD_AUTO; - mcPeriod = NULL; - lcMethod = X_PERIOD_AUTO; - lcPeriod = NULL; - hcMethod = X_PERIOD_AUTO; - hcPeriod = NULL; - - // - showSwingHighs = false; - showSwingLows = false; - showCurrent = false; - showShort = false; - showMedium = false; - showLong = false; - showHind = false; - } - - // - // Default ... - void Default() - { - // - length = 14; - - // - scMethod = X_PERIOD_AUTO; - scPeriod = NULL; - mcMethod = X_PERIOD_AUTO; - mcPeriod = NULL; - lcMethod = X_PERIOD_AUTO; - lcPeriod = NULL; - hcMethod = X_PERIOD_AUTO; - hcPeriod = NULL; - - // - showSwingHighs = true; - showSwingLows = true; - showCurrent = true; - showShort = true; - showMedium = true; - showLong = true; - showHind = true; - } - - // - // Validate ... - bool IsValid() - { - // - bool result = false; - - // - result = - // - length > 2 && - // - (IsValid(scMethod, scPeriod) && - IsValid(mcMethod, mcPeriod) && - IsValid(lcMethod, lcPeriod) && - IsValid(hcMethod, hcPeriod)) - // - ; - - // - return result; - } - - // - // Retrieve MAx Length ... - int Max() - { - // - int result = 0; - - // - result = - // - MathMax(0, length) - // - ; - - // - return result; - } -}; - -// -// Define Conditions ... -struct XCHSwingsConditions -{ - // - // Common ... - string symbol; - ENUM_TIMEFRAMES period; - datetime time; - - // - // Buffers ... - - // - // Current ... - double cSH[]; - double cSL[]; - - // - // Short ... - double sSH[]; - double sSL[]; - - // - // Medium ... - double mSH[]; - double mSL[]; - - // - // Long ... - double lSH[]; - double lSL[]; - - // - // Hind ... - double hSH[]; - double hSL[]; - - // - // Conditions ... - - // - // Current ... - bool isCSwingHigh; - bool isCSwingLow; - - // - // Short ... - bool isSSwingHigh; - bool isSSwingLow; - - // - // Medium ... - bool isMSwingHigh; - bool isMSwingLow; - - // - // Long ... - bool isLSwingHigh; - bool isLSwingLow; - - // - // Hind ... - bool isHSwingHigh; - bool isHSwingLow; - - // - void Clean() - { - // - Clean(cSH); - Clean(cSL); - Clean(sSH); - Clean(sSL); - Clean(mSH); - Clean(mSL); - Clean(lSH); - Clean(lSL); - Clean(hSH); - Clean(hSL); - - // - ArraySetAsSeries(cSH, true); - ArraySetAsSeries(cSL, true); - ArraySetAsSeries(sSH, true); - ArraySetAsSeries(sSL, true); - ArraySetAsSeries(mSH, true); - ArraySetAsSeries(mSL, true); - ArraySetAsSeries(lSH, true); - ArraySetAsSeries(lSL, true); - ArraySetAsSeries(hSH, true); - ArraySetAsSeries(hSL, true); - - // - // Conditions ... - - // - // Current ... - isCSwingHigh = false; - isCSwingLow = false; - - // - // Short ... - isSSwingHigh = false; - isSSwingLow = false; - - // - // Medium ... - isMSwingHigh = false; - isMSwingLow = false; - - // - // Long ... - isLSwingHigh = false; - isLSwingLow = false; - - // - // Hind ... - isHSwingHigh = false; - isHSwingLow = false; - } - - // - void GenerateScore( - double &bullishScore, - double &bearishScore // - ) - { - // - bullishScore = 0; - bearishScore = 0; - - // - // Since We have to Use this - // Only for Filtering Signals ... - // We Can Ignore Scoring ... - // or Complete this later ... - - // - // Conditions ... - - // - // Current ... - - // - // Short ... - - // - // Medium ... - - // - // Long ... - - // - // Hind ... - } - - // - string GenerateSummary( - bool onlyCommons = false, - bool onlyConditions = false, - bool includeScores = true, - bool ignoreFalseConditions = true, - string separator = "\n" // - ) - { - // - string result = NULL; - - // - double bullishScore = 0; - double bearishScore = 0; - GenerateScore( - bullishScore, - bearishScore // - ); - - // - string scoresStr = - // - "Scores: " + separator + - "---------------" + separator + - "Bullish: " + ToString(bullishScore) + separator + - "Bearish: " + ToString(bearishScore) + separator + - "" - // - ; - - // - string commonStr = GenerateSpecifiedCommonSummary( - this, - separator, - includeScores // - ); - - // - string conditionsStr = - // - // Current ... - ToString("isCSwingHigh", isCSwingHigh, ignoreFalseConditions, separator) + - ToString("isCSwingLow", isCSwingLow, ignoreFalseConditions, separator) + - // - // Short ... - ToString("isSSwingHigh", isSSwingHigh, ignoreFalseConditions, separator) + - ToString("isSSwingLow", isSSwingLow, ignoreFalseConditions, separator) + - // - // Medium ... - ToString("isMSwingHigh", isMSwingHigh, ignoreFalseConditions, separator) + - ToString("isMSwingLow", isMSwingLow, ignoreFalseConditions, separator) + - // - // Long ... - ToString("isLSwingHigh", isLSwingHigh, ignoreFalseConditions, separator) + - ToString("isLSwingLow", isLSwingLow, ignoreFalseConditions, separator) + - // - // Hind ... - ToString("isHSwingHigh", isHSwingHigh, ignoreFalseConditions, separator) + - ToString("isHSwingLow", isHSwingLow, ignoreFalseConditions, separator) + - // - "" - // - ; - - // - result = - // - "[" + GetTag() + "]" + separator + - (onlyConditions - ? "" - : commonStr) + - (!includeScores - ? "" - : scoresStr) + - " " + separator + - (onlyCommons - ? "" - : conditionsStr) + - "" - // - ; - - // - return result; - } - - // - string GetTag() - { - return "XCHSwings"; - } -}; - -// -// Class ... -class XSCXCHSwingsHelper : public XSCBaseHelper -{ - // - // Public ... -public: - // - // Props ... - - // - // Constructors ... - XSCXCHSwingsHelper() : XSCBaseHelper(_Symbol, _Period) - { - } - - // - // Deconstructor ... - ~XSCXCHSwingsHelper() - { - // - Clean(cSHBuffer); - Clean(cSLBuffer); - Clean(sSHBuffer); - Clean(sSLBuffer); - Clean(mSHBuffer); - Clean(mSLBuffer); - Clean(lSHBuffer); - Clean(lSLBuffer); - Clean(hSHBuffer); - Clean(hSLBuffer); - } - - // - // Tools ... - bool Init( - string symbol, // Trading Symbol - ENUM_TIMEFRAMES period, // Trading Period - XCHSwingsInputs &inputs // Inputs - ) - { - // - bool result = false; - - // - mSymbol = symbol; - mPeriod = period; - - // - result = inputs.IsValid(); - if (!result) - { - return result; - } - - // - mInputs = inputs; - - // - ArraySetAsSeries(cSHBuffer, true); - ArraySetAsSeries(cSLBuffer, true); - ArraySetAsSeries(sSHBuffer, true); - ArraySetAsSeries(sSLBuffer, true); - ArraySetAsSeries(mSHBuffer, true); - ArraySetAsSeries(mSLBuffer, true); - ArraySetAsSeries(lSHBuffer, true); - ArraySetAsSeries(lSLBuffer, true); - ArraySetAsSeries(hSHBuffer, true); - ArraySetAsSeries(hSLBuffer, true); - - // - mHandler = iCustom( - mSymbol, - mPeriod, - "x-saherelm.xchswings", - // - // Inputs ... - // - // Market ... - "", - mInputs.length, // Length - // - // Cycles ... - "", - // - // Short ... - "", - mInputs.scMethod, - mInputs.scPeriod, - // - // Medium ... - "", - mInputs.mcMethod, - mInputs.mcPeriod, - // - // Long ... - "", - mInputs.lcMethod, - mInputs.lcPeriod, - // - // Hind ... - "", - mInputs.hcMethod, - mInputs.hcPeriod, - // - // Presentation ... - "", - mInputs.showSwingHighs, - mInputs.showSwingLows, - mInputs.showCurrent, - mInputs.showShort, - mInputs.showMedium, - mInputs.showLong, - mInputs.showHind - // - ); - result = mHandler != INVALID_HANDLE; - if (!result) - { - return result; - } - - // - return result; - } - - // - // Inputs ... - - // - XCHSwingsInputs GetInputs() - { - return mInputs; - } - - // - bool SetInputs( - XCHSwingsInputs &inputs // Configs - ) - { - // - return Init( - mSymbol, - mPeriod, - inputs - // - ); - } - - // - // Buffers ... - - // - // Current ... - - // - double GetCSH( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return cSHBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyCSH( - 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, - cSHBuffer, - buffer, - forceClean - // - ); - } - - // - double GetCSL( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return cSLBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyCSL( - 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, - cSLBuffer, - buffer, - forceClean - // - ); - } - - // - // Short ... - - // - double GetSSH( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return sSHBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopySSH( - 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, - sSHBuffer, - buffer, - forceClean - // - ); - } - - // - double GetSSL( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return sSLBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopySSL( - 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, - sSLBuffer, - buffer, - forceClean - // - ); - } - - // - // Medium ... - - // - double GetMSH( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return mSHBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyMSH( - 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, - mSHBuffer, - buffer, - forceClean - // - ); - } - - // - double GetMSL( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return mSLBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyMSL( - 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, - mSLBuffer, - buffer, - forceClean - // - ); - } - - // - // Long ... - - // - double GetLSH( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return lSHBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyLSH( - 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, - lSHBuffer, - buffer, - forceClean - // - ); - } - - // - double GetLSL( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return lSLBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyLSL( - 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, - lSLBuffer, - buffer, - forceClean - // - ); - } - - // - // Hind ... - - // - double GetHSH( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return hSHBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyHSH( - 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, - hSHBuffer, - buffer, - forceClean - // - ); - } - - // - double GetHSL( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return hSLBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyHSL( - 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, - hSLBuffer, - buffer, - forceClean - // - ); - } - - // - // Tools ... - - // - // Conditions ... - - // - bool GetConditions( - XCHSwingsConditions &conditions, // - int barIndex = 0, // - int loopback = 5 // - ) - { - // - bool result = true; - - // - if (loopback < 5) - { - loopback = 5; - } - - // - conditions.Clean(); - - // - conditions.symbol = mSymbol; - conditions.period = mPeriod; - conditions.time = TimeCurrent(); - - // - int zIndex = barIndex; - int cIndex = zIndex + 1; - int pIndex = cIndex + 1; - int ppIndex = pIndex + 1; - - // - // Buffers ... - - // - // Current ... - CopyCSH( - zIndex, - loopback, - conditions.cSH // - ); - CopyCSL( - zIndex, - loopback, - conditions.cSL // - ); - - // - // Short ... - CopySSH( - zIndex, - loopback, - conditions.sSH // - ); - CopySSL( - zIndex, - loopback, - conditions.sSL // - ); - - // - // Medium ... - CopyMSH( - zIndex, - loopback, - conditions.mSH // - ); - CopyMSL( - zIndex, - loopback, - conditions.mSL // - ); - - // - // Long ... - CopyLSH( - zIndex, - loopback, - conditions.lSH // - ); - CopyLSL( - zIndex, - loopback, - conditions.lSL // - ); - - // - // Hind ... - CopyHSH( - zIndex, - loopback, - conditions.hSH // - ); - CopyHSL( - zIndex, - loopback, - conditions.hSL // - ); - - // - // Conditions ... - - // - XOHCL cBar; - result = cBar.Init( - mSymbol, - mPeriod, - cIndex // - ); - if (!result) - { - return result; - } - - // - XOHCL pBar; - result = pBar.Init( - mSymbol, - mPeriod, - pIndex // - ); - if (!result) - { - return result; - } - - // - // Current ... - - // - bool isCSwingHigh = - cSHBuffer[cIndex] != 0 && - cSHBuffer[cIndex] != EMPTY_VALUE; - - // - bool isCSwingLow = - cSLBuffer[cIndex] != 0 && - cSLBuffer[cIndex] != EMPTY_VALUE; - - // - conditions.isCSwingHigh = isCSwingHigh; - conditions.isCSwingLow = isCSwingLow; - - // - // Short ... - - // - bool isSSwingHigh = - sSHBuffer[cIndex] != 0 && - sSHBuffer[cIndex] != EMPTY_VALUE; - - // - bool isSSwingLow = - sSLBuffer[cIndex] != 0 && - sSLBuffer[cIndex] != EMPTY_VALUE; - - // - conditions.isSSwingHigh = isSSwingHigh; - conditions.isSSwingLow = isSSwingLow; - - // - // Medium ... - - // - bool isMSwingHigh = - mSHBuffer[cIndex] != 0 && - mSHBuffer[cIndex] != EMPTY_VALUE; - - // - bool isMSwingLow = - mSLBuffer[cIndex] != 0 && - mSLBuffer[cIndex] != EMPTY_VALUE; - - // - conditions.isMSwingHigh = isMSwingHigh; - conditions.isMSwingLow = isMSwingLow; - - // - // Long ... - - // - bool isLSwingHigh = - lSHBuffer[cIndex] != 0 && - lSHBuffer[cIndex] != EMPTY_VALUE; - - // - bool isLSwingLow = - lSLBuffer[cIndex] != 0 && - lSLBuffer[cIndex] != EMPTY_VALUE; - - // - conditions.isLSwingHigh = isLSwingHigh; - conditions.isLSwingLow = isLSwingLow; - - // - // Hind ... - - // - bool isHSwingHigh = - hSHBuffer[cIndex] != 0 && - hSHBuffer[cIndex] != EMPTY_VALUE; - - // - bool isHSwingLow = - hSLBuffer[cIndex] != 0 && - hSLBuffer[cIndex] != EMPTY_VALUE; - - // - conditions.isHSwingHigh = isHSwingHigh; - conditions.isHSwingLow = isHSwingLow; - - // - return result; - } - - // - // Protected ... -protected: - // - // Private ... -private: - // - // Props ... - XCHSwingsInputs mInputs; // Inputs ... - - // - // Buffers ... - - // - // Current ... - double cSHBuffer[]; - double cSLBuffer[]; - - // - double sSHBuffer[]; - double sSLBuffer[]; - // Short ... - - // - // Medium ... - double mSHBuffer[]; - double mSLBuffer[]; - - // - // Long ... - double lSHBuffer[]; - double lSLBuffer[]; - - // - // Hind ... - double hSHBuffer[]; - double hSLBuffer[]; - - // - // Tools ... - - // - // Calculate Values Until Now ... - void Calculate() - { - // - int totalBars = CountBars(); - if (totalBars > 1000) - { - totalBars = 1000; - } - - // - // Current ... - CopyBuffer( - mHandler, - XCHSwings_C_SH_LINE, - 0, - totalBars, - cSHBuffer - // - ); - CopyBuffer( - mHandler, - XCHSwings_C_SL_LINE, - 0, - totalBars, - cSLBuffer - // - ); - - // - // Short ... - CopyBuffer( - mHandler, - XCHSwings_S_SH_LINE, - 0, - totalBars, - sSHBuffer - // - ); - CopyBuffer( - mHandler, - XCHSwings_S_SL_LINE, - 0, - totalBars, - sSLBuffer - // - ); - - // - // Medium ... - CopyBuffer( - mHandler, - XCHSwings_M_SH_LINE, - 0, - totalBars, - mSHBuffer - // - ); - CopyBuffer( - mHandler, - XCHSwings_M_SL_LINE, - 0, - totalBars, - mSLBuffer - // - ); - - // - // Long ... - CopyBuffer( - mHandler, - XCHSwings_L_SH_LINE, - 0, - totalBars, - lSHBuffer - // - ); - CopyBuffer( - mHandler, - XCHSwings_L_SL_LINE, - 0, - totalBars, - lSLBuffer - // - ); - - // - // Hind ... - CopyBuffer( - mHandler, - XCHSwings_H_SH_LINE, - 0, - totalBars, - hSHBuffer - // - ); - CopyBuffer( - mHandler, - XCHSwings_H_SL_LINE, - 0, - totalBars, - hSLBuffer - // - ); - }; -}; - -// \ No newline at end of file diff --git a/Helpers/x-saherelm.xchtd.helper.mq5 b/Helpers/x-saherelm.xchtd.helper.mq5 deleted file mode 100644 index 92ade3ad..00000000 --- a/Helpers/x-saherelm.xchtd.helper.mq5 +++ /dev/null @@ -1,2956 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Helper Class Library -// ---------------------------------------------- -// Name: XSCXCHTDHelper -// 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_XCHTD_MODE -{ - XCHTD_POWER_MODE = 0, // Using Power - XCHTD_PRESSURE_MODE = 1, // Using Pressure - XCHTD_TYPE_MODE = 2, // Using Type - XCHTD_STRONG_MODE = 3, // Using Power and Pressures -}; - -// -enum ENUM_XCHTD_BUFFERS -{ - // - XCHTD_C_BULL_LINE = 0, - XCHTD_C_BEAR_LINE = 1, - // - XCHTD_S_BULL_LINE = 2, - XCHTD_S_BEAR_LINE = 3, - // - XCHTD_M_BULL_LINE = 4, - XCHTD_M_BEAR_LINE = 5, - // - XCHTD_L_BULL_LINE = 6, - XCHTD_L_BEAR_LINE = 7, - // - XCHTD_H_BULL_LINE = 8, - XCHTD_H_BEAR_LINE = 9, -}; - -// -// Input Models ... -struct XCHTDInputs -{ - // - // Props ... - - // - // Market ... - int length; // Length - ENUM_XCHTD_MODE mode; // Mode - - // - // Cycles ... - - // - // Short ... - ENUM_X_PERIOD_METHOD scMethod; // How to Find Period - ENUM_TIMEFRAMES scPeriod; // Time Period - - // - // Medium ... - ENUM_X_PERIOD_METHOD mcMethod; // How to Find Period - ENUM_TIMEFRAMES mcPeriod; // Time Period - - // - // Long ... - ENUM_X_PERIOD_METHOD lcMethod; // How to Find Period - ENUM_TIMEFRAMES lcPeriod; // Time Period - - // - // Hind ... - ENUM_X_PERIOD_METHOD hcMethod; // How to Find Period - ENUM_TIMEFRAMES hcPeriod; // Time Period - - // - // Presentation ... - bool showCurrent; // Show Current Cycle - bool showShort; // Show Short Cycle - bool showMedium; // Show Medium Cycle - bool showLong; // Show Long Cycle - bool showHind; // Show Hind Cycle - - // - // Constructor(s) ... - XCHTDInputs() - { - // - Clean(); - } - - // - // Tools ... - - // - // Clean ... - void Clean() - { - // - length = 0; - mode = XCHTD_POWER_MODE; - - // - scMethod = X_PERIOD_AUTO; - scPeriod = NULL; - mcMethod = X_PERIOD_AUTO; - mcPeriod = NULL; - lcMethod = X_PERIOD_AUTO; - lcPeriod = NULL; - hcMethod = X_PERIOD_AUTO; - hcPeriod = NULL; - - // - showCurrent = false; - showShort = false; - showMedium = false; - showLong = false; - showHind = false; - } - - // - // Default ... - void Default() - { - // - length = 14; - mode = XCHTD_POWER_MODE; - - // - scMethod = X_PERIOD_AUTO; - scPeriod = NULL; - mcMethod = X_PERIOD_AUTO; - mcPeriod = NULL; - lcMethod = X_PERIOD_AUTO; - lcPeriod = NULL; - hcMethod = X_PERIOD_AUTO; - hcPeriod = NULL; - - // - showCurrent = true; - showShort = true; - showMedium = true; - showLong = true; - showHind = true; - } - - // - // Validate ... - bool IsValid() - { - // - bool result = false; - - // - result = - // - length > 0 && - // - (IsValid(scMethod, scPeriod) && - IsValid(mcMethod, mcPeriod) && - IsValid(lcMethod, lcPeriod) && - IsValid(hcMethod, hcPeriod)) - // - ; - - // - return result; - } - - // - // Retrieve MAx Length ... - int Max() - { - // - int result = 0; - - // - result = - // - MathMax(0, length) - // - ; - - // - return result; - } -}; - -// -// Define Conditions ... -struct XCHTDConditions -{ - // - // Common ... - string symbol; - ENUM_TIMEFRAMES period; - datetime time; - - // - // Buffers ... - - // - // Current ... - double cBull[]; - double cBear[]; - - // - // Short ... - double sBull[]; - double sBear[]; - - // - // Medium ... - double mBull[]; - double mBear[]; - - // - // Long ... - double lBull[]; - double lBear[]; - - // - // Hind ... - double hBull[]; - double hBear[]; - - // - // Conditions ... - - // - // Power ... - bool hasBullishPower; - bool hasBearishPower; - bool isBullishPowerUp; - bool isBearishPowerUp; - bool isBullishPowerIncreasing; - bool isBullishPowerDecreasing; - bool isBearishPowerIncreasing; - bool isBearishPowerDecreasing; - - // - // Current ... - bool isCBullish; - bool isCBearish; - bool isCSwitchedToBullish; - bool isCSwitchedToBearish; - - // - // Short ... - bool isSBullish; - bool isSBearish; - bool isSSwitchedToBullish; - bool isSSwitchedToBearish; - - // - // Medium ... - bool isMBullish; - bool isMBearish; - bool isMSwitchedToBullish; - bool isMSwitchedToBearish; - - // - // Long ... - bool isLBullish; - bool isLBearish; - bool isLSwitchedToBullish; - bool isLSwitchedToBearish; - - // - // Hind ... - bool isHBullish; - bool isHBearish; - bool isHSwitchedToBullish; - bool isHSwitchedToBearish; - - // - void Clean() - { - // - Clean(cBull); - Clean(cBear); - Clean(sBull); - Clean(sBear); - Clean(mBull); - Clean(mBear); - Clean(lBull); - Clean(lBear); - Clean(hBull); - Clean(hBear); - - // - ArraySetAsSeries(cBull, true); - ArraySetAsSeries(cBear, true); - ArraySetAsSeries(sBull, true); - ArraySetAsSeries(sBear, true); - ArraySetAsSeries(mBull, true); - ArraySetAsSeries(mBear, true); - ArraySetAsSeries(lBull, true); - ArraySetAsSeries(lBear, true); - ArraySetAsSeries(hBull, true); - ArraySetAsSeries(hBear, true); - - // - // Conditions ... - - // - // Power ... - hasBullishPower = false; - hasBearishPower = false; - isBullishPowerUp = false; - isBearishPowerUp = false; - isBullishPowerIncreasing = false; - isBullishPowerDecreasing = false; - isBearishPowerIncreasing = false; - isBearishPowerDecreasing = false; - - // - // Current ... - isCBullish = false; - isCBearish = false; - isCSwitchedToBullish = false; - isCSwitchedToBearish = false; - - // - // Short ... - isSBullish = false; - isSBearish = false; - isSSwitchedToBullish = false; - isSSwitchedToBearish = false; - - // - // Medium ... - isMBullish = false; - isMBearish = false; - isMSwitchedToBullish = false; - isMSwitchedToBearish = false; - - // - // Long ... - isLBullish = false; - isLBearish = false; - isLSwitchedToBullish = false; - isLSwitchedToBearish = false; - - // - // Hind ... - isHBullish = false; - isHBearish = false; - isHSwitchedToBullish = false; - isHSwitchedToBearish = false; - } - - // - void GenerateScore( - double &bullishScore, - double &bearishScore // - ) - { - // - bullishScore = 0; - bearishScore = 0; - - // - // Since We have to Use this - // Only for Filtering Signals ... - // We Can Ignore Scoring ... - // or Complete this later ... - - // - // Conditions ... - - // - // Power ... - if (hasBullishPower) - { - bullishScore++; - } - if (hasBearishPower) - { - bearishScore++; - } - if (isBullishPowerUp) - { - bullishScore++; - } - if (isBearishPowerUp) - { - bearishScore++; - } - if (isBullishPowerIncreasing) - { - bullishScore++; - } - if (isBullishPowerDecreasing) - { - bearishScore++; - } - if (isBearishPowerIncreasing) - { - bearishScore++; - } - if (isBearishPowerDecreasing) - { - bullishScore++; - } - - // - // Current ... - if (isCBullish) - { - bullishScore++; - } - if (isCBearish) - { - bearishScore++; - } - if (isCSwitchedToBullish) - { - bullishScore++; - } - if (isCSwitchedToBearish) - { - bearishScore++; - } - - // - // Short ... - if (isSBullish) - { - bullishScore++; - } - if (isSBearish) - { - bearishScore++; - } - if (isSSwitchedToBullish) - { - bullishScore++; - } - if (isSSwitchedToBearish) - { - bearishScore++; - } - - // - // Medium ... - if (isMBullish) - { - bullishScore++; - } - if (isMBearish) - { - bearishScore++; - } - if (isMSwitchedToBullish) - { - bullishScore++; - } - if (isMSwitchedToBearish) - { - bearishScore++; - } - - // - // Long ... - if (isLBullish) - { - bullishScore++; - } - if (isLBearish) - { - bearishScore++; - } - if (isLSwitchedToBullish) - { - bullishScore++; - } - if (isLSwitchedToBearish) - { - bearishScore++; - } - - // - // Hind ... - if (isHBullish) - { - bullishScore++; - } - if (isHBearish) - { - bearishScore++; - } - if (isHSwitchedToBullish) - { - bullishScore++; - } - if (isHSwitchedToBearish) - { - bearishScore++; - } - } - - // - string GenerateSummary( - bool onlyCommons = false, - bool onlyConditions = false, - bool includeScores = true, - bool ignoreFalseConditions = true, - string separator = "\n" // - ) - { - // - string result = NULL; - - // - double bullishScore = 0; - double bearishScore = 0; - GenerateScore( - bullishScore, - bearishScore // - ); - - // - string scoresStr = - // - "Scores: " + separator + - "---------------" + separator + - "Bullish: " + ToString(bullishScore) + separator + - "Bearish: " + ToString(bearishScore) + separator + - "" - // - ; - - // - string commonStr = GenerateSpecifiedCommonSummary( - this, - separator, - includeScores // - ); - - // - string conditionsStr = - // - // Power ... - ToString("hasBullishPower", hasBullishPower, ignoreFalseConditions, separator) + - ToString("hasBearishPower", hasBearishPower, ignoreFalseConditions, separator) + - ToString("isBullishPowerUp", isBullishPowerUp, ignoreFalseConditions, separator) + - ToString("isBearishPowerUp", isBearishPowerUp, ignoreFalseConditions, separator) + - ToString("isBullishPowerIncreasing", isBullishPowerIncreasing, ignoreFalseConditions, separator) + - ToString("isBullishPowerDecreasing", isBullishPowerDecreasing, ignoreFalseConditions, separator) + - ToString("isBearishPowerIncreasing", isBearishPowerIncreasing, ignoreFalseConditions, separator) + - ToString("isBearishPowerDecreasing", isBearishPowerDecreasing, ignoreFalseConditions, separator) + - // - // Current ... - ToString("isCBullish", isCBullish, ignoreFalseConditions, separator) + - ToString("isCBearish", isCBearish, ignoreFalseConditions, separator) + - ToString("isCSwitchedToBullish", isCSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isCSwitchedToBearish", isCSwitchedToBearish, ignoreFalseConditions, separator) + - // - // Short ... - ToString("isSBullish", isSBullish, ignoreFalseConditions, separator) + - ToString("isSBearish", isSBearish, ignoreFalseConditions, separator) + - ToString("isSSwitchedToBullish", isSSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isSSwitchedToBearish", isSSwitchedToBearish, ignoreFalseConditions, separator) + - // - // Medium ... - ToString("isMBullish", isMBullish, ignoreFalseConditions, separator) + - ToString("isMBearish", isMBearish, ignoreFalseConditions, separator) + - ToString("isMSwitchedToBullish", isMSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isMSwitchedToBearish", isMSwitchedToBearish, ignoreFalseConditions, separator) + - // - // Long ... - ToString("isLBullish", isLBullish, ignoreFalseConditions, separator) + - ToString("isLBearish", isLBearish, ignoreFalseConditions, separator) + - ToString("isLSwitchedToBullish", isLSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isLSwitchedToBearish", isLSwitchedToBearish, ignoreFalseConditions, separator) + - // - // Hind ... - ToString("isHBullish", isHBullish, ignoreFalseConditions, separator) + - ToString("isHBearish", isHBearish, ignoreFalseConditions, separator) + - ToString("isHSwitchedToBullish", isHSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isHSwitchedToBearish", isHSwitchedToBearish, ignoreFalseConditions, separator) + - // - "" - // - ; - - // - result = - // - "[" + GetTag() + "]" + separator + - (onlyConditions - ? "" - : commonStr) + - (!includeScores - ? "" - : scoresStr) + - " " + separator + - (onlyCommons - ? "" - : conditionsStr) + - "" - // - ; - - // - return result; - } - - // - string GetTag() - { - return "XCHTD"; - } -}; - -// -// Class ... -class XSCXCHTDHelper : public XSCBaseHelper -{ - // - // Public ... -public: - // - // Props ... - - // - // Constructors ... - XSCXCHTDHelper() : XSCBaseHelper(_Symbol, _Period) - { - } - - // - // Deconstructor ... - ~XSCXCHTDHelper() - { - // - Clean(cBullBuffer); - Clean(cBearBuffer); - Clean(sBullBuffer); - Clean(sBearBuffer); - Clean(mBullBuffer); - Clean(mBearBuffer); - Clean(lBullBuffer); - Clean(lBearBuffer); - Clean(hBullBuffer); - Clean(hBearBuffer); - } - - // - // Tools ... - bool Init( - string symbol, // Trading Symbol - ENUM_TIMEFRAMES period, // Trading Period - XCHTDInputs &inputs // Inputs - ) - { - // - bool result = false; - - // - mSymbol = symbol; - mPeriod = period; - - // - result = inputs.IsValid(); - if (!result) - { - return result; - } - - // - mInputs = inputs; - - // - ArraySetAsSeries(cBullBuffer, true); - ArraySetAsSeries(cBearBuffer, true); - ArraySetAsSeries(sBullBuffer, true); - ArraySetAsSeries(sBearBuffer, true); - ArraySetAsSeries(mBullBuffer, true); - ArraySetAsSeries(mBearBuffer, true); - ArraySetAsSeries(lBullBuffer, true); - ArraySetAsSeries(lBearBuffer, true); - ArraySetAsSeries(hBullBuffer, true); - ArraySetAsSeries(hBearBuffer, true); - - // - mHandler = iCustom( - mSymbol, - mPeriod, - "x-saherelm.xchtd", - // - // Inputs ... - // - // Market ... - "", - mInputs.length, // Length - mInputs.mode, // Mode - // - // Cycles ... - "", - // - // Short ... - "", - mInputs.scMethod, - mInputs.scPeriod, - // - // Medium ... - "", - mInputs.mcMethod, - mInputs.mcPeriod, - // - // Long ... - "", - mInputs.lcMethod, - mInputs.lcPeriod, - // - // Hind ... - "", - mInputs.hcMethod, - mInputs.hcPeriod, - // - // Presentation ... - "", - mInputs.showCurrent, - mInputs.showShort, - mInputs.showMedium, - mInputs.showLong, - mInputs.showHind - // - ); - result = mHandler != INVALID_HANDLE; - if (!result) - { - return result; - } - - // - return result; - } - - // - // Inputs ... - - // - XCHTDInputs GetInputs() - { - return mInputs; - } - - // - bool SetInputs( - XCHTDInputs &inputs // Configs - ) - { - // - return Init( - mSymbol, - mPeriod, - inputs - // - ); - } - - // - // Buffers ... - - // - // Current ... - - // - double GetCBull( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return cBullBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyCBull( - 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, - cBullBuffer, - buffer, - forceClean - // - ); - } - - // - double GetCBear( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return cBearBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyCBear( - 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, - cBearBuffer, - buffer, - forceClean - // - ); - } - - // - // Short ... - - // - double GetSBull( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return sBullBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopySBull( - 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, - sBullBuffer, - buffer, - forceClean - // - ); - } - - // - double GetSBear( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return sBearBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopySBear( - 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, - sBearBuffer, - buffer, - forceClean - // - ); - } - - // - // Medium ... - - // - double GetMBull( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return mBullBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyMBull( - 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, - mBullBuffer, - buffer, - forceClean - // - ); - } - - // - double GetMBear( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return mBearBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyMBear( - 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, - mBearBuffer, - buffer, - forceClean - // - ); - } - - // - // Long ... - - // - double GetLBull( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return lBullBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyLBull( - 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, - lBullBuffer, - buffer, - forceClean - // - ); - } - - // - double GetLBear( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return lBearBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyLBear( - 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, - lBearBuffer, - buffer, - forceClean - // - ); - } - - // - // Hind ... - - // - double GetHBull( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return hBullBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyHBull( - 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, - hBullBuffer, - buffer, - forceClean - // - ); - } - - // - double GetHBear( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return hBearBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyHBear( - 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, - hBearBuffer, - buffer, - forceClean - // - ); - } - - // - // Tools ... - - // - void GetCycle( - int barIndex, // Bar Index - double &bull, - double &bear, - ENUM_X_MARKET_CYCLES cycle // - ) - { - // - bull = 0; - bear = 0; - - // - switch (cycle) - { - // - // CURRENT ... - case X_MARKET_CYCLE_UNKNOWN: - // - bull = GetCBull(barIndex); - bear = GetCBear(barIndex); - break; - // - // SHORT ... - case X_MARKET_CYCLE_SHORT: - // - bull = GetSBull(barIndex); - bear = GetSBear(barIndex); - break; - // - // MEDIUM ... - case X_MARKET_CYCLE_MEDIUM: - // - bull = GetMBull(barIndex); - bear = GetMBear(barIndex); - break; - // - // LONG ... - case X_MARKET_CYCLE_LONG: - // - bull = GetLBull(barIndex); - bear = GetLBear(barIndex); - break; - // - // HIND ... - case X_MARKET_CYCLE_HIND: - // - bull = GetHBull(barIndex); - bear = GetHBear(barIndex); - break; - } - } - - // - bool IsCycleBullish( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle // - ) - { - // - bool result = false; - - // - double bull = 0; - double bear = 0; - GetCycle( - barIndex, - bull, - bear, - cycle // - ); - - // - result = bull > bear; - - // - return result; - } - - // - bool IsCycleBearish( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle // - ) - { - // - bool result = false; - - // - double bull = 0; - double bear = 0; - GetCycle( - barIndex, - bull, - bear, - cycle // - ); - - // - result = bull < bear; - - // - return result; - } - - // - double GetCyclePower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle // - ) - { - // - double result = 0; - - // - double bull = 0; - double bear = 0; - GetCycle( - barIndex, - bull, - bear, - cycle // - ); - - // - result = MathAbs(bull - bear); - - // - return result; - } - - // - int GetPowers( - int barIndex, // Bar Index - double &values[] // - ) - { - // - int result = 0; - - // - Clean(values); - - // - ENUM_X_MARKET_CYCLES allCycles[]; - int count = GetAllMarketCycles(allCycles); - if (!IsValidSize(count)) - { - return result; - } - - // - result = GetCyclesPowers( - barIndex, - values, - allCycles // - ); - - // - return result; - } - - // - int GetCyclesPowers( - int barIndex, // Bar Index - double &values[], - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - int result = 0; - - // - Clean(values); - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - double iValue = GetCyclePower( - barIndex, - cycles[i] // - ); - - // - Add( - iValue, - values // - ); - } - - // - result = ArraySize(values); - - // - return result; - } - - // - int GetBullishCycles( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - int result = 0; - - // - Clean(cycles); - - // - ENUM_X_MARKET_CYCLES allCycles[]; - int count = GetAllMarketCycles(allCycles); - if (!IsValidSize(count)) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - bool isBullish = IsCycleBullish( - barIndex, - allCycles[i] // - ); - - // - if (isBullish) - { - // - Add( - allCycles[i], - cycles // - ); - } - } - - // - result = ArraySize(cycles); - - // - return result; - } - - // - int GetBearishCycles( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - int result = 0; - - // - Clean(cycles); - - // - ENUM_X_MARKET_CYCLES allCycles[]; - int count = GetAllMarketCycles(allCycles); - if (!IsValidSize(count)) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - bool isBearish = IsCycleBearish( - barIndex, - allCycles[i] // - ); - - // - if (isBearish) - { - // - Add( - allCycles[i], - cycles // - ); - } - } - - // - result = ArraySize(cycles); - - // - return result; - } - - // - int GetBullishCyclesPowers( - int barIndex, // Bar Index - double &values[] // - ) - { - // - int result = 0; - - // - Clean(values); - - // - ENUM_X_MARKET_CYCLES cycles[]; - int count = GetBullishCycles( - barIndex, - cycles // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = GetCyclesPowers( - barIndex, - values, - cycles // - ); - - // - return result; - } - - // - int GetBearishCyclesPowers( - int barIndex, // Bar Index - double &values[] // - ) - { - // - int result = 0; - - // - Clean(values); - - // - ENUM_X_MARKET_CYCLES cycles[]; - int count = GetBearishCycles( - barIndex, - cycles // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = GetCyclesPowers( - barIndex, - values, - cycles // - ); - - // - return result; - } - - // - double GetMaxPower( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - double values[]; - int count = GetPowers( - barIndex, - values // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetMinPower( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - double values[]; - int count = GetPowers( - barIndex, - values // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetCyclesMaxPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - double values[]; - int count = GetCyclesPowers( - barIndex, - values, - cycles // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetCyclesMinPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - double values[]; - int count = GetCyclesPowers( - barIndex, - values, - cycles // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetMaxBullishPower( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - double values[]; - int count = GetBullishCyclesPowers( - barIndex, - values // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetMinBullishPower( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - double values[]; - int count = GetBullishCyclesPowers( - barIndex, - values // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetMaxBearishPower( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - double values[]; - int count = GetBearishCyclesPowers( - barIndex, - values // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetMinBearishPower( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - double values[]; - int count = GetBearishCyclesPowers( - barIndex, - values // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetBullishPower( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - double values[]; - int count = GetBullishCyclesPowers( - barIndex, - values // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = GetSum(values); - - // - return result; - } - - // - double GetBearishPower( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - double values[]; - int count = GetBearishCyclesPowers( - barIndex, - values // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = GetSum(values); - - // - return result; - } - - // - double GetCyclesBullishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - int cyclesCount = ArraySize(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - bool isBullish = IsCycleBullish( - barIndex, - cycles[i] // - ); - if (isBullish) - { - // - double power = GetCyclePower( - barIndex, - cycles[i] // - ); - - // - result += MathAbs(power); - } - } - - // - return result; - } - - // - double GetCyclesBearishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - int cyclesCount = ArraySize(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - bool isBearish = IsCycleBearish( - barIndex, - cycles[i] // - ); - if (isBearish) - { - // - double power = GetCyclePower( - barIndex, - cycles[i] // - ); - - // - result += MathAbs(power); - } - } - - // - return result; - } - - // - bool HasBullishPower( - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - double bullishPower = GetBullishPower(barIndex); - double bearishPower = GetBearishPower(barIndex); - - // - result = - // - bearishPower >= 0 && - bullishPower > bearishPower - // - ; - - // - return result; - } - - // - bool HasBearishPower( - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - double bullishPower = GetBullishPower(barIndex); - double bearishPower = GetBearishPower(barIndex); - - // - result = - // - bullishPower >= 0 && - bearishPower > bullishPower - // - ; - - // - return result; - } - - // - bool HasCyclesBullishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - bool result = false; - - // - double bullishPower = GetCyclesBullishPower(barIndex, cycles); - double bearishPower = GetCyclesBearishPower(barIndex, cycles); - - // - result = - // - bearishPower >= 0 && - bullishPower > bearishPower - // - ; - - // - return result; - } - - // - bool HasCyclesBearishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - bool result = false; - - // - double bullishPower = GetCyclesBullishPower(barIndex, cycles); - double bearishPower = GetCyclesBearishPower(barIndex, cycles); - - // - result = - // - bullishPower >= 0 && - bearishPower > bullishPower - // - ; - - // - return result; - } - - // - // Check Bullish Power Increasing ... - bool IsBullishPowerIncreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBullishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBullishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bullish Power Decreasing ... - bool IsBullishPowerDecreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBullishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBullishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Increasing ... - bool IsBearishPowerIncreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBearishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBearishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Decreasing ... - bool IsBearishPowerDecreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBearishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBearishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Check Bullish Power Increasing ... - bool IsCyclesBullishPowerIncreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBullishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBullishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bullish Power Decreasing ... - bool IsCyclesBullishPowerDecreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBullishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBullishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Increasing ... - bool IsCyclesBearishPowerIncreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBearishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBearishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Decreasing ... - bool IsCyclesBearishPowerDecreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBearishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBearishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Conditions ... - - // - bool GetConditions( - XCHTDConditions &conditions, // - int barIndex = 0, // - int loopback = 5 // - ) - { - // - bool result = true; - - // - if (loopback < 5) - { - loopback = 5; - } - - // - conditions.Clean(); - - // - conditions.symbol = mSymbol; - conditions.period = mPeriod; - conditions.time = TimeCurrent(); - - // - int zIndex = barIndex; - int cIndex = zIndex + 1; - int pIndex = cIndex + 1; - int ppIndex = pIndex + 1; - - // - // Buffers ... - - // - // Current ... - CopyCBull( - zIndex, - loopback, - conditions.cBull // - ); - CopyCBear( - zIndex, - loopback, - conditions.cBear // - ); - - // - // Short ... - CopySBull( - zIndex, - loopback, - conditions.sBull // - ); - CopySBear( - zIndex, - loopback, - conditions.sBear // - ); - - // - // Medium ... - CopyMBull( - zIndex, - loopback, - conditions.mBull // - ); - CopyMBear( - zIndex, - loopback, - conditions.mBear // - ); - - // - // Long ... - CopyLBull( - zIndex, - loopback, - conditions.lBull // - ); - CopyLBear( - zIndex, - loopback, - conditions.lBear // - ); - - // - // Hind ... - CopyHBull( - zIndex, - loopback, - conditions.hBull // - ); - CopyHBear( - zIndex, - loopback, - conditions.hBear // - ); - - // - // Conditions ... - - // - XOHCL cBar; - result = cBar.Init( - mSymbol, - mPeriod, - cIndex // - ); - if (!result) - { - return result; - } - - // - XOHCL pBar; - result = pBar.Init( - mSymbol, - mPeriod, - pIndex // - ); - if (!result) - { - return result; - } - - // - // Power ... - - // - bool hasBullishPower = HasBullishPower(cIndex); - bool hasBullishPowerPrev = HasBullishPower(pIndex); - - // - bool hasBearishPower = HasBearishPower(cIndex); - bool hasBearishPowerPrev = HasBearishPower(pIndex); - - // - bool isBullishPowerUp = hasBullishPower && - !hasBullishPowerPrev; - bool isBearishPowerUp = hasBearishPower && - !hasBearishPowerPrev; - - // - bool isBullishPowerIncreasing = IsBullishPowerIncreasing(cIndex); - bool isBullishPowerDecreasing = IsBullishPowerDecreasing(cIndex); - bool isBearishPowerIncreasing = IsBearishPowerIncreasing(cIndex); - bool isBearishPowerDecreasing = IsBearishPowerDecreasing(cIndex); - - // - conditions.hasBullishPower = hasBullishPower; - conditions.hasBearishPower = hasBearishPower; - conditions.isBullishPowerUp = isBullishPowerUp; - conditions.isBearishPowerUp = isBearishPowerUp; - conditions.isBullishPowerIncreasing = isBullishPowerIncreasing; - conditions.isBullishPowerDecreasing = isBullishPowerDecreasing; - conditions.isBearishPowerIncreasing = isBearishPowerIncreasing; - conditions.isBearishPowerDecreasing = isBearishPowerDecreasing; - - // - // Current ... - - // - bool isCBullish = conditions.cBull[cIndex] > conditions.cBear[cIndex]; - bool isCBullishPrev = conditions.cBull[pIndex] > conditions.cBear[pIndex]; - - // - bool isCBearish = conditions.cBull[cIndex] < conditions.cBear[cIndex]; - bool isCBearishPrev = conditions.cBull[pIndex] < conditions.cBear[pIndex]; - - // - bool isCSwitchedToBullish = isCBullish && - !isCBullishPrev; - bool isCSwitchedToBearish = isCBearish && - !isCBearishPrev; - - // - conditions.isCBullish = isCBullish; - conditions.isCBearish = isCBearish; - conditions.isCSwitchedToBullish = isCSwitchedToBullish; - conditions.isCSwitchedToBearish = isCSwitchedToBearish; - - // - // Short ... - - // - bool isSBullish = conditions.sBull[cIndex] > conditions.sBear[cIndex]; - bool isSBullishPrev = conditions.sBull[pIndex] > conditions.sBear[pIndex]; - - // - bool isSBearish = conditions.sBull[cIndex] < conditions.sBear[cIndex]; - bool isSBearishPrev = conditions.sBull[pIndex] < conditions.sBear[pIndex]; - - // - bool isSSwitchedToBullish = isSBullish && - !isSBullishPrev; - bool isSSwitchedToBearish = isSBearish && - !isSBearishPrev; - - // - conditions.isSBullish = isSBullish; - conditions.isSBearish = isSBearish; - conditions.isSSwitchedToBullish = isSSwitchedToBullish; - conditions.isSSwitchedToBearish = isSSwitchedToBearish; - - // - // Medium ... - - // - bool isMBullish = conditions.mBull[cIndex] > conditions.mBear[cIndex]; - bool isMBullishPrev = conditions.mBull[pIndex] > conditions.mBear[pIndex]; - - // - bool isMBearish = conditions.mBull[cIndex] < conditions.mBear[cIndex]; - bool isMBearishPrev = conditions.mBull[pIndex] < conditions.mBear[pIndex]; - - // - bool isMSwitchedToBullish = isMBullish && - !isMBullishPrev; - bool isMSwitchedToBearish = isMBearish && - !isMBearishPrev; - - // - conditions.isMBullish = isMBullish; - conditions.isMBearish = isMBearish; - conditions.isMSwitchedToBullish = isMSwitchedToBullish; - conditions.isMSwitchedToBearish = isMSwitchedToBearish; - - // - // Long ... - - // - bool isLBullish = conditions.lBull[cIndex] > conditions.lBear[cIndex]; - bool isLBullishPrev = conditions.lBull[pIndex] > conditions.lBear[pIndex]; - - // - bool isLBearish = conditions.lBull[cIndex] < conditions.lBear[cIndex]; - bool isLBearishPrev = conditions.lBull[pIndex] < conditions.lBear[pIndex]; - - // - bool isLSwitchedToBullish = isLBullish && - !isLBullishPrev; - bool isLSwitchedToBearish = isLBearish && - !isLBearishPrev; - - // - conditions.isLBullish = isLBullish; - conditions.isLBearish = isLBearish; - conditions.isLSwitchedToBullish = isLSwitchedToBullish; - conditions.isLSwitchedToBearish = isLSwitchedToBearish; - - // - // Hind ... - - // - bool isHBullish = conditions.hBull[cIndex] > conditions.hBear[cIndex]; - bool isHBullishPrev = conditions.hBull[pIndex] > conditions.hBear[pIndex]; - - // - bool isHBearish = conditions.hBull[cIndex] < conditions.hBear[cIndex]; - bool isHBearishPrev = conditions.hBull[pIndex] < conditions.hBear[pIndex]; - - // - bool isHSwitchedToBullish = isHBullish && - !isHBullishPrev; - bool isHSwitchedToBearish = isHBearish && - !isHBearishPrev; - - // - conditions.isHBullish = isHBullish; - conditions.isHBearish = isHBearish; - conditions.isHSwitchedToBullish = isHSwitchedToBullish; - conditions.isHSwitchedToBearish = isHSwitchedToBearish; - - // - return result; - } - - // - // Protected ... -protected: - // - // Private ... -private: - // - // Props ... - XCHTDInputs mInputs; // Inputs ... - - // - // Buffers ... - - // - // Current ... - double cBullBuffer[]; - double cBearBuffer[]; - - // - // Short ... - double sBullBuffer[]; - double sBearBuffer[]; - - // - // Medium ... - double mBullBuffer[]; - double mBearBuffer[]; - - // - // Long ... - double lBullBuffer[]; - double lBearBuffer[]; - - // - // Hind ... - double hBullBuffer[]; - double hBearBuffer[]; - - // - // Tools ... - - // - // Calculate Values Until Now ... - void Calculate() - { - // - int totalBars = CountBars(); - if (totalBars > 1000) - { - totalBars = 1000; - } - - // - // Current ... - - // - // Bull ... - CopyBuffer( - mHandler, - XCHTD_C_BULL_LINE, - 0, - totalBars, - cBullBuffer - // - ); - - // - // Bear ... - CopyBuffer( - mHandler, - XCHTD_C_BEAR_LINE, - 0, - totalBars, - cBearBuffer - // - ); - - // - // Short ... - - // - // Bull ... - CopyBuffer( - mHandler, - XCHTD_S_BULL_LINE, - 0, - totalBars, - sBullBuffer - // - ); - - // - // Bear ... - CopyBuffer( - mHandler, - XCHTD_S_BEAR_LINE, - 0, - totalBars, - sBearBuffer - // - ); - - // - // Medium ... - - // - // Bull ... - CopyBuffer( - mHandler, - XCHTD_M_BULL_LINE, - 0, - totalBars, - mBullBuffer - // - ); - - // - // Bear ... - CopyBuffer( - mHandler, - XCHTD_M_BEAR_LINE, - 0, - totalBars, - mBearBuffer - // - ); - - // - // Long ... - - // - // Bull ... - CopyBuffer( - mHandler, - XCHTD_L_BULL_LINE, - 0, - totalBars, - lBullBuffer - // - ); - - // - // Bear ... - CopyBuffer( - mHandler, - XCHTD_L_BEAR_LINE, - 0, - totalBars, - lBearBuffer - // - ); - - // - // Hind ... - - // - // Bull ... - CopyBuffer( - mHandler, - XCHTD_H_BULL_LINE, - 0, - totalBars, - hBullBuffer - // - ); - - // - // Bear ... - CopyBuffer( - mHandler, - XCHTD_H_BEAR_LINE, - 0, - totalBars, - hBearBuffer - // - ); - }; -}; - -// \ No newline at end of file diff --git a/Helpers/x-saherelm.xchvlm.helper.mq5 b/Helpers/x-saherelm.xchvlm.helper.mq5 deleted file mode 100644 index e4bc4c82..00000000 --- a/Helpers/x-saherelm.xchvlm.helper.mq5 +++ /dev/null @@ -1,2465 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Helper Class Library -// ---------------------------------------------- -// Name: XSCXCHVLMHelper -// 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_XCHVLM_BUFFERS -{ - // - XCHVLM_C_LINE = 0, - // - XCHVLM_S_LINE = 2, - // - XCHVLM_M_LINE = 4, - // - XCHVLM_L_LINE = 6, - // - XCHVLM_H_LINE = 8, -}; - -// -enum ENUM_XCHVLM_STATES -{ - // - XCHVLM_BULLISH_STATE = 0, - XCHVLM_BEARISH_STATE = 1, -}; - -// -// Input Models ... -struct XCHVLMInputs -{ - // - // Props ... - - // - // Market ... - int length; // Length - - // - // Cycles ... - - // - // Short ... - ENUM_X_PERIOD_METHOD scMethod; // How to Find Period - ENUM_TIMEFRAMES scPeriod; // Time Period - - // - // Medium ... - ENUM_X_PERIOD_METHOD mcMethod; // How to Find Period - ENUM_TIMEFRAMES mcPeriod; // Time Period - - // - // Long ... - ENUM_X_PERIOD_METHOD lcMethod; // How to Find Period - ENUM_TIMEFRAMES lcPeriod; // Time Period - - // - // Hind ... - ENUM_X_PERIOD_METHOD hcMethod; // How to Find Period - ENUM_TIMEFRAMES hcPeriod; // Time Period - - // - // Presentation ... - bool showCurrent; // Show Current Cycle - bool showShort; // Show Short Cycle - bool showMedium; // Show Medium Cycle - bool showLong; // Show Long Cycle - bool showHind; // Show Hind Cycle - - // - // Constructor(s) ... - XCHVLMInputs() - { - // - Clean(); - } - - // - // Tools ... - - // - // Clean ... - void Clean() - { - // - length = 0; - - // - scMethod = X_PERIOD_AUTO; - scPeriod = NULL; - mcMethod = X_PERIOD_AUTO; - mcPeriod = NULL; - lcMethod = X_PERIOD_AUTO; - lcPeriod = NULL; - hcMethod = X_PERIOD_AUTO; - hcPeriod = NULL; - - // - showCurrent = false; - showShort = false; - showMedium = false; - showLong = false; - showHind = false; - } - - // - // Default ... - void Default() - { - // - length = 14; - - // - scMethod = X_PERIOD_AUTO; - scPeriod = NULL; - mcMethod = X_PERIOD_AUTO; - mcPeriod = NULL; - lcMethod = X_PERIOD_AUTO; - lcPeriod = NULL; - hcMethod = X_PERIOD_AUTO; - hcPeriod = NULL; - - // - showCurrent = true; - showShort = true; - showMedium = true; - showLong = true; - showHind = true; - } - - // - // Validate ... - bool IsValid() - { - // - bool result = false; - - // - result = - // - length > 0 && - // - (IsValid(scMethod, scPeriod) && - IsValid(mcMethod, mcPeriod) && - IsValid(lcMethod, lcPeriod) && - IsValid(hcMethod, hcPeriod)) - // - ; - - // - return result; - } - - // - // Retrieve MAx Length ... - int Max() - { - // - int result = 0; - - // - result = - // - MathMax(0, length) - // - ; - - // - return result; - } -}; - -// -// Define Conditions ... -struct XCHVLMConditions -{ - // - // Common ... - string symbol; - ENUM_TIMEFRAMES period; - datetime time; - - // - // Buffers ... - - // - // Current ... - double cVolume[]; - - // - // Short ... - double sVolume[]; - - // - // Medium ... - double mVolume[]; - - // - // Long ... - double lVolume[]; - - // - // Hind ... - double hVolume[]; - - // - // Conditions ... - // - // Power ... - bool hasBullishPower; - bool hasBearishPower; - bool isBullishPowerUp; - bool isBearishPowerUp; - bool isBullishPowerIncreasing; - bool isBullishPowerDecreasing; - bool isBearishPowerIncreasing; - bool isBearishPowerDecreasing; - - // - // Current ... - bool isCBullish; - bool isCBearish; - bool isCSwitchedToBullish; - bool isCSwitchedToBearish; - - // - // Short ... - bool isSBullish; - bool isSBearish; - bool isSSwitchedToBullish; - bool isSSwitchedToBearish; - - // - // Medium ... - bool isMBullish; - bool isMBearish; - bool isMSwitchedToBullish; - bool isMSwitchedToBearish; - - // - // Long ... - bool isLBullish; - bool isLBearish; - bool isLSwitchedToBullish; - bool isLSwitchedToBearish; - - // - // Hind ... - bool isHBullish; - bool isHBearish; - bool isHSwitchedToBullish; - bool isHSwitchedToBearish; - - // - void Clean() - { - // - Clean(cVolume); - Clean(sVolume); - Clean(mVolume); - Clean(lVolume); - Clean(hVolume); - - // - ArraySetAsSeries(cVolume, true); - ArraySetAsSeries(sVolume, true); - ArraySetAsSeries(mVolume, true); - ArraySetAsSeries(lVolume, true); - ArraySetAsSeries(hVolume, true); - - // - // Conditions ... - - // - // Power ... - hasBullishPower = false; - hasBearishPower = false; - isBullishPowerUp = false; - isBearishPowerUp = false; - isBullishPowerIncreasing = false; - isBullishPowerDecreasing = false; - isBearishPowerIncreasing = false; - isBearishPowerDecreasing = false; - - // - // Current ... - isCBullish = false; - isCBearish = false; - isCSwitchedToBullish = false; - isCSwitchedToBearish = false; - - // - // Short ... - isSBullish = false; - isSBearish = false; - isSSwitchedToBullish = false; - isSSwitchedToBearish = false; - - // - // Medium ... - isMBullish = false; - isMBearish = false; - isMSwitchedToBullish = false; - isMSwitchedToBearish = false; - - // - // Long ... - isLBullish = false; - isLBearish = false; - isLSwitchedToBullish = false; - isLSwitchedToBearish = false; - - // - // Hind ... - isHBullish = false; - isHBearish = false; - isHSwitchedToBullish = false; - isHSwitchedToBearish = false; - } - - // - void GenerateScore( - double &bullishScore, - double &bearishScore // - ) - { - // - bullishScore = 0; - bearishScore = 0; - - // - // Since We have to Use this - // Only for Filtering Signals ... - // We Can Ignore Scoring ... - // or Complete this later ... - - // - // Conditions ... - - // - // Power ... - if (hasBullishPower) - { - bullishScore++; - } - if (hasBearishPower) - { - bearishScore++; - } - if (isBullishPowerUp) - { - bullishScore++; - } - if (isBearishPowerUp) - { - bearishScore++; - } - if (isBullishPowerIncreasing) - { - bullishScore++; - } - if (isBullishPowerDecreasing) - { - bearishScore++; - } - if (isBearishPowerIncreasing) - { - bearishScore++; - } - if (isBearishPowerDecreasing) - { - bullishScore++; - } - - // - // Current ... - if (isCBullish) - { - bullishScore++; - } - if (isCBearish) - { - bearishScore++; - } - if (isCSwitchedToBullish) - { - bullishScore++; - } - if (isCSwitchedToBearish) - { - bearishScore++; - } - - // - // Short ... - if (isSBullish) - { - bullishScore++; - } - if (isSBearish) - { - bearishScore++; - } - if (isSSwitchedToBullish) - { - bullishScore++; - } - if (isSSwitchedToBearish) - { - bearishScore++; - } - - // - // Medium ... - if (isMBullish) - { - bullishScore++; - } - if (isMBearish) - { - bearishScore++; - } - if (isMSwitchedToBullish) - { - bullishScore++; - } - if (isMSwitchedToBearish) - { - bearishScore++; - } - - // - // Long ... - if (isLBullish) - { - bullishScore++; - } - if (isLBearish) - { - bearishScore++; - } - if (isLSwitchedToBullish) - { - bullishScore++; - } - if (isLSwitchedToBearish) - { - bearishScore++; - } - - // - // Hind ... - if (isHBullish) - { - bullishScore++; - } - if (isHBearish) - { - bearishScore++; - } - if (isHSwitchedToBullish) - { - bullishScore++; - } - if (isHSwitchedToBearish) - { - bearishScore++; - } - } - - // - string GenerateSummary( - bool onlyCommons = false, - bool onlyConditions = false, - bool includeScores = true, - bool ignoreFalseConditions = true, - string separator = "\n" // - ) - { - // - string result = NULL; - - // - double bullishScore = 0; - double bearishScore = 0; - GenerateScore( - bullishScore, - bearishScore // - ); - - // - string scoresStr = - // - "Scores: " + separator + - "---------------" + separator + - "Bullish: " + ToString(bullishScore) + separator + - "Bearish: " + ToString(bearishScore) + separator + - "" - // - ; - - // - string commonStr = GenerateSpecifiedCommonSummary( - this, - separator, - includeScores // - ); - - // - string conditionsStr = - // - // Power ... - ToString("hasBullishPower", hasBullishPower, ignoreFalseConditions, separator) + - ToString("hasBearishPower", hasBearishPower, ignoreFalseConditions, separator) + - ToString("isBullishPowerUp", isBullishPowerUp, ignoreFalseConditions, separator) + - ToString("isBearishPowerUp", isBearishPowerUp, ignoreFalseConditions, separator) + - ToString("isBullishPowerIncreasing", isBullishPowerIncreasing, ignoreFalseConditions, separator) + - ToString("isBullishPowerDecreasing", isBullishPowerDecreasing, ignoreFalseConditions, separator) + - ToString("isBearishPowerIncreasing", isBearishPowerIncreasing, ignoreFalseConditions, separator) + - ToString("isBearishPowerDecreasing", isBearishPowerDecreasing, ignoreFalseConditions, separator) + - // - // Current ... - ToString("isCBullish", isCBullish, ignoreFalseConditions, separator) + - ToString("isCBearish", isCBearish, ignoreFalseConditions, separator) + - ToString("isCSwitchedToBullish", isCSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isCSwitchedToBearish", isCSwitchedToBearish, ignoreFalseConditions, separator) + - // - // Short ... - ToString("isSBullish", isSBullish, ignoreFalseConditions, separator) + - ToString("isSBearish", isSBearish, ignoreFalseConditions, separator) + - ToString("isSSwitchedToBullish", isSSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isSSwitchedToBearish", isSSwitchedToBearish, ignoreFalseConditions, separator) + - // - // Medium ... - ToString("isMBullish", isMBullish, ignoreFalseConditions, separator) + - ToString("isMBearish", isMBearish, ignoreFalseConditions, separator) + - ToString("isMSwitchedToBullish", isMSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isMSwitchedToBearish", isMSwitchedToBearish, ignoreFalseConditions, separator) + - // - // Long ... - ToString("isLBullish", isLBullish, ignoreFalseConditions, separator) + - ToString("isLBearish", isLBearish, ignoreFalseConditions, separator) + - ToString("isLSwitchedToBullish", isLSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isLSwitchedToBearish", isLSwitchedToBearish, ignoreFalseConditions, separator) + - // - // Hind ... - ToString("isHBullish", isHBullish, ignoreFalseConditions, separator) + - ToString("isHBearish", isHBearish, ignoreFalseConditions, separator) + - ToString("isHSwitchedToBullish", isHSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isHSwitchedToBearish", isHSwitchedToBearish, ignoreFalseConditions, separator) + - // - "" - // - ; - - // - result = - // - "[" + GetTag() + "]" + separator + - (onlyConditions - ? "" - : commonStr) + - (!includeScores - ? "" - : scoresStr) + - " " + separator + - (onlyCommons - ? "" - : conditionsStr) + - "" - // - ; - - // - return result; - } - - // - string GetTag() - { - return "XCHVLM"; - } -}; - -// -// Class ... -class XSCXCHVLMHelper : public XSCBaseHelper -{ - // - // Public ... -public: - // - // Props ... - - // - // Constructors ... - XSCXCHVLMHelper() : XSCBaseHelper(_Symbol, _Period) - { - } - - // - // Deconstructor ... - ~XSCXCHVLMHelper() - { - // - Clean(cVolumeBuffer); - Clean(sVolumeBuffer); - Clean(mVolumeBuffer); - Clean(lVolumeBuffer); - Clean(hVolumeBuffer); - } - - // - // Tools ... - bool Init( - string symbol, // Trading Symbol - ENUM_TIMEFRAMES period, // Trading Period - XCHVLMInputs &inputs // Inputs - ) - { - // - bool result = false; - - // - mSymbol = symbol; - mPeriod = period; - - // - result = inputs.IsValid(); - if (!result) - { - return result; - } - - // - mInputs = inputs; - - // - ArraySetAsSeries(cVolumeBuffer, true); - ArraySetAsSeries(sVolumeBuffer, true); - ArraySetAsSeries(mVolumeBuffer, true); - ArraySetAsSeries(lVolumeBuffer, true); - ArraySetAsSeries(hVolumeBuffer, true); - - // - mHandler = iCustom( - mSymbol, - mPeriod, - "x-saherelm.xchvlm", - // - // Inputs ... - // - // Market ... - "", - mInputs.length, // Length - // - // Cycles ... - "", - // - // Short ... - "", - mInputs.scMethod, - mInputs.scPeriod, - // - // Medium ... - "", - mInputs.mcMethod, - mInputs.mcPeriod, - // - // Long ... - "", - mInputs.lcMethod, - mInputs.lcPeriod, - // - // Hind ... - "", - mInputs.hcMethod, - mInputs.hcPeriod, - // - // Presentation ... - "", - mInputs.showCurrent, - mInputs.showShort, - mInputs.showMedium, - mInputs.showLong, - mInputs.showHind - // - ); - result = mHandler != INVALID_HANDLE; - if (!result) - { - return result; - } - - // - return result; - } - - // - // Inputs ... - - // - XCHVLMInputs GetInputs() - { - return mInputs; - } - - // - bool SetInputs( - XCHVLMInputs &inputs // Configs - ) - { - // - return Init( - mSymbol, - mPeriod, - inputs - // - ); - } - - // - // Buffers ... - - // - // Current ... - - // - double GetC( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return cVolumeBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyC( - 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, - cVolumeBuffer, - buffer, - forceClean - // - ); - } - - // - // Short ... - - // - double GetS( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return sVolumeBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyS( - 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, - sVolumeBuffer, - buffer, - forceClean - // - ); - } - - // - // Medium ... - - // - double GetM( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return mVolumeBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyM( - 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, - mVolumeBuffer, - buffer, - forceClean - // - ); - } - - // - // Long ... - - // - double GetL( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return lVolumeBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyL( - 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, - lVolumeBuffer, - buffer, - forceClean - // - ); - } - - // - // Hind ... - - // - double GetH( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return hVolumeBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyH( - 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, - hVolumeBuffer, - buffer, - forceClean - // - ); - } - - // - // Tools ... - - // - ENUM_XCHVLM_STATES ToState(double value) - { - // - ENUM_XCHVLM_STATES result = value >= 0 - ? XCHVLM_BULLISH_STATE - : XCHVLM_BEARISH_STATE; - - // - return result; - } - - // - bool IsBullish(double value) - { - // - bool result = false; - - // - result = - // - ToState(value) == XCHVLM_BULLISH_STATE; - // - ; - - // - return result; - } - - // - bool IsBearish(double value) - { - // - bool result = false; - - // - result = - // - ToState(value) == XCHVLM_BEARISH_STATE; - // - ; - - // - return result; - } - - // - int GetValues( - int barIndex, // Bar Index - double &values[] // Result - ) - { - // - int result = 0; - - // - Clean(values); - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetAllMarketCycles(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double iValue = GetCycleValue( - barIndex, - cycles[i] // - ); - - // - Add( - iValue, - values // - ); - } - - // - result = ArraySize(values); - - // - return result; - } - - // - double GetCycleValue( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle // Cycle - ) - { - // - double result = 0; - - // - switch (cycle) - { - // - // CURRENT ... - case X_MARKET_CYCLE_UNKNOWN: - result = GetC(barIndex); - break; - - // - // SHORT ... - case X_MARKET_CYCLE_SHORT: - result = GetS(barIndex); - break; - - // - // MEDIUM ... - case X_MARKET_CYCLE_MEDIUM: - result = GetM(barIndex); - break; - - // - // LONG ... - case X_MARKET_CYCLE_LONG: - result = GetL(barIndex); - break; - - // - // HIND ... - case X_MARKET_CYCLE_HIND: - result = GetH(barIndex); - break; - } - - // - return result; - } - - // - int GetBullishCycles( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - int result = 0; - - // - Clean(cycles); - - // - ENUM_X_MARKET_CYCLES allCycles[]; - int allCyclesCount = GetAllMarketCycles(allCycles); - if (!IsValidSize(allCyclesCount)) - { - return result; - } - - // - for (int i = 0; i < allCyclesCount; i++) - { - // - double cValue = GetCycleValue( - barIndex, - allCycles[i] // - ); - - // - if (IsBullish(cValue)) - { - // - Add( - allCycles[i], - cycles // - ); - } - } - - // - result = ArraySize(cycles); - - // - return result; - } - - // - int GetBearishCycles( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - int result = 0; - - // - Clean(cycles); - - // - ENUM_X_MARKET_CYCLES allCycles[]; - int allCyclesCount = GetAllMarketCycles(allCycles); - if (!IsValidSize(allCyclesCount)) - { - return result; - } - - // - for (int i = 0; i < allCyclesCount; i++) - { - // - double cValue = GetCycleValue( - barIndex, - allCycles[i] // - ); - - // - if (IsBearish(cValue)) - { - // - Add( - allCycles[i], - cycles // - ); - } - } - - // - result = ArraySize(cycles); - - // - return result; - } - - // - int GetCyclesValues( - int barIndex, // Bar Index - double &values[], // Values - ENUM_X_MARKET_CYCLES &cycles[] // Cycles - ) - { - // - int result = 0; - - // - Clean(values); - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - double iValue = GetCycleValue( - barIndex, - cycles[i] // - ); - - // - Add( - iValue, - values // - ); - } - - // - result = ArraySize(values); - - // - return result; - } - - // - int GetBullishCyclesValues( - int barIndex, // Bar Index - double &values[] // Values - ) - { - // - int result = 0; - - // - Clean(values); - - // - ENUM_X_MARKET_CYCLES cycles[]; - int count = GetBullishCycles( - barIndex, - cycles // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = GetCyclesValues( - barIndex, - values, - cycles // - ); - - // - return result; - } - - // - int GetBearishCyclesValues( - int barIndex, // Bar Index - double &values[] // Values - ) - { - // - int result = 0; - - // - Clean(values); - - // - ENUM_X_MARKET_CYCLES cycles[]; - int count = GetBearishCycles( - barIndex, - cycles // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = GetCyclesValues( - barIndex, - values, - cycles // - ); - - // - return result; - } - - // - double GetCyclesMax( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Cycles - ) - { - // - double result = 0; - - // - double values[]; - int count = GetCyclesValues( - barIndex, - values, - cycles // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetCyclesMin( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Cycles - ) - { - // - double result = 0; - - // - double values[]; - int count = GetCyclesValues( - barIndex, - values, - cycles // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetMax( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - double values[]; - int valuesCount = GetValues( - barIndex, - values // - ); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetMin( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - double values[]; - int valuesCount = GetValues( - barIndex, - values // - ); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetBullishPower( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - double values[]; - int count = GetBullishCyclesValues( - barIndex, - values // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = MathAbs(GetSum(values)); - - // - return result; - } - - // - double GetBearishPower( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - double values[]; - int count = GetBearishCyclesValues( - barIndex, - values // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = MathAbs(GetSum(values)); - - // - return result; - } - - // - double GetCyclesBullishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - int cyclesCount = ArraySize(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double power = GetCycleValue( - barIndex, - cycles[i] // - ); - - // - if (IsBullish(power)) - { - result += MathAbs(power); - } - } - - // - return result; - } - - // - double GetCyclesBearishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - int cyclesCount = ArraySize(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double power = GetCycleValue( - barIndex, - cycles[i] // - ); - - // - if (IsBearish(power)) - { - result += MathAbs(power); - } - } - - // - return result; - } - - // - bool HasBullishPower( - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - double bullishPower = GetBullishPower(barIndex); - double bearishPower = GetBearishPower(barIndex); - - // - result = - // - bearishPower >= 0 && - bullishPower > bearishPower - // - ; - - // - return result; - } - - // - bool HasBearishPower( - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - double bullishPower = GetBullishPower(barIndex); - double bearishPower = GetBearishPower(barIndex); - - // - result = - // - bullishPower >= 0 && - bearishPower > bullishPower - // - ; - - // - return result; - } - - // - bool HasCyclesBullishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - bool result = false; - - // - double bullishPower = GetCyclesBullishPower(barIndex, cycles); - double bearishPower = GetCyclesBearishPower(barIndex, cycles); - - // - result = - // - bearishPower >= 0 && - bullishPower > bearishPower - // - ; - - // - return result; - } - - // - bool HasCyclesBearishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - bool result = false; - - // - double bullishPower = GetCyclesBullishPower(barIndex, cycles); - double bearishPower = GetCyclesBearishPower(barIndex, cycles); - - // - result = - // - bullishPower >= 0 && - bearishPower > bullishPower - // - ; - - // - return result; - } - - // - // Check Bullish Power Increasing ... - bool IsBullishPowerIncreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBullishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBullishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bullish Power Decreasing ... - bool IsBullishPowerDecreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBullishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBullishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Increasing ... - bool IsBearishPowerIncreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBearishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBearishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Decreasing ... - bool IsBearishPowerDecreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBearishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBearishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Check Bullish Power Increasing ... - bool IsCyclesBullishPowerIncreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBullishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBullishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bullish Power Decreasing ... - bool IsCyclesBullishPowerDecreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBullishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBullishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Increasing ... - bool IsCyclesBearishPowerIncreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBearishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBearishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Decreasing ... - bool IsCyclesBearishPowerDecreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBearishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBearishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Conditions ... - - // - bool GetConditions( - XCHVLMConditions &conditions, // - int barIndex = 0, // - int loopback = 5 // - ) - { - // - bool result = true; - - // - if (loopback < 5) - { - loopback = 5; - } - - // - conditions.Clean(); - - // - conditions.symbol = mSymbol; - conditions.period = mPeriod; - conditions.time = TimeCurrent(); - - // - int zIndex = barIndex; - int cIndex = zIndex + 1; - int pIndex = cIndex + 1; - int ppIndex = pIndex + 1; - - // - // Buffers ... - - // - // Current ... - CopyC( - zIndex, - loopback, - conditions.cVolume // - ); - - // - // Short ... - CopyS( - zIndex, - loopback, - conditions.sVolume // - ); - - // - // Medium ... - CopyM( - zIndex, - loopback, - conditions.mVolume // - ); - - // - // Long ... - CopyL( - zIndex, - loopback, - conditions.lVolume // - ); - - // - // Hind ... - CopyH( - zIndex, - loopback, - conditions.hVolume // - ); - - // - // Conditions ... - - // - XOHCL cBar; - result = cBar.Init( - mSymbol, - mPeriod, - cIndex // - ); - if (!result) - { - return result; - } - - // - XOHCL pBar; - result = pBar.Init( - mSymbol, - mPeriod, - pIndex // - ); - if (!result) - { - return result; - } - - // - // Power ... - - // - bool hasBullishPower = HasBullishPower(cIndex); - bool hasBullishPowerPrev = HasBullishPower(pIndex); - - // - bool hasBearishPower = HasBearishPower(cIndex); - bool hasBearishPowerPrev = HasBearishPower(pIndex); - - // - bool isBullishPowerUp = hasBullishPower && - !hasBullishPowerPrev; - bool isBearishPowerUp = hasBearishPower && - !hasBearishPowerPrev; - - // - bool isBullishPowerIncreasing = IsBullishPowerIncreasing(cIndex); - bool isBullishPowerDecreasing = IsBullishPowerDecreasing(cIndex); - bool isBearishPowerIncreasing = IsBearishPowerIncreasing(cIndex); - bool isBearishPowerDecreasing = IsBearishPowerDecreasing(cIndex); - - // - conditions.hasBullishPower = hasBullishPower; - conditions.hasBearishPower = hasBearishPower; - conditions.isBullishPowerUp = isBullishPowerUp; - conditions.isBearishPowerUp = isBearishPowerUp; - conditions.isBullishPowerIncreasing = isBullishPowerIncreasing; - conditions.isBullishPowerDecreasing = isBullishPowerDecreasing; - conditions.isBearishPowerIncreasing = isBearishPowerIncreasing; - conditions.isBearishPowerDecreasing = isBearishPowerDecreasing; - - // - // Current ... - - // - bool isCBullish = IsBullish(conditions.cVolume[cIndex]); - bool isCBullishPrev = IsBullish(conditions.cVolume[pIndex]); - - // - bool isCBearish = IsBearish(conditions.cVolume[cIndex]); - bool isCBearishPrev = IsBearish(conditions.cVolume[pIndex]); - - // - bool isCSwitchedToBullish = isCBullish && - !isCBullishPrev; - bool isCSwitchedToBearish = isCBearish && - !isCBearishPrev; - - // - conditions.isCBullish = isCBullish; - conditions.isCBearish = isCBearish; - conditions.isCSwitchedToBullish = isCSwitchedToBullish; - conditions.isCSwitchedToBearish = isCSwitchedToBearish; - - // - // Short ... - - // - bool isSBullish = IsBullish(conditions.sVolume[cIndex]); - bool isSBullishPrev = IsBullish(conditions.sVolume[pIndex]); - - // - bool isSBearish = IsBearish(conditions.sVolume[cIndex]); - bool isSBearishPrev = IsBearish(conditions.sVolume[pIndex]); - - // - bool isSSwitchedToBullish = isSBullish && - !isSBullishPrev; - bool isSSwitchedToBearish = isSBearish && - !isSBearishPrev; - - // - conditions.isSBullish = isSBullish; - conditions.isSBearish = isSBearish; - conditions.isSSwitchedToBullish = isSSwitchedToBullish; - conditions.isSSwitchedToBearish = isSSwitchedToBearish; - - // - // Medium ... - - // - bool isMBullish = IsBullish(conditions.mVolume[cIndex]); - bool isMBullishPrev = IsBullish(conditions.mVolume[pIndex]); - - // - bool isMBearish = IsBearish(conditions.mVolume[cIndex]); - bool isMBearishPrev = IsBearish(conditions.mVolume[pIndex]); - - // - bool isMSwitchedToBullish = isMBullish && - !isMBullishPrev; - bool isMSwitchedToBearish = isMBearish && - !isMBearishPrev; - - // - conditions.isMBullish = isMBullish; - conditions.isMBearish = isMBearish; - conditions.isMSwitchedToBullish = isMSwitchedToBullish; - conditions.isMSwitchedToBearish = isMSwitchedToBearish; - - // - // Long ... - - // - bool isLBullish = IsBullish(conditions.lVolume[cIndex]); - bool isLBullishPrev = IsBullish(conditions.lVolume[pIndex]); - - // - bool isLBearish = IsBearish(conditions.lVolume[cIndex]); - bool isLBearishPrev = IsBearish(conditions.lVolume[pIndex]); - - // - bool isLSwitchedToBullish = isLBullish && - !isLBullishPrev; - bool isLSwitchedToBearish = isLBearish && - !isLBearishPrev; - - // - conditions.isLBullish = isLBullish; - conditions.isLBearish = isLBearish; - conditions.isLSwitchedToBullish = isLSwitchedToBullish; - conditions.isLSwitchedToBearish = isLSwitchedToBearish; - - // - // Hind ... - - // - bool isHBullish = IsBullish(conditions.hVolume[cIndex]); - bool isHBullishPrev = IsBullish(conditions.hVolume[pIndex]); - - // - bool isHBearish = IsBearish(conditions.hVolume[cIndex]); - bool isHBearishPrev = IsBearish(conditions.hVolume[pIndex]); - - // - bool isHSwitchedToBullish = isHBullish && - !isHBullishPrev; - bool isHSwitchedToBearish = isHBearish && - !isHBearishPrev; - - // - conditions.isHBullish = isHBullish; - conditions.isHBearish = isHBearish; - conditions.isHSwitchedToBullish = isHSwitchedToBullish; - conditions.isHSwitchedToBearish = isHSwitchedToBearish; - - // - return result; - } - - // - // Protected ... -protected: - // - // Private ... -private: - // - // Props ... - XCHVLMInputs mInputs; // Inputs ... - - // - // Buffers ... - - // - // Current ... - double cVolumeBuffer[]; - - // - // Short ... - double sVolumeBuffer[]; - - // - // Medium ... - double mVolumeBuffer[]; - - // - // Long ... - double lVolumeBuffer[]; - - // - // Hind ... - double hVolumeBuffer[]; - - // - // Tools ... - - // - // Calculate Values Until Now ... - void Calculate() - { - // - int totalBars = CountBars(); - if (totalBars > 1000) - { - totalBars = 1000; - } - - // - // Current ... - CopyBuffer( - mHandler, - XCHVLM_C_LINE, - 0, - totalBars, - cVolumeBuffer - // - ); - - // - // Short ... - CopyBuffer( - mHandler, - XCHVLM_S_LINE, - 0, - totalBars, - sVolumeBuffer - // - ); - - // - // Medium ... - CopyBuffer( - mHandler, - XCHVLM_M_LINE, - 0, - totalBars, - mVolumeBuffer - // - ); - - // - // Long ... - CopyBuffer( - mHandler, - XCHVLM_L_LINE, - 0, - totalBars, - lVolumeBuffer - // - ); - - // - // Hind ... - CopyBuffer( - mHandler, - XCHVLM_H_LINE, - 0, - totalBars, - hVolumeBuffer - // - ); - }; -}; - -// \ No newline at end of file diff --git a/Helpers/x-saherelm.xchvwap.helper.mq5 b/Helpers/x-saherelm.xchvwap.helper.mq5 deleted file mode 100644 index dda8248a..00000000 --- a/Helpers/x-saherelm.xchvwap.helper.mq5 +++ /dev/null @@ -1,2702 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Helper Class Library -// ---------------------------------------------- -// Name: XSCXCHVWAPHelper -// 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_XCHVWAP_BUFFERS -{ - // - XCHVWAP_S_LINE = 0, - XCHVWAP_S_STATE_LINE = 10, - // - XCHVWAP_M_LINE = 2, - XCHVWAP_M_STATE_LINE = 11, - // - XCHVWAP_L_LINE = 4, - XCHVWAP_L_STATE_LINE = 12, - // - XCHVWAP_H_LINE = 6, - XCHVWAP_H_STATE_LINE = 13, -}; - -// -enum ENUM_XCHVWAP_STATES -{ - // - XCHVWAP_BULLISH_STATE = 1, - XCHVWAP_BEARISH_STATE = 2, - XCHVWAP_NEUTURAL_STATE = 3, -}; - -// -// Input Models ... -struct XCHVWAPInputs -{ - // - // Props ... - - // - // Market ... - ENUM_APPLIED_PRICE appliedTo; // Applied To - - // - // Cycles ... - - // - // Short ... - ENUM_X_PERIOD_METHOD scMethod; // How to Find Period - ENUM_TIMEFRAMES scPeriod; // Time Period - - // - // Medium ... - ENUM_X_PERIOD_METHOD mcMethod; // How to Find Period - ENUM_TIMEFRAMES mcPeriod; // Time Period - - // - // Long ... - ENUM_X_PERIOD_METHOD lcMethod; // How to Find Period - ENUM_TIMEFRAMES lcPeriod; // Time Period - - // - // Hind ... - ENUM_X_PERIOD_METHOD hcMethod; // How to Find Period - ENUM_TIMEFRAMES hcPeriod; // Time Period - - // - // Presentation ... - bool showShort; // Show Short Cycle - bool showMedium; // Show Medium Cycle - bool showLong; // Show Long Cycle - bool showHind; // Show Hind Cycle - - // - // Constructor(s) ... - XCHVWAPInputs() - { - // - Clean(); - } - - // - // Tools ... - - // - // Clean ... - void Clean() - { - // - appliedTo = PRICE_CLOSE; - - // - scMethod = X_PERIOD_AUTO; - scPeriod = NULL; - mcMethod = X_PERIOD_AUTO; - mcPeriod = NULL; - lcMethod = X_PERIOD_AUTO; - lcPeriod = NULL; - hcMethod = X_PERIOD_AUTO; - hcPeriod = NULL; - - // - showShort = false; - showMedium = false; - showLong = false; - showHind = false; - } - - // - // Default ... - void Default() - { - // - appliedTo = PRICE_CLOSE; - - // - scMethod = X_PERIOD_AUTO; - scPeriod = NULL; - mcMethod = X_PERIOD_AUTO; - mcPeriod = NULL; - lcMethod = X_PERIOD_AUTO; - lcPeriod = NULL; - hcMethod = X_PERIOD_AUTO; - hcPeriod = NULL; - - // - showShort = true; - showMedium = true; - showLong = true; - showHind = true; - } - - // - // Validate ... - bool IsValid() - { - // - bool result = false; - - // - result = - // - (IsValid(scMethod, scPeriod) && - IsValid(mcMethod, mcPeriod) && - IsValid(lcMethod, lcPeriod) && - IsValid(hcMethod, hcPeriod)) - // - ; - - // - return result; - } - - // - // Retrieve MAx Length ... - int Max() - { - // - int result = 0; - - // - result = - // - MathMax(0, 0) - // - ; - - // - return result; - } -}; - -// -// Define Conditions ... -struct XCHVWAPConditions -{ - // - // Common ... - string symbol; - ENUM_TIMEFRAMES period; - datetime time; - - // - // Buffers ... - - // - // Short ... - double s[]; - double sState[]; - - // - // Medium ... - double m[]; - double mState[]; - - // - // Long ... - double l[]; - double lState[]; - - // - // Hind ... - double h[]; - double hState[]; - - // - // Conditions ... - // - // Power ... - bool hasBullishPower; - bool hasBearishPower; - bool isBullishPowerUp; - bool isBearishPowerUp; - bool isBullishPowerIncreasing; - bool isBullishPowerDecreasing; - bool isBearishPowerIncreasing; - bool isBearishPowerDecreasing; - - // - // Short ... - bool isSBullish; - bool isSBearish; - bool isSSwitchedToBullish; - bool isSSwitchedToBearish; - - // - // Medium ... - bool isMBullish; - bool isMBearish; - bool isMSwitchedToBullish; - bool isMSwitchedToBearish; - - // - // Long ... - bool isLBullish; - bool isLBearish; - bool isLSwitchedToBullish; - bool isLSwitchedToBearish; - - // - // Hind ... - bool isHBullish; - bool isHBearish; - bool isHSwitchedToBullish; - bool isHSwitchedToBearish; - - // - void Clean() - { - // - Clean(s); - Clean(sState); - Clean(m); - Clean(mState); - Clean(l); - Clean(lState); - Clean(h); - Clean(hState); - - // - ArraySetAsSeries(s, true); - ArraySetAsSeries(sState, true); - ArraySetAsSeries(m, true); - ArraySetAsSeries(mState, true); - ArraySetAsSeries(l, true); - ArraySetAsSeries(lState, true); - ArraySetAsSeries(h, true); - ArraySetAsSeries(hState, true); - - // - // Conditions ... - - // - // Power ... - hasBullishPower = false; - hasBearishPower = false; - isBullishPowerUp = false; - isBearishPowerUp = false; - isBullishPowerIncreasing = false; - isBullishPowerDecreasing = false; - isBearishPowerIncreasing = false; - isBearishPowerDecreasing = false; - - // - // Short ... - isSBullish = false; - isSBearish = false; - isSSwitchedToBullish = false; - isSSwitchedToBearish = false; - - // - // Medium ... - isMBullish = false; - isMBearish = false; - isMSwitchedToBullish = false; - isMSwitchedToBearish = false; - - // - // Long ... - isLBullish = false; - isLBearish = false; - isLSwitchedToBullish = false; - isLSwitchedToBearish = false; - - // - // Hind ... - isHBullish = false; - isHBearish = false; - isHSwitchedToBullish = false; - isHSwitchedToBearish = false; - } - - // - void GenerateScore( - double &bullishScore, - double &bearishScore // - ) - { - // - bullishScore = 0; - bearishScore = 0; - - // - // Since We have to Use this - // Only for Filtering Signals ... - // We Can Ignore Scoring ... - // or Complete this later ... - - // - // Conditions ... - - // - // Power ... - if (hasBullishPower) - { - bullishScore++; - } - if (hasBearishPower) - { - bearishScore++; - } - if (isBullishPowerUp) - { - bullishScore++; - } - if (isBearishPowerUp) - { - bearishScore++; - } - if (isBullishPowerIncreasing) - { - bullishScore++; - } - if (isBullishPowerDecreasing) - { - bearishScore++; - } - if (isBearishPowerIncreasing) - { - bearishScore++; - } - if (isBearishPowerDecreasing) - { - bullishScore++; - } - - // - // Short ... - if (isSBullish) - { - bullishScore++; - } - if (isSBearish) - { - bearishScore++; - } - if (isSSwitchedToBullish) - { - bullishScore++; - } - if (isSSwitchedToBearish) - { - bearishScore++; - } - - // - // Medium ... - if (isMBullish) - { - bullishScore++; - } - if (isMBearish) - { - bearishScore++; - } - if (isMSwitchedToBullish) - { - bullishScore++; - } - if (isMSwitchedToBearish) - { - bearishScore++; - } - - // - // Long ... - if (isLBullish) - { - bullishScore++; - } - if (isLBearish) - { - bearishScore++; - } - if (isLSwitchedToBullish) - { - bullishScore++; - } - if (isLSwitchedToBearish) - { - bearishScore++; - } - - // - // Hind ... - if (isHBullish) - { - bullishScore++; - } - if (isHBearish) - { - bearishScore++; - } - if (isHSwitchedToBullish) - { - bullishScore++; - } - if (isHSwitchedToBearish) - { - bearishScore++; - } - } - - // - string GenerateSummary( - bool onlyCommons = false, - bool onlyConditions = false, - bool includeScores = true, - bool ignoreFalseConditions = true, - string separator = "\n" // - ) - { - // - string result = NULL; - - // - double bullishScore = 0; - double bearishScore = 0; - GenerateScore( - bullishScore, - bearishScore // - ); - - // - string scoresStr = - // - "Scores: " + separator + - "---------------" + separator + - "Bullish: " + ToString(bullishScore) + separator + - "Bearish: " + ToString(bearishScore) + separator + - "" - // - ; - - // - string commonStr = GenerateSpecifiedCommonSummary( - this, - separator, - includeScores // - ); - - // - string conditionsStr = - // - // Power ... - ToString("hasBullishPower", hasBullishPower, ignoreFalseConditions, separator) + - ToString("hasBearishPower", hasBearishPower, ignoreFalseConditions, separator) + - ToString("isBullishPowerUp", isBullishPowerUp, ignoreFalseConditions, separator) + - ToString("isBearishPowerUp", isBearishPowerUp, ignoreFalseConditions, separator) + - ToString("isBullishPowerIncreasing", isBullishPowerIncreasing, ignoreFalseConditions, separator) + - ToString("isBullishPowerDecreasing", isBullishPowerDecreasing, ignoreFalseConditions, separator) + - ToString("isBearishPowerIncreasing", isBearishPowerIncreasing, ignoreFalseConditions, separator) + - ToString("isBearishPowerDecreasing", isBearishPowerDecreasing, ignoreFalseConditions, separator) + - // - // Short ... - ToString("isSBullish", isSBullish, ignoreFalseConditions, separator) + - ToString("isSBearish", isSBearish, ignoreFalseConditions, separator) + - ToString("isSSwitchedToBullish", isSSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isSSwitchedToBearish", isSSwitchedToBearish, ignoreFalseConditions, separator) + - // - // Medium ... - ToString("isMBullish", isMBullish, ignoreFalseConditions, separator) + - ToString("isMBearish", isMBearish, ignoreFalseConditions, separator) + - ToString("isMSwitchedToBullish", isMSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isMSwitchedToBearish", isMSwitchedToBearish, ignoreFalseConditions, separator) + - // - // Long ... - ToString("isLBullish", isLBullish, ignoreFalseConditions, separator) + - ToString("isLBearish", isLBearish, ignoreFalseConditions, separator) + - ToString("isLSwitchedToBullish", isLSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isLSwitchedToBearish", isLSwitchedToBearish, ignoreFalseConditions, separator) + - // - // Hind ... - ToString("isHBullish", isHBullish, ignoreFalseConditions, separator) + - ToString("isHBearish", isHBearish, ignoreFalseConditions, separator) + - ToString("isHSwitchedToBullish", isHSwitchedToBullish, ignoreFalseConditions, separator) + - ToString("isHSwitchedToBearish", isHSwitchedToBearish, ignoreFalseConditions, separator) + - // - "" - // - ; - - // - result = - // - "[" + GetTag() + "]" + separator + - (onlyConditions - ? "" - : commonStr) + - (!includeScores - ? "" - : scoresStr) + - " " + separator + - (onlyCommons - ? "" - : conditionsStr) + - "" - // - ; - - // - return result; - } - - // - string GetTag() - { - return "XCHVWAP"; - } -}; - -// -// Class ... -class XSCXCHVWAPHelper : public XSCBaseHelper -{ - // - // Public ... - public: - // - // Props ... - - // - // Constructors ... - XSCXCHVWAPHelper() - : XSCBaseHelper(_Symbol, _Period) - { - } - - // - // Deconstructor ... - ~XSCXCHVWAPHelper() - { - // - Clean(sBuffer); - Clean(sStateBuffer); - Clean(mBuffer); - Clean(mStateBuffer); - Clean(lBuffer); - Clean(lStateBuffer); - Clean(hBuffer); - Clean(hStateBuffer); - } - - // - // Tools ... - bool Init( - string symbol, // Trading Symbol - ENUM_TIMEFRAMES period, // Trading Period - XCHVWAPInputs &inputs // Inputs - ) - { - // - bool result = false; - - // - mSymbol = symbol; - mPeriod = period; - - // - result = inputs.IsValid(); - if (!result) - { - return result; - } - - // - mInputs = inputs; - - // - ArraySetAsSeries(sBuffer, true); - ArraySetAsSeries(sStateBuffer, true); - ArraySetAsSeries(mBuffer, true); - ArraySetAsSeries(mStateBuffer, true); - ArraySetAsSeries(lBuffer, true); - ArraySetAsSeries(lStateBuffer, true); - ArraySetAsSeries(hBuffer, true); - ArraySetAsSeries(hStateBuffer, true); - - // - mHandler = iCustom( - mSymbol, - mPeriod, - "x-saherelm.xchvwap", - // - // Inputs ... - // - // Market ... - "", - mInputs.appliedTo, - // - // Cycles ... - "", - // - // Short ... - "", - mInputs.scMethod, - mInputs.scPeriod, - // - // Medium ... - "", - mInputs.mcMethod, - mInputs.mcPeriod, - // - // Long ... - "", - mInputs.lcMethod, - mInputs.lcPeriod, - // - // Hind ... - "", - mInputs.hcMethod, - mInputs.hcPeriod, - // - // Presentation ... - "", - mInputs.showShort, - mInputs.showMedium, - mInputs.showLong, - mInputs.showHind - // - ); - result = mHandler != INVALID_HANDLE; - if (!result) - { - return result; - } - - // - return result; - } - - // - // Inputs ... - - // - XCHVWAPInputs GetInputs() - { - return mInputs; - } - - // - bool SetInputs( - XCHVWAPInputs &inputs // Configs - ) - { - // - return Init( - mSymbol, - mPeriod, - inputs - // - ); - } - - // - // Buffers ... - - // - // Short ... - - // - double GetS( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return sBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyS( - 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, - sBuffer, - buffer, - forceClean - // - ); - } - - // - double GetSState( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return sStateBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopySState( - 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, - sStateBuffer, - buffer, - forceClean - // - ); - } - - // - // Medium ... - - // - double GetM( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return mBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyM( - 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, - mBuffer, - buffer, - forceClean - // - ); - } - - // - double GetMState( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return mStateBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyMState( - 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, - mStateBuffer, - buffer, - forceClean - // - ); - } - - // - // Long ... - - // - double GetL( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return lBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyL( - 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, - lBuffer, - buffer, - forceClean - // - ); - } - - // - double GetLState( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return lStateBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyLState( - 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, - lStateBuffer, - buffer, - forceClean - // - ); - } - - // - // Hind ... - - // - double GetH( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return hBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyH( - 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, - hBuffer, - buffer, - forceClean - // - ); - } - - // - double GetHState( - int barIndex // Bar Index - ) - { - // - if (barIndex < 0) - { - barIndex = 0; - } - - // - Calculate(); - - // - return hStateBuffer[barIndex]; - } - - // - // Copy Required Buffer ... - int CopyHState( - 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, - hStateBuffer, - buffer, - forceClean - // - ); - } - - // - // Tools ... - - // - ENUM_XCHVWAP_STATES ToState(double value) - { - // - ENUM_XCHVWAP_STATES result = value == 1 - ? XCHVWAP_BULLISH_STATE - : value == 2 - ? XCHVWAP_BEARISH_STATE - : XCHVWAP_NEUTURAL_STATE; - - // - return result; - } - - // - bool IsBullish(double value) - { - // - bool result = false; - - // - result = - // - ToState(value) == XCHVWAP_BULLISH_STATE; - // - ; - - // - return result; - } - - // - bool IsBearish(double value) - { - // - bool result = false; - - // - result = - // - ToState(value) == XCHVWAP_BEARISH_STATE; - // - ; - - // - return result; - } - - // - int GetValues( - int barIndex, // Bar Index - double &values[] // Result - ) - { - // - int result = 0; - - // - Clean(values); - - // - ENUM_X_MARKET_CYCLES cycles[]; - int cyclesCount = GetAllMarketCycles(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double iValue = GetCycleValue( - barIndex, - cycles[i] // - ); - - // - Add( - iValue, - values // - ); - } - - // - result = ArraySize(values); - - // - return result; - } - - // - double GetCycleValue( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle // Cycle - ) - { - // - double result = 0; - - // - switch (cycle) - { - // - // SHORT ... - case X_MARKET_CYCLE_SHORT: - result = GetS(barIndex); - break; - - // - // MEDIUM ... - case X_MARKET_CYCLE_MEDIUM: - result = GetM(barIndex); - break; - - // - // LONG ... - case X_MARKET_CYCLE_LONG: - result = GetL(barIndex); - break; - - // - // HIND ... - case X_MARKET_CYCLE_HIND: - result = GetH(barIndex); - break; - } - - // - return result; - } - - // - double GetCycleState( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES cycle // Cycle - ) - { - // - double result = 0; - - // - switch (cycle) - { - // - // SHORT ... - case X_MARKET_CYCLE_SHORT: - result = GetSState(barIndex); - break; - - // - // MEDIUM ... - case X_MARKET_CYCLE_MEDIUM: - result = GetMState(barIndex); - break; - - // - // LONG ... - case X_MARKET_CYCLE_LONG: - result = GetLState(barIndex); - break; - - // - // HIND ... - case X_MARKET_CYCLE_HIND: - result = GetHState(barIndex); - break; - } - - // - return result; - } - - // - int GetBullishCycles( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - int result = 0; - - // - Clean(cycles); - - // - ENUM_X_MARKET_CYCLES allCycles[]; - int allCyclesCount = GetAllMarketCycles(allCycles); - if (!IsValidSize(allCyclesCount)) - { - return result; - } - - // - for (int i = 0; i < allCyclesCount; i++) - { - // - double cState = GetCycleState( - barIndex, - allCycles[i] // - ); - - // - if (IsBullish(cState)) - { - // - Add( - allCycles[i], - cycles // - ); - } - } - - // - result = ArraySize(cycles); - - // - return result; - } - - // - int GetBearishCycles( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Result - ) - { - // - int result = 0; - - // - Clean(cycles); - - // - ENUM_X_MARKET_CYCLES allCycles[]; - int allCyclesCount = GetAllMarketCycles(allCycles); - if (!IsValidSize(allCyclesCount)) - { - return result; - } - - // - for (int i = 0; i < allCyclesCount; i++) - { - // - double cState = GetCycleState( - barIndex, - allCycles[i] // - ); - - // - if (IsBearish(cState)) - { - // - Add( - allCycles[i], - cycles // - ); - } - } - - // - result = ArraySize(cycles); - - // - return result; - } - - // - int GetCyclesValues( - int barIndex, // Bar Index - double &values[], // Values - ENUM_X_MARKET_CYCLES &cycles[] // Cycles - ) - { - // - int result = 0; - - // - Clean(values); - - // - int count = ArraySize(cycles); - if (!IsValidSize(count)) - { - return result; - } - - // - for (int i = 0; i < count; i++) - { - // - double iValue = GetCycleValue( - barIndex, - cycles[i] // - ); - - // - Add( - iValue, - values // - ); - } - - // - result = ArraySize(values); - - // - return result; - } - - // - int GetBullishCyclesValues( - int barIndex, // Bar Index - double &values[] // Values - ) - { - // - int result = 0; - - // - Clean(values); - - // - ENUM_X_MARKET_CYCLES cycles[]; - int count = GetBullishCycles( - barIndex, - cycles // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = GetCyclesValues( - barIndex, - values, - cycles // - ); - - // - return result; - } - - // - int GetBearishCyclesValues( - int barIndex, // Bar Index - double &values[] // Values - ) - { - // - int result = 0; - - // - Clean(values); - - // - ENUM_X_MARKET_CYCLES cycles[]; - int count = GetBearishCycles( - barIndex, - cycles // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = GetCyclesValues( - barIndex, - values, - cycles // - ); - - // - return result; - } - - // - double GetCyclesMax( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Cycles - ) - { - // - double result = 0; - - // - double values[]; - int count = GetCyclesValues( - barIndex, - values, - cycles // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetCyclesMin( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // Cycles - ) - { - // - double result = 0; - - // - double values[]; - int count = GetCyclesValues( - barIndex, - values, - cycles // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetMax( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - double values[]; - int valuesCount = GetValues( - barIndex, - values // - ); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetSpecifiedMax(values); - - // - return result; - } - - // - double GetMin( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - double values[]; - int valuesCount = GetValues( - barIndex, - values // - ); - if (!IsValidSize(valuesCount)) - { - return result; - } - - // - result = GetSpecifiedMin(values); - - // - return result; - } - - // - double GetBullishPower( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - double values[]; - int count = GetBullishCyclesValues( - barIndex, - values // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = MathAbs(GetSum(values)); - - // - return result; - } - - // - double GetBearishPower( - int barIndex // Bar Index - ) - { - // - double result = 0; - - // - double values[]; - int count = GetBearishCyclesValues( - barIndex, - values // - ); - if (!IsValidSize(count)) - { - return result; - } - - // - result = MathAbs(GetSum(values)); - - // - return result; - } - - // - double GetCyclesBullishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - int cyclesCount = ArraySize(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double power = GetCycleValue( - barIndex, - cycles[i] // - ); - - // - if (IsBullish(power)) - { - result += MathAbs(power); - } - } - - // - return result; - } - - // - double GetCyclesBearishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - double result = 0; - - // - int cyclesCount = ArraySize(cycles); - if (!IsValidSize(cyclesCount)) - { - return result; - } - - // - for (int i = 0; i < cyclesCount; i++) - { - // - double power = GetCycleValue( - barIndex, - cycles[i] // - ); - - // - if (IsBearish(power)) - { - result += MathAbs(power); - } - } - - // - return result; - } - - // - bool HasBullishPower( - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - double bullishPower = GetBullishPower(barIndex); - double bearishPower = GetBearishPower(barIndex); - - // - result = - // - bearishPower >= 0 && - bullishPower > bearishPower - // - ; - - // - return result; - } - - // - bool HasBearishPower( - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - double bullishPower = GetBullishPower(barIndex); - double bearishPower = GetBearishPower(barIndex); - - // - result = - // - bullishPower >= 0 && - bearishPower > bullishPower - // - ; - - // - return result; - } - - // - bool HasCyclesBullishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - bool result = false; - - // - double bullishPower = GetCyclesBullishPower(barIndex, cycles); - double bearishPower = GetCyclesBearishPower(barIndex, cycles); - - // - result = - // - bearishPower >= 0 && - bullishPower > bearishPower - // - ; - - // - return result; - } - - // - bool HasCyclesBearishPower( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[] // - ) - { - // - bool result = false; - - // - double bullishPower = GetCyclesBullishPower(barIndex, cycles); - double bearishPower = GetCyclesBearishPower(barIndex, cycles); - - // - result = - // - bullishPower >= 0 && - bearishPower > bullishPower - // - ; - - // - return result; - } - - // - // Check Bullish Power Increasing ... - bool IsBullishPowerIncreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBullishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBullishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bullish Power Decreasing ... - bool IsBullishPowerDecreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBullishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBullishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Increasing ... - bool IsBearishPowerIncreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBearishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBearishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Decreasing ... - bool IsBearishPowerDecreasing( - int barIndex, // Bar Index - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetBearishPower(barIndex); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetBearishPower(i); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Check Bullish Power Increasing ... - bool IsCyclesBullishPowerIncreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBullishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBullishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bullish Power Decreasing ... - bool IsCyclesBullishPowerDecreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBullishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBullishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Increasing ... - bool IsCyclesBearishPowerIncreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBearishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBearishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower > iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower > lastPower - // - ; - } - - // - return result; - } - - // - // Check Bearish Power Decreasing ... - bool IsCyclesBearishPowerDecreasing( - int barIndex, // Bar Index - ENUM_X_MARKET_CYCLES &cycles[], // - int loopback = 5 // Loopback - ) - { - // - bool result = false; - - // - if (loopback <= 0) - { - loopback = 5; - } - - // - double firstPower = GetCyclesBearishPower(barIndex, cycles); - double lastPower = firstPower; - for (int i = barIndex + 1; i < barIndex + loopback; i++) - { - // - double iPower = GetCyclesBearishPower(i, cycles); - - // - result = - // - iPower > 0 && - firstPower > 0 && - lastPower < iPower - // - ; - if (!result) - { - break; - } - - // - lastPower = iPower; - } - - // - if (result) - { - // - result = - // - firstPower < lastPower - // - ; - } - - // - return result; - } - - // - // Check Order of VWaps ... - - // - // Only Check Orders of VWap Buffers - // not State of them ... - bool IsBullishOrder( - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - double shortVWap = GetS(barIndex); - double mediumVWap = GetM(barIndex); - double longVWap = GetL(barIndex); - double hindVWap = GetH(barIndex); - - // - result = shortVWap > mediumVWap && - mediumVWap > longVWap && - longVWap > hindVWap; - - // - return result; - } - - bool IsSwitchedToBullishOrder( - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - bool isCBullishOrder = IsBullishOrder(barIndex); - bool isPBullishOrder = IsBullishOrder(barIndex + 1); - - // - result = - isCBullishOrder && - !isPBullishOrder; - - // - return result; - } - - // - // Only Check Orders of VWap Buffers - // not State of them ... - bool IsBearishOrder( - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - double shortVWap = GetS(barIndex); - double mediumVWap = GetM(barIndex); - double longVWap = GetL(barIndex); - double hindVWap = GetH(barIndex); - - // - result = shortVWap < mediumVWap && - mediumVWap < longVWap && - longVWap < hindVWap; - - // - return result; - } - - bool IsSwitchedToBearishOrder( - int barIndex // Bar Index - ) - { - // - bool result = false; - - // - bool isCBearishOrder = IsBearishOrder(barIndex); - bool isPBearishOrder = IsBearishOrder(barIndex + 1); - - // - result = - isCBearishOrder && - !isPBearishOrder; - - // - return result; - } - - // - // Conditions ... - - // - bool GetConditions( - XCHVWAPConditions &conditions, // - int barIndex = 0, // - int loopback = 5 // - ) - { - // - bool result = true; - - // - if (loopback < 5) - { - loopback = 5; - } - - // - conditions.Clean(); - - // - conditions.symbol = mSymbol; - conditions.period = mPeriod; - conditions.time = TimeCurrent(); - - // - int zIndex = barIndex; - int cIndex = zIndex + 1; - int pIndex = cIndex + 1; - int ppIndex = pIndex + 1; - - // - // Buffers ... - - // - // Short ... - CopyS( - zIndex, - loopback, - conditions.s // - ); - CopySState( - zIndex, - loopback, - conditions.sState // - ); - - // - // Medium ... - CopyM( - zIndex, - loopback, - conditions.m // - ); - CopyMState( - zIndex, - loopback, - conditions.mState // - ); - - // - // Long ... - CopyL( - zIndex, - loopback, - conditions.l // - ); - CopyLState( - zIndex, - loopback, - conditions.lState // - ); - - // - // Hind ... - CopyH( - zIndex, - loopback, - conditions.h // - ); - CopyHState( - zIndex, - loopback, - conditions.hState // - ); - - // - // Conditions ... - - // - XOHCL cBar; - result = cBar.Init( - mSymbol, - mPeriod, - cIndex // - ); - if (!result) - { - return result; - } - - // - XOHCL pBar; - result = pBar.Init( - mSymbol, - mPeriod, - pIndex // - ); - if (!result) - { - return result; - } - - // - // Power ... - - // - bool hasBullishPower = HasBullishPower(cIndex); - bool hasBullishPowerPrev = HasBullishPower(pIndex); - - // - bool hasBearishPower = HasBearishPower(cIndex); - bool hasBearishPowerPrev = HasBearishPower(pIndex); - - // - bool isBullishPowerUp = hasBullishPower && - !hasBullishPowerPrev; - bool isBearishPowerUp = hasBearishPower && - !hasBearishPowerPrev; - - // - bool isBullishPowerIncreasing = IsBullishPowerIncreasing(cIndex); - bool isBullishPowerDecreasing = IsBullishPowerDecreasing(cIndex); - bool isBearishPowerIncreasing = IsBearishPowerIncreasing(cIndex); - bool isBearishPowerDecreasing = IsBearishPowerDecreasing(cIndex); - - // - conditions.hasBullishPower = hasBullishPower; - conditions.hasBearishPower = hasBearishPower; - conditions.isBullishPowerUp = isBullishPowerUp; - conditions.isBearishPowerUp = isBearishPowerUp; - conditions.isBullishPowerIncreasing = isBullishPowerIncreasing; - conditions.isBullishPowerDecreasing = isBullishPowerDecreasing; - conditions.isBearishPowerIncreasing = isBearishPowerIncreasing; - conditions.isBearishPowerDecreasing = isBearishPowerDecreasing; - - // - // Short ... - - // - bool isSBullish = IsBullish(conditions.sState[cIndex]); - bool isSBullishPrev = IsBullish(conditions.sState[pIndex]); - - // - bool isSBearish = IsBearish(conditions.sState[cIndex]); - bool isSBearishPrev = IsBearish(conditions.sState[pIndex]); - - // - bool isSSwitchedToBullish = isSBullish && - !isSBullishPrev; - bool isSSwitchedToBearish = isSBearish && - !isSBearishPrev; - - // - conditions.isSBullish = isSBullish; - conditions.isSBearish = isSBearish; - conditions.isSSwitchedToBullish = isSSwitchedToBullish; - conditions.isSSwitchedToBearish = isSSwitchedToBearish; - - // - // Medium ... - - // - bool isMBullish = IsBullish(conditions.mState[cIndex]); - bool isMBullishPrev = IsBullish(conditions.mState[pIndex]); - - // - bool isMBearish = IsBearish(conditions.mState[cIndex]); - bool isMBearishPrev = IsBearish(conditions.mState[pIndex]); - - // - bool isMSwitchedToBullish = isMBullish && - !isMBullishPrev; - bool isMSwitchedToBearish = isMBearish && - !isMBearishPrev; - - // - conditions.isMBullish = isMBullish; - conditions.isMBearish = isMBearish; - conditions.isMSwitchedToBullish = isMSwitchedToBullish; - conditions.isMSwitchedToBearish = isMSwitchedToBearish; - - // - // Long ... - - // - bool isLBullish = IsBullish(conditions.lState[cIndex]); - bool isLBullishPrev = IsBullish(conditions.lState[pIndex]); - - // - bool isLBearish = IsBearish(conditions.lState[cIndex]); - bool isLBearishPrev = IsBearish(conditions.lState[pIndex]); - - // - bool isLSwitchedToBullish = isLBullish && - !isLBullishPrev; - bool isLSwitchedToBearish = isLBearish && - !isLBearishPrev; - - // - conditions.isLBullish = isLBullish; - conditions.isLBearish = isLBearish; - conditions.isLSwitchedToBullish = isLSwitchedToBullish; - conditions.isLSwitchedToBearish = isLSwitchedToBearish; - - // - // Hind ... - - // - bool isHBullish = IsBullish(conditions.hState[cIndex]); - bool isHBullishPrev = IsBullish(conditions.hState[pIndex]); - - // - bool isHBearish = IsBearish(conditions.hState[cIndex]); - bool isHBearishPrev = IsBearish(conditions.hState[pIndex]); - - // - bool isHSwitchedToBullish = isHBullish && - !isHBullishPrev; - bool isHSwitchedToBearish = isHBearish && - !isHBearishPrev; - - // - conditions.isHBullish = isHBullish; - conditions.isHBearish = isHBearish; - conditions.isHSwitchedToBullish = isHSwitchedToBullish; - conditions.isHSwitchedToBearish = isHSwitchedToBearish; - - // - return result; - } - - // - // Protected ... - protected: - // - // Private ... - private: - // - // Props ... - XCHVWAPInputs mInputs; // Inputs ... - - // - // Buffers ... - - // - // Short ... - double sBuffer[]; - double sStateBuffer[]; - - // - // Medium ... - double mBuffer[]; - double mStateBuffer[]; - - // - // Long ... - double lBuffer[]; - double lStateBuffer[]; - - // - // Hind ... - double hBuffer[]; - double hStateBuffer[]; - - // - // Tools ... - - // - // Calculate Values Until Now ... - void Calculate() - { - // - int totalBars = CountBars(); - if (totalBars > 1000) - { - totalBars = 1000; - } - - // - // Short ... - CopyBuffer( - mHandler, - XCHVWAP_S_LINE, - 0, - totalBars, - sBuffer - // - ); - CopyBuffer( - mHandler, - XCHVWAP_S_STATE_LINE, - 0, - totalBars, - sStateBuffer - // - ); - - // - // Medium ... - CopyBuffer( - mHandler, - XCHVWAP_M_LINE, - 0, - totalBars, - mBuffer - // - ); - CopyBuffer( - mHandler, - XCHVWAP_M_STATE_LINE, - 0, - totalBars, - mStateBuffer - // - ); - - // - // Long ... - CopyBuffer( - mHandler, - XCHVWAP_L_LINE, - 0, - totalBars, - lBuffer - // - ); - CopyBuffer( - mHandler, - XCHVWAP_L_STATE_LINE, - 0, - totalBars, - lStateBuffer - // - ); - - // - // Hind ... - CopyBuffer( - mHandler, - XCHVWAP_H_LINE, - 0, - totalBars, - hBuffer - // - ); - CopyBuffer( - mHandler, - XCHVWAP_H_STATE_LINE, - 0, - totalBars, - hStateBuffer - // - ); - }; -}; - -// \ No newline at end of file diff --git a/Helpers/x-saherelm.xosc.helper.mq5 b/Helpers/x-saherelm.xosc.helper.mq5 deleted file mode 100644 index 2d2da01e..00000000 --- a/Helpers/x-saherelm.xosc.helper.mq5 +++ /dev/null @@ -1,1342 +0,0 @@ -/////////////////////////////////////////////////////// -// -// 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() - { - // - Clean(atrBuffer); - Clean(rsiBuffer); - Clean(cciBuffer); - Clean(sarBuffer); - Clean(bullPBuffer); - Clean(bearPBuffer); - Clean(stddevBuffer); - Clean(volumeBuffer); - Clean(rviMainBuffer); - Clean(momentumBuffer); - Clean(macdMainBuffer); - Clean(rviSignalBuffer); - Clean(stochMainBuffer); - Clean(macdSignalBuffer); - Clean(stochSignalBuffer); - } - - // - // 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(); - if (totalBars > 1000) - { - totalBars = 1000; - } - - // - // 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/Indicators/x-saherelm.x-time.indicator.mq5 b/Indicators/x-saherelm.x-time.indicator.mq5 deleted file mode 100644 index d2edf38a..00000000 --- a/Indicators/x-saherelm.x-time.indicator.mq5 +++ /dev/null @@ -1,237 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Indicator -// --------------------------------------------- -// Name: XCTime -// Description: Timing Indicator ... -// -// -// Maintainer: -// ------------ -// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) -// -////////////////////////////////////////////////////// -// -// Global Properties ... -#property copyright "Copyright 2023, SaherElm IT Center" -#property link "https://saherelm.ir" -#property version "1.00" -#property description "SaherElm XCTime Indicator" -#property strict - -// -// START Constants ... -// - -// -#define ShortName "XCTime" -#include "../Libraries/x-saherelm.common.lib.mq5" - -// -// END Constants ... -// - -// -// START Inputs ... -// - -// -input color clr = clrYellow; // Text Color -input ENUM_BASE_CORNER corner = CORNER_LEFT_LOWER; // Text Position - -// -input group "Presentation"; -input bool showTime = true; // Show Time - -// -// END Inputs ... -// - -// -// START Buffers ... -// - -// -#property indicator_chart_window - -// -#property indicator_buffers 0 -#property indicator_plots 0 - -// -// END Buffers ... -// - -// -// START Global Definitions: Variables, Properties and etc ... -// - -// -// END Global Definitions: Variables, Properties and etc ... -// - -// -// START Event Handlers ... -// - -// -// Initialization ... -int OnInit() -{ - // - // Validate Inputs ... - if (showTime) - { - CreateIndicatorObject(); - } - else - { - ObjectDelete(0, ShortName); - } - - // - // Set Indicator ShortName ... - SetIndicatorName(); - - // - // Init Succeed ... - return INIT_SUCCEEDED; -} - -// -// DeInitialization ... -void OnDeinit(const int reason) -{ - // - // REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function - // REASON_REMOVE 1 Program removed from a chart - // REASON_RECOMPILE 2 Program recompiled - // REASON_CHARTCHANGE 3 A symbol or a chart period is changed - // REASON_CHARTCLOSE 4 Chart closed - // REASON_PARAMETERS 5 Inputs changed by a user - // REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings - // REASON_TEMPLATE 7 Another chart template applied - // REASON_INITFAILED 8 The OnInit() handler returned a non-zero value - // REASON_CLOSE 9 Terminal closed - - // - ulong chID = FindChartID( - _Symbol, - _Period - // - ); - - // - // Delete Object ... - ObjectDelete(chID, ShortName); - - // - Comment(""); -} - -// -// Calculating what we want ... -int OnCalculate( - 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 ... -) -{ - // - ArraySetAsSeries(time, true); - - // - if (!showTime) - { - return rates_total; - } - - // - ulong chID = FindChartID( - _Symbol, - _Period - // - ); - - //s - int offset = TimeGMTOffset(); - string timeString = - "Local: " + string(TimeLocal()) + - ", Server: " + string(TimeTradeServer()); - timeString = timeString; - - // - string objText = timeString; - - // - ObjectSetInteger(chID, ShortName, OBJPROP_COLOR, clr); - ObjectSetString(chID, ShortName, OBJPROP_TEXT, objText); - ObjectSetInteger(chID, ShortName, OBJPROP_FONTSIZE, 10); - ObjectSetString(chID, ShortName, OBJPROP_FONT, "Arial"); - - // - return rates_total; -} - -// -// END Event Handlers ... -// - -// -// START Functions ... -// - -// -// Set Indicator Short Name and also we can define Buffers Labels ... -void SetIndicatorName() -{ - IndicatorSetString(INDICATOR_SHORTNAME, ShortName); -} - -// -void CreateIndicatorObject() -{ - // - if (!showTime) - { - return; - } - - // - ObjectCreate(0, ShortName, OBJ_LABEL, 0, 0, 0); - ObjectSetInteger(0, ShortName, OBJPROP_CORNER, corner); - ObjectSetInteger(0, ShortName, OBJPROP_XDISTANCE, 10); - ObjectSetInteger(0, ShortName, OBJPROP_YDISTANCE, 2); - - // - ENUM_ANCHOR_POINT Anchor = ANCHOR_LEFT_UPPER; - switch (corner) - { - case CORNER_LEFT_UPPER: - Anchor = ANCHOR_LEFT_UPPER; - break; - case CORNER_RIGHT_UPPER: - Anchor = ANCHOR_RIGHT_UPPER; - break; - case CORNER_LEFT_LOWER: - Anchor = ANCHOR_LEFT_LOWER; - break; - case CORNER_RIGHT_LOWER: - Anchor = ANCHOR_RIGHT_LOWER; - break; - } - - // - ObjectSetInteger(0, ShortName, OBJPROP_ANCHOR, Anchor); -} - -// -// END Functions ... -// diff --git a/Indicators/x-saherelm.xchche.mq5 b/Indicators/x-saherelm.xchche.mq5 deleted file mode 100644 index 9b6b3892..00000000 --- a/Indicators/x-saherelm.xchche.mq5 +++ /dev/null @@ -1,1190 +0,0 @@ -/////////////////////////////////////////////////////// -// SaherElm IT Center MQL5 Indicator -// ------------------------------------------- -// Name: XCHCHE -// Description: XCHCHE Cycles ... -// -// Maintainer: -// ------------ -// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) -// -////////////////////////////////////////////////////// -// -// Global Properties ... -#property copyright "Copyright 2023, SaherElm IT Center" -#property link "https://saherelm.ir" -#property version "1.00" -#property description "SaherElm XCHCHE Indicator" -#property strict - -// -#define ShortName "XCHCHE" - -// -// Includes Common Library ... -#include -#include "../Libraries/x-saherelm.common.lib.mq5" - -// -// Inputs ... - -// -input group "Market"; -input int length = 35; // Length -input int loopback = 26; // Loopback -input double multiplier1 = 3.0; // 1st Multiplier -input double multiplier2 = 3.5; // 2nd Multiplier - -// -input group "Calculation"; -input ENUM_APPLIED_PRICE upAppliedTo = PRICE_HIGH; // Up Zone Applied to -input ENUM_APPLIED_PRICE downAppliedTo = PRICE_LOW; // Down Zone Applied to - -// -input group "Cycles"; - -// -input group "Short"; -input ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES scPeriod = NULL; // Time Period - -// -input group "Medium"; -input ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES mcPeriod = NULL; // Time Period - -// -input group "Long"; -input ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES lcPeriod = NULL; // Time Period - -// -input group "Hind"; -input ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period - -// -// Presentation ... -input group "Presentation"; - -// -input bool showLE1 = true; // Show Long Exit 1 -input bool showLE2 = true; // Show Long Exit 2 -input bool showSE1 = true; // Show Short Exit 1 -input bool showSE2 = true; // Show Short Exit 2 - -// -input bool showCurrent = true; // Show Current Cycle -input bool showShort = true; // Show Short Cycle -input bool showMedium = true; // Show Medium Cycle -input bool showLong = true; // Show Long Cycle -input bool showHind = true; // Show Hind Cycle - -// -// Buffers ... - -// -#define hideColorIDX 0 -#define bullishColorIDX 1 -#define bearishColorIDX 2 - -// -#property indicator_chart_window - -// -#property indicator_buffers 20 -#property indicator_plots 20 - -// -// Current ... - -// -// Long Exit 1 ... -#define cLE1BufferIndex 0 -double cLE1Buffer[]; - -// -#property indicator_label1 "XCHCHE C LE 1" -#property indicator_type1 DRAW_LINE -#property indicator_color1 clrLime -#property indicator_style1 STYLE_DOT - -// -// Short Exit 1 ... -#define cSE1BufferIndex 1 -double cSE1Buffer[]; - -// -#property indicator_label2 "XCHCHE C SE 1" -#property indicator_type2 DRAW_LINE -#property indicator_style2 STYLE_DOT -#property indicator_color2 clrRed - -// -// Long Exit 2 ... -#define cLE2BufferIndex 2 -double cLE2Buffer[]; - -// -#property indicator_label3 "XCHCHE C LE 2" -#property indicator_type3 DRAW_LINE -#property indicator_style3 STYLE_DOT -#property indicator_color3 clrAqua - -// -// Short Exit 2 ... -#define cSE2BufferIndex 3 -double cSE2Buffer[]; - -// -#property indicator_label4 "XCHCHE C SE 2" -#property indicator_type4 DRAW_LINE -#property indicator_style4 STYLE_DOT -#property indicator_color4 clrMagenta - -// -// Short ... - -// -// Long Exit 1 ... -#define sLE1BufferIndex 4 -double sLE1Buffer[]; - -// -#property indicator_label5 "XCHCHE S LE 1" -#property indicator_type5 DRAW_LINE -#property indicator_color5 clrLime -#property indicator_style5 STYLE_DOT - -// -// Short Exit 1 ... -#define sSE1BufferIndex 5 -double sSE1Buffer[]; - -// -#property indicator_label6 "XCHCHE S SE 1" -#property indicator_type6 DRAW_LINE -#property indicator_style6 STYLE_DOT -#property indicator_color6 clrRed - -// -// Long Exit 2 ... -#define sLE2BufferIndex 6 -double sLE2Buffer[]; - -// -#property indicator_label7 "XCHCHE S LE 2" -#property indicator_type7 DRAW_LINE -#property indicator_style7 STYLE_DOT -#property indicator_color7 clrAqua - -// -// Short Exit 2 ... -#define sSE2BufferIndex 7 -double sSE2Buffer[]; - -// -#property indicator_label8 "XCHCHE S SE 2" -#property indicator_type8 DRAW_LINE -#property indicator_style8 STYLE_DOT -#property indicator_color8 clrMagenta - -// -// Medium ... - -// -// Long Exit 1 ... -#define mLE1BufferIndex 8 -double mLE1Buffer[]; - -// -#property indicator_label9 "XCHCHE M LE 1" -#property indicator_type9 DRAW_LINE -#property indicator_color9 clrLime -#property indicator_style9 STYLE_DOT - -// -// Short Exit 1 ... -#define mSE1BufferIndex 9 -double mSE1Buffer[]; - -// -#property indicator_label10 "XCHCHE M SE 1" -#property indicator_type10 DRAW_LINE -#property indicator_style10 STYLE_DOT -#property indicator_color10 clrRed - -// -// Long Exit 2 ... -#define mLE2BufferIndex 10 -double mLE2Buffer[]; - -// -#property indicator_label11 "XCHCHE M LE 2" -#property indicator_type11 DRAW_LINE -#property indicator_style11 STYLE_DOT -#property indicator_color11 clrAqua - -// -// Short Exit 2 ... -#define mSE2BufferIndex 11 -double mSE2Buffer[]; - -// -#property indicator_label12 "XCHCHE M SE 2" -#property indicator_type12 DRAW_LINE -#property indicator_style12 STYLE_DOT -#property indicator_color12 clrMagenta - -// -// Long ... - -// -// Long Exit 1 ... -#define lLE1BufferIndex 12 -double lLE1Buffer[]; - -// -#property indicator_label13 "XCHCHE L LE 1" -#property indicator_type13 DRAW_LINE -#property indicator_color13 clrLime -#property indicator_style13 STYLE_DOT - -// -// Short Exit 1 ... -#define lSE1BufferIndex 13 -double lSE1Buffer[]; - -// -#property indicator_label14 "XCHCHE L SE 1" -#property indicator_type14 DRAW_LINE -#property indicator_style14 STYLE_DOT -#property indicator_color14 clrRed - -// -// Long Exit 2 ... -#define lLE2BufferIndex 14 -double lLE2Buffer[]; - -// -#property indicator_label15 "XCHCHE L LE 2" -#property indicator_type15 DRAW_LINE -#property indicator_style15 STYLE_DOT -#property indicator_color15 clrAqua - -// -// Short Exit 2 ... -#define lSE2BufferIndex 15 -double lSE2Buffer[]; - -// -#property indicator_label16 "XCHCHE L SE 2" -#property indicator_type16 DRAW_LINE -#property indicator_style16 STYLE_DOT -#property indicator_color16 clrMagenta - -// -// Hind ... - -// -// Long Exit 1 ... -#define hLE1BufferIndex 16 -double hLE1Buffer[]; - -// -#property indicator_label17 "XCHCHE H LE 1" -#property indicator_type17 DRAW_LINE -#property indicator_color17 clrLime -#property indicator_style17 STYLE_DOT - -// -// Short Exit 1 ... -#define hSE1BufferIndex 17 -double hSE1Buffer[]; - -// -#property indicator_label18 "XCHCHE H SE 1" -#property indicator_type18 DRAW_LINE -#property indicator_style18 STYLE_DOT -#property indicator_color18 clrRed - -// -// Long Exit 2 ... -#define hLE2BufferIndex 18 -double hLE2Buffer[]; - -// -#property indicator_label19 "XCHCHE H LE 2" -#property indicator_type19 DRAW_LINE -#property indicator_style19 STYLE_DOT -#property indicator_color19 clrAqua - -// -// Short Exit 2 ... -#define hSE2BufferIndex 19 -double hSE2Buffer[]; - -// -#property indicator_label20 "XCHCHE H SE 2" -#property indicator_type20 DRAW_LINE -#property indicator_style20 STYLE_DOT -#property indicator_color20 clrMagenta - -// -// Variables, Properties and etc ... - -// -int maxLength; - -// -#define hi1Idx 0 -#define lo1Idx 1 -#define hi2Idx 2 -#define lo2Idx 3 -#define trend1Idx 4 -#define trend2Idx 5 - -// -// Current ... -int mCSMLength = length; -double cWork[][6]; - -// -// Short ... -int mSCLength = 0; -int mSSMLength = 0; -ENUM_TIMEFRAMES mSCPeriod = NULL; -double sWork[][6]; - -// -// Medium ... -int mMCLength = 0; -int mMSMLength = 0; -ENUM_TIMEFRAMES mMCPeriod = NULL; -double mWork[][6]; - -// -// Long ... -int mLCLength = 0; -int mLSMLength = 0; -ENUM_TIMEFRAMES mLCPeriod = NULL; -double lWork[][6]; - -// -// Hind ... -int mHCLength = 0; -int mHSMLength = 0; -ENUM_TIMEFRAMES mHCPeriod = NULL; -double hWork[][6]; - -// -// Event Handlers ... - -// -// Initialization ... -int OnInit() -{ - // - // Validate Inputs ... - if (!ValidateInputs()) - { - return INIT_PARAMETERS_INCORRECT; - } - - // - if (!InitMarketCycles()) - { - return INIT_PARAMETERS_INCORRECT; - } - - // - // because in some cases we may have more than one input for - // calculation and we must prevent any calculation - // untill we pass the biggest input length, here we get max Input length - // and then wait until pass it ... - maxLength = ExtractMaxLengthOfInputs(); - - // - // Define Index Buffers ... - DefineBuffers(); - - // - // Set Indicator ShortName ... - SetIndicatorName(); - - // - // Init Succeed ... - return INIT_SUCCEEDED; -} - -// -// DeInitialization ... -void OnDeinit(const int reason) -{ - // - // REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function - // REASON_REMOVE 1 Program removed from a chart - // REASON_RECOMPILE 2 Program recompiled - // REASON_CHARTCHANGE 3 A symbol or a chart period is changed - // REASON_CHARTCLOSE 4 Chart closed - // REASON_PARAMETERS 5 Inputs changed by a user - // REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings - // REASON_TEMPLATE 7 Another chart template applied - // REASON_INITFAILED 8 The OnInit() handler returned a non-zero value - // REASON_CLOSE 9 Terminal closed -} - -// -// Calculating what we want ... -int OnCalculate( - 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 (Bars(_Symbol, _Period) < rates_total) - { - return (prev_calculated); - } - - // - if (ArrayRange(cWork, 0) != rates_total) - { - // - ArrayResize(cWork, rates_total); - ArrayResize(sWork, rates_total); - ArrayResize(mWork, rates_total); - ArrayResize(lWork, rates_total); - ArrayResize(hWork, rates_total); - } - - // - // this counts Available Bars ... - int limit; - - // - limit = prev_calculated - 1; - if (limit < 0) - { - limit = 0; - } - - // - // Main Loop ... - for (int i = limit; i < rates_total && !IsStopped(); i++) - { - // - CalculateBuffers( - // - i, - prev_calculated, - rates_total, - // - open, - high, - low, - close // - ); - } - - // - return rates_total; -} - -// -// Functions ... - -// -// Validate Input Args for Initialization ... -bool ValidateInputs() -{ - // - bool result = false; - - // - result = - // - length >= 2 && - loopback >= 0 && - // - (IsValid(scMethod, scPeriod) && - IsValid(mcMethod, mcPeriod) && - IsValid(lcMethod, lcPeriod) && - IsValid(hcMethod, hcPeriod)) - // - ; - - // - return result; -} - -// -// Initialize Market Cycles ... -bool InitMarketCycles() -{ - // - bool result = false; - - // - // Current Cycle Initialization ... - - // - int cPeriodSeconds = PeriodSeconds(_Period); - - // - // Short Cycle Initialization ... - - // - // Find Cycle Period ... - if (scMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mSCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_SHORT, - _Period // - ); - } - else - { - mSCPeriod = scPeriod; - } - - // - result = IsValid(mSCPeriod); - if (!result) - { - return result; - } - - // - mSCLength = PeriodSeconds(mSCPeriod) / cPeriodSeconds; - mSSMLength = mSCLength * mCSMLength; - result = mSCLength > 0; - if (!result) - { - return result; - } - - // - // Medium Cycle Initialization ... - - // - // Find Cycle Period ... - if (mcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mMCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_MEDIUM, - _Period // - ); - } - else - { - mMCPeriod = mcPeriod; - } - - // - result = IsValid(mMCPeriod); - if (!result) - { - return result; - } - - // - mMCLength = PeriodSeconds(mMCPeriod) / cPeriodSeconds; - mMSMLength = mMCLength * mCSMLength; - result = mMCLength > 0; - if (!result) - { - return result; - } - - // - // Long Cycle Initialization ... - - // - // Find Cycle Period ... - if (lcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mLCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_LONG, - _Period // - ); - } - else - { - mLCPeriod = lcPeriod; - } - - // - result = IsValid(mLCPeriod); - if (!result) - { - return result; - } - - // - mLCLength = PeriodSeconds(mLCPeriod) / cPeriodSeconds; - mLSMLength = mLCLength * mCSMLength; - result = mLCLength > 0; - if (!result) - { - return result; - } - - // - // Hind Cycle Initialization ... - - // - // Find Cycle Period ... - if (hcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mHCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_HIND, - _Period // - ); - } - else - { - mHCPeriod = hcPeriod; - } - - // - result = IsValid(mHCPeriod); - if (!result) - { - return result; - } - - // - mHCLength = PeriodSeconds(mHCPeriod) / cPeriodSeconds; - mHSMLength = mHCLength * mCSMLength; - result = mHCLength > 0; - if (!result) - { - return result; - } - - // - return result; -} - -// -// Retrieve all Exists Input Max Length ... -// use for Start Of Drawing ... -int ExtractMaxLengthOfInputs() -{ - // - int result = 0; - - // - result = MathMax(mCSMLength, mSSMLength); - result = MathMax(result, mMSMLength); - result = MathMax(result, mLSMLength); - result = MathMax(result, mHSMLength); - - // - return result; -} - -// -// Define Indexes and Styles ... -void DefineBuffers() -{ - // - // Current ... - - // - // Long Exit 1 ... - bool canShowCLE1 = showCurrent && showLE1; - ENUM_DRAW_TYPE cLE1DrawType = canShowCLE1 ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(cLE1BufferIndex, cLE1Buffer, INDICATOR_DATA); - PlotIndexSetInteger(cLE1BufferIndex, PLOT_SHOW_DATA, canShowCLE1); - PlotIndexSetInteger(cLE1BufferIndex, PLOT_DRAW_TYPE, cLE1DrawType); - - // - // Long Exit 2 ... - bool canShowCLE2 = showCurrent && showLE2; - ENUM_DRAW_TYPE cLE2DrawType = canShowCLE2 ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(cLE2BufferIndex, cLE2Buffer, INDICATOR_DATA); - PlotIndexSetInteger(cLE2BufferIndex, PLOT_SHOW_DATA, canShowCLE2); - PlotIndexSetInteger(cLE2BufferIndex, PLOT_DRAW_TYPE, cLE2DrawType); - - // - // Short Exit 1 ... - bool canShowCSE1 = showCurrent && showSE1; - ENUM_DRAW_TYPE cSE1DrawType = canShowCSE1 ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(cSE1BufferIndex, cSE1Buffer, INDICATOR_DATA); - PlotIndexSetInteger(cSE1BufferIndex, PLOT_SHOW_DATA, canShowCSE1); - PlotIndexSetInteger(cSE1BufferIndex, PLOT_DRAW_TYPE, cSE1DrawType); - - // - // Short Exit 2 ... - bool canShowCSE2 = showCurrent && showSE2; - ENUM_DRAW_TYPE cSE2DrawType = canShowCSE2 ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(cSE2BufferIndex, cSE2Buffer, INDICATOR_DATA); - PlotIndexSetInteger(cSE2BufferIndex, PLOT_SHOW_DATA, canShowCSE2); - PlotIndexSetInteger(cSE2BufferIndex, PLOT_DRAW_TYPE, cSE2DrawType); - - // - // Short ... - - // - // Long Exit 1 ... - bool canShowSLE1 = showShort && showLE1; - ENUM_DRAW_TYPE sLE1DrawType = canShowSLE1 ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(sLE1BufferIndex, sLE1Buffer, INDICATOR_DATA); - PlotIndexSetInteger(sLE1BufferIndex, PLOT_SHOW_DATA, canShowSLE1); - PlotIndexSetInteger(sLE1BufferIndex, PLOT_DRAW_TYPE, sLE1DrawType); - - // - // Long Exit 2 ... - bool canShowSLE2 = showShort && showLE2; - ENUM_DRAW_TYPE sLE2DrawType = canShowSLE2 ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(sLE2BufferIndex, sLE2Buffer, INDICATOR_DATA); - PlotIndexSetInteger(sLE2BufferIndex, PLOT_SHOW_DATA, canShowSLE2); - PlotIndexSetInteger(sLE2BufferIndex, PLOT_DRAW_TYPE, sLE2DrawType); - - // - bool canShowSSE1 = showShort && showSE1; - // Short Exit 1 ... - ENUM_DRAW_TYPE sSE1DrawType = canShowSSE1 ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(sSE1BufferIndex, sSE1Buffer, INDICATOR_DATA); - PlotIndexSetInteger(sSE1BufferIndex, PLOT_SHOW_DATA, canShowSSE1); - PlotIndexSetInteger(sSE1BufferIndex, PLOT_DRAW_TYPE, sSE1DrawType); - - // - // Short Exit 2 ... - bool canShowSSE2 = showShort && showSE2; - ENUM_DRAW_TYPE sSE2DrawType = canShowSSE2 ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(sSE2BufferIndex, sSE2Buffer, INDICATOR_DATA); - PlotIndexSetInteger(sSE2BufferIndex, PLOT_SHOW_DATA, canShowSSE2); - PlotIndexSetInteger(sSE2BufferIndex, PLOT_DRAW_TYPE, sSE2DrawType); - - // - // Medium ... - - // - // Long Exit 1 ... - bool canShowMLE1 = showMedium && showLE1; - ENUM_DRAW_TYPE mLE1DrawType = canShowMLE1 ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(mLE1BufferIndex, mLE1Buffer, INDICATOR_DATA); - PlotIndexSetInteger(mLE1BufferIndex, PLOT_SHOW_DATA, canShowMLE1); - PlotIndexSetInteger(mLE1BufferIndex, PLOT_DRAW_TYPE, mLE1DrawType); - - // - // Long Exit 2 ... - bool canShowMLE2 = showMedium && showLE2; - ENUM_DRAW_TYPE mLE2DrawType = canShowMLE2 ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(mLE2BufferIndex, mLE2Buffer, INDICATOR_DATA); - PlotIndexSetInteger(mLE2BufferIndex, PLOT_SHOW_DATA, canShowMLE2); - PlotIndexSetInteger(mLE2BufferIndex, PLOT_DRAW_TYPE, mLE2DrawType); - - // - // Short Exit 1 ... - bool canShowMSE1 = showMedium && showSE1; - ENUM_DRAW_TYPE mSE1DrawType = canShowMSE1 ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(mSE1BufferIndex, mSE1Buffer, INDICATOR_DATA); - PlotIndexSetInteger(mSE1BufferIndex, PLOT_SHOW_DATA, canShowMSE1); - PlotIndexSetInteger(mSE1BufferIndex, PLOT_DRAW_TYPE, mSE1DrawType); - - // - // Short Exit 2 ... - bool canShowMSE2 = showMedium && showSE2; - ENUM_DRAW_TYPE mSE2DrawType = canShowMSE2 ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(mSE2BufferIndex, mSE2Buffer, INDICATOR_DATA); - PlotIndexSetInteger(mSE2BufferIndex, PLOT_SHOW_DATA, canShowMSE2); - PlotIndexSetInteger(mSE2BufferIndex, PLOT_DRAW_TYPE, mSE2DrawType); - - // - // Long ... - - // - // Long Exit 1 ... - bool canShowLLE1 = showLong && showLE1; - ENUM_DRAW_TYPE lLE1DrawType = canShowLLE1 ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(lLE1BufferIndex, lLE1Buffer, INDICATOR_DATA); - PlotIndexSetInteger(lLE1BufferIndex, PLOT_SHOW_DATA, canShowLLE1); - PlotIndexSetInteger(lLE1BufferIndex, PLOT_DRAW_TYPE, lLE1DrawType); - - // - // Long Exit 2 ... - bool canShowLLE2 = showLong && showLE2; - ENUM_DRAW_TYPE lLE2DrawType = canShowLLE2 ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(lLE2BufferIndex, lLE2Buffer, INDICATOR_DATA); - PlotIndexSetInteger(lLE2BufferIndex, PLOT_SHOW_DATA, canShowLLE2); - PlotIndexSetInteger(lLE2BufferIndex, PLOT_DRAW_TYPE, lLE2DrawType); - - // - // Short Exit 1 ... - bool canShowLSE1 = showLong && showSE1; - ENUM_DRAW_TYPE lSE1DrawType = canShowLSE1 ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(lSE1BufferIndex, lSE1Buffer, INDICATOR_DATA); - PlotIndexSetInteger(lSE1BufferIndex, PLOT_SHOW_DATA, canShowLSE1); - PlotIndexSetInteger(lSE1BufferIndex, PLOT_DRAW_TYPE, lSE1DrawType); - - // - // Short Exit 2 ... - bool canShowLSE2 = showLong && showSE2; - ENUM_DRAW_TYPE lSE2DrawType = canShowLSE2 ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(lSE2BufferIndex, lSE2Buffer, INDICATOR_DATA); - PlotIndexSetInteger(lSE2BufferIndex, PLOT_SHOW_DATA, canShowLSE2); - PlotIndexSetInteger(lSE2BufferIndex, PLOT_DRAW_TYPE, lSE2DrawType); - - // - // Hind ... - - // - // Long Exit 1 ... - bool canShowHLE1 = showHind && showLE1; - ENUM_DRAW_TYPE hLE1DrawType = canShowHLE1 ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(hLE1BufferIndex, hLE1Buffer, INDICATOR_DATA); - PlotIndexSetInteger(hLE1BufferIndex, PLOT_SHOW_DATA, canShowHLE1); - PlotIndexSetInteger(hLE1BufferIndex, PLOT_DRAW_TYPE, hLE1DrawType); - - // - // Long Exit 2 ... - bool canShowHLE2 = showHind && showLE2; - ENUM_DRAW_TYPE hLE2DrawType = canShowHLE2 ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(hLE2BufferIndex, hLE2Buffer, INDICATOR_DATA); - PlotIndexSetInteger(hLE2BufferIndex, PLOT_SHOW_DATA, canShowHLE2); - PlotIndexSetInteger(hLE2BufferIndex, PLOT_DRAW_TYPE, hLE2DrawType); - - // - // Short Exit 1 ... - bool canShowHSE1 = showHind && showSE1; - ENUM_DRAW_TYPE hSE1DrawType = canShowHSE1 ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(hSE1BufferIndex, hSE1Buffer, INDICATOR_DATA); - PlotIndexSetInteger(hSE1BufferIndex, PLOT_SHOW_DATA, canShowHSE1); - PlotIndexSetInteger(hSE1BufferIndex, PLOT_DRAW_TYPE, hSE1DrawType); - - // - // Short Exit 2 ... - bool canShowHSE2 = showHind && showSE2; - ENUM_DRAW_TYPE hSE2DrawType = canShowHSE2 ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(hSE2BufferIndex, hSE2Buffer, INDICATOR_DATA); - PlotIndexSetInteger(hSE2BufferIndex, PLOT_SHOW_DATA, canShowHSE2); - PlotIndexSetInteger(hSE2BufferIndex, PLOT_DRAW_TYPE, hSE2DrawType); -} - -// -// Set Indicator Short Name and also we can define Buffers Labels ... -void SetIndicatorName() -{ - IndicatorSetString(INDICATOR_SHORTNAME, ShortName); -} - -// -// Calculations ... - -// -// Calculate Buffers ... -void CalculateBuffers( - int bar_index, // Selected Bar Index - const int prevCalculated, - const int ratesTotal, - const double &open[], - const double &high[], - const double &close[], - const double &low[] // -) -{ - // - CalculateCycles( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low // - ); -} - -// -void CalculateCycles( - int bar_index, // Selected Bar Index - const int prevCalculated, - const int ratesTotal, - const double &open[], - const double &high[], - const double &close[], - const double &low[] // -) -{ - // - // CURRENT ... - CalculateCycle( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - mCSMLength, - cWork, - cLE1Buffer, - cLE2Buffer, - cSE1Buffer, - cSE2Buffer // - ); - - // - // SHORT ... - CalculateCycle( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - mSSMLength, - sWork, - sLE1Buffer, - sLE2Buffer, - sSE1Buffer, - sSE2Buffer // - ); - - // - // MEDIUM ... - CalculateCycle( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - mMSMLength, - mWork, - mLE1Buffer, - mLE2Buffer, - mSE1Buffer, - mSE2Buffer // - ); - - // - // LONG ... - CalculateCycle( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - mLSMLength, - lWork, - lLE1Buffer, - lLE2Buffer, - lSE1Buffer, - lSE2Buffer // - ); - - // - // HIND ... - CalculateCycle( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - mHSMLength, - hWork, - hLE1Buffer, - hLE2Buffer, - hSE1Buffer, - hSE2Buffer // - ); -} - -// -void CalculateCycle( - int bar_index, // Selected Bar Index - const int prevCalculated, - const int ratesTotal, - const double &open[], - const double &high[], - const double &close[], - const double &low[], - // - int _length, // Calculation Length - double &work[][], // Working Array - // - double &le1[], - double &le2[], - double &se1[], - double &se2[] // -) -{ - // - // Cleanup Buffers ... - le1[bar_index] = se1[bar_index] = EMPTY_VALUE; - le2[bar_index] = se2[bar_index] = EMPTY_VALUE; - - // - int start = MathMax(bar_index - loopback, 0); - - // - // Calculate ATR Value ... - double atrValue = 0; - for (int k = 1; k <= _length && (bar_index - k - 1) >= 0; k++) - { - // - atrValue += MathMax(high[bar_index - k], close[MathMax(bar_index - k - 1, 0)]) - - MathMin(low[bar_index - k], close[MathMax(bar_index - k - 1, 0)]); - } - atrValue /= (double)_length; - - // - // Retrieve Highest High and Lowest Lows ... - double loopbackMax = high[ArrayMaximum(high, start, loopback)]; - double loopbackMin = low[ArrayMinimum(low, start, loopback)]; - - // - // Fill Multi Dimesional Working Array ... - work[bar_index][hi1Idx] = loopbackMax - multiplier1 * atrValue; - work[bar_index][lo1Idx] = loopbackMin + multiplier1 * atrValue; - work[bar_index][hi2Idx] = loopbackMax - multiplier2 * atrValue; - work[bar_index][lo2Idx] = loopbackMin + multiplier2 * atrValue; - work[bar_index][trend1Idx] = (bar_index > 0) ? work[bar_index - 1][trend1Idx] : 0; - work[bar_index][trend2Idx] = (bar_index > 0) ? work[bar_index - 1][trend2Idx] : 0; - - // - if (bar_index > 0) - { - // - // Calculate Trends ... - if (close[bar_index] > work[bar_index - 1][lo1Idx]) - { - work[bar_index][trend1Idx] = 1; - } - - // - if (close[bar_index] < work[bar_index - 1][hi1Idx]) - { - work[bar_index][trend1Idx] = -1; - } - - // - if (close[bar_index] > work[bar_index - 1][lo2Idx]) - { - work[bar_index][trend2Idx] = 1; - } - - // - if (close[bar_index] < work[bar_index - 1][hi2Idx]) - { - work[bar_index][trend2Idx] = -1; - } - - // - // Calculate Exit Values ... - - // - // Exit 1 ... - - // - // Long ... - if (multiplier1 > 0 && work[bar_index][trend1Idx] == 1) - { - // - if (work[bar_index][hi1Idx] < work[bar_index - 1][hi1Idx]) - { - work[bar_index][hi1Idx] = work[bar_index - 1][hi1Idx]; - } - - // - le1[bar_index] = work[bar_index][hi1Idx]; - - // // - // if (le1[bar_index - 1] == EMPTY_VALUE) - // { - // longExit1StartBuffer[bar_index] = le1[bar_index]; - // } - } - - // - // Short ... - if (multiplier1 > 0 && work[bar_index][trend1Idx] == -1) - { - // - if (work[bar_index][lo1Idx] > work[bar_index - 1][lo1Idx]) - { - work[bar_index][lo1Idx] = work[bar_index - 1][lo1Idx]; - } - - // - se1[bar_index] = work[bar_index][lo1Idx]; - - // // - // if (se1[bar_index - 1] == EMPTY_VALUE) - // { - // shortExit1StartBuffer[bar_index] = se1[bar_index]; - // } - } - - // - // Exit 2 ... - - // - // Long ... - if (multiplier2 > 0 && work[bar_index][trend2Idx] == 1) - { - if (work[bar_index][hi2Idx] < work[bar_index - 1][hi2Idx]) - { - work[bar_index][hi2Idx] = work[bar_index - 1][hi2Idx]; - } - - // - le2[bar_index] = work[bar_index][hi2Idx]; - - // // - // if (le2[bar_index - 1] == EMPTY_VALUE) - // { - // longExit2StartBuffer[bar_index] = le2[bar_index]; - // } - } - - // - // Short ... - if (multiplier2 > 0 && work[bar_index][trend2Idx] == -1) - { - // - if (work[bar_index][lo2Idx] > work[bar_index - 1][lo2Idx]) - { - work[bar_index][lo2Idx] = work[bar_index - 1][lo2Idx]; - } - - // - se2[bar_index] = work[bar_index][lo2Idx]; - - // // - // if (se2[bar_index - 1] == EMPTY_VALUE) - // { - // shortExit2StartBuffer[bar_index] = se2[bar_index]; - // } - } - } -} - -// \ No newline at end of file diff --git a/Indicators/x-saherelm.xchdon.mq5 b/Indicators/x-saherelm.xchdon.mq5 deleted file mode 100644 index 64f53ece..00000000 --- a/Indicators/x-saherelm.xchdon.mq5 +++ /dev/null @@ -1,1603 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Indicator -// ------------------------------------------------- -// Name: XCHDON -// Description: Donchain on Cycles ... -// -// -// Maintainer: -// ------------ -// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) -// -////////////////////////////////////////////////////// -// -// Global Properties ... -#property copyright "Copyright 2023, SaherElm IT Center" -#property link "https://saherelm.ir" -#property version "1.00" -#property description "SaherElm XCHDON Indicator" -#property strict - -// -#define ShortName "XCHDON" - -// -// Includes Common Library ... -#include "../Libraries/x-saherelm.common.lib.mq5" - -// -// Inputs ... - -// -input group "Market"; -input int length = 52; // Market Length - -// -input group "Cycles"; - -// -input group "Short"; -input ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES scPeriod = NULL; // Time Period - -// -input group "Medium"; -input ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES mcPeriod = NULL; // Time Period - -// -input group "Long"; -input ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES lcPeriod = NULL; // Time Period - -// -input group "Hind"; -input ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period - -// -input group "Presentation"; - -// -input bool showUpper = true; // Show Upper Band -input bool showLower = true; // Show Lower Band - -// -input bool showOpen = true; // Show Open -input bool showHigh = true; // Show High -input bool showClose = true; // Show Close -input bool showLow = true; // Show Low - -// -input bool showCurrent = true; // Show Current Cycle -input bool showShort = true; // Show Short Cycle -input bool showMedium = true; // Show Medium Cycle -input bool showLong = true; // Show Long Cycle -input bool showHind = true; // Show Hind Cycle - -// -// Buffers ... - -// -#property indicator_chart_window - -// -#property indicator_buffers 40 -#property indicator_plots 40 - -// -// Current ... - -// -// Open ... - -// -#define cOpenUpperBufferIndex 0 -double cOpenUpperBuffer[]; - -// -#property indicator_label1 "XCHDON C O U" -#property indicator_type1 DRAW_LINE -#property indicator_color1 clrCornflowerBlue -#property indicator_width1 1 - -// -#define cOpenLowerBufferIndex 1 -double cOpenLowerBuffer[]; - -// -#property indicator_label2 "XCHDON C O L" -#property indicator_type2 DRAW_LINE -#property indicator_color2 clrCornflowerBlue -#property indicator_width2 1 - -// -// High ... - -// -#define cHighUpperBufferIndex 2 -double cHighUpperBuffer[]; - -// -#property indicator_label3 "XCHDON C H U" -#property indicator_type3 DRAW_LINE -#property indicator_color3 clrAquamarine -#property indicator_width3 1 - -// -#define cHighLowerBufferIndex 3 -double cHighLowerBuffer[]; - -// -#property indicator_label4 "XCHDON C H L" -#property indicator_type4 DRAW_LINE -#property indicator_color4 clrAquamarine -#property indicator_width4 1 - -// -// Low ... - -// -#define cLowUpperBufferIndex 4 -double cLowUpperBuffer[]; - -// -#property indicator_label5 "XCHDON C L U" -#property indicator_type5 DRAW_LINE -#property indicator_color5 clrDarkOrchid -#property indicator_width5 1 - -// -#define cLowLowerBufferIndex 5 -double cLowLowerBuffer[]; - -// -#property indicator_label6 "XCHDON C L L" -#property indicator_type6 DRAW_LINE -#property indicator_color6 clrDarkOrchid -#property indicator_width6 1 - -// -// Close ... - -// -#define cCloseUpperBufferIndex 6 -double cCloseUpperBuffer[]; - -// -#property indicator_label7 "XCHDON C C U" -#property indicator_type7 DRAW_LINE -#property indicator_color7 clrCoral -#property indicator_width7 1 - -// -#define cCloseLowerBufferIndex 7 -double cCloseLowerBuffer[]; - -// -#property indicator_label8 "XCHDON C C L" -#property indicator_type8 DRAW_LINE -#property indicator_color8 clrCoral -#property indicator_width8 1 - -// -// Short ... - -// -// Open ... - -// -#define sOpenUpperBufferIndex 8 -double sOpenUpperBuffer[]; - -// -#property indicator_label9 "XCHDON S O U" -#property indicator_type9 DRAW_LINE -#property indicator_color9 clrCornflowerBlue -#property indicator_width9 1 - -// -#define sOpenLowerBufferIndex 9 -double sOpenLowerBuffer[]; - -// -#property indicator_label10 "XCHDON S O L" -#property indicator_type10 DRAW_LINE -#property indicator_color10 clrCornflowerBlue -#property indicator_width10 1 - -// -// High ... - -// -#define sHighUpperBufferIndex 10 -double sHighUpperBuffer[]; - -// -#property indicator_label11 "XCHDON S H U" -#property indicator_type11 DRAW_LINE -#property indicator_color11 clrAquamarine -#property indicator_width11 1 - -// -#define sHighLowerBufferIndex 11 -double sHighLowerBuffer[]; - -// -#property indicator_label12 "XCHDON S H L" -#property indicator_type12 DRAW_LINE -#property indicator_color12 clrAquamarine -#property indicator_width12 1 - -// -// Low ... - -// -#define sLowUpperBufferIndex 12 -double sLowUpperBuffer[]; - -// -#property indicator_label13 "XCHDON S L U" -#property indicator_type13 DRAW_LINE -#property indicator_color13 clrDarkOrchid -#property indicator_width13 1 - -// -#define sLowLowerBufferIndex 13 -double sLowLowerBuffer[]; - -// -#property indicator_label14 "XCHDON S L L" -#property indicator_type14 DRAW_LINE -#property indicator_color14 clrDarkOrchid -#property indicator_width14 1 - -// -// Close ... - -// -#define sCloseUpperBufferIndex 14 -double sCloseUpperBuffer[]; - -// -#property indicator_label15 "XCHDON S C U" -#property indicator_type15 DRAW_LINE -#property indicator_color15 clrCoral -#property indicator_width15 1 - -// -#define sCloseLowerBufferIndex 15 -double sCloseLowerBuffer[]; - -// -#property indicator_label16 "XCHDON S C L" -#property indicator_type16 DRAW_LINE -#property indicator_color16 clrCoral -#property indicator_width16 1 - -// -// Medium ... - -// -// Open ... - -// -#define mOpenUpperBufferIndex 16 -double mOpenUpperBuffer[]; - -// -#property indicator_label17 "XCHDON M O U" -#property indicator_type17 DRAW_LINE -#property indicator_color17 clrCornflowerBlue -#property indicator_width17 1 - -// -#define mOpenLowerBufferIndex 17 -double mOpenLowerBuffer[]; - -// -#property indicator_label18 "XCHDON M O L" -#property indicator_type18 DRAW_LINE -#property indicator_color18 clrCornflowerBlue -#property indicator_width18 1 - -// -// High ... - -// -#define mHighUpperBufferIndex 18 -double mHighUpperBuffer[]; - -// -#property indicator_label19 "XCHDON M H U" -#property indicator_type19 DRAW_LINE -#property indicator_color19 clrAquamarine -#property indicator_width19 1 - -// -#define mHighLowerBufferIndex 19 -double mHighLowerBuffer[]; - -// -#property indicator_label20 "XCHDON M H L" -#property indicator_type20 DRAW_LINE -#property indicator_color20 clrAquamarine -#property indicator_width20 1 - -// -// Low ... - -// -#define mLowUpperBufferIndex 20 -double mLowUpperBuffer[]; - -// -#property indicator_label21 "XCHDON M L U" -#property indicator_type21 DRAW_LINE -#property indicator_color21 clrDarkOrchid -#property indicator_width21 1 - -// -#define mLowLowerBufferIndex 21 -double mLowLowerBuffer[]; - -// -#property indicator_label22 "XCHDON M L L" -#property indicator_type22 DRAW_LINE -#property indicator_color22 clrDarkOrchid -#property indicator_width22 1 - -// -// Close ... - -// -#define mCloseUpperBufferIndex 22 -double mCloseUpperBuffer[]; - -// -#property indicator_label23 "XCHDON M C U" -#property indicator_type23 DRAW_LINE -#property indicator_color23 clrCoral -#property indicator_width23 1 - -// -#define mCloseLowerBufferIndex 23 -double mCloseLowerBuffer[]; - -// -#property indicator_label24 "XCHDON M C L" -#property indicator_type24 DRAW_LINE -#property indicator_color24 clrCoral -#property indicator_width24 1 - -// -// Long ... - -// -// Open ... - -// -#define lOpenUpperBufferIndex 24 -double lOpenUpperBuffer[]; - -// -#property indicator_label25 "XCHDON L O U" -#property indicator_type25 DRAW_LINE -#property indicator_color25 clrCornflowerBlue -#property indicator_width25 1 - -// -#define lOpenLowerBufferIndex 25 -double lOpenLowerBuffer[]; - -// -#property indicator_label26 "XCHDON L O L" -#property indicator_type26 DRAW_LINE -#property indicator_color26 clrCornflowerBlue -#property indicator_width26 1 - -// -// High ... - -// -#define lHighUpperBufferIndex 26 -double lHighUpperBuffer[]; - -// -#property indicator_label27 "XCHDON L H U" -#property indicator_type27 DRAW_LINE -#property indicator_color27 clrAquamarine -#property indicator_width27 1 - -// -#define lHighLowerBufferIndex 27 -double lHighLowerBuffer[]; - -// -#property indicator_label28 "XCHDON L H L" -#property indicator_type28 DRAW_LINE -#property indicator_color28 clrAquamarine -#property indicator_width28 1 - -// -// Low ... - -// -#define lLowUpperBufferIndex 28 -double lLowUpperBuffer[]; - -// -#property indicator_label29 "XCHDON L L U" -#property indicator_type29 DRAW_LINE -#property indicator_color29 clrDarkOrchid -#property indicator_width29 1 - -// -#define lLowLowerBufferIndex 29 -double lLowLowerBuffer[]; - -// -#property indicator_label30 "XCHDON L L L" -#property indicator_type30 DRAW_LINE -#property indicator_color30 clrDarkOrchid -#property indicator_width30 1 - -// -// Close ... - -// -#define lCloseUpperBufferIndex 30 -double lCloseUpperBuffer[]; - -// -#property indicator_label31 "XCHDON L C U" -#property indicator_type31 DRAW_LINE -#property indicator_color31 clrCoral -#property indicator_width31 1 - -// -#define lCloseLowerBufferIndex 31 -double lCloseLowerBuffer[]; - -// -#property indicator_label32 "XCHDON L C L" -#property indicator_type32 DRAW_LINE -#property indicator_color32 clrCoral -#property indicator_width32 1 - -// -// Hind ... - -// -// Open ... - -// -#define hOpenUpperBufferIndex 32 -double hOpenUpperBuffer[]; - -// -#property indicator_label33 "XCHDON H O U" -#property indicator_type33 DRAW_LINE -#property indicator_color33 clrCornflowerBlue -#property indicator_width33 1 - -// -#define hOpenLowerBufferIndex 33 -double hOpenLowerBuffer[]; - -// -#property indicator_label34 "XCHDON H O L" -#property indicator_type34 DRAW_LINE -#property indicator_color34 clrCornflowerBlue -#property indicator_width34 1 - -// -// High ... - -// -#define hHighUpperBufferIndex 34 -double hHighUpperBuffer[]; - -// -#property indicator_label35 "XCHDON H H U" -#property indicator_type35 DRAW_LINE -#property indicator_color35 clrAquamarine -#property indicator_width35 1 - -// -#define hHighLowerBufferIndex 35 -double hHighLowerBuffer[]; - -// -#property indicator_label36 "XCHDON H H L" -#property indicator_type36 DRAW_LINE -#property indicator_color36 clrAquamarine -#property indicator_width36 1 - -// -// Low ... - -// -#define hLowUpperBufferIndex 36 -double hLowUpperBuffer[]; - -// -#property indicator_label37 "XCHDON H L U" -#property indicator_type37 DRAW_LINE -#property indicator_color37 clrDarkOrchid -#property indicator_width37 1 - -// -#define hLowLowerBufferIndex 37 -double hLowLowerBuffer[]; - -// -#property indicator_label38 "XCHDON H L L" -#property indicator_type38 DRAW_LINE -#property indicator_color38 clrDarkOrchid -#property indicator_width38 1 - -// -// Close ... - -// -#define hCloseUpperBufferIndex 38 -double hCloseUpperBuffer[]; - -// -#property indicator_label39 "XCHDON H C U" -#property indicator_type39 DRAW_LINE -#property indicator_color39 clrCoral -#property indicator_width39 1 - -// -#define hCloseLowerBufferIndex 39 -double hCloseLowerBuffer[]; - -// -#property indicator_label40 "XCHDON H C L" -#property indicator_type40 DRAW_LINE -#property indicator_color40 clrCoral -#property indicator_width40 1 - -// -// Variables, Properties and etc ... - -// -int maxLength; - -// -// Current ... -int mCMarketLength = length; - -// -// Short ... -int mSCycleLength = 0; -int mSMarketLength = 0; -ENUM_TIMEFRAMES mSCPeriod = NULL; - -// -// Medium ... -int mMCycleLength = 0; -int mMMarketLength = 0; -ENUM_TIMEFRAMES mMCPeriod = NULL; - -// -// Long ... -int mLCycleLength = 0; -int mLMarketLength = 0; -ENUM_TIMEFRAMES mLCPeriod = NULL; - -// -// Hind ... -int mHCycleLength = 0; -int mHMarketLength = 0; -ENUM_TIMEFRAMES mHCPeriod = NULL; - -// -// Event Handlers ... - -// -// Initialization ... -int OnInit() -{ - // - // Validate Inputs ... - if (!ValidateInputs()) - { - return INIT_PARAMETERS_INCORRECT; - } - - // - if (!InitMarketCycles()) - { - return INIT_PARAMETERS_INCORRECT; - } - - // - // because in some cases we may have more than one input for - // calculation and we must prevent any calculation - // untill we pass the biggest input length, here we get max Input length - // and then wait until pass it ... - maxLength = ExtractMaxLengthOfInputs(); - - // - // Define Index Buffers ... - DefineBuffers(); - - // - // Set Indicator ShortName ... - SetIndicatorName(); - - // - // Init Succeed ... - return INIT_SUCCEEDED; -} - -// -// DeInitialization ... -void OnDeinit(const int reason) -{ - // - // REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function - // REASON_REMOVE 1 Program removed from a chart - // REASON_RECOMPILE 2 Program recompiled - // REASON_CHARTCHANGE 3 A symbol or a chart period is changed - // REASON_CHARTCLOSE 4 Chart closed - // REASON_PARAMETERS 5 Inputs changed by a user - // REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings - // REASON_TEMPLATE 7 Another chart template applied - // REASON_INITFAILED 8 The OnInit() handler returned a non-zero value - // REASON_CLOSE 9 Terminal closed -} - -// -// Calculating what we want ... -int OnCalculate( - 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 < maxLength - 1) - { - return prev_calculated; - } - - // - int start = prev_calculated == 0 - ? maxLength - : prev_calculated - 1; - - // - // Main Loop ... - for (int i = start; i < rates_total; i++) - { - // - CalculateBuffers( - // - i, - prev_calculated, - rates_total, - // - open, - high, - close, - low, - tick_volume - // - ); - } - - // - return rates_total; -} - -// -// Functions ... - -// -// Validate Input Args for Initialization ... -bool ValidateInputs() -{ - // - bool result = false; - - // - result = - // - length > 2 - // - && - // - (IsValid(scMethod, scPeriod) && - IsValid(mcMethod, mcPeriod) && - IsValid(lcMethod, lcPeriod) && - IsValid(hcMethod, hcPeriod)) - // - ; - - // - return result; -} - -// -// Initialize Market Cycles ... -bool InitMarketCycles() -{ - // - bool result = false; - - // - // Current Cycle Initialization ... - - // - int cPeriodSeconds = PeriodSeconds(_Period); - - // - // Short Cycle Initialization ... - - // - // Find Cycle Period ... - if (scMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mSCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_SHORT, - _Period // - ); - } - else - { - mSCPeriod = scPeriod; - } - - // - result = IsValid(mSCPeriod); - if (!result) - { - return result; - } - - // - mSCycleLength = PeriodSeconds(mSCPeriod) / cPeriodSeconds; - mSMarketLength = mSCycleLength * mCMarketLength; - result = mSCycleLength > 0; - if (!result) - { - return result; - } - - // - // Medium Cycle Initialization ... - - // - // Find Cycle Period ... - if (mcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mMCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_MEDIUM, - _Period // - ); - } - else - { - mMCPeriod = mcPeriod; - } - - // - result = IsValid(mMCPeriod); - if (!result) - { - return result; - } - - // - mMCycleLength = PeriodSeconds(mMCPeriod) / cPeriodSeconds; - mMMarketLength = mMCycleLength * mCMarketLength; - result = mMCycleLength > 0; - if (!result) - { - return result; - } - - // - // Long Cycle Initialization ... - - // - // Find Cycle Period ... - if (lcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mLCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_LONG, - _Period // - ); - } - else - { - mLCPeriod = lcPeriod; - } - - // - result = IsValid(mLCPeriod); - if (!result) - { - return result; - } - - // - mLCycleLength = PeriodSeconds(mLCPeriod) / cPeriodSeconds; - mLMarketLength = mLCycleLength * mCMarketLength; - result = mLCycleLength > 0; - if (!result) - { - return result; - } - - // - // Hind Cycle Initialization ... - - // - // Find Cycle Period ... - if (hcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mHCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_HIND, - _Period // - ); - } - else - { - mHCPeriod = hcPeriod; - } - - // - result = IsValid(mHCPeriod); - if (!result) - { - return result; - } - - // - mHCycleLength = PeriodSeconds(mHCPeriod) / cPeriodSeconds; - mHMarketLength = mHCycleLength * mCMarketLength; - result = mHCycleLength > 0; - if (!result) - { - return result; - } - - // - return result; -} - -// -// Retrieve all Exists Input Max Length ... -// use for Start Of Drawing ... -int ExtractMaxLengthOfInputs() -{ - // - int result = 0; - - // - // Current ... - result = MathMax(mCMarketLength, mSMarketLength); - result = MathMax(result, mMMarketLength); - result = MathMax(result, mLMarketLength); - result = MathMax(result, mHMarketLength); - - // - return result; -} - -// -// Set Indicator Short Name and also we can define Buffers Labels ... -void SetIndicatorName() -{ - // - IndicatorSetString(INDICATOR_SHORTNAME, ShortName); - IndicatorSetInteger(INDICATOR_DIGITS, _Digits); -} - -// -// Define Indexes and Styles ... -void DefineBuffers() -{ - // - // CURRENT ... - - // - // Open ... - - // - // UPPER ... - bool canShowCOpenUpper = showUpper && showOpen && showCurrent; - ENUM_DRAW_TYPE cOpenUpperDrawType = canShowCOpenUpper ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(cOpenUpperBufferIndex, cOpenUpperBuffer, INDICATOR_DATA); - PlotIndexSetDouble(cOpenUpperBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(cOpenUpperBufferIndex, PLOT_SHOW_DATA, canShowCOpenUpper); - PlotIndexSetInteger(cOpenUpperBufferIndex, PLOT_DRAW_TYPE, cOpenUpperDrawType); - - // - // LOWER ... - bool canShowCOpenLower = showLower && showOpen && showCurrent; - ENUM_DRAW_TYPE cOpenLowerDrawType = canShowCOpenLower ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(cOpenLowerBufferIndex, cOpenLowerBuffer, INDICATOR_DATA); - PlotIndexSetDouble(cOpenLowerBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(cOpenLowerBufferIndex, PLOT_SHOW_DATA, canShowCOpenLower); - PlotIndexSetInteger(cOpenLowerBufferIndex, PLOT_DRAW_TYPE, cOpenLowerDrawType); - - // - // Close ... - - // - // UPPER ... - bool canShowCCloseUpper = showUpper && showClose && showCurrent; - ENUM_DRAW_TYPE cCloseUpperDrawType = canShowCCloseUpper ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(cCloseUpperBufferIndex, cCloseUpperBuffer, INDICATOR_DATA); - PlotIndexSetDouble(cCloseUpperBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(cCloseUpperBufferIndex, PLOT_SHOW_DATA, canShowCCloseUpper); - PlotIndexSetInteger(cCloseUpperBufferIndex, PLOT_DRAW_TYPE, cCloseUpperDrawType); - - // - // LOWER ... - bool canShowCCloseLower = showLower && showClose && showCurrent; - ENUM_DRAW_TYPE cCloseLowerDrawType = canShowCCloseLower ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(cCloseLowerBufferIndex, cCloseLowerBuffer, INDICATOR_DATA); - PlotIndexSetDouble(cCloseLowerBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(cCloseLowerBufferIndex, PLOT_SHOW_DATA, canShowCCloseLower); - PlotIndexSetInteger(cCloseLowerBufferIndex, PLOT_DRAW_TYPE, cCloseLowerDrawType); - - // - // High ... - - // - // UPPER ... - bool canShowCHighUpper = showUpper && showHigh && showCurrent; - ENUM_DRAW_TYPE cHighUpperDrawType = canShowCHighUpper ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(cHighUpperBufferIndex, cHighUpperBuffer, INDICATOR_DATA); - PlotIndexSetDouble(cHighUpperBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(cHighUpperBufferIndex, PLOT_SHOW_DATA, canShowCHighUpper); - PlotIndexSetInteger(cHighUpperBufferIndex, PLOT_DRAW_TYPE, cHighUpperDrawType); - - // - // LOWER ... - bool canShowCHighLower = showLower && showHigh && showCurrent; - ENUM_DRAW_TYPE cHighLowerDrawType = canShowCHighLower ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(cHighLowerBufferIndex, cHighLowerBuffer, INDICATOR_DATA); - PlotIndexSetDouble(cHighLowerBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(cHighLowerBufferIndex, PLOT_SHOW_DATA, canShowCHighLower); - PlotIndexSetInteger(cHighLowerBufferIndex, PLOT_DRAW_TYPE, cHighLowerDrawType); - - // - // Low ... - - // - // UPPER ... - bool canShowCLowUpper = showUpper && showLow && showCurrent; - ENUM_DRAW_TYPE cLowUpperDrawType = canShowCLowUpper ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(cLowUpperBufferIndex, cLowUpperBuffer, INDICATOR_DATA); - PlotIndexSetDouble(cLowUpperBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(cLowUpperBufferIndex, PLOT_SHOW_DATA, canShowCLowUpper); - PlotIndexSetInteger(cLowUpperBufferIndex, PLOT_DRAW_TYPE, cLowUpperDrawType); - - // - // LOWER ... - bool canShowCLowLower = showLower && showLow && showCurrent; - ENUM_DRAW_TYPE cLowLowerDrawType = canShowCLowLower ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(cLowLowerBufferIndex, cLowLowerBuffer, INDICATOR_DATA); - PlotIndexSetDouble(cLowLowerBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(cLowLowerBufferIndex, PLOT_SHOW_DATA, canShowCLowLower); - PlotIndexSetInteger(cLowLowerBufferIndex, PLOT_DRAW_TYPE, cLowLowerDrawType); - - // - // SHORT ... - - // - // Open ... - - // - // UPPER ... - bool canShowSOpenUpper = showUpper && showOpen && showShort; - ENUM_DRAW_TYPE sOpenUpperDrawType = canShowSOpenUpper ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(sOpenUpperBufferIndex, sOpenUpperBuffer, INDICATOR_DATA); - PlotIndexSetDouble(sOpenUpperBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(sOpenUpperBufferIndex, PLOT_SHOW_DATA, canShowSOpenUpper); - PlotIndexSetInteger(sOpenUpperBufferIndex, PLOT_DRAW_TYPE, sOpenUpperDrawType); - - // - // LOWER ... - bool canShowSOpenLower = showLower && showOpen && showShort; - ENUM_DRAW_TYPE sOpenLowerDrawType = canShowSOpenLower ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(sOpenLowerBufferIndex, sOpenLowerBuffer, INDICATOR_DATA); - PlotIndexSetDouble(sOpenLowerBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(sOpenLowerBufferIndex, PLOT_SHOW_DATA, canShowSOpenLower); - PlotIndexSetInteger(sOpenLowerBufferIndex, PLOT_DRAW_TYPE, sOpenLowerDrawType); - - // - // Close ... - - // - // UPPER ... - bool canShowSCloseUpper = showUpper && showClose && showShort; - ENUM_DRAW_TYPE sCloseUpperDrawType = canShowSCloseUpper ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(sCloseUpperBufferIndex, sCloseUpperBuffer, INDICATOR_DATA); - PlotIndexSetDouble(sCloseUpperBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(sCloseUpperBufferIndex, PLOT_SHOW_DATA, canShowSCloseUpper); - PlotIndexSetInteger(sCloseUpperBufferIndex, PLOT_DRAW_TYPE, sCloseUpperDrawType); - - // - // LOWER ... - bool canShowSCloseLower = showLower && showClose && showShort; - ENUM_DRAW_TYPE sCloseLowerDrawType = canShowSCloseLower ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(sCloseLowerBufferIndex, sCloseLowerBuffer, INDICATOR_DATA); - PlotIndexSetDouble(sCloseLowerBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(sCloseLowerBufferIndex, PLOT_SHOW_DATA, canShowSCloseLower); - PlotIndexSetInteger(sCloseLowerBufferIndex, PLOT_DRAW_TYPE, sCloseLowerDrawType); - - // - // High ... - - // - // UPPER ... - bool canShowSHighUpper = showUpper && showHigh && showShort; - ENUM_DRAW_TYPE sHighUpperDrawType = canShowSHighUpper ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(sHighUpperBufferIndex, sHighUpperBuffer, INDICATOR_DATA); - PlotIndexSetDouble(sHighUpperBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(sHighUpperBufferIndex, PLOT_SHOW_DATA, canShowSHighUpper); - PlotIndexSetInteger(sHighUpperBufferIndex, PLOT_DRAW_TYPE, sHighUpperDrawType); - - // - // LOWER ... - bool canShowSHighLower = showLower && showHigh && showShort; - ENUM_DRAW_TYPE sHighLowerDrawType = canShowSHighLower ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(sHighLowerBufferIndex, sHighLowerBuffer, INDICATOR_DATA); - PlotIndexSetDouble(sHighLowerBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(sHighLowerBufferIndex, PLOT_SHOW_DATA, canShowSHighLower); - PlotIndexSetInteger(sHighLowerBufferIndex, PLOT_DRAW_TYPE, sHighLowerDrawType); - - // - // Low ... - - // - // UPPER ... - bool canShowSLowUpper = showUpper && showLow && showShort; - ENUM_DRAW_TYPE sLowUpperDrawType = canShowSLowUpper ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(sLowUpperBufferIndex, sLowUpperBuffer, INDICATOR_DATA); - PlotIndexSetDouble(sLowUpperBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(sLowUpperBufferIndex, PLOT_SHOW_DATA, canShowSLowUpper); - PlotIndexSetInteger(sLowUpperBufferIndex, PLOT_DRAW_TYPE, sLowUpperDrawType); - - // - // LOWER ... - bool canShowSLowLower = showLower && showLow && showShort; - ENUM_DRAW_TYPE sLowLowerDrawType = canShowSLowLower ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(sLowLowerBufferIndex, sLowLowerBuffer, INDICATOR_DATA); - PlotIndexSetDouble(sLowLowerBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(sLowLowerBufferIndex, PLOT_SHOW_DATA, canShowSLowLower); - PlotIndexSetInteger(sLowLowerBufferIndex, PLOT_DRAW_TYPE, sLowLowerDrawType); - - // - // MEDIUM ... - - // - // Open ... - - // - // UPPER ... - bool canShowMOpenUpper = showUpper && showOpen && showMedium; - ENUM_DRAW_TYPE mOpenUpperDrawType = canShowMOpenUpper ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(mOpenUpperBufferIndex, mOpenUpperBuffer, INDICATOR_DATA); - PlotIndexSetDouble(mOpenUpperBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(mOpenUpperBufferIndex, PLOT_SHOW_DATA, canShowMOpenUpper); - PlotIndexSetInteger(mOpenUpperBufferIndex, PLOT_DRAW_TYPE, mOpenUpperDrawType); - - // - // LOWER ... - bool canShowMOpenLower = showLower && showOpen && showMedium; - ENUM_DRAW_TYPE mOpenLowerDrawType = canShowMOpenLower ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(mOpenLowerBufferIndex, mOpenLowerBuffer, INDICATOR_DATA); - PlotIndexSetDouble(mOpenLowerBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(mOpenLowerBufferIndex, PLOT_SHOW_DATA, canShowMOpenLower); - PlotIndexSetInteger(mOpenLowerBufferIndex, PLOT_DRAW_TYPE, mOpenLowerDrawType); - - // - // Close ... - - // - // UPPER ... - bool canShowMCloseUpper = showUpper && showClose && showMedium; - ENUM_DRAW_TYPE mCloseUpperDrawType = canShowMCloseUpper ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(mCloseUpperBufferIndex, mCloseUpperBuffer, INDICATOR_DATA); - PlotIndexSetDouble(mCloseUpperBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(mCloseUpperBufferIndex, PLOT_SHOW_DATA, canShowMCloseUpper); - PlotIndexSetInteger(mCloseUpperBufferIndex, PLOT_DRAW_TYPE, mCloseUpperDrawType); - - // - // LOWER ... - bool canShowMCloseLower = showLower && showClose && showMedium; - ENUM_DRAW_TYPE mCloseLowerDrawType = canShowMCloseLower ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(mCloseLowerBufferIndex, mCloseLowerBuffer, INDICATOR_DATA); - PlotIndexSetDouble(mCloseLowerBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(mCloseLowerBufferIndex, PLOT_SHOW_DATA, canShowMCloseLower); - PlotIndexSetInteger(mCloseLowerBufferIndex, PLOT_DRAW_TYPE, mCloseLowerDrawType); - - // - // High ... - - // - // UPPER ... - bool canShowMHighUpper = showUpper && showHigh && showMedium; - ENUM_DRAW_TYPE mHighUpperDrawType = canShowMHighUpper ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(mHighUpperBufferIndex, mHighUpperBuffer, INDICATOR_DATA); - PlotIndexSetDouble(mHighUpperBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(mHighUpperBufferIndex, PLOT_SHOW_DATA, canShowMHighUpper); - PlotIndexSetInteger(mHighUpperBufferIndex, PLOT_DRAW_TYPE, mHighUpperDrawType); - - // - // LOWER ... - bool canShowMHighLower = showLower && showHigh && showMedium; - ENUM_DRAW_TYPE mHighLowerDrawType = canShowMHighLower ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(mHighLowerBufferIndex, mHighLowerBuffer, INDICATOR_DATA); - PlotIndexSetDouble(mHighLowerBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(mHighLowerBufferIndex, PLOT_SHOW_DATA, canShowMHighLower); - PlotIndexSetInteger(mHighLowerBufferIndex, PLOT_DRAW_TYPE, mHighLowerDrawType); - - // - // Low ... - - // - // UPPER ... - bool canShowMLowUpper = showUpper && showLow && showMedium; - ENUM_DRAW_TYPE mLowUpperDrawType = canShowMLowUpper ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(mLowUpperBufferIndex, mLowUpperBuffer, INDICATOR_DATA); - PlotIndexSetDouble(mLowUpperBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(mLowUpperBufferIndex, PLOT_SHOW_DATA, canShowMLowUpper); - PlotIndexSetInteger(mLowUpperBufferIndex, PLOT_DRAW_TYPE, mLowUpperDrawType); - - // - // LOWER ... - bool canShowMLowLower = showLower && showLow && showMedium; - ENUM_DRAW_TYPE mLowLowerDrawType = canShowMLowLower ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(mLowLowerBufferIndex, mLowLowerBuffer, INDICATOR_DATA); - PlotIndexSetDouble(mLowLowerBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(mLowLowerBufferIndex, PLOT_SHOW_DATA, canShowMLowLower); - PlotIndexSetInteger(mLowLowerBufferIndex, PLOT_DRAW_TYPE, mLowLowerDrawType); - - // - // LONG ... - - // - // Open ... - - // - // UPPER ... - bool canShowLOpenUpper = showUpper && showOpen && showLong; - ENUM_DRAW_TYPE lOpenUpperDrawType = canShowLOpenUpper ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(lOpenUpperBufferIndex, lOpenUpperBuffer, INDICATOR_DATA); - PlotIndexSetDouble(lOpenUpperBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(lOpenUpperBufferIndex, PLOT_SHOW_DATA, canShowLOpenUpper); - PlotIndexSetInteger(lOpenUpperBufferIndex, PLOT_DRAW_TYPE, lOpenUpperDrawType); - - // - // LOWER ... - bool canShowLOpenLower = showLower && showOpen && showLong; - ENUM_DRAW_TYPE lOpenLowerDrawType = canShowLOpenLower ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(lOpenLowerBufferIndex, lOpenLowerBuffer, INDICATOR_DATA); - PlotIndexSetDouble(lOpenLowerBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(lOpenLowerBufferIndex, PLOT_SHOW_DATA, canShowLOpenLower); - PlotIndexSetInteger(lOpenLowerBufferIndex, PLOT_DRAW_TYPE, lOpenLowerDrawType); - - // - // Close ... - - // - // UPPER ... - bool canShowLCloseUpper = showUpper && showClose && showLong; - ENUM_DRAW_TYPE lCloseUpperDrawType = canShowLCloseUpper ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(lCloseUpperBufferIndex, lCloseUpperBuffer, INDICATOR_DATA); - PlotIndexSetDouble(lCloseUpperBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(lCloseUpperBufferIndex, PLOT_SHOW_DATA, canShowLCloseUpper); - PlotIndexSetInteger(lCloseUpperBufferIndex, PLOT_DRAW_TYPE, lCloseUpperDrawType); - - // - // LOWER ... - bool canShowLCloseLower = showLower && showClose && showLong; - ENUM_DRAW_TYPE lCloseLowerDrawType = canShowLCloseLower ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(lCloseLowerBufferIndex, lCloseLowerBuffer, INDICATOR_DATA); - PlotIndexSetDouble(lCloseLowerBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(lCloseLowerBufferIndex, PLOT_SHOW_DATA, canShowLCloseLower); - PlotIndexSetInteger(lCloseLowerBufferIndex, PLOT_DRAW_TYPE, lCloseLowerDrawType); - - // - // High ... - - // - // UPPER ... - bool canShowLHighUpper = showUpper && showHigh && showLong; - ENUM_DRAW_TYPE lHighUpperDrawType = canShowLHighUpper ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(lHighUpperBufferIndex, lHighUpperBuffer, INDICATOR_DATA); - PlotIndexSetDouble(lHighUpperBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(lHighUpperBufferIndex, PLOT_SHOW_DATA, canShowLHighUpper); - PlotIndexSetInteger(lHighUpperBufferIndex, PLOT_DRAW_TYPE, lHighUpperDrawType); - - // - // LOWER ... - bool canShowLHighLower = showLower && showHigh && showLong; - ENUM_DRAW_TYPE lHighLowerDrawType = canShowLHighLower ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(lHighLowerBufferIndex, lHighLowerBuffer, INDICATOR_DATA); - PlotIndexSetDouble(lHighLowerBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(lHighLowerBufferIndex, PLOT_SHOW_DATA, canShowLHighLower); - PlotIndexSetInteger(lHighLowerBufferIndex, PLOT_DRAW_TYPE, lHighLowerDrawType); - - // - // Low ... - - // - // UPPER ... - bool canShowLLowUpper = showUpper && showLow && showLong; - ENUM_DRAW_TYPE lLowUpperDrawType = canShowLLowUpper ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(lLowUpperBufferIndex, lLowUpperBuffer, INDICATOR_DATA); - PlotIndexSetDouble(lLowUpperBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(lLowUpperBufferIndex, PLOT_SHOW_DATA, canShowLLowUpper); - PlotIndexSetInteger(lLowUpperBufferIndex, PLOT_DRAW_TYPE, lLowUpperDrawType); - - // - // LOWER ... - bool canShowLLowLower = showLower && showLow && showLong; - ENUM_DRAW_TYPE lLowLowerDrawType = canShowLLowLower ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(lLowLowerBufferIndex, lLowLowerBuffer, INDICATOR_DATA); - PlotIndexSetDouble(lLowLowerBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(lLowLowerBufferIndex, PLOT_SHOW_DATA, canShowLLowLower); - PlotIndexSetInteger(lLowLowerBufferIndex, PLOT_DRAW_TYPE, lLowLowerDrawType); - - // - // HIND ... - - // - // Open ... - - // - // UPPER ... - bool canShowHOpenUpper = showUpper && showOpen && showHind; - ENUM_DRAW_TYPE hOpenUpperDrawType = canShowHOpenUpper ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(hOpenUpperBufferIndex, hOpenUpperBuffer, INDICATOR_DATA); - PlotIndexSetDouble(hOpenUpperBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(hOpenUpperBufferIndex, PLOT_SHOW_DATA, canShowHOpenUpper); - PlotIndexSetInteger(hOpenUpperBufferIndex, PLOT_DRAW_TYPE, hOpenUpperDrawType); - - // - // LOWER ... - bool canShowHOpenLower = showLower && showOpen && showHind; - ENUM_DRAW_TYPE hOpenLowerDrawType = canShowHOpenLower ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(hOpenLowerBufferIndex, hOpenLowerBuffer, INDICATOR_DATA); - PlotIndexSetDouble(hOpenLowerBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(hOpenLowerBufferIndex, PLOT_SHOW_DATA, canShowHOpenLower); - PlotIndexSetInteger(hOpenLowerBufferIndex, PLOT_DRAW_TYPE, hOpenLowerDrawType); - - // - // Close ... - - // - // UPPER ... - bool canShowHCloseUpper = showUpper && showClose && showHind; - ENUM_DRAW_TYPE hCloseUpperDrawType = canShowHCloseUpper ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(hCloseUpperBufferIndex, hCloseUpperBuffer, INDICATOR_DATA); - PlotIndexSetDouble(hCloseUpperBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(hCloseUpperBufferIndex, PLOT_SHOW_DATA, canShowHCloseUpper); - PlotIndexSetInteger(hCloseUpperBufferIndex, PLOT_DRAW_TYPE, hCloseUpperDrawType); - - // - // LOWER ... - bool canShowHCloseLower = showLower && showClose && showHind; - ENUM_DRAW_TYPE hCloseLowerDrawType = canShowHCloseLower ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(hCloseLowerBufferIndex, hCloseLowerBuffer, INDICATOR_DATA); - PlotIndexSetDouble(hCloseLowerBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(hCloseLowerBufferIndex, PLOT_SHOW_DATA, canShowHCloseLower); - PlotIndexSetInteger(hCloseLowerBufferIndex, PLOT_DRAW_TYPE, hCloseLowerDrawType); - - // - // High ... - - // - // UPPER ... - bool canShowHHighUpper = showUpper && showHigh && showHind; - ENUM_DRAW_TYPE hHighUpperDrawType = canShowHHighUpper ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(hHighUpperBufferIndex, hHighUpperBuffer, INDICATOR_DATA); - PlotIndexSetDouble(hHighUpperBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(hHighUpperBufferIndex, PLOT_SHOW_DATA, canShowHHighUpper); - PlotIndexSetInteger(hHighUpperBufferIndex, PLOT_DRAW_TYPE, hHighUpperDrawType); - - // - // LOWER ... - bool canShowHHighLower = showLower && showHigh && showHind; - ENUM_DRAW_TYPE hHighLowerDrawType = canShowHHighLower ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(hHighLowerBufferIndex, hHighLowerBuffer, INDICATOR_DATA); - PlotIndexSetDouble(hHighLowerBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(hHighLowerBufferIndex, PLOT_SHOW_DATA, canShowHHighLower); - PlotIndexSetInteger(hHighLowerBufferIndex, PLOT_DRAW_TYPE, hHighLowerDrawType); - - // - // Low ... - - // - // UPPER ... - bool canShowHLowUpper = showUpper && showLow && showHind; - ENUM_DRAW_TYPE hLowUpperDrawType = canShowHLowUpper ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(hLowUpperBufferIndex, hLowUpperBuffer, INDICATOR_DATA); - PlotIndexSetDouble(hLowUpperBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(hLowUpperBufferIndex, PLOT_SHOW_DATA, canShowHLowUpper); - PlotIndexSetInteger(hLowUpperBufferIndex, PLOT_DRAW_TYPE, hLowUpperDrawType); - - // - // LOWER ... - bool canShowHLowLower = showLower && showLow && showHind; - ENUM_DRAW_TYPE hLowLowerDrawType = canShowHLowLower ? DRAW_LINE : DRAW_NONE; - SetIndexBuffer(hLowLowerBufferIndex, hLowLowerBuffer, INDICATOR_DATA); - PlotIndexSetDouble(hLowLowerBufferIndex, PLOT_EMPTY_VALUE, EMPTY_VALUE); - PlotIndexSetInteger(hLowLowerBufferIndex, PLOT_SHOW_DATA, canShowHLowLower); - PlotIndexSetInteger(hLowLowerBufferIndex, PLOT_DRAW_TYPE, hLowLowerDrawType); -} - -// -// Calculations ... - -// -// Calculate Buffers ... -void CalculateBuffers( - int bar_index, // Selected Bar Index - const int prevCalculated, - const int ratesTotal, - const double &open[], - const double &high[], - const double &close[], - const double &low[], - const long &tickVolume[] // -) -{ - // - CalculateCycles( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - tickVolume // - ); -} - -// -void CalculateCycles( - int bar_index, // Selected Bar Index - const int prevCalculated, - const int ratesTotal, - const double &open[], - const double &high[], - const double &close[], - const double &low[], - const long &tickVolume[] // -) -{ - // - // CURRENT ... - CalculateCycle( - // - bar_index, - prevCalculated, - ratesTotal, - // - open, - high, - close, - low, - tickVolume, - // - mCMarketLength, - // - cOpenUpperBuffer, - cOpenLowerBuffer, - cHighUpperBuffer, - cHighLowerBuffer, - cLowUpperBuffer, - cLowLowerBuffer, - cCloseUpperBuffer, - cCloseLowerBuffer // - ); - - // - // SHORT ... - CalculateCycle( - // - bar_index, - prevCalculated, - ratesTotal, - // - open, - high, - close, - low, - tickVolume, - // - mSMarketLength, - // - sOpenUpperBuffer, - sOpenLowerBuffer, - sHighUpperBuffer, - sHighLowerBuffer, - sLowUpperBuffer, - sLowLowerBuffer, - sCloseUpperBuffer, - sCloseLowerBuffer // - ); - - // - // MEDIUM ... - CalculateCycle( - // - bar_index, - prevCalculated, - ratesTotal, - // - open, - high, - close, - low, - tickVolume, - // - mMMarketLength, - // - mOpenUpperBuffer, - mOpenLowerBuffer, - mHighUpperBuffer, - mHighLowerBuffer, - mLowUpperBuffer, - mLowLowerBuffer, - mCloseUpperBuffer, - mCloseLowerBuffer // - ); - - // - // LONG ... - CalculateCycle( - // - bar_index, - prevCalculated, - ratesTotal, - // - open, - high, - close, - low, - tickVolume, - // - mLMarketLength, - // - lOpenUpperBuffer, - lOpenLowerBuffer, - lHighUpperBuffer, - lHighLowerBuffer, - lLowUpperBuffer, - lLowLowerBuffer, - lCloseUpperBuffer, - lCloseLowerBuffer // - ); - - // - // HIND ... - CalculateCycle( - // - bar_index, - prevCalculated, - ratesTotal, - // - open, - high, - close, - low, - tickVolume, - // - mHMarketLength, - // - hOpenUpperBuffer, - hOpenLowerBuffer, - hHighUpperBuffer, - hHighLowerBuffer, - hLowUpperBuffer, - hLowLowerBuffer, - hCloseUpperBuffer, - hCloseLowerBuffer // - ); -} - -// -void CalculateCycle( - int bar_index, // Selected Bar Index - const int prevCalculated, - const int ratesTotal, - // - const double &open[], - const double &high[], - const double &close[], - const double &low[], - const long &tickVolume[], - // - int _length, - // - double &_ouBuffer[], - double &_olBuffer[], - double &_huBuffer[], - double &_hlBuffer[], - double &_luBuffer[], - double &_llBuffer[], - double &_cuBuffer[], - double &_clBuffer[] // -) -{ - // - double iUpper = 0; - double iLower = 0; - - // - // OPEN ... - - // - iUpper = open[ArrayMaximum(open, bar_index - _length + 1, _length)]; - iLower = open[ArrayMinimum(open, bar_index - _length + 1, _length)]; - - // - _ouBuffer[bar_index] = iUpper; - _olBuffer[bar_index] = iLower; - - // - // HIGH ... - - // - iUpper = high[ArrayMaximum(high, bar_index - _length + 1, _length)]; - iLower = high[ArrayMinimum(high, bar_index - _length + 1, _length)]; - - // - _huBuffer[bar_index] = iUpper; - _hlBuffer[bar_index] = iLower; - - // - // LOW ... - - // - iUpper = low[ArrayMaximum(low, bar_index - _length + 1, _length)]; - iLower = low[ArrayMinimum(low, bar_index - _length + 1, _length)]; - - // - _luBuffer[bar_index] = iUpper; - _llBuffer[bar_index] = iLower; - - // - // CLOSE ... - - // - iUpper = close[ArrayMaximum(close, bar_index - _length + 1, _length)]; - iLower = close[ArrayMinimum(close, bar_index - _length + 1, _length)]; - - // - _cuBuffer[bar_index] = iUpper; - _clBuffer[bar_index] = iLower; -} - -// \ No newline at end of file diff --git a/Indicators/x-saherelm.xchhk.mq5 b/Indicators/x-saherelm.xchhk.mq5 deleted file mode 100644 index ff6fae86..00000000 --- a/Indicators/x-saherelm.xchhk.mq5 +++ /dev/null @@ -1,1070 +0,0 @@ -/////////////////////////////////////////////////////// -// SaherElm IT Center MQL5 Indicator -// ------------------------------------------- -// Name: XCHHK -// Description: Smoothed HikenAshi Cycles ... -// -// Maintainer: -// ------------ -// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) -// -////////////////////////////////////////////////////// -// -// Global Properties ... -#property copyright "Copyright 2023, SaherElm IT Center" -#property link "https://saherelm.ir" -#property version "1.00" -#property description "SaherElm XCHHK Indicator" -#property strict - -// -#define ShortName "XCHHK" - -// -// Includes Common Library ... -#include -#include "../Libraries/x-saherelm.common.lib.mq5" - -// -// Inputs ... - -// -input group "Market"; - -// -input int cSmoothingLength = 14; // Smoothing Length - -// -input group "Cycles"; - -// -input group "Short"; -input ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES scPeriod = NULL; // Time Period - -// -input group "Medium"; -input ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES mcPeriod = NULL; // Time Period - -// -input group "Long"; -input ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES lcPeriod = NULL; // Time Period - -// -input group "Hind"; -input ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period - -// -// Presentation ... -input group "Presentation"; - -// -input bool ignoreShadows = false; // Ignore Bar Shadows - -// -input bool showCurrent = true; // Show Current Cycle -input bool showShort = true; // Show Short Cycle -input bool showMedium = true; // Show Medium Cycle -input bool showLong = true; // Show Long Cycle -input bool showHind = true; // Show Hind Cycle - -// -// Buffers ... - -// -#define hideColorIDX 0 -#define bullishColorIDX 1 -#define bearishColorIDX 2 - -// -#property indicator_chart_window - -// -#property indicator_buffers 29 -#property indicator_plots 25 - -// -// Current ... - -// -#define cOpenBufferIndex 0 -double cOpenBuffer[]; - -// -#define cHighBufferIndex 1 -double cHighBuffer[]; - -// -#define cLowBufferIndex 2 -double cLowBuffer[]; - -// -#define cCloseBufferIndex 3 -double cCloseBuffer[]; - -// -#define cColorBufferIndex 4 -double cColorBuffer[]; - -// -#define cBufferIndex 0 -#property indicator_label1 "C Open;C High;C Low;C Close" -#property indicator_type1 DRAW_COLOR_CANDLES -#property indicator_color1 CLR_NONE, clrAqua, clrMagenta - -// -// Short ... - -// -#define sOpenBufferIndex 5 -double sOpenBuffer[]; - -// -#define sHighBufferIndex 6 -double sHighBuffer[]; - -// -#define sLowBufferIndex 7 -double sLowBuffer[]; - -// -#define sCloseBufferIndex 8 -double sCloseBuffer[]; - -// -#define sColorBufferIndex 9 -double sColorBuffer[]; - -// -#define sBufferIndex 1 -#property indicator_label2 "S Open;S High;S Low;S Close" -#property indicator_type2 DRAW_COLOR_CANDLES -#property indicator_color2 CLR_NONE, clrAqua, clrMagenta - -// -// Medium ... - -// -#define mOpenBufferIndex 10 -double mOpenBuffer[]; - -// -#define mHighBufferIndex 11 -double mHighBuffer[]; - -// -#define mLowBufferIndex 12 -double mLowBuffer[]; - -// -#define mCloseBufferIndex 13 -double mCloseBuffer[]; - -// -#define mColorBufferIndex 14 -double mColorBuffer[]; - -// -#define mBufferIndex 2 -#property indicator_label3 "M Open;M High;M Low;M Close" -#property indicator_type3 DRAW_COLOR_CANDLES -#property indicator_color3 CLR_NONE, clrAqua, clrMagenta - -// -// Long ... - -// -#define lOpenBufferIndex 15 -double lOpenBuffer[]; - -// -#define lHighBufferIndex 16 -double lHighBuffer[]; - -// -#define lLowBufferIndex 17 -double lLowBuffer[]; - -// -#define lCloseBufferIndex 18 -double lCloseBuffer[]; - -// -#define lColorBufferIndex 19 -double lColorBuffer[]; - -// -#define lBufferIndex 3 -#property indicator_label4 "L Open;L High;L Low;L Close" -#property indicator_type4 DRAW_COLOR_CANDLES -#property indicator_color4 CLR_NONE, clrAqua, clrMagenta - -// -// Hind ... - -// -#define hOpenBufferIndex 20 -double hOpenBuffer[]; - -// -#define hHighBufferIndex 21 -double hHighBuffer[]; - -// -#define hLowBufferIndex 22 -double hLowBuffer[]; - -// -#define hCloseBufferIndex 23 -double hCloseBuffer[]; - -// -#define hColorBufferIndex 24 -double hColorBuffer[]; - -// -#define hBufferIndex 4 -#property indicator_label5 "H Open;H High;H Low;H Close" -#property indicator_type5 DRAW_COLOR_CANDLES -#property indicator_color5 CLR_NONE, clrAqua, clrMagenta - -// -// Data Buffers ... - -// -#define openBufferIndex 25 -double openBuffer[]; - -// -#define highBufferIndex 26 -double highBuffer[]; - -// -#define lowBufferIndex 27 -double lowBuffer[]; - -// -#define closeBufferIndex 28 -double closeBuffer[]; - -// -// Variables, Properties and etc ... - -// -int maxLength; - -// -// Current ... -int mCSMLength = cSmoothingLength; - -// -// Short ... -int mSCLength = 0; -int mSSMLength = 0; -ENUM_TIMEFRAMES mSCPeriod = NULL; - -// -// Medium ... -int mMCLength = 0; -int mMSMLength = 0; -ENUM_TIMEFRAMES mMCPeriod = NULL; - -// -// Long ... -int mLCLength = 0; -int mLSMLength = 0; -ENUM_TIMEFRAMES mLCPeriod = NULL; - -// -// Hind ... -int mHCLength = 0; -int mHSMLength = 0; -ENUM_TIMEFRAMES mHCPeriod = NULL; - -// -// Event Handlers ... - -// -// Initialization ... -int OnInit() -{ - // - // Validate Inputs ... - if (!ValidateInputs()) - { - return INIT_PARAMETERS_INCORRECT; - } - - // - if (!InitMarketCycles()) - { - return INIT_PARAMETERS_INCORRECT; - } - - // - // because in some cases we may have more than one input for - // calculation and we must prevent any calculation - // untill we pass the biggest input length, here we get max Input length - // and then wait until pass it ... - maxLength = ExtractMaxLengthOfInputs(); - - // - // Define Index Buffers ... - DefineBuffers(); - - // - // Set Indicator ShortName ... - SetIndicatorName(); - - // - // Init Succeed ... - return INIT_SUCCEEDED; -} - -// -// DeInitialization ... -void OnDeinit(const int reason) -{ - // - // REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function - // REASON_REMOVE 1 Program removed from a chart - // REASON_RECOMPILE 2 Program recompiled - // REASON_CHARTCHANGE 3 A symbol or a chart period is changed - // REASON_CHARTCLOSE 4 Chart closed - // REASON_PARAMETERS 5 Inputs changed by a user - // REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings - // REASON_TEMPLATE 7 Another chart template applied - // REASON_INITFAILED 8 The OnInit() handler returned a non-zero value - // REASON_CLOSE 9 Terminal closed -} - -// -// Calculating what we want ... -int OnCalculate( - const int rates_total, // Total Bars on Chart ... - const int prev_calculated, // Total Calculated Bars on Charts ... - const datetime &time[], // History of Open Time ... - const double &open[], // History of Open Price ... - const double &high[], // History of High Price ... - const double &low[], // History of Low Price ... - const double &close[], // History of Close Price ... - const long &tick_volume[], // History of Tick Volumes on Bar ... - const long &volume[], // History of Trade Volumes ... - const int &spread[] // History of Spread Price ... -) -{ - // - // Prepare Buffers ... - ArraySetAsSeries(time, true); - ArraySetAsSeries(open, true); - ArraySetAsSeries(high, true); - ArraySetAsSeries(low, true); - ArraySetAsSeries(close, true); - ArraySetAsSeries(tick_volume, true); - ArraySetAsSeries(volume, true); - ArraySetAsSeries(spread, true); - - // - // this counts Available Bars ... - int limit; - - // - limit = (prev_calculated > rates_total || prev_calculated <= 0) ? rates_total : (rates_total - prev_calculated) + 1; - - // - // Main Loop ... - for (int i = limit - 1; i >= 0 && !IsStopped(); i--) - { - CalculateHK(i, prev_calculated, rates_total, open, high, close, low); - } - - // - CalculateCycles(rates_total, prev_calculated); - - // - return rates_total; -} - -// -// Functions ... - -// -// Validate Input Args for Initialization ... -bool ValidateInputs() -{ - // - bool result = false; - - // - result = - // - cSmoothingLength > 2 && - // - (IsValid(scMethod, scPeriod) && - IsValid(mcMethod, mcPeriod) && - IsValid(lcMethod, lcPeriod) && - IsValid(hcMethod, hcPeriod)) - // - ; - - // - return result; -} - -// -// Initialize Market Cycles ... -bool InitMarketCycles() -{ - // - bool result = false; - - // - // Current Cycle Initialization ... - - // - int cPeriodSeconds = PeriodSeconds(_Period); - - // - // Short Cycle Initialization ... - - // - // Find Cycle Period ... - if (scMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mSCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_SHORT, - _Period // - ); - } - else - { - mSCPeriod = scPeriod; - } - - // - result = IsValid(mSCPeriod); - if (!result) - { - return result; - } - - // - mSCLength = PeriodSeconds(mSCPeriod) / cPeriodSeconds; - mSSMLength = mSCLength * mCSMLength; - result = mSCLength > 0; - if (!result) - { - return result; - } - - // - // Medium Cycle Initialization ... - - // - // Find Cycle Period ... - if (mcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mMCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_MEDIUM, - _Period // - ); - } - else - { - mMCPeriod = mcPeriod; - } - - // - result = IsValid(mMCPeriod); - if (!result) - { - return result; - } - - // - mMCLength = PeriodSeconds(mMCPeriod) / cPeriodSeconds; - mMSMLength = mMCLength * mCSMLength; - result = mMCLength > 0; - if (!result) - { - return result; - } - - // - // Long Cycle Initialization ... - - // - // Find Cycle Period ... - if (lcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mLCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_LONG, - _Period // - ); - } - else - { - mLCPeriod = lcPeriod; - } - - // - result = IsValid(mLCPeriod); - if (!result) - { - return result; - } - - // - mLCLength = PeriodSeconds(mLCPeriod) / cPeriodSeconds; - mLSMLength = mLCLength * mCSMLength; - result = mLCLength > 0; - if (!result) - { - return result; - } - - // - // Hind Cycle Initialization ... - - // - // Find Cycle Period ... - if (hcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mHCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_HIND, - _Period // - ); - } - else - { - mHCPeriod = hcPeriod; - } - - // - result = IsValid(mHCPeriod); - if (!result) - { - return result; - } - - // - mHCLength = PeriodSeconds(mHCPeriod) / cPeriodSeconds; - mHSMLength = mHCLength * mCSMLength; - result = mHCLength > 0; - if (!result) - { - return result; - } - - // - return result; -} - -// -// Retrieve all Exists Input Max Length ... -// use for Start Of Drawing ... -int ExtractMaxLengthOfInputs() -{ - // - int result = 0; - - // - result = MathMax(mCSMLength, mSSMLength); - result = MathMax(result, mMSMLength); - result = MathMax(result, mLSMLength); - result = MathMax(result, mHSMLength); - - // - return result; -} - -// -// Define Indexes and Styles ... -void DefineBuffers() -{ - // - // Data Buffers ... - - // - // Open ... - ArraySetAsSeries(openBuffer, true); - SetIndexBuffer(openBufferIndex, openBuffer, INDICATOR_CALCULATIONS); - - // - // High ... - ArraySetAsSeries(highBuffer, true); - SetIndexBuffer(highBufferIndex, highBuffer, INDICATOR_CALCULATIONS); - - // - // Low ... - ArraySetAsSeries(lowBuffer, true); - SetIndexBuffer(lowBufferIndex, lowBuffer, INDICATOR_CALCULATIONS); - - // - // Close ... - ArraySetAsSeries(closeBuffer, true); - SetIndexBuffer(closeBufferIndex, closeBuffer, INDICATOR_CALCULATIONS); - - // - // Current ... - - // - // Color ... - ArraySetAsSeries(cColorBuffer, true); - SetIndexBuffer(cColorBufferIndex, cColorBuffer, INDICATOR_COLOR_INDEX); - - // - // Set EMPTY_VALUE on Bar Buffer ... - PlotIndexSetDouble(cBufferIndex, PLOT_EMPTY_VALUE, 0.0); - - // - PlotIndexSetInteger(cBufferIndex, PLOT_SHOW_DATA, false); - PlotIndexSetInteger(cColorBufferIndex, PLOT_SHOW_DATA, false); - - // - // Open ... - ArraySetAsSeries(cOpenBuffer, true); - PlotIndexSetInteger(cOpenBufferIndex, PLOT_SHOW_DATA, false); - SetIndexBuffer(cOpenBufferIndex, cOpenBuffer, INDICATOR_DATA); - - // - // High ... - ArraySetAsSeries(cHighBuffer, true); - PlotIndexSetInteger(cHighBufferIndex, PLOT_SHOW_DATA, false); - SetIndexBuffer(cHighBufferIndex, cHighBuffer, INDICATOR_DATA); - - // - // Close ... - ArraySetAsSeries(cCloseBuffer, true); - PlotIndexSetInteger(cCloseBufferIndex, PLOT_SHOW_DATA, false); - SetIndexBuffer(cCloseBufferIndex, cCloseBuffer, INDICATOR_DATA); - - // - // Low ... - ArraySetAsSeries(cLowBuffer, true); - PlotIndexSetInteger(cLowBufferIndex, PLOT_SHOW_DATA, false); - SetIndexBuffer(cLowBufferIndex, cLowBuffer, INDICATOR_DATA); - - // - // Short ... - - // - // Color ... - ArraySetAsSeries(sColorBuffer, true); - SetIndexBuffer(sColorBufferIndex, sColorBuffer, INDICATOR_COLOR_INDEX); - - // - // Set EMPTY_VALUE on Bar Buffer ... - PlotIndexSetDouble(sBufferIndex, PLOT_EMPTY_VALUE, 0.0); - - // - PlotIndexSetInteger(sBufferIndex, PLOT_SHOW_DATA, false); - PlotIndexSetInteger(sColorBufferIndex, PLOT_SHOW_DATA, false); - - // - // Open ... - ArraySetAsSeries(sOpenBuffer, true); - PlotIndexSetInteger(sOpenBufferIndex, PLOT_SHOW_DATA, false); - SetIndexBuffer(sOpenBufferIndex, sOpenBuffer, INDICATOR_DATA); - - // - // High ... - ArraySetAsSeries(sHighBuffer, true); - PlotIndexSetInteger(sHighBufferIndex, PLOT_SHOW_DATA, false); - SetIndexBuffer(sHighBufferIndex, sHighBuffer, INDICATOR_DATA); - - // - // Close ... - ArraySetAsSeries(sCloseBuffer, true); - PlotIndexSetInteger(sCloseBufferIndex, PLOT_SHOW_DATA, false); - SetIndexBuffer(sCloseBufferIndex, sCloseBuffer, INDICATOR_DATA); - - // - // Low ... - ArraySetAsSeries(sLowBuffer, true); - PlotIndexSetInteger(sLowBufferIndex, PLOT_SHOW_DATA, false); - SetIndexBuffer(sLowBufferIndex, sLowBuffer, INDICATOR_DATA); - - // - // Medium ... - - // - // Color ... - ArraySetAsSeries(mColorBuffer, true); - SetIndexBuffer(mColorBufferIndex, mColorBuffer, INDICATOR_COLOR_INDEX); - - // - // Set EMPTY_VALUE on Bar Buffer ... - PlotIndexSetDouble(mBufferIndex, PLOT_EMPTY_VALUE, 0.0); - - // - PlotIndexSetInteger(mBufferIndex, PLOT_SHOW_DATA, false); - PlotIndexSetInteger(mColorBufferIndex, PLOT_SHOW_DATA, false); - - // - // Open ... - ArraySetAsSeries(mOpenBuffer, true); - PlotIndexSetInteger(mOpenBufferIndex, PLOT_SHOW_DATA, false); - SetIndexBuffer(mOpenBufferIndex, mOpenBuffer, INDICATOR_DATA); - - // - // High ... - ArraySetAsSeries(mHighBuffer, true); - PlotIndexSetInteger(mHighBufferIndex, PLOT_SHOW_DATA, false); - SetIndexBuffer(mHighBufferIndex, mHighBuffer, INDICATOR_DATA); - - // - // Close ... - ArraySetAsSeries(mCloseBuffer, true); - PlotIndexSetInteger(mCloseBufferIndex, PLOT_SHOW_DATA, false); - SetIndexBuffer(mCloseBufferIndex, mCloseBuffer, INDICATOR_DATA); - - // - // Low ... - ArraySetAsSeries(mLowBuffer, true); - PlotIndexSetInteger(mLowBufferIndex, PLOT_SHOW_DATA, false); - SetIndexBuffer(mLowBufferIndex, mLowBuffer, INDICATOR_DATA); - - // - // Long ... - - // - // Color ... - ArraySetAsSeries(lColorBuffer, true); - SetIndexBuffer(lColorBufferIndex, lColorBuffer, INDICATOR_COLOR_INDEX); - - // - // Set EMPTY_VALUE on Bar Buffer ... - PlotIndexSetDouble(lBufferIndex, PLOT_EMPTY_VALUE, 0.0); - - // - PlotIndexSetInteger(lBufferIndex, PLOT_SHOW_DATA, false); - PlotIndexSetInteger(lColorBufferIndex, PLOT_SHOW_DATA, false); - - // - // Open ... - ArraySetAsSeries(lOpenBuffer, true); - PlotIndexSetInteger(lOpenBufferIndex, PLOT_SHOW_DATA, false); - SetIndexBuffer(lOpenBufferIndex, lOpenBuffer, INDICATOR_DATA); - - // - // High ... - ArraySetAsSeries(lHighBuffer, true); - PlotIndexSetInteger(lHighBufferIndex, PLOT_SHOW_DATA, false); - SetIndexBuffer(lHighBufferIndex, lHighBuffer, INDICATOR_DATA); - - // - // Close ... - ArraySetAsSeries(lCloseBuffer, true); - PlotIndexSetInteger(lCloseBufferIndex, PLOT_SHOW_DATA, false); - SetIndexBuffer(lCloseBufferIndex, lCloseBuffer, INDICATOR_DATA); - - // - // Low ... - ArraySetAsSeries(lLowBuffer, true); - PlotIndexSetInteger(lLowBufferIndex, PLOT_SHOW_DATA, false); - SetIndexBuffer(lLowBufferIndex, lLowBuffer, INDICATOR_DATA); - - // - // Hind ... - - // - // Color ... - ArraySetAsSeries(hColorBuffer, true); - SetIndexBuffer(hColorBufferIndex, hColorBuffer, INDICATOR_COLOR_INDEX); - - // - // Set EMPTY_VALUE on Bar Buffer ... - PlotIndexSetDouble(hBufferIndex, PLOT_EMPTY_VALUE, 0.0); - - // - PlotIndexSetInteger(hBufferIndex, PLOT_SHOW_DATA, false); - PlotIndexSetInteger(hColorBufferIndex, PLOT_SHOW_DATA, false); - - // - // Open ... - ArraySetAsSeries(hOpenBuffer, true); - PlotIndexSetInteger(hOpenBufferIndex, PLOT_SHOW_DATA, false); - SetIndexBuffer(hOpenBufferIndex, hOpenBuffer, INDICATOR_DATA); - - // - // High ... - ArraySetAsSeries(hHighBuffer, true); - PlotIndexSetInteger(hHighBufferIndex, PLOT_SHOW_DATA, false); - SetIndexBuffer(hHighBufferIndex, hHighBuffer, INDICATOR_DATA); - - // - // Close ... - ArraySetAsSeries(hCloseBuffer, true); - PlotIndexSetInteger(hCloseBufferIndex, PLOT_SHOW_DATA, false); - SetIndexBuffer(hCloseBufferIndex, hCloseBuffer, INDICATOR_DATA); - - // - // Low ... - ArraySetAsSeries(hLowBuffer, true); - PlotIndexSetInteger(hLowBufferIndex, PLOT_SHOW_DATA, false); - SetIndexBuffer(hLowBufferIndex, hLowBuffer, INDICATOR_DATA); -} - -// -// Set Indicator Short Name and also we can define Buffers Labels ... -void SetIndicatorName() -{ - IndicatorSetString(INDICATOR_SHORTNAME, ShortName); -} - -// -// Calculations ... - -// -// Calculate Hiken Ashi ... -void CalculateHK( - int bar_index, // Selected Bar Index - const int prevCalculated, - const int ratesTotal, - const double &open[], - const double &high[], - const double &close[], - const double &low[] // -) -{ - // - double mPrevHKOpenValue; - double mPrevHKCloseValue; - - // - if (ArraySize(open) <= bar_index + 1) - { - // - mPrevHKOpenValue = 0; - mPrevHKCloseValue = 0; - } - else - { - // - mPrevHKOpenValue = openBuffer[bar_index + 1]; - mPrevHKCloseValue = closeBuffer[bar_index + 1]; - } - - // - double mHKOpenValue = (mPrevHKOpenValue + mPrevHKCloseValue) / 2; - double mHKCloseValue = (open[bar_index] + high[bar_index] + close[bar_index] + low[bar_index]) / 4; - double mHKHighValue = MathMax(high[bar_index], MathMax(mHKOpenValue, mHKCloseValue)); - double mHKLowValue = MathMin(low[bar_index], MathMin(mHKOpenValue, mHKCloseValue)); - - // - openBuffer[bar_index] = mHKOpenValue; - highBuffer[bar_index] = mHKHighValue; - lowBuffer[bar_index] = mHKLowValue; - closeBuffer[bar_index] = mHKCloseValue; -} - -// -void CalculateCycles( - int ratesTotal, // Total Bars - int prevCalculated // Calculated Bars -) -{ - // - // Current ... - CalculateCycle( - cOpenBuffer, - cHighBuffer, - cLowBuffer, - cCloseBuffer, - cColorBuffer, - mCSMLength, - showCurrent, - ratesTotal, - prevCalculated // - ); - - // - // Short ... - CalculateCycle( - sOpenBuffer, - sHighBuffer, - sLowBuffer, - sCloseBuffer, - sColorBuffer, - mSSMLength, - showShort, - ratesTotal, - prevCalculated // - ); - - // - // Medium ... - CalculateCycle( - mOpenBuffer, - mHighBuffer, - mLowBuffer, - mCloseBuffer, - mColorBuffer, - mMSMLength, - showMedium, - ratesTotal, - prevCalculated // - ); - - // - // Long ... - CalculateCycle( - lOpenBuffer, - lHighBuffer, - lLowBuffer, - lCloseBuffer, - lColorBuffer, - mLSMLength, - showLong, - ratesTotal, - prevCalculated // - ); - - // - // Hind ... - CalculateCycle( - hOpenBuffer, - hHighBuffer, - hLowBuffer, - hCloseBuffer, - hColorBuffer, - mHSMLength, - showHind, - ratesTotal, - prevCalculated // - ); -} - -// -void CalculateCycle( - double &open[], - double &high[], - double &low[], - double &close[], - double &clr[], // Color Index Buffer - int length, // Calculation Length - bool show, // Show or not - int ratesTotal, // Total Bars - int prevCalculated // Calculated Bars -) -{ - // - // Open ... - int calculatedSMOpens = ExponentialMAOnBuffer( - ratesTotal, - prevCalculated, - 0, - length, - openBuffer, - open // - ); - - // - // Close ... - int calculatedSMCloses = ExponentialMAOnBuffer( - ratesTotal, - prevCalculated, - 0, - length, - closeBuffer, - close // - ); - - // - int calculatedSMLows = 0; - int calculatedSMHighs = 0; - if (!ignoreShadows) - { - // - // High ... - calculatedSMHighs = ExponentialMAOnBuffer( - ratesTotal, - prevCalculated, - 0, - length, - highBuffer, - high // - ); - - // - // Low ... - calculatedSMLows = ExponentialMAOnBuffer( - ratesTotal, - prevCalculated, - 0, - length, - lowBuffer, - low // - ); - } - else - { - // - // High ... - calculatedSMHighs = ExponentialMAOnBuffer( - ratesTotal, - prevCalculated, - 0, - length, - openBuffer, - high // - ); - - // - // Low ... - calculatedSMLows = ExponentialMAOnBuffer( - ratesTotal, - prevCalculated, - 0, - length, - closeBuffer, - low // - ); - } - - // - // Find Calculated Items for Colors Calculations ... - int mNumberOfItems = MathMin(calculatedSMOpens, calculatedSMHighs); - mNumberOfItems = MathMin(mNumberOfItems, calculatedSMLows); - mNumberOfItems = MathMin(mNumberOfItems, calculatedSMCloses); - - // - // Create a Loop for Color of Candles ... - for (int i = 0; i < mNumberOfItems; i++) - { - // - bool isBearish = - // - open[i] > close[i] - // - ; - - // - if (show) - { - // - clr[i] = isBearish - ? bearishColorIDX - : bullishColorIDX; - } - else - { - // - clr[i] = hideColorIDX; - } - } -} - -// \ No newline at end of file diff --git a/Indicators/x-saherelm.xchich.mq5 b/Indicators/x-saherelm.xchich.mq5 deleted file mode 100644 index f468e31d..00000000 --- a/Indicators/x-saherelm.xchich.mq5 +++ /dev/null @@ -1,1826 +0,0 @@ -/////////////////////////////////////////////////////// -// -// SaherElm IT Center MQL5 Indicator -// ------------------------------------------------- -// Name: XCHICH -// Description: Ichimoku Kinko Hyo on Cycles ... -// -// -// Maintainer: -// ------------ -// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) -// -////////////////////////////////////////////////////// -// -// Global Properties ... -#property copyright "Copyright 2023, SaherElm IT Center" -#property link "https://saherelm.ir" -#property version "1.00" -#property description "SaherElm XCHICH Indicator" -#property strict - -// -#define ShortName "XCHICH" - -// -// Includes Common Library ... -#include "../Libraries/x-saherelm.common.lib.mq5" - -// -// Ichimoku Lines Calculator Mode ... -enum ENUM_X_ICHIMOKU_CALCULATION_MODE -{ - // - X_XICH_HH_LL_MODE = 1, // Highest High and Lowest Low - X_XICH_HO_LC_MODE = 2, // Highest Open and Lowest Close -}; - -// -// Inputs ... - -// -input group "Market"; - -// -// TENKANSEN ... -input group "Tenkan Sen"; -input int tenkanSenLength = 9; // Length -input ENUM_X_ICHIMOKU_CALCULATION_MODE tenkanSenMode = X_XICH_HH_LL_MODE; // Calculation Mode - -// -// KIJUNSEN ... -input group "Kijun Sen"; -input int kijunSenLength = 26; // Length -input ENUM_X_ICHIMOKU_CALCULATION_MODE kijunSenMode = X_XICH_HH_LL_MODE; // Calculation Mode - -// -// SENKOUSPANB ... -input group "Senkou Span B"; -input int senkouSpanBLength = 52; // Length -input ENUM_X_ICHIMOKU_CALCULATION_MODE senkouSpanBMode = X_XICH_HH_LL_MODE; // Calculation Mode - -// -// CHIKOUSPAN ... -input group "Chikou Span"; -input ENUM_APPLIED_PRICE chikuoSpanAppliedTo = PRICE_CLOSE; // Price Type - -// -input group "Cycles"; - -// -input group "Short"; -input ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES scPeriod = NULL; // Time Period - -// -input group "Medium"; -input ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES mcPeriod = NULL; // Time Period - -// -input group "Long"; -input ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES lcPeriod = NULL; // Time Period - -// -input group "Hind"; -input ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period - -// -input group "Presentation"; - -// -input bool showTenkanSen = true; // Show Tenkan Sen -input bool showKijunSen = true; // Show Kijun Sen -input bool showChikouSpan = true; // Show Chikou Span -input bool showSenkouSpanA = true; // Show Senkou Span A -input bool showSenkouSpanB = true; // Show Senkou Span B -input bool showKumo = true; // Show Kumo -input bool shiftKumo = true; // Shift Kumo to Future - -// -input bool showCurrent = true; // Show Current Cycle -input bool showShort = true; // Show Short Cycle -input bool showMedium = true; // Show Medium Cycle -input bool showLong = true; // Show Long Cycle -input bool showHind = true; // Show Hind Cycle - - -// -// Buffers ... - -// -#define hideColorIDX 0 -#define bullishColorIDX 1 -#define bearishColorIDX 2 - -// -#property indicator_chart_window - -// -#property indicator_buffers 40 -#property indicator_plots 30 - -// -// CURRENT ... - -// -#define cTenBufferIndex 0 -double cTenBuffer[]; - -// -#property indicator_label1 "XICH C TK" -#property indicator_type1 DRAW_LINE -#property indicator_color1 clrBrown -#property indicator_style1 STYLE_SOLID -#property indicator_width1 1 - -// -#define cKijBufferIndex 1 -double cKijBuffer[]; - -// -#property indicator_label2 "XICH C KJ" -#property indicator_type2 DRAW_LINE -#property indicator_color2 clrDodgerBlue -#property indicator_style2 STYLE_SOLID -#property indicator_width2 1 - -// -#define cChikBufferIndex 2 -double cChikBuffer[]; - -// -#property indicator_label3 "XICH C CS" -#property indicator_type3 DRAW_LINE -#property indicator_color3 clrDarkGreen -#property indicator_style3 STYLE_SOLID -#property indicator_width3 1 - -// -#define cSSABufferIndex 3 -double cSSABuffer[]; - -// -#property indicator_label4 "XICH C SSA" -#property indicator_type4 DRAW_LINE -#property indicator_color4 clrLightGray -#property indicator_style4 STYLE_DASHDOTDOT -#property indicator_width4 1 - -// -#define cSSBBufferIndex 4 -double cSSBBuffer[]; - -// -#property indicator_label5 "XICH C SSB" -#property indicator_type5 DRAW_LINE -#property indicator_color5 clrLightGray -#property indicator_style5 STYLE_DASHDOTDOT -#property indicator_width5 1 - -// -// SHORT ... - -// -#define sTenBufferIndex 5 -double sTenBuffer[]; - -// -#property indicator_label6 "XICH S TK" -#property indicator_type6 DRAW_LINE -#property indicator_color6 clrBrown -#property indicator_style6 STYLE_SOLID -#property indicator_width6 1 - -// -#define sKijBufferIndex 6 -double sKijBuffer[]; - -// -#property indicator_label7 "XICH S KJ" -#property indicator_type7 DRAW_LINE -#property indicator_color7 clrDodgerBlue -#property indicator_style7 STYLE_SOLID -#property indicator_width7 1 - -// -#define sChikBufferIndex 7 -double sChikBuffer[]; - -// -#property indicator_label8 "XICH S CS" -#property indicator_type8 DRAW_LINE -#property indicator_color8 clrDarkGreen -#property indicator_style8 STYLE_SOLID -#property indicator_width8 1 - -// -#define sSSABufferIndex 8 -double sSSABuffer[]; - -// -#property indicator_label9 "XICH S SSA" -#property indicator_type9 DRAW_LINE -#property indicator_color9 clrLightGray -#property indicator_style9 STYLE_DASHDOTDOT -#property indicator_width9 1 - -// -#define sSSBBufferIndex 9 -double sSSBBuffer[]; - -// -#property indicator_label10 "XICH S SSB" -#property indicator_type10 DRAW_LINE -#property indicator_color10 clrLightGray -#property indicator_style10 STYLE_DASHDOTDOT -#property indicator_width10 1 - -// -// MEDIUM ... - -// -#define mTenBufferIndex 10 -double mTenBuffer[]; - -// -#property indicator_label11 "XICH M TK" -#property indicator_type11 DRAW_LINE -#property indicator_color11 clrBrown -#property indicator_style11 STYLE_SOLID -#property indicator_width11 1 - -// -#define mKijBufferIndex 11 -double mKijBuffer[]; - -// -#property indicator_label12 "XICH M KJ" -#property indicator_type12 DRAW_LINE -#property indicator_color12 clrDodgerBlue -#property indicator_style12 STYLE_SOLID -#property indicator_width12 1 - -// -#define mChikBufferIndex 12 -double mChikBuffer[]; - -// -#property indicator_label13 "XICH M CS" -#property indicator_type13 DRAW_LINE -#property indicator_color13 clrDarkGreen -#property indicator_style13 STYLE_SOLID -#property indicator_width13 1 - -// -#define mSSABufferIndex 13 -double mSSABuffer[]; - -// -#property indicator_label14 "XICH M SSA" -#property indicator_type14 DRAW_LINE -#property indicator_color14 clrLightGray -#property indicator_style14 STYLE_DASHDOTDOT -#property indicator_width14 1 - -// -#define mSSBBufferIndex 14 -double mSSBBuffer[]; - -// -#property indicator_label15 "XICH M SSB" -#property indicator_type15 DRAW_LINE -#property indicator_color15 clrLightGray -#property indicator_style15 STYLE_DASHDOTDOT -#property indicator_width15 1 - -// -// LONG ... - -// -#define lTenBufferIndex 15 -double lTenBuffer[]; - -// -#property indicator_label16 "XICH L TK" -#property indicator_type16 DRAW_LINE -#property indicator_color16 clrBrown -#property indicator_style16 STYLE_SOLID -#property indicator_width16 1 - -// -#define lKijBufferIndex 16 -double lKijBuffer[]; - -// -#property indicator_label17 "XICH L KJ" -#property indicator_type17 DRAW_LINE -#property indicator_color17 clrDodgerBlue -#property indicator_style17 STYLE_SOLID -#property indicator_width17 1 - -// -#define lChikBufferIndex 17 -double lChikBuffer[]; - -// -#property indicator_label18 "XICH L CS" -#property indicator_type18 DRAW_LINE -#property indicator_color18 clrDarkGreen -#property indicator_style18 STYLE_SOLID -#property indicator_width18 1 - -// -#define lSSABufferIndex 18 -double lSSABuffer[]; - -// -#property indicator_label19 "XICH L SSA" -#property indicator_type19 DRAW_LINE -#property indicator_color19 clrLightGray -#property indicator_style19 STYLE_DASHDOTDOT -#property indicator_width19 1 - -// -#define lSSBBufferIndex 19 -double lSSBBuffer[]; - -// -#property indicator_label20 "XICH L SSB" -#property indicator_type20 DRAW_LINE -#property indicator_color20 clrLightGray -#property indicator_style20 STYLE_DASHDOTDOT -#property indicator_width20 1 - -// -// HIND ... - -// -#define hTenBufferIndex 20 -double hTenBuffer[]; - -// -#property indicator_label21 "XICH H TK" -#property indicator_type21 DRAW_LINE -#property indicator_color21 clrBrown -#property indicator_style21 STYLE_SOLID -#property indicator_width21 1 - -// -#define hKijBufferIndex 21 -double hKijBuffer[]; - -// -#property indicator_label22 "XICH H KJ" -#property indicator_type22 DRAW_LINE -#property indicator_color22 clrDodgerBlue -#property indicator_style22 STYLE_SOLID -#property indicator_width22 1 - -// -#define hChikBufferIndex 22 -double hChikBuffer[]; - -// -#property indicator_label23 "XICH H CS" -#property indicator_type23 DRAW_LINE -#property indicator_color23 clrDarkGreen -#property indicator_style23 STYLE_SOLID -#property indicator_width23 1 - -// -#define hSSABufferIndex 23 -double hSSABuffer[]; - -// -#property indicator_label24 "XICH H SSA" -#property indicator_type24 DRAW_LINE -#property indicator_color24 clrLightGray -#property indicator_style24 STYLE_DASHDOTDOT -#property indicator_width24 1 - -// -#define hSSBBufferIndex 24 -double hSSBBuffer[]; - -// -#property indicator_label25 "XICH H SSB" -#property indicator_type25 DRAW_LINE -#property indicator_color25 clrLightGray -#property indicator_style25 STYLE_DASHDOTDOT -#property indicator_width25 1 - -// -// -// - -// -// CURRENT ... - -// -#define cSSAKCBufferIndex 25 -double cSSAKCBuffer[]; - -// -#define cSSBKCBufferIndex 26 -double cSSBKCBuffer[]; - -// -// CLOUD ... - -// -#define cKCBufferIndex 25 - -// -#property indicator_label26 "XICH C Kumo" -#property indicator_type26 DRAW_FILLING -#property indicator_color26 clrAqua, clrMagenta -#property indicator_style26 STYLE_SOLID -#property indicator_width26 1 - -// -// SHORT ... - -// -#define sSSAKCBufferIndex 27 -double sSSAKCBuffer[]; - -// -#define sSSBKCBufferIndex 28 -double sSSBKCBuffer[]; - -// -// CLOUD ... - -// -#define sKCBufferIndex 26 - -// -#property indicator_label27 "XICH S Kumo" -#property indicator_type27 DRAW_FILLING -#property indicator_color27 clrAqua, clrMagenta -#property indicator_style27 STYLE_SOLID -#property indicator_width27 1 - -// -// MEDIUM ... - -// -#define mSSAKCBufferIndex 29 -double mSSAKCBuffer[]; - -// -#define mSSBKCBufferIndex 30 -double mSSBKCBuffer[]; - -// -// CLOUD ... - -// -#define mKCBufferIndex 27 - -// -#property indicator_label28 "XICH M Kumo" -#property indicator_type28 DRAW_FILLING -#property indicator_color28 clrAqua, clrMagenta -#property indicator_style28 STYLE_SOLID -#property indicator_width28 1 - -// -// LONG ... - -// -#define lSSAKCBufferIndex 31 -double lSSAKCBuffer[]; - -// -#define lSSBKCBufferIndex 32 -double lSSBKCBuffer[]; - -// -// CLOUD ... - -// -#define lKCBufferIndex 28 - -// -#property indicator_label29 "XICH L Kumo" -#property indicator_type29 DRAW_FILLING -#property indicator_color29 clrAqua, clrMagenta -#property indicator_style29 STYLE_SOLID -#property indicator_width29 1 - -// -// HIND ... - -// -#define hSSAKCBufferIndex 33 -double hSSAKCBuffer[]; - -// -#define hSSBKCBufferIndex 34 -double hSSBKCBuffer[]; - -// -// CLOUD ... - -// -#define hKCBufferIndex 29 - -// -#property indicator_label30 "XICH H Kumo" -#property indicator_type30 DRAW_FILLING -#property indicator_color30 clrAqua, clrMagenta -#property indicator_style30 STYLE_SOLID -#property indicator_width30 1 - -// -// Variables, Properties and etc ... - -// -int maxLength; - -// -// Current ... -int mCTenkanSenLength = tenkanSenLength; -int mCKijunSenLength = kijunSenLength; -int mCSenkouSpanBLength = senkouSpanBLength; - -// -// Short ... -int mSCycleLength = 0; -int mSTenkanSenLength = 0; -int mSKijunSenLength = 0; -int mSSenkouSpanBLength = 0; -ENUM_TIMEFRAMES mSCPeriod = NULL; - -// -// Medium ... -int mMCycleLength = 0; -int mMTenkanSenLength = 0; -int mMKijunSenLength = 0; -int mMSenkouSpanBLength = 0; -ENUM_TIMEFRAMES mMCPeriod = NULL; - -// -// Long ... -int mLCycleLength = 0; -int mLTenkanSenLength = 0; -int mLKijunSenLength = 0; -int mLSenkouSpanBLength = 0; -ENUM_TIMEFRAMES mLCPeriod = NULL; - -// -// Hind ... -int mHCycleLength = 0; -int mHTenkanSenLength = 0; -int mHKijunSenLength = 0; -int mHSenkouSpanBLength = 0; -ENUM_TIMEFRAMES mHCPeriod = NULL; - -// -ENUM_SERIESMODE mTenkanSenTopMode = NULL; -ENUM_SERIESMODE mTenkanSenBottomMode = NULL; - -// -ENUM_SERIESMODE mKijunSenTopMode = NULL; -ENUM_SERIESMODE mKijunSenBottomMode = NULL; - -// -ENUM_SERIESMODE mSenkouSpanBTopMode = NULL; -ENUM_SERIESMODE mSenkouSpanBBottomMode = NULL; - -// -// Event Handlers ... - -// -// Initialization ... -int OnInit() -{ - // - // Validate Inputs ... - if (!ValidateInputs()) - { - return INIT_PARAMETERS_INCORRECT; - } - - // - if (!InitMarketCycles()) - { - return INIT_PARAMETERS_INCORRECT; - } - - // - // because in some cases we may have more than one input for - // calculation and we must prevent any calculation - // untill we pass the biggest input length, here we get max Input length - // and then wait until pass it ... - maxLength = ExtractMaxLengthOfInputs(); - - // - // Define Index Buffers ... - DefineBuffers(); - - // - // Set Indicator ShortName ... - SetIndicatorName(); - - // - // Init Succeed ... - return INIT_SUCCEEDED; -} - -// -// DeInitialization ... -void OnDeinit(const int reason) -{ - // - // REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function - // REASON_REMOVE 1 Program removed from a chart - // REASON_RECOMPILE 2 Program recompiled - // REASON_CHARTCHANGE 3 A symbol or a chart period is changed - // REASON_CHARTCLOSE 4 Chart closed - // REASON_PARAMETERS 5 Inputs changed by a user - // REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings - // REASON_TEMPLATE 7 Another chart template applied - // REASON_INITFAILED 8 The OnInit() handler returned a non-zero value - // REASON_CLOSE 9 Terminal closed -} - -// -// Calculating what we want ... -int OnCalculate( - const int rates_total, // Total Bars on Chart ... - const int prev_calculated, // Total Calculated Bars on Charts ... - const datetime &time[], // History of Open Time ... - const double &open[], // History of Open Price ... - const double &high[], // History of High Price ... - const double &low[], // History of Low Price ... - const double &close[], // History of Close Price ... - const long &tick_volume[], // History of Tick Volumes on Bar ... - const long &volume[], // History of Trade Volumes ... - const int &spread[] // History of Spread Price ... -) -{ - // - // Prepare Buffers ... - ArraySetAsSeries(time, true); - ArraySetAsSeries(open, true); - ArraySetAsSeries(high, true); - ArraySetAsSeries(low, true); - ArraySetAsSeries(close, true); - ArraySetAsSeries(tick_volume, true); - ArraySetAsSeries(volume, true); - ArraySetAsSeries(spread, true); - - // - // this counts Available Bars ... - int limit; - - // - limit = (prev_calculated > rates_total || prev_calculated <= 0) ? rates_total : (rates_total - prev_calculated) + 1; - - // - // Main Loop ... - for (int i = limit - 1; i >= 0 && !IsStopped(); i--) - { - // - CalculateBuffers( - // - i, - prev_calculated, - rates_total, - // - open, - high, - close, - low, - tick_volume - // - ); - } - - // - return rates_total; -} - -// -// Functions ... - -// -// Validate Input Args for Initialization ... -bool ValidateInputs() -{ - // - bool result = false; - - // - result = - // - (tenkanSenLength > 2 && - kijunSenLength > tenkanSenLength && - senkouSpanBLength > kijunSenLength) - // - && - // - (IsValid(scMethod, scPeriod) && - IsValid(mcMethod, mcPeriod) && - IsValid(lcMethod, lcPeriod) && - IsValid(hcMethod, hcPeriod)) - // - ; - - // - return result; -} - -// -// Initialize Market Cycles ... -bool InitMarketCycles() -{ - // - bool result = false; - - // - // Current Cycle Initialization ... - - // - int cPeriodSeconds = PeriodSeconds(_Period); - - // - // Short Cycle Initialization ... - - // - // Find Cycle Period ... - if (scMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mSCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_SHORT, - _Period // - ); - } - else - { - mSCPeriod = scPeriod; - } - - // - result = IsValid(mSCPeriod); - if (!result) - { - return result; - } - - // - mSCycleLength = PeriodSeconds(mSCPeriod) / cPeriodSeconds; - mSTenkanSenLength = mSCycleLength * mCTenkanSenLength; - mSKijunSenLength = mSCycleLength * mCKijunSenLength; - mSSenkouSpanBLength = mSCycleLength * mCSenkouSpanBLength; - result = mSCycleLength > 0; - if (!result) - { - return result; - } - - // - // Medium Cycle Initialization ... - - // - // Find Cycle Period ... - if (mcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mMCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_MEDIUM, - _Period // - ); - } - else - { - mMCPeriod = mcPeriod; - } - - // - result = IsValid(mMCPeriod); - if (!result) - { - return result; - } - - // - mMCycleLength = PeriodSeconds(mMCPeriod) / cPeriodSeconds; - mMTenkanSenLength = mMCycleLength * mCTenkanSenLength; - mMKijunSenLength = mMCycleLength * mCKijunSenLength; - mMSenkouSpanBLength = mMCycleLength * mCSenkouSpanBLength; - result = mMCycleLength > 0; - if (!result) - { - return result; - } - - // - // Long Cycle Initialization ... - - // - // Find Cycle Period ... - if (lcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mLCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_LONG, - _Period // - ); - } - else - { - mLCPeriod = lcPeriod; - } - - // - result = IsValid(mLCPeriod); - if (!result) - { - return result; - } - - // - mLCycleLength = PeriodSeconds(mLCPeriod) / cPeriodSeconds; - mLTenkanSenLength = mLCycleLength * mCTenkanSenLength; - mLKijunSenLength = mLCycleLength * mCKijunSenLength; - mLSenkouSpanBLength = mLCycleLength * mCSenkouSpanBLength; - result = mLCycleLength > 0; - if (!result) - { - return result; - } - - // - // Hind Cycle Initialization ... - - // - // Find Cycle Period ... - if (hcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mHCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_HIND, - _Period // - ); - } - else - { - mHCPeriod = hcPeriod; - } - - // - result = IsValid(mHCPeriod); - if (!result) - { - return result; - } - - // - mHCycleLength = PeriodSeconds(mHCPeriod) / cPeriodSeconds; - mHTenkanSenLength = mHCycleLength * mCTenkanSenLength; - mHKijunSenLength = mHCycleLength * mCKijunSenLength; - mHSenkouSpanBLength = mHCycleLength * mCSenkouSpanBLength; - result = mHCycleLength > 0; - if (!result) - { - return result; - } - - // - return result; -} - -// -// Retrieve all Exists Input Max Length ... -// use for Start Of Drawing ... -int ExtractMaxLengthOfInputs() -{ - // - int result = 0; - - // - // Current ... - result = MathMax(mCTenkanSenLength, mCKijunSenLength); - result = MathMax(result, mCSenkouSpanBLength); - - // - // Short ... - result = MathMax(mSTenkanSenLength, mSKijunSenLength); - result = MathMax(result, mSSenkouSpanBLength); - - // - // Medium ... - result = MathMax(mMTenkanSenLength, mMKijunSenLength); - result = MathMax(result, mMSenkouSpanBLength); - - // - // Long ... - result = MathMax(mLTenkanSenLength, mLKijunSenLength); - result = MathMax(result, mLSenkouSpanBLength); - - // - // Hind ... - result = MathMax(mHTenkanSenLength, mHKijunSenLength); - result = MathMax(result, mHSenkouSpanBLength); - - // - return result; -} - -// -// Set Indicator Short Name and also we can define Buffers Labels ... -void SetIndicatorName() -{ - // - IndicatorSetString(INDICATOR_SHORTNAME, ShortName); - IndicatorSetInteger(INDICATOR_DIGITS, _Digits); -} - -// -// Define Indexes and Styles ... -void DefineBuffers() -{ - // - // Current ... - - // - // TENKANSEN ... - - // - bool canCShowTenkanSen = showTenkanSen && showCurrent; - ENUM_DRAW_TYPE cTenkanSenDrawType = canCShowTenkanSen ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(cTenBuffer, true); - SetIndexBuffer(cTenBufferIndex, cTenBuffer, INDICATOR_DATA); - PlotIndexSetInteger(cTenBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(cTenBufferIndex, PLOT_SHOW_DATA, canCShowTenkanSen); - PlotIndexSetInteger(cTenBufferIndex, PLOT_DRAW_TYPE, cTenkanSenDrawType); - - // - // KIJUNSEN ... - - // - bool canCShowKijunSen = showKijunSen && showCurrent; - ENUM_DRAW_TYPE cKijunSenDrawType = canCShowKijunSen ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(cKijBuffer, true); - SetIndexBuffer(cKijBufferIndex, cKijBuffer, INDICATOR_DATA); - PlotIndexSetInteger(cKijBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(cKijBufferIndex, PLOT_SHOW_DATA, canCShowKijunSen); - PlotIndexSetInteger(cKijBufferIndex, PLOT_DRAW_TYPE, cKijunSenDrawType); - - // - // CHIKOUSPAN ... - - // - bool canCShowChikouSpan = showChikouSpan && showCurrent; - ENUM_DRAW_TYPE cChikouSpanDrawType = canCShowChikouSpan ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(cChikBuffer, true); - SetIndexBuffer(cChikBufferIndex, cChikBuffer, INDICATOR_DATA); - PlotIndexSetInteger(cChikBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(cChikBufferIndex, PLOT_SHIFT, -mCKijunSenLength); - PlotIndexSetInteger(cChikBufferIndex, PLOT_SHOW_DATA, canCShowChikouSpan); - PlotIndexSetInteger(cChikBufferIndex, PLOT_DRAW_TYPE, cChikouSpanDrawType); - - // - // SENKOUSPAN A and B ... - int cShiftSize = shiftKumo ? mCKijunSenLength : 0; - - // - // SENKOUSPANA ... - bool canCShowSenkouSpanA = showSenkouSpanA && showCurrent; - ENUM_DRAW_TYPE cSenkouSpanADrawType = canCShowSenkouSpanA ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(cSSABuffer, true); - SetIndexBuffer(cSSABufferIndex, cSSABuffer, INDICATOR_DATA); - PlotIndexSetInteger(cSSABufferIndex, PLOT_SHIFT, cShiftSize); - PlotIndexSetInteger(cSSABufferIndex, PLOT_SHOW_DATA, canCShowSenkouSpanA); - PlotIndexSetInteger(cSSABufferIndex, PLOT_DRAW_TYPE, cSenkouSpanADrawType); - - // - // SENKOUSPANB ... - bool canCShowSenkouSpanB = showSenkouSpanB && showCurrent; - ENUM_DRAW_TYPE cSenkouSpanBDrawType = canCShowSenkouSpanB ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(cSSBBuffer, true); - SetIndexBuffer(cSSBBufferIndex, cSSBBuffer, INDICATOR_DATA); - PlotIndexSetInteger(cSSBBufferIndex, PLOT_SHIFT, cShiftSize); - PlotIndexSetInteger(cSSBBufferIndex, PLOT_SHOW_DATA, canCShowSenkouSpanB); - PlotIndexSetInteger(cSSBBufferIndex, PLOT_DRAW_TYPE, cSenkouSpanBDrawType); - - // - // Short ... - - // - // TENKANSEN ... - - // - bool canSShowTenkanSen = showTenkanSen && showShort; - ENUM_DRAW_TYPE sTenkanSenDrawType = canSShowTenkanSen ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(sTenBuffer, true); - SetIndexBuffer(sTenBufferIndex, sTenBuffer, INDICATOR_DATA); - PlotIndexSetInteger(sTenBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(sTenBufferIndex, PLOT_SHOW_DATA, canSShowTenkanSen); - PlotIndexSetInteger(sTenBufferIndex, PLOT_DRAW_TYPE, sTenkanSenDrawType); - - // - // KIJUNSEN ... - - // - bool canSShowKijunSen = showKijunSen && showShort; - ENUM_DRAW_TYPE sKijunSenDrawType = canSShowKijunSen ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(sKijBuffer, true); - SetIndexBuffer(sKijBufferIndex, sKijBuffer, INDICATOR_DATA); - PlotIndexSetInteger(sKijBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(sKijBufferIndex, PLOT_SHOW_DATA, canSShowKijunSen); - PlotIndexSetInteger(sKijBufferIndex, PLOT_DRAW_TYPE, sKijunSenDrawType); - - // - // CHIKOUSPAN ... - - // - bool canSShowChikouSpan = showChikouSpan && showShort; - ENUM_DRAW_TYPE sChikouSpanDrawType = canSShowChikouSpan ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(sChikBuffer, true); - SetIndexBuffer(sChikBufferIndex, sChikBuffer, INDICATOR_DATA); - PlotIndexSetInteger(sChikBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(sChikBufferIndex, PLOT_SHIFT, -mSKijunSenLength); - PlotIndexSetInteger(sChikBufferIndex, PLOT_SHOW_DATA, canSShowChikouSpan); - PlotIndexSetInteger(sChikBufferIndex, PLOT_DRAW_TYPE, sChikouSpanDrawType); - - // - // SENKOUSPAN A and B ... - int sShiftSize = shiftKumo ? mSKijunSenLength : 0; - - // - // SENKOUSPANA ... - bool canSShowSenkouSpanA = showSenkouSpanA && showShort; - ENUM_DRAW_TYPE sSenkouSpanADrawType = canSShowSenkouSpanA ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(sSSABuffer, true); - SetIndexBuffer(sSSABufferIndex, sSSABuffer, INDICATOR_DATA); - PlotIndexSetInteger(sSSABufferIndex, PLOT_SHIFT, sShiftSize); - PlotIndexSetInteger(sSSABufferIndex, PLOT_SHOW_DATA, canSShowSenkouSpanA); - PlotIndexSetInteger(sSSABufferIndex, PLOT_DRAW_TYPE, sSenkouSpanADrawType); - - // - // SENKOUSPANB ... - bool canSShowSenkouSpanB = showSenkouSpanB && showShort; - ENUM_DRAW_TYPE sSenkouSpanBDrawType = canSShowSenkouSpanB ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(sSSBBuffer, true); - SetIndexBuffer(sSSBBufferIndex, sSSBBuffer, INDICATOR_DATA); - PlotIndexSetInteger(sSSBBufferIndex, PLOT_SHIFT, sShiftSize); - PlotIndexSetInteger(sSSBBufferIndex, PLOT_SHOW_DATA, canSShowSenkouSpanB); - PlotIndexSetInteger(sSSBBufferIndex, PLOT_DRAW_TYPE, sSenkouSpanBDrawType); - - // - // Medium ... - - // - // TENKANSEN ... - - // - bool canMShowTenkanSen = showTenkanSen && showMedium; - ENUM_DRAW_TYPE mTenkanSenDrawType = canMShowTenkanSen ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(mTenBuffer, true); - SetIndexBuffer(mTenBufferIndex, mTenBuffer, INDICATOR_DATA); - PlotIndexSetInteger(mTenBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(mTenBufferIndex, PLOT_SHOW_DATA, canMShowTenkanSen); - PlotIndexSetInteger(mTenBufferIndex, PLOT_DRAW_TYPE, mTenkanSenDrawType); - - // - // KIJUNSEN ... - - // - bool canMShowKijunSen = showKijunSen && showMedium; - ENUM_DRAW_TYPE mKijunSenDrawType = canMShowKijunSen ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(mKijBuffer, true); - SetIndexBuffer(mKijBufferIndex, mKijBuffer, INDICATOR_DATA); - PlotIndexSetInteger(mKijBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(mKijBufferIndex, PLOT_SHOW_DATA, canMShowKijunSen); - PlotIndexSetInteger(mKijBufferIndex, PLOT_DRAW_TYPE, mKijunSenDrawType); - - // - // CHIKOUSPAN ... - - // - bool canMShowChikouSpan = showChikouSpan && showMedium; - ENUM_DRAW_TYPE mChikouSpanDrawType = canMShowChikouSpan ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(mChikBuffer, true); - SetIndexBuffer(mChikBufferIndex, mChikBuffer, INDICATOR_DATA); - PlotIndexSetInteger(mChikBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(mChikBufferIndex, PLOT_SHIFT, -mMKijunSenLength); - PlotIndexSetInteger(mChikBufferIndex, PLOT_SHOW_DATA, canMShowChikouSpan); - PlotIndexSetInteger(mChikBufferIndex, PLOT_DRAW_TYPE, mChikouSpanDrawType); - - // - // SENKOUSPAN A and B ... - int mShiftSize = shiftKumo ? mMKijunSenLength : 0; - - // - // SENKOUSPANA ... - bool canMShowSenkouSpanA = showSenkouSpanA && showMedium; - ENUM_DRAW_TYPE mSenkouSpanADrawType = canMShowSenkouSpanA ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(mSSABuffer, true); - SetIndexBuffer(mSSABufferIndex, mSSABuffer, INDICATOR_DATA); - PlotIndexSetInteger(mSSABufferIndex, PLOT_SHIFT, mShiftSize); - PlotIndexSetInteger(mSSABufferIndex, PLOT_SHOW_DATA, canMShowSenkouSpanA); - PlotIndexSetInteger(mSSABufferIndex, PLOT_DRAW_TYPE, mSenkouSpanADrawType); - - // - // SENKOUSPANB ... - bool canMShowSenkouSpanB = showSenkouSpanB && showMedium; - ENUM_DRAW_TYPE mSenkouSpanBDrawType = canMShowSenkouSpanB ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(mSSBBuffer, true); - SetIndexBuffer(mSSBBufferIndex, mSSBBuffer, INDICATOR_DATA); - PlotIndexSetInteger(mSSBBufferIndex, PLOT_SHIFT, mShiftSize); - PlotIndexSetInteger(mSSBBufferIndex, PLOT_SHOW_DATA, canMShowSenkouSpanB); - PlotIndexSetInteger(mSSBBufferIndex, PLOT_DRAW_TYPE, mSenkouSpanBDrawType); - - // - // Long ... - - // - // TENKANSEN ... - - // - bool canLShowTenkanSen = showTenkanSen && showLong; - ENUM_DRAW_TYPE lTenkanSenDrawType = canLShowTenkanSen ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(lTenBuffer, true); - SetIndexBuffer(lTenBufferIndex, lTenBuffer, INDICATOR_DATA); - PlotIndexSetInteger(lTenBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(lTenBufferIndex, PLOT_SHOW_DATA, canLShowTenkanSen); - PlotIndexSetInteger(lTenBufferIndex, PLOT_DRAW_TYPE, lTenkanSenDrawType); - - // - // KIJUNSEN ... - - // - bool canLShowKijunSen = showKijunSen && showLong; - ENUM_DRAW_TYPE lKijunSenDrawType = canLShowKijunSen ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(lKijBuffer, true); - SetIndexBuffer(lKijBufferIndex, lKijBuffer, INDICATOR_DATA); - PlotIndexSetInteger(lKijBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(lKijBufferIndex, PLOT_SHOW_DATA, canLShowKijunSen); - PlotIndexSetInteger(lKijBufferIndex, PLOT_DRAW_TYPE, lKijunSenDrawType); - - // - // CHIKOUSPAN ... - - // - bool canLShowChikouSpan = showChikouSpan && showLong; - ENUM_DRAW_TYPE lChikouSpanDrawType = canLShowChikouSpan ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(lChikBuffer, true); - SetIndexBuffer(lChikBufferIndex, lChikBuffer, INDICATOR_DATA); - PlotIndexSetInteger(lChikBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(lChikBufferIndex, PLOT_SHIFT, -mLKijunSenLength); - PlotIndexSetInteger(lChikBufferIndex, PLOT_SHOW_DATA, canLShowChikouSpan); - PlotIndexSetInteger(lChikBufferIndex, PLOT_DRAW_TYPE, lChikouSpanDrawType); - - // - // SENKOUSPAN A and B ... - int lShiftSize = shiftKumo ? mLKijunSenLength : 0; - - // - // SENKOUSPANA ... - bool canLShowSenkouSpanA = showSenkouSpanA && showLong; - ENUM_DRAW_TYPE lSenkouSpanADrawType = canLShowSenkouSpanA ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(lSSABuffer, true); - SetIndexBuffer(lSSABufferIndex, lSSABuffer, INDICATOR_DATA); - PlotIndexSetInteger(lSSABufferIndex, PLOT_SHIFT, lShiftSize); - PlotIndexSetInteger(lSSABufferIndex, PLOT_SHOW_DATA, canLShowSenkouSpanA); - PlotIndexSetInteger(lSSABufferIndex, PLOT_DRAW_TYPE, lSenkouSpanADrawType); - - // - // SENKOUSPANB ... - bool canLShowSenkouSpanB = showSenkouSpanB && showLong; - ENUM_DRAW_TYPE lSenkouSpanBDrawType = canLShowSenkouSpanB ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(lSSBBuffer, true); - SetIndexBuffer(lSSBBufferIndex, lSSBBuffer, INDICATOR_DATA); - PlotIndexSetInteger(lSSBBufferIndex, PLOT_SHIFT, lShiftSize); - PlotIndexSetInteger(lSSBBufferIndex, PLOT_SHOW_DATA, canLShowSenkouSpanB); - PlotIndexSetInteger(lSSBBufferIndex, PLOT_DRAW_TYPE, lSenkouSpanBDrawType); - - // - // Hind ... - - // - // TENKANSEN ... - - // - bool canHShowTenkanSen = showTenkanSen && showHind; - ENUM_DRAW_TYPE hTenkanSenDrawType = canHShowTenkanSen ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(hTenBuffer, true); - SetIndexBuffer(hTenBufferIndex, hTenBuffer, INDICATOR_DATA); - PlotIndexSetInteger(hTenBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(hTenBufferIndex, PLOT_SHOW_DATA, canHShowTenkanSen); - PlotIndexSetInteger(hTenBufferIndex, PLOT_DRAW_TYPE, hTenkanSenDrawType); - - // - // KIJUNSEN ... - - // - bool canHShowKijunSen = showKijunSen && showHind; - ENUM_DRAW_TYPE hKijunSenDrawType = canHShowKijunSen ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(hKijBuffer, true); - SetIndexBuffer(hKijBufferIndex, hKijBuffer, INDICATOR_DATA); - PlotIndexSetInteger(hKijBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(hKijBufferIndex, PLOT_SHOW_DATA, canHShowKijunSen); - PlotIndexSetInteger(hKijBufferIndex, PLOT_DRAW_TYPE, hKijunSenDrawType); - - // - // CHIKOUSPAN ... - - // - bool canHShowChikouSpan = showChikouSpan && showHind; - ENUM_DRAW_TYPE hChikouSpanDrawType = canHShowChikouSpan ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(hChikBuffer, true); - SetIndexBuffer(hChikBufferIndex, hChikBuffer, INDICATOR_DATA); - PlotIndexSetInteger(hChikBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(hChikBufferIndex, PLOT_SHIFT, -mHKijunSenLength); - PlotIndexSetInteger(hChikBufferIndex, PLOT_SHOW_DATA, canHShowChikouSpan); - PlotIndexSetInteger(hChikBufferIndex, PLOT_DRAW_TYPE, hChikouSpanDrawType); - - // - // SENKOUSPAN A and B ... - int hShiftSize = shiftKumo ? mHKijunSenLength : 0; - - // - // SENKOUSPANA ... - bool canHShowSenkouSpanA = showSenkouSpanA && showHind; - ENUM_DRAW_TYPE hSenkouSpanADrawType = canHShowSenkouSpanA ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(hSSABuffer, true); - SetIndexBuffer(hSSABufferIndex, hSSABuffer, INDICATOR_DATA); - PlotIndexSetInteger(hSSABufferIndex, PLOT_SHIFT, hShiftSize); - PlotIndexSetInteger(hSSABufferIndex, PLOT_SHOW_DATA, canHShowSenkouSpanA); - PlotIndexSetInteger(hSSABufferIndex, PLOT_DRAW_TYPE, hSenkouSpanADrawType); - - // - // SENKOUSPANB ... - bool canHShowSenkouSpanB = showSenkouSpanB && showHind; - ENUM_DRAW_TYPE hSenkouSpanBDrawType = canHShowSenkouSpanB ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(hSSBBuffer, true); - SetIndexBuffer(hSSBBufferIndex, hSSBBuffer, INDICATOR_DATA); - PlotIndexSetInteger(hSSBBufferIndex, PLOT_SHIFT, hShiftSize); - PlotIndexSetInteger(hSSBBufferIndex, PLOT_SHOW_DATA, canHShowSenkouSpanB); - PlotIndexSetInteger(hSSBBufferIndex, PLOT_DRAW_TYPE, hSenkouSpanBDrawType); - - // - // Here we Create KUMO CLOUD Buffers ... - - // - // int lastBufferIndex = hSSBBufferIndex; - - // - // Current ... - bool cCanShowKumo = showKumo && showCurrent; - ENUM_DRAW_TYPE cKumoDrawType = cCanShowKumo ? DRAW_FILLING : DRAW_NONE; - - // - // SENKOUSPANA ... - ArraySetAsSeries(cSSAKCBuffer, true); - SetIndexBuffer(cSSAKCBufferIndex, cSSAKCBuffer, INDICATOR_DATA); - PlotIndexSetInteger(cSSAKCBufferIndex, PLOT_DRAW_BEGIN, maxLength); - - // - // SENKOUSPANB ... - ArraySetAsSeries(cSSBKCBuffer, true); - SetIndexBuffer(cSSBKCBufferIndex, cSSBKCBuffer, INDICATOR_DATA); - PlotIndexSetInteger(cSSBKCBufferIndex, PLOT_DRAW_BEGIN, maxLength); - - // - PlotIndexSetInteger(cKCBufferIndex, PLOT_SHOW_DATA, false); - PlotIndexSetInteger(cKCBufferIndex, PLOT_SHIFT, cShiftSize); - PlotIndexSetInteger(cKCBufferIndex, PLOT_DRAW_TYPE, cKumoDrawType); - - // - // Short ... - bool sCanShowKumo = showKumo && showShort; - ENUM_DRAW_TYPE sKumoDrawType = sCanShowKumo ? DRAW_FILLING : DRAW_NONE; - - // - // SENKOUSPANA ... - ArraySetAsSeries(sSSAKCBuffer, true); - SetIndexBuffer(sSSAKCBufferIndex, sSSAKCBuffer, INDICATOR_DATA); - PlotIndexSetInteger(sSSAKCBufferIndex, PLOT_DRAW_BEGIN, maxLength); - - // - // SENKOUSPANB ... - ArraySetAsSeries(sSSBKCBuffer, true); - SetIndexBuffer(sSSBKCBufferIndex, sSSBKCBuffer, INDICATOR_DATA); - PlotIndexSetInteger(sSSBKCBufferIndex, PLOT_DRAW_BEGIN, maxLength); - - // - PlotIndexSetInteger(sKCBufferIndex, PLOT_SHOW_DATA, false); - PlotIndexSetInteger(sKCBufferIndex, PLOT_SHIFT, sShiftSize); - PlotIndexSetInteger(sKCBufferIndex, PLOT_DRAW_TYPE, sKumoDrawType); - - // - // Medium ... - bool mCanShowKumo = showKumo && showMedium; - ENUM_DRAW_TYPE mKumoDrawType = mCanShowKumo ? DRAW_FILLING : DRAW_NONE; - - // - // SENKOUSPANA ... - ArraySetAsSeries(mSSAKCBuffer, true); - SetIndexBuffer(mSSAKCBufferIndex, mSSAKCBuffer, INDICATOR_DATA); - PlotIndexSetInteger(mSSAKCBufferIndex, PLOT_DRAW_BEGIN, maxLength); - - // - // SENKOUSPANB ... - ArraySetAsSeries(mSSBKCBuffer, true); - SetIndexBuffer(mSSBKCBufferIndex, mSSBKCBuffer, INDICATOR_DATA); - PlotIndexSetInteger(mSSBKCBufferIndex, PLOT_DRAW_BEGIN, maxLength); - - // - PlotIndexSetInteger(mKCBufferIndex, PLOT_SHOW_DATA, false); - PlotIndexSetInteger(mKCBufferIndex, PLOT_SHIFT, mShiftSize); - PlotIndexSetInteger(mKCBufferIndex, PLOT_DRAW_TYPE, mKumoDrawType); - - // - // Long ... - bool lCanShowKumo = showKumo && showLong; - ENUM_DRAW_TYPE lKumoDrawType = lCanShowKumo ? DRAW_FILLING : DRAW_NONE; - - // - // SENKOUSPANA ... - ArraySetAsSeries(lSSAKCBuffer, true); - SetIndexBuffer(lSSAKCBufferIndex, lSSAKCBuffer, INDICATOR_DATA); - PlotIndexSetInteger(lSSAKCBufferIndex, PLOT_DRAW_BEGIN, maxLength); - - // - // SENKOUSPANB ... - ArraySetAsSeries(lSSBKCBuffer, true); - SetIndexBuffer(lSSBKCBufferIndex, lSSBKCBuffer, INDICATOR_DATA); - PlotIndexSetInteger(lSSBKCBufferIndex, PLOT_DRAW_BEGIN, maxLength); - - // - PlotIndexSetInteger(lKCBufferIndex, PLOT_SHOW_DATA, false); - PlotIndexSetInteger(lKCBufferIndex, PLOT_SHIFT, lShiftSize); - PlotIndexSetInteger(lKCBufferIndex, PLOT_DRAW_TYPE, lKumoDrawType); - - // - // Hind ... - bool hCanShowKumo = showKumo && showHind; - ENUM_DRAW_TYPE hKumoDrawType = hCanShowKumo ? DRAW_FILLING : DRAW_NONE; - - // - // SENKOUSPANA ... - ArraySetAsSeries(hSSAKCBuffer, true); - SetIndexBuffer(hSSAKCBufferIndex, hSSAKCBuffer, INDICATOR_DATA); - PlotIndexSetInteger(hSSAKCBufferIndex, PLOT_DRAW_BEGIN, maxLength); - - // - // SENKOUSPANB ... - ArraySetAsSeries(hSSBKCBuffer, true); - SetIndexBuffer(hSSBKCBufferIndex, hSSBKCBuffer, INDICATOR_DATA); - PlotIndexSetInteger(hSSBKCBufferIndex, PLOT_DRAW_BEGIN, maxLength); - - // - PlotIndexSetInteger(hKCBufferIndex, PLOT_SHOW_DATA, false); - PlotIndexSetInteger(hKCBufferIndex, PLOT_SHIFT, hShiftSize); - PlotIndexSetInteger(hKCBufferIndex, PLOT_DRAW_TYPE, hKumoDrawType); -} - -// -// Calculations ... - -// -// Calculate Buffers ... -void CalculateBuffers( - int bar_index, // Selected Bar Index - const int prevCalculated, - const int ratesTotal, - const double &open[], - const double &high[], - const double &close[], - const double &low[], - const long &tickVolume[] // -) -{ - // - CalculateCycles( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - tickVolume // - ); -} - -// -void CalculateCycles( - int bar_index, // Selected Bar Index - const int prevCalculated, - const int ratesTotal, - const double &open[], - const double &high[], - const double &close[], - const double &low[], - const long &tickVolume[] // -) -{ - // - // CURRENT ... - CalculateCycle( - // - bar_index, - prevCalculated, - ratesTotal, - // - open, - high, - close, - low, - tickVolume, - // - mCTenkanSenLength, - mCKijunSenLength, - mCSenkouSpanBLength, - // - cTenBuffer, - cKijBuffer, - cChikBuffer, - cSSABuffer, - cSSBBuffer, - cSSAKCBuffer, - cSSBKCBuffer - // - ); - - // - // SHORT ... - CalculateCycle( - // - bar_index, - prevCalculated, - ratesTotal, - // - open, - high, - close, - low, - tickVolume, - // - mSTenkanSenLength, - mSKijunSenLength, - mSSenkouSpanBLength, - // - sTenBuffer, - sKijBuffer, - sChikBuffer, - sSSABuffer, - sSSBBuffer, - sSSAKCBuffer, - sSSBKCBuffer - // - ); - - // - // MEDIUM ... - CalculateCycle( - // - bar_index, - prevCalculated, - ratesTotal, - // - open, - high, - close, - low, - tickVolume, - // - mMTenkanSenLength, - mMKijunSenLength, - mMSenkouSpanBLength, - // - mTenBuffer, - mKijBuffer, - mChikBuffer, - mSSABuffer, - mSSBBuffer, - mSSAKCBuffer, - mSSBKCBuffer - // - ); - - // - // LONG ... - CalculateCycle( - // - bar_index, - prevCalculated, - ratesTotal, - // - open, - high, - close, - low, - tickVolume, - // - mLTenkanSenLength, - mLKijunSenLength, - mLSenkouSpanBLength, - // - lTenBuffer, - lKijBuffer, - lChikBuffer, - lSSABuffer, - lSSBBuffer, - lSSAKCBuffer, - lSSBKCBuffer - // - ); - - // - // HIND ... - CalculateCycle( - // - bar_index, - prevCalculated, - ratesTotal, - // - open, - high, - close, - low, - tickVolume, - // - mHTenkanSenLength, - mHKijunSenLength, - mHSenkouSpanBLength, - // - hTenBuffer, - hKijBuffer, - hChikBuffer, - hSSABuffer, - hSSBBuffer, - hSSAKCBuffer, - hSSBKCBuffer - // - ); -} - -// -void CalculateCycle( - int bar_index, // Selected Bar Index - const int prevCalculated, - const int ratesTotal, - const double &open[], - const double &high[], - const double &close[], - const double &low[], - const long &tickVolume[], - // - int _tenkanSenLength, - int _kijunSenLength, - int _senkouSpanBLength, - // - double &_tenkanSenBuffer[], - double &_kijunSenBuffer[], - double &_chikouSpanBuffer[], - double &_senkouABuffer[], - double &_senkouBBuffer[], - double &_cloudSenkouSpanABuffer[], - double &_cloudSenkouSpanBBuffer[] - // -) -{ - // - double topValue; - double bottomValue; - - // - // TENKANSEN ... - - // - // Extract Tenkan Sen Top/Bottom Calculation Mode based on User Input ... - if (mTenkanSenTopMode == NULL || mTenkanSenBottomMode == NULL) - { - // - switch (tenkanSenMode) - { - // - case X_XICH_HH_LL_MODE: - // - mTenkanSenTopMode = MODE_HIGH; - mTenkanSenBottomMode = MODE_LOW; - break; - - // - case X_XICH_HO_LC_MODE: - // - mTenkanSenTopMode = MODE_OPEN; - mTenkanSenBottomMode = MODE_CLOSE; - break; - } - } - - // - XOHCL bar; - bar.Init( - _Symbol, - _Period, - bar_index - // - ); - - // - // Calculate Top ... - topValue = bar - .FindHighest( - _tenkanSenLength, - mTenkanSenTopMode - // - ); - - // - // Calculate Bottom ... - bottomValue = bar - .FindLowest( - _tenkanSenLength, - mTenkanSenBottomMode - // - ); - - // - double tenkanSenValue = (topValue + bottomValue) / 2; - _tenkanSenBuffer[bar_index] = tenkanSenValue; - - // - // KIJUNSEN ... - - // - // Extract Kijun Sen Top/Bottom Calculation Mode based on User Input ... - if (mKijunSenTopMode == NULL || mKijunSenBottomMode == NULL) - { - // - switch (kijunSenMode) - { - // - case X_XICH_HH_LL_MODE: - // - mKijunSenTopMode = MODE_HIGH; - mKijunSenBottomMode = MODE_LOW; - break; - - // - case X_XICH_HO_LC_MODE: - // - mKijunSenTopMode = MODE_OPEN; - mKijunSenBottomMode = MODE_CLOSE; - break; - } - } - - // - // Calculate Top ... - topValue = bar - .FindHighest( - _kijunSenLength, - mKijunSenTopMode - // - ); - - // - // Calculate Bottom ... - bottomValue = bar - .FindLowest( - _kijunSenLength, - mKijunSenBottomMode - // - ); - - // - double kijunSenValue = (topValue + bottomValue) / 2; - _kijunSenBuffer[bar_index] = kijunSenValue; - - // - // CHIKOUSPAN ... - double chikouSpanValue = bar - .GetPrice(chikuoSpanAppliedTo); - - // - _chikouSpanBuffer[bar_index] = chikouSpanValue; - - // - // KUMO ... - - // - // SENKOUSPANA ... - double senkouSpanAValue = (tenkanSenValue + kijunSenValue) / 2; - _senkouABuffer[bar_index] = senkouSpanAValue; - _cloudSenkouSpanABuffer[bar_index] = senkouSpanAValue; - - // - // SENKOUSPANB ... - - // - // Extract Senkou Span B Top/Bottom Calculation Mode based on User Input ... - if (mSenkouSpanBTopMode == NULL || mSenkouSpanBBottomMode == NULL) - { - // - switch (senkouSpanBMode) - { - // - case X_XICH_HH_LL_MODE: - // - mSenkouSpanBTopMode = MODE_HIGH; - mSenkouSpanBBottomMode = MODE_LOW; - break; - - // - case X_XICH_HO_LC_MODE: - // - mSenkouSpanBTopMode = MODE_OPEN; - mSenkouSpanBBottomMode = MODE_CLOSE; - break; - } - } - - // - // Calculate Top ... - topValue = bar - .FindHighest( - _senkouSpanBLength, - mSenkouSpanBTopMode - // - ); - - // - // Calculate Bottom ... - bottomValue = bar - .FindLowest( - _senkouSpanBLength, - mSenkouSpanBBottomMode - // - ); - - // - double senkouSpanBValue = (topValue + bottomValue) / 2; - _senkouBBuffer[bar_index] = senkouSpanBValue; - _cloudSenkouSpanBBuffer[bar_index] = senkouSpanBValue; - - // -} - -// \ No newline at end of file diff --git a/Indicators/x-saherelm.xchm.mq5 b/Indicators/x-saherelm.xchm.mq5 deleted file mode 100644 index cb3572d2..00000000 --- a/Indicators/x-saherelm.xchm.mq5 +++ /dev/null @@ -1,1089 +0,0 @@ -/////////////////////////////////////////////////////// -// SaherElm IT Center MQL5 Indicator -// ------------------------------------------- -// Name: XCHM -// Description: XCHMrend Detector ... -// -// Maintainer: -// ------------ -// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) -// -////////////////////////////////////////////////////// -// -// Global Properties ... -#property copyright "Copyright 2023, SaherElm IT Center" -#property link "https://saherelm.ir" -#property version "1.00" -#property description "SaherElm XCHM Indicator" -#property strict - -// -#define ShortName "XCHM" - -// -// Includes Common Library ... -#include "../Libraries/x-saherelm.common.lib.mq5" - -// -// Inputs ... - -// -// Market ... -input group "Market"; -input int fastLength = 9; // Fast Length -input int slowLength = 18; // Slow Length -input ENUM_MA_METHOD method = MODE_SMA; // Mode -input ENUM_APPLIED_PRICE appliedTo = PRICE_CLOSE; // Applied To - -// -input group "Cycles"; - -// -input group "Short"; -input ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES scPeriod = NULL; // Time Period - -// -input group "Medium"; -input ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES mcPeriod = NULL; // Time Period - -// -input group "Long"; -input ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES lcPeriod = NULL; // Time Period - -// -input group "Hind"; -input ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period - -// -// Presentation ... -input group "Presentation"; - -// -// Parts ... -input bool showFast = true; // Show Fast -input bool showSlow = true; // Show Slow - -// -// AVG ... -input bool showAVG = true; // Show Average - -// -// Cycles ... -input bool showCurrent = true; // Show Current Cycle -input bool showShort = true; // Show Short Cycle -input bool showMedium = true; // Show Medium Cycle -input bool showLong = true; // Show Long Cycle -input bool showHind = true; // Show Hind Cycle - -// -// Buffers ... - -// -#property indicator_chart_window - -// -#property indicator_buffers 12 -#property indicator_plots 12 - -// -// AVG ... - -// -// Fast ... -#define avgFastBufferIndex 0 -double avgFastBuffer[]; - -// -#property indicator_label1 "XCHM AF" -#property indicator_type1 DRAW_LINE -#property indicator_color1 clrGreen -#property indicator_style1 STYLE_SOLID -#property indicator_width1 1 - -// -// Slow ... -#define avgSlowBufferIndex 1 -double avgSlowBuffer[]; - -// -#property indicator_label2 "XCHM AS" -#property indicator_type2 DRAW_LINE -#property indicator_color2 clrRed -#property indicator_style2 STYLE_SOLID -#property indicator_width2 1 - -// -// Current ... - -// -// Fast ... -#define cFastBufferIndex 2 -double cFastBuffer[]; - -// -#property indicator_label3 "XCHM CF" -#property indicator_type3 DRAW_LINE -#property indicator_color3 clrAqua -#property indicator_style3 STYLE_DOT -#property indicator_width3 1 - -// -// Slow ... -#define cSlowBufferIndex 3 -double cSlowBuffer[]; - -// -#property indicator_label4 "XCHM CS" -#property indicator_type4 DRAW_LINE -#property indicator_color4 clrMagenta -#property indicator_style4 STYLE_DOT -#property indicator_width4 1 - -// -// Short ... - -// -// Fast ... -#define sFastBufferIndex 4 -double sFastBuffer[]; - -// -#property indicator_label5 "XCHM SF" -#property indicator_type5 DRAW_LINE -#property indicator_color5 clrAqua -#property indicator_style5 STYLE_DOT -#property indicator_width5 1 - -// -// Slow ... -#define sSlowBufferIndex 5 -double sSlowBuffer[]; - -// -#property indicator_label6 "XCHM SS" -#property indicator_type6 DRAW_LINE -#property indicator_color6 clrMagenta -#property indicator_style6 STYLE_DOT -#property indicator_width6 1 - -// -// Medium ... - -// -// Fast ... -#define mFastBufferIndex 6 -double mFastBuffer[]; - -// -#property indicator_label7 "XCHM MF" -#property indicator_type7 DRAW_LINE -#property indicator_color7 clrAqua -#property indicator_style7 STYLE_DOT -#property indicator_width7 1 - -// -// Slow ... -#define mSlowBufferIndex 7 -double mSlowBuffer[]; - -// -#property indicator_label8 "XCHM MS" -#property indicator_type8 DRAW_LINE -#property indicator_color8 clrMagenta -#property indicator_style8 STYLE_DOT -#property indicator_width8 1 - -// -// Long ... - -// -// Fast ... -#define lFastBufferIndex 8 -double lFastBuffer[]; - -// -#property indicator_label9 "XCHM LF" -#property indicator_type9 DRAW_LINE -#property indicator_color9 clrAqua -#property indicator_style9 STYLE_DOT -#property indicator_width9 1 - -// -// Slow ... -#define lSlowBufferIndex 9 -double lSlowBuffer[]; - -// -#property indicator_label10 "XCHM LS" -#property indicator_type10 DRAW_LINE -#property indicator_color10 clrMagenta -#property indicator_style10 STYLE_DOT -#property indicator_width10 1 - -// -// Hind ... - -// -// Fast ... -#define hFastBufferIndex 10 -double hFastBuffer[]; - -// -#property indicator_label11 "XCHM HF" -#property indicator_type11 DRAW_LINE -#property indicator_color11 clrAqua -#property indicator_style11 STYLE_DOT -#property indicator_width11 1 - -// -// Slow ... -#define hSlowBufferIndex 11 -double hSlowBuffer[]; - -// -#property indicator_label12 "XCHM HS" -#property indicator_type12 DRAW_LINE -#property indicator_color12 clrMagenta -#property indicator_style12 STYLE_DOT -#property indicator_width12 1 - -// -// Variables ... - -// -int maxLength; - -// -// Current ... -int cFastHandler = INVALID_HANDLE; -int cSlowHandler = INVALID_HANDLE; - -// -// Short ... -int mSCLength = 0; -int mSCFastLength = 0; -int mSCSlowLength = 0; -ENUM_TIMEFRAMES mSCPeriod = NULL; -int sFastHandler = INVALID_HANDLE; -int sSlowHandler = INVALID_HANDLE; - -// -// Medium ... -int mMCLength = 0; -int mMCFastLength = 0; -int mMCSlowLength = 0; -ENUM_TIMEFRAMES mMCPeriod = NULL; -int mFastHandler = INVALID_HANDLE; -int mSlowHandler = INVALID_HANDLE; - -// -// Long ... -int mLCLength = 0; -int mLCFastLength = 0; -int mLCSlowLength = 0; -ENUM_TIMEFRAMES mLCPeriod = NULL; -int lFastHandler = INVALID_HANDLE; -int lSlowHandler = INVALID_HANDLE; - -// -// Hind ... -int mHCLength = 0; -int mHCFastLength = 0; -int mHCSlowLength = 0; -ENUM_TIMEFRAMES mHCPeriod = NULL; -int hFastHandler = INVALID_HANDLE; -int hSlowHandler = INVALID_HANDLE; - -// -// EVENT Handlers ... - -// -// Initialization ... -int OnInit() -{ - // - // Validate Inputs ... - if (!ValidateInputs()) - { - return INIT_PARAMETERS_INCORRECT; - } - - // - if (!InitMarketCycles()) - { - return INIT_PARAMETERS_INCORRECT; - } - - // - // because in some cases we may have more than one input for - // calculation and we must prevent any calculation - // untill we pass the biggest input length, here we get max Input length - // and then wait until pass it ... - maxLength = ExtractMaxLengthOfInputs(); - - // - // Define Index Buffers ... - DefineBuffers(); - - // - // Set Indicator ShortName ... - SetIndicatorName(); - - // - // Init Succeed ... - return INIT_SUCCEEDED; -} - -// -// DeInitialization ... -void OnDeinit(const int reason) -{ - // - // REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function - // REASON_REMOVE 1 Program removed from a chart - // REASON_RECOMPILE 2 Program recompiled - // REASON_CHARTCHANGE 3 A symbol or a chart period is changed - // REASON_CHARTCLOSE 4 Chart closed - // REASON_PARAMETERS 5 Inputs changed by a user - // REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings - // REASON_TEMPLATE 7 Another chart template applied - // REASON_INITFAILED 8 The OnInit() handler returned a non-zero value - // REASON_CLOSE 9 Terminal closed - - // - // Current ... - IndicatorRelease(cFastHandler); - IndicatorRelease(cSlowHandler); - - // - // Short ... - IndicatorRelease(sFastHandler); - IndicatorRelease(sSlowHandler); - - // - // Medium ... - IndicatorRelease(mFastHandler); - IndicatorRelease(mSlowHandler); - - // - // Long ... - IndicatorRelease(lFastHandler); - IndicatorRelease(lSlowHandler); - - // - // Hind ... - IndicatorRelease(hFastHandler); - IndicatorRelease(hSlowHandler); -} - -// -// Calculating what we want ... -int OnCalculate( - 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 ... -) -{ - // - ArraySetAsSeries(low, true); - ArraySetAsSeries(open, true); - ArraySetAsSeries(high, true); - ArraySetAsSeries(close, true); - - // - // this counts Available Bars ... - int limit; - - // - // Validate Calculated Bars ... - bool isPassedRequiredCalculatedBars = - // - // Current ... - BarsCalculated(cFastHandler) >= maxLength && - BarsCalculated(cSlowHandler) >= maxLength && - // - // Short ... - BarsCalculated(sFastHandler) >= maxLength && - BarsCalculated(sSlowHandler) >= maxLength && - // - // Medium ... - BarsCalculated(mFastHandler) >= maxLength && - BarsCalculated(mSlowHandler) >= maxLength && - // - // Long ... - BarsCalculated(lFastHandler) >= maxLength && - BarsCalculated(lSlowHandler) >= maxLength && - // - // Hind ... - BarsCalculated(hFastHandler) >= maxLength && - BarsCalculated(hSlowHandler) >= maxLength - // - ; - if (!isPassedRequiredCalculatedBars) - { - return prev_calculated; - } - - // - limit = - (prev_calculated > rates_total || prev_calculated <= 0) - ? rates_total - : (rates_total - prev_calculated) + 1; - - // - // Buffers Copy ... - - // - // Current ... - int copiedCFasts = CopyBuffer(cFastHandler, 0, 0, limit, cFastBuffer); - int copiedCSlows = CopyBuffer(cSlowHandler, 0, 0, limit, cSlowBuffer); - - // - // Short ... - int copiedSFasts = CopyBuffer(sFastHandler, 0, 0, limit, sFastBuffer); - int copiedSSlows = CopyBuffer(sSlowHandler, 0, 0, limit, sSlowBuffer); - - // - // Medium ... - int copiedMFasts = CopyBuffer(mFastHandler, 0, 0, limit, mFastBuffer); - int copiedMSlows = CopyBuffer(mSlowHandler, 0, 0, limit, mSlowBuffer); - - // - // Long ... - int copiedLFasts = CopyBuffer(lFastHandler, 0, 0, limit, lFastBuffer); - int copiedLSlows = CopyBuffer(lSlowHandler, 0, 0, limit, lSlowBuffer); - - // - // Hind ... - int copiedHFasts = CopyBuffer(hFastHandler, 0, 0, limit, hFastBuffer); - int copiedHSlows = CopyBuffer(hSlowHandler, 0, 0, limit, hSlowBuffer); - - // - // Validate Copied Items ... - bool isPassedRequiredCopiedItems = - // - // - // Current ... - copiedCFasts > 0 && - copiedCSlows > 0 && - // - // Short ... - copiedSFasts > 0 && - copiedSSlows > 0 && - // - // Medium ... - copiedMFasts > 0 && - copiedMSlows > 0 && - // - // Long ... - copiedLFasts > 0 && - copiedLSlows > 0 && - // - // Hind ... - copiedHFasts > 0 && - copiedHSlows > 0 - // - ; - if (!isPassedRequiredCopiedItems) - { - return prev_calculated; - } - - // - // Main Loop ... - for (int i = limit - 1; i >= 0 && !IsStopped(); i--) - { - CalculateBuffers(i); - } - - // - return rates_total; -} - -// -// CUSTOM Functions ... - -// -// Validate Input Args for Initialization ... -bool ValidateInputs() -{ - // - bool result = - // - fastLength > 2 && - slowLength > fastLength && - // - (IsValid(scMethod, scPeriod) && - IsValid(mcMethod, mcPeriod) && - IsValid(lcMethod, lcPeriod) && - IsValid(hcMethod, hcPeriod)) - // - ; - - // - return result; -} - -// -// Retrieve all Exists Input Max Length ... -// use for Start Of Drawing ... -int ExtractMaxLengthOfInputs() -{ - // - int result = 0; - - // - // Current ... - result = MathMax(fastLength, slowLength); - - // - // Short ... - result = MathMax(result, mSCFastLength); - result = MathMax(result, mSCSlowLength); - - // - // Medium ... - result = MathMax(result, mMCFastLength); - result = MathMax(result, mMCSlowLength); - - // - // Long ... - result = MathMax(result, mLCFastLength); - result = MathMax(result, mLCSlowLength); - - // - // Hind ... - result = MathMax(result, mHCFastLength); - result = MathMax(result, mHCSlowLength); - - // - return result; -} - -// -// Set Indicator Short Name and also we can define Buffers Labels ... -void SetIndicatorName() -{ - // - IndicatorSetInteger(INDICATOR_DIGITS, _Digits); - IndicatorSetString(INDICATOR_SHORTNAME, ShortName); -} - -// -// Define Indexes and Styles ... -void DefineBuffers() -{ - // - // AVG ... - - // - // Fast ... - bool canShowAVGFast = showAVG && showFast; - ENUM_DRAW_TYPE avgFastDrawType = canShowAVGFast ? DRAW_LINE : DRAW_NONE; - ArraySetAsSeries(avgFastBuffer, true); - SetIndexBuffer(avgFastBufferIndex, avgFastBuffer, INDICATOR_DATA); - PlotIndexSetDouble(avgFastBufferIndex, PLOT_EMPTY_VALUE, 0); - PlotIndexSetInteger(avgFastBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(avgFastBufferIndex, PLOT_SHOW_DATA, canShowAVGFast); - PlotIndexSetInteger(avgFastBufferIndex, PLOT_DRAW_TYPE, avgFastDrawType); - - // - // Slow ... - bool canShowAVGSlow = showAVG && showSlow; - ENUM_DRAW_TYPE avgSlowDrawType = canShowAVGSlow ? DRAW_LINE : DRAW_NONE; - ArraySetAsSeries(avgSlowBuffer, true); - SetIndexBuffer(avgSlowBufferIndex, avgSlowBuffer, INDICATOR_DATA); - PlotIndexSetDouble(avgSlowBufferIndex, PLOT_EMPTY_VALUE, 0); - PlotIndexSetInteger(avgSlowBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(avgSlowBufferIndex, PLOT_SHOW_DATA, canShowAVGSlow); - PlotIndexSetInteger(avgSlowBufferIndex, PLOT_DRAW_TYPE, avgSlowDrawType); - - // - // Current ... - - // - // Fast ... - bool canShowCFast = showCurrent && showFast; - ENUM_DRAW_TYPE cFastDrawType = canShowCFast ? DRAW_LINE : DRAW_NONE; - ArraySetAsSeries(cFastBuffer, true); - SetIndexBuffer(cFastBufferIndex, cFastBuffer, INDICATOR_DATA); - PlotIndexSetDouble(cFastBufferIndex, PLOT_EMPTY_VALUE, 0); - PlotIndexSetInteger(cFastBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(cFastBufferIndex, PLOT_SHOW_DATA, canShowCFast); - PlotIndexSetInteger(cFastBufferIndex, PLOT_DRAW_TYPE, cFastDrawType); - - // - // Slow ... - bool canShowCSlow = showCurrent && showSlow; - ENUM_DRAW_TYPE cSlowDrawType = canShowCSlow ? DRAW_LINE : DRAW_NONE; - ArraySetAsSeries(cSlowBuffer, true); - SetIndexBuffer(cSlowBufferIndex, cSlowBuffer, INDICATOR_DATA); - PlotIndexSetDouble(cSlowBufferIndex, PLOT_EMPTY_VALUE, 0); - PlotIndexSetInteger(cSlowBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(cSlowBufferIndex, PLOT_SHOW_DATA, canShowCSlow); - PlotIndexSetInteger(cSlowBufferIndex, PLOT_DRAW_TYPE, cSlowDrawType); - - // - // Short ... - - // - // Fast ... - bool canShowSFast = showShort && showFast; - ENUM_DRAW_TYPE sFastDrawType = canShowSFast ? DRAW_LINE : DRAW_NONE; - ArraySetAsSeries(sFastBuffer, true); - SetIndexBuffer(sFastBufferIndex, sFastBuffer, INDICATOR_DATA); - PlotIndexSetDouble(sFastBufferIndex, PLOT_EMPTY_VALUE, 0); - PlotIndexSetInteger(sFastBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(sFastBufferIndex, PLOT_SHOW_DATA, canShowSFast); - PlotIndexSetInteger(sFastBufferIndex, PLOT_DRAW_TYPE, sFastDrawType); - - // - // Slow ... - bool canShowSSlow = showShort && showSlow; - ENUM_DRAW_TYPE sSlowDrawType = canShowSSlow ? DRAW_LINE : DRAW_NONE; - ArraySetAsSeries(sSlowBuffer, true); - SetIndexBuffer(sSlowBufferIndex, sSlowBuffer, INDICATOR_DATA); - PlotIndexSetDouble(sSlowBufferIndex, PLOT_EMPTY_VALUE, 0); - PlotIndexSetInteger(sSlowBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(sSlowBufferIndex, PLOT_SHOW_DATA, canShowSSlow); - PlotIndexSetInteger(sSlowBufferIndex, PLOT_DRAW_TYPE, sSlowDrawType); - - // - // Medium ... - - // - // Fast ... - bool canShowMFast = showMedium && showFast; - ENUM_DRAW_TYPE mFastDrawType = canShowMFast ? DRAW_LINE : DRAW_NONE; - ArraySetAsSeries(mFastBuffer, true); - SetIndexBuffer(mFastBufferIndex, mFastBuffer, INDICATOR_DATA); - PlotIndexSetDouble(mFastBufferIndex, PLOT_EMPTY_VALUE, 0); - PlotIndexSetInteger(mFastBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(mFastBufferIndex, PLOT_SHOW_DATA, canShowMFast); - PlotIndexSetInteger(mFastBufferIndex, PLOT_DRAW_TYPE, mFastDrawType); - - // - // Slow ... - bool canShowMSlow = showMedium && showSlow; - ENUM_DRAW_TYPE mSlowDrawType = canShowMSlow ? DRAW_LINE : DRAW_NONE; - ArraySetAsSeries(mSlowBuffer, true); - SetIndexBuffer(mSlowBufferIndex, mSlowBuffer, INDICATOR_DATA); - PlotIndexSetDouble(mSlowBufferIndex, PLOT_EMPTY_VALUE, 0); - PlotIndexSetInteger(mSlowBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(mSlowBufferIndex, PLOT_SHOW_DATA, canShowMSlow); - PlotIndexSetInteger(mSlowBufferIndex, PLOT_DRAW_TYPE, mSlowDrawType); - - // - // Long ... - - // - // Fast ... - bool canShowLFast = showLong && showFast; - ENUM_DRAW_TYPE lFastDrawType = canShowLFast ? DRAW_LINE : DRAW_NONE; - ArraySetAsSeries(lFastBuffer, true); - SetIndexBuffer(lFastBufferIndex, lFastBuffer, INDICATOR_DATA); - PlotIndexSetDouble(lFastBufferIndex, PLOT_EMPTY_VALUE, 0); - PlotIndexSetInteger(lFastBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(lFastBufferIndex, PLOT_SHOW_DATA, canShowLFast); - PlotIndexSetInteger(lFastBufferIndex, PLOT_DRAW_TYPE, lFastDrawType); - - // - // Slow ... - bool canShowLSlow = showLong && showSlow; - ENUM_DRAW_TYPE lSlowDrawType = canShowLSlow ? DRAW_LINE : DRAW_NONE; - ArraySetAsSeries(lSlowBuffer, true); - SetIndexBuffer(lSlowBufferIndex, lSlowBuffer, INDICATOR_DATA); - PlotIndexSetDouble(lSlowBufferIndex, PLOT_EMPTY_VALUE, 0); - PlotIndexSetInteger(lSlowBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(lSlowBufferIndex, PLOT_SHOW_DATA, canShowLSlow); - PlotIndexSetInteger(lSlowBufferIndex, PLOT_DRAW_TYPE, lSlowDrawType); - - // - // Hind ... - - // - // Fast ... - bool canShowHFast = showHind && showFast; - ENUM_DRAW_TYPE hFastDrawType = canShowHFast ? DRAW_LINE : DRAW_NONE; - ArraySetAsSeries(hFastBuffer, true); - SetIndexBuffer(hFastBufferIndex, hFastBuffer, INDICATOR_DATA); - PlotIndexSetDouble(hFastBufferIndex, PLOT_EMPTY_VALUE, 0); - PlotIndexSetInteger(hFastBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(hFastBufferIndex, PLOT_SHOW_DATA, canShowHFast); - PlotIndexSetInteger(hFastBufferIndex, PLOT_DRAW_TYPE, hFastDrawType); - - // - // Slow ... - bool canShowHSlow = showHind && showSlow; - ENUM_DRAW_TYPE hSlowDrawType = canShowHSlow ? DRAW_LINE : DRAW_NONE; - ArraySetAsSeries(hSlowBuffer, true); - SetIndexBuffer(hSlowBufferIndex, hSlowBuffer, INDICATOR_DATA); - PlotIndexSetDouble(hSlowBufferIndex, PLOT_EMPTY_VALUE, 0); - PlotIndexSetInteger(hSlowBufferIndex, PLOT_DRAW_BEGIN, maxLength); - PlotIndexSetInteger(hSlowBufferIndex, PLOT_SHOW_DATA, canShowHSlow); - PlotIndexSetInteger(hSlowBufferIndex, PLOT_DRAW_TYPE, hSlowDrawType); -} - -// -// Initial Market Cycles ... -bool InitMarketCycles() -{ - // - bool result = false; - - // - // Current Cycle Initialization ... - - // - int cPeriodSeconds = PeriodSeconds(_Period); - - // - // Initialize Handlers ... - cFastHandler = iMA( - _Symbol, - _Period, - fastLength, - 0, - method, - appliedTo // - ); - cSlowHandler = iMA( - _Symbol, - _Period, - slowLength, - 0, - method, - appliedTo // - ); - result = - // - cFastHandler != INVALID_HANDLE && - cSlowHandler != INVALID_HANDLE - // - ; - if (!result) - { - return result; - } - - // - // Short Cycle Initialization ... - - // - // Find Cycle Period ... - if (scMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mSCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_SHORT, - _Period // - ); - } - else - { - mSCPeriod = scPeriod; - } - - // - result = IsValid(mSCPeriod); - if (!result) - { - return result; - } - - // - mSCLength = PeriodSeconds(mSCPeriod) / cPeriodSeconds; - mSCFastLength = fastLength * mSCLength; - mSCSlowLength = slowLength * mSCLength; - - // - result = mSCLength > 0; - if (!result) - { - return result; - } - - // - // Initialize Handlers ... - sFastHandler = iMA( - _Symbol, - _Period, - mSCFastLength, - 0, - method, - appliedTo // - ); - sSlowHandler = iMA( - _Symbol, - _Period, - mSCSlowLength, - 0, - method, - appliedTo // - ); - result = - // - sFastHandler != INVALID_HANDLE && - sSlowHandler != INVALID_HANDLE - // - ; - if (!result) - { - return result; - } - - // - // Medium Cycle Initialization ... - - // - // Find Cycle Period ... - if (mcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mMCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_MEDIUM, - _Period // - ); - } - else - { - mMCPeriod = mcPeriod; - } - - // - result = IsValid(mMCPeriod); - if (!result) - { - return result; - } - - // - mMCLength = PeriodSeconds(mMCPeriod) / cPeriodSeconds; - mMCFastLength = fastLength * mMCLength; - mMCSlowLength = slowLength * mMCLength; - - // - result = mMCLength > 0; - if (!result) - { - return result; - } - - // - // Initialize Handlers ... - mFastHandler = iMA( - _Symbol, - _Period, - mMCFastLength, - 0, - method, - appliedTo // - ); - mSlowHandler = iMA( - _Symbol, - _Period, - mMCSlowLength, - 0, - method, - appliedTo // - ); - result = - // - mFastHandler != INVALID_HANDLE && - mSlowHandler != INVALID_HANDLE - // - ; - if (!result) - { - return result; - } - - // - // Long Cycle Initialization ... - - // - // Find Cycle Period ... - if (lcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mLCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_LONG, - _Period // - ); - } - else - { - mLCPeriod = lcPeriod; - } - - // - result = IsValid(mLCPeriod); - if (!result) - { - return result; - } - - // - mLCLength = PeriodSeconds(mLCPeriod) / cPeriodSeconds; - mLCFastLength = fastLength * mLCLength; - mLCSlowLength = slowLength * mLCLength; - - // - result = mLCLength > 0; - if (!result) - { - return result; - } - - // - // Initialize Handlers ... - lFastHandler = iMA( - _Symbol, - _Period, - mLCFastLength, - 0, - method, - appliedTo // - ); - lSlowHandler = iMA( - _Symbol, - _Period, - mLCSlowLength, - 0, - method, - appliedTo // - ); - result = - // - lFastHandler != INVALID_HANDLE && - lSlowHandler != INVALID_HANDLE - // - ; - if (!result) - { - return result; - } - - // - // Hind Cycle Initialization ... - - // - // Find Cycle Period ... - if (hcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mHCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_HIND, - _Period // - ); - } - else - { - mHCPeriod = hcPeriod; - } - - // - result = IsValid(mHCPeriod); - if (!result) - { - return result; - } - - // - mHCLength = PeriodSeconds(mHCPeriod) / cPeriodSeconds; - mHCFastLength = fastLength * mHCLength; - mHCSlowLength = slowLength * mHCLength; - - // - result = mHCLength > 0; - if (!result) - { - return result; - } - - // - // Initialize Handlers ... - hFastHandler = iMA( - _Symbol, - _Period, - mHCFastLength, - 0, - method, - appliedTo // - ); - hSlowHandler = iMA( - _Symbol, - _Period, - mHCSlowLength, - 0, - method, - appliedTo // - ); - result = - // - hFastHandler != INVALID_HANDLE && - hSlowHandler != INVALID_HANDLE - // - ; - if (!result) - { - return result; - } - - // - return result; -} - -// -// Do all Custom Calculations ... -void CalculateBuffers(int barIndex) -{ - // - double cFast = cFastBuffer[barIndex]; - double sFast = sFastBuffer[barIndex]; - double mFast = mFastBuffer[barIndex]; - double lFast = lFastBuffer[barIndex]; - double hFast = hFastBuffer[barIndex]; - - // - double fast = - cFast + - sFast + - mFast + - lFast + - hFast; - avgFastBuffer[barIndex] = fast / 5; - - // - double cSlow = cSlowBuffer[barIndex]; - double sSlow = sSlowBuffer[barIndex]; - double mSlow = mSlowBuffer[barIndex]; - double lSlow = lSlowBuffer[barIndex]; - double hSlow = hSlowBuffer[barIndex]; - - // - double slow = - cSlow + - sSlow + - mSlow + - lSlow + - hSlow; - avgSlowBuffer[barIndex] = slow / 5; -} - -// \ No newline at end of file diff --git a/Indicators/x-saherelm.xchstr.mq5 b/Indicators/x-saherelm.xchstr.mq5 deleted file mode 100644 index b67b000c..00000000 --- a/Indicators/x-saherelm.xchstr.mq5 +++ /dev/null @@ -1,1246 +0,0 @@ -/////////////////////////////////////////////////////// -// SaherElm IT Center MQL5 Indicator -// ------------------------------------------- -// Name: XCHSTR -// Description: Smoothed HikenAshi Cycles ... -// -// Maintainer: -// ------------ -// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) -// -////////////////////////////////////////////////////// -// -// Global Properties ... -#property copyright "Copyright 2023, SaherElm IT Center" -#property link "https://saherelm.ir" -#property version "1.00" -#property description "SaherElm XCHSTR Indicator" -#property strict - -// -#define ShortName "XCHSTR" - -// -// Includes Common Library ... -#include "../Libraries/x-saherelm.common.lib.mq5" - -// -// Inputs ... - -// -input group "Market"; - -// -input int atrLength = 14; // Length -input double atrMultiplier = 3.0; // Multiplier -input ENUM_APPLIED_PRICE atrAppliedTo = PRICE_MEDIAN; // Applied To - -// -input group "Cycles"; - -// -input group "Short"; -input ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES scPeriod = NULL; // Time Period - -// -input group "Medium"; -input ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES mcPeriod = NULL; // Time Period - -// -input group "Long"; -input ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES lcPeriod = NULL; // Time Period - -// -input group "Hind"; -input ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period - -// -// Presentation ... -input group "Presentation"; - -// -input bool showCurrent = true; // Show Current Cycle -input bool showShort = true; // Show Short Cycle -input bool showMedium = true; // Show Medium Cycle -input bool showLong = true; // Show Long Cycle -input bool showHind = true; // Show Hind Cycle - -// -// Buffers ... - -// -#define hideColorIDX 0 -#define bullishColorIDX 1 -#define bearishColorIDX 2 - -// -#property indicator_chart_window - -// -#property indicator_buffers 35 -#property indicator_plots 10 - -// -// Current ... - -// -#define cBufferIndex 0 -#define cPlotBufferIndex 0 -double cBuffer[]; - -// -#define cColorBufferIndex 1 -double cColorBuffer[]; - -// -#property indicator_label1 "C XSTR" -#property indicator_type1 DRAW_COLOR_LINE -#property indicator_color1 CLR_NONE, clrGreen, clrDarkRed -#property indicator_style1 STYLE_DOT - -// -// Short ... - -// -#define sBufferIndex 2 -#define sPlotBufferIndex 1 -double sBuffer[]; - -// -#define sColorBufferIndex 3 -double sColorBuffer[]; - -// -#property indicator_label2 "S XSTR" -#property indicator_type2 DRAW_COLOR_LINE -#property indicator_color2 CLR_NONE, clrGreen, clrDarkRed -#property indicator_style2 STYLE_DOT - -// -// Medium ... - -// -#define mBufferIndex 4 -#define mPlotBufferIndex 2 -double mBuffer[]; - -// -#define mColorBufferIndex 5 -double mColorBuffer[]; - -// -#property indicator_label3 "M XSTR" -#property indicator_type3 DRAW_COLOR_LINE -#property indicator_color3 CLR_NONE, clrGreen, clrDarkRed -#property indicator_style3 STYLE_DOT - -// -// Long ... - -// -#define lBufferIndex 6 -#define lPlotBufferIndex 3 -double lBuffer[]; - -// -#define lColorBufferIndex 7 -double lColorBuffer[]; - -// -#property indicator_label4 "L XSTR" -#property indicator_type4 DRAW_COLOR_LINE -#property indicator_color4 CLR_NONE, clrGreen, clrDarkRed -#property indicator_style4 STYLE_DOT - -// -// Hind ... - -// -#define hBufferIndex 8 -#define hPlotBufferIndex 4 -double hBuffer[]; - -// -#define hColorBufferIndex 9 -double hColorBuffer[]; - -// -#property indicator_label5 "H XSTR" -#property indicator_type5 DRAW_COLOR_LINE -#property indicator_color5 CLR_NONE, clrGreen, clrDarkRed -#property indicator_style5 STYLE_DOT - -// -// Data Buffers ... - -// -// Current ... - -// -#define cAtrBufferIndex 10 -double cAtrBuffer[]; - -// -#define cTrendBufferIndex 11 -double cTrendBuffer[]; - -// -#define cUpBufferIndex 12 -double cUpBuffer[]; - -// -#define cDownBufferIndex 13 -double cDownBuffer[]; - -// -#define cPriceBufferIndex 14 -double cPriceBuffer[]; - -// -// Short ... - -// -#define sAtrBufferIndex 15 -double sAtrBuffer[]; - -// -#define sTrendBufferIndex 16 -double sTrendBuffer[]; - -// -#define sUpBufferIndex 17 -double sUpBuffer[]; - -// -#define sDownBufferIndex 18 -double sDownBuffer[]; - -// -#define sPriceBufferIndex 19 -double sPriceBuffer[]; - -// -// Medium ... - -// -#define mAtrBufferIndex 20 -double mAtrBuffer[]; - -// -#define mTrendBufferIndex 21 -double mTrendBuffer[]; - -// -#define mUpBufferIndex 22 -double mUpBuffer[]; - -// -#define mDownBufferIndex 23 -double mDownBuffer[]; - -// -#define mPriceBufferIndex 24 -double mPriceBuffer[]; - -// -// Long ... - -// -#define lAtrBufferIndex 25 -double lAtrBuffer[]; - -// -#define lTrendBufferIndex 26 -double lTrendBuffer[]; - -// -#define lUpBufferIndex 27 -double lUpBuffer[]; - -// -#define lDownBufferIndex 28 -double lDownBuffer[]; - -// -#define lPriceBufferIndex 29 -double lPriceBuffer[]; - -// -// Hind ... - -// -#define hAtrBufferIndex 30 -double hAtrBuffer[]; - -// -#define hTrendBufferIndex 31 -double hTrendBuffer[]; - -// -#define hUpBufferIndex 32 -double hUpBuffer[]; - -// -#define hDownBufferIndex 33 -double hDownBuffer[]; - -// -#define hPriceBufferIndex 34 -double hPriceBuffer[]; - -// -// Variables, Properties and etc ... - -// -int changeOfTrend; -int startBearishTrend; -int startBullishTrend; - -// -int maxLength; - -// -// Current ... -int mCSMLength = atrLength; -int mCAtrHandler = INVALID_HANDLE; - -// -// Short ... -int mSCLength = 0; -int mSSMLength = 0; -int mSAtrHandler = INVALID_HANDLE; -ENUM_TIMEFRAMES mSCPeriod = NULL; - -// -// Medium ... -int mMCLength = 0; -int mMSMLength = 0; -int mMAtrHandler = INVALID_HANDLE; -ENUM_TIMEFRAMES mMCPeriod = NULL; - -// -// Long ... -int mLCLength = 0; -int mLSMLength = 0; -int mLAtrHandler = INVALID_HANDLE; -ENUM_TIMEFRAMES mLCPeriod = NULL; - -// -// Hind ... -int mHCLength = 0; -int mHSMLength = 0; -int mHAtrHandler = INVALID_HANDLE; -ENUM_TIMEFRAMES mHCPeriod = NULL; - -// -// Event Handlers ... - -// -// Initialization ... -int OnInit() -{ - // - // Validate Inputs ... - if (!ValidateInputs()) - { - return INIT_PARAMETERS_INCORRECT; - } - - // - if (!InitMarketCycles()) - { - return INIT_PARAMETERS_INCORRECT; - } - - // - // because in some cases we may have more than one input for - // calculation and we must prevent any calculation - // untill we pass the biggest input length, here we get max Input length - // and then wait until pass it ... - maxLength = ExtractMaxLengthOfInputs(); - - // - // Define Index Buffers ... - DefineBuffers(); - - // - // Set Indicator ShortName ... - SetIndicatorName(); - - // - // Init Succeed ... - return INIT_SUCCEEDED; -} - -// -// DeInitialization ... -void OnDeinit(const int reason) -{ - // - // REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function - // REASON_REMOVE 1 Program removed from a chart - // REASON_RECOMPILE 2 Program recompiled - // REASON_CHARTCHANGE 3 A symbol or a chart period is changed - // REASON_CHARTCLOSE 4 Chart closed - // REASON_PARAMETERS 5 Inputs changed by a user - // REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings - // REASON_TEMPLATE 7 Another chart template applied - // REASON_INITFAILED 8 The OnInit() handler returned a non-zero value - // REASON_CLOSE 9 Terminal closed -} - -// -// Calculating what we want ... -int OnCalculate( - 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 ... -) -{ - // - int numOfRequiredAtrs; - if (prev_calculated > rates_total || prev_calculated < 0) - { - numOfRequiredAtrs = rates_total; - } - else - { - // - numOfRequiredAtrs = rates_total - prev_calculated; - if (prev_calculated > 0) - { - numOfRequiredAtrs++; - } - } - - // - // Checking for stop ... - if (IsStopped()) - { - return 0; - } - - // - // Check Number of items Copy or not ... - int copiedCATRs = CopyBuffer(mCAtrHandler, 0, 0, numOfRequiredAtrs, cAtrBuffer); - int copiedSATRs = CopyBuffer(mSAtrHandler, 0, 0, numOfRequiredAtrs, sAtrBuffer); - int copiedMATRs = CopyBuffer(mMAtrHandler, 0, 0, numOfRequiredAtrs, mAtrBuffer); - int copiedLATRs = CopyBuffer(mLAtrHandler, 0, 0, numOfRequiredAtrs, lAtrBuffer); - int copiedHATRs = CopyBuffer(mHAtrHandler, 0, 0, numOfRequiredAtrs, hAtrBuffer); - if (copiedCATRs <= 0 || - copiedSATRs <= 0 || - copiedMATRs <= 0 || - copiedLATRs <= 0 || - copiedHATRs <= 0) - { - return 0; - } - - // - int limit; - - // - // checking for the limit start of calculation of an indicator ... - if (prev_calculated > rates_total || prev_calculated <= 0) - { - // - // starting index for calculation of all bars ... - limit = maxLength; - } - else - { - // - // starting number for calculation of new bars - limit = prev_calculated - 1; - } - - // - // Main Loop ... - for (int i = limit; i < rates_total && !IsStopped(); i++) - { - // - CalculateBuffers( - open, - high, - low, - close, - i // - ); - } - - // - return rates_total; -} - -// -// Functions ... - -// -// Validate Input Args for Initialization ... -bool ValidateInputs() -{ - // - bool result = false; - - // - result = - // - atrLength >= 2 && - atrMultiplier > 0 && - // - (IsValid(scMethod, scPeriod) && - IsValid(mcMethod, mcPeriod) && - IsValid(lcMethod, lcPeriod) && - IsValid(hcMethod, hcPeriod)) - // - ; - - // - return result; -} - -// -// Initialize Market Cycles ... -bool InitMarketCycles() -{ - // - bool result = false; - - // - // Current Cycle Initialization ... - - // - int cPeriodSeconds = PeriodSeconds(_Period); - - // - mCAtrHandler = iATR( - _Symbol, - _Period, - mCSMLength // - ); - result = mCAtrHandler != INVALID_HANDLE; - if (!result) - { - return result; - } - - // - // Short Cycle Initialization ... - - // - // Find Cycle Period ... - if (scMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mSCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_SHORT, - _Period // - ); - } - else - { - mSCPeriod = scPeriod; - } - - // - result = IsValid(mSCPeriod); - if (!result) - { - return result; - } - - // - mSCLength = PeriodSeconds(mSCPeriod) / cPeriodSeconds; - mSSMLength = mSCLength * mCSMLength; - result = mSCLength > 0; - if (!result) - { - return result; - } - - // - mSAtrHandler = iATR( - _Symbol, - _Period, - mSSMLength // - ); - result = mSAtrHandler != INVALID_HANDLE; - if (!result) - { - return result; - } - - // - // Medium Cycle Initialization ... - - // - // Find Cycle Period ... - if (mcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mMCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_MEDIUM, - _Period // - ); - } - else - { - mMCPeriod = mcPeriod; - } - - // - result = IsValid(mMCPeriod); - if (!result) - { - return result; - } - - // - mMCLength = PeriodSeconds(mMCPeriod) / cPeriodSeconds; - mMSMLength = mMCLength * mCSMLength; - result = mMCLength > 0; - if (!result) - { - return result; - } - - // - mMAtrHandler = iATR( - _Symbol, - _Period, - mMSMLength // - ); - result = mMAtrHandler != INVALID_HANDLE; - if (!result) - { - return result; - } - - // - // Long Cycle Initialization ... - - // - // Find Cycle Period ... - if (lcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mLCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_LONG, - _Period // - ); - } - else - { - mLCPeriod = lcPeriod; - } - - // - result = IsValid(mLCPeriod); - if (!result) - { - return result; - } - - // - mLCLength = PeriodSeconds(mLCPeriod) / cPeriodSeconds; - mLSMLength = mLCLength * mCSMLength; - result = mLCLength > 0; - if (!result) - { - return result; - } - - // - mLAtrHandler = iATR( - _Symbol, - _Period, - mLSMLength // - ); - result = mLAtrHandler != INVALID_HANDLE; - if (!result) - { - return result; - } - - // - // Hind Cycle Initialization ... - - // - // Find Cycle Period ... - if (hcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mHCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_HIND, - _Period // - ); - } - else - { - mHCPeriod = hcPeriod; - } - - // - result = IsValid(mHCPeriod); - if (!result) - { - return result; - } - - // - mHCLength = PeriodSeconds(mHCPeriod) / cPeriodSeconds; - mHSMLength = mHCLength * mCSMLength; - result = mHCLength > 0; - if (!result) - { - return result; - } - - // - mHAtrHandler = iATR( - _Symbol, - _Period, - mHSMLength // - ); - result = mHAtrHandler != INVALID_HANDLE; - if (!result) - { - return result; - } - - // - return result; -} - -// -// Retrieve all Exists Input Max Length ... -// use for Start Of Drawing ... -int ExtractMaxLengthOfInputs() -{ - // - int result = 0; - - // - result = MathMax(mCSMLength, mSSMLength); - result = MathMax(result, mMSMLength); - result = MathMax(result, mLSMLength); - result = MathMax(result, mHSMLength); - - // - return result; -} - -// -// Define Indexes and Styles ... -void DefineBuffers() -{ - // - // CURRENT Cycle ... - - // - // STR ... - SetIndexBuffer(cBufferIndex, cBuffer, INDICATOR_DATA); - - // - // Color ... - SetIndexBuffer(cColorBufferIndex, cColorBuffer, INDICATOR_COLOR_INDEX); - - // - // Set EMPTY_VALUE on Bar Buffer ... - PlotIndexSetDouble(cPlotBufferIndex, PLOT_EMPTY_VALUE, 0.0); - PlotIndexSetInteger(cPlotBufferIndex, PLOT_SHOW_DATA, showCurrent); - - // - // Data Buffers ... - - // - // ATR ... - SetIndexBuffer(cAtrBufferIndex, cAtrBuffer, INDICATOR_CALCULATIONS); - - // - // Price ... - SetIndexBuffer(cPriceBufferIndex, cPriceBuffer, INDICATOR_CALCULATIONS); - - // - // Trend ... - SetIndexBuffer(cTrendBufferIndex, cTrendBuffer, INDICATOR_CALCULATIONS); - - // - // Up ... - SetIndexBuffer(cUpBufferIndex, cUpBuffer, INDICATOR_CALCULATIONS); - - // - // Down ... - SetIndexBuffer(cDownBufferIndex, cDownBuffer, INDICATOR_CALCULATIONS); - - // - // SHORT Cycle ... - - // - // STR ... - SetIndexBuffer(sBufferIndex, sBuffer, INDICATOR_DATA); - - // - // Color ... - SetIndexBuffer(sColorBufferIndex, sColorBuffer, INDICATOR_COLOR_INDEX); - - // - // Set EMPTY_VALUE on Bar Buffer ... - PlotIndexSetDouble(sPlotBufferIndex, PLOT_EMPTY_VALUE, 0.0); - PlotIndexSetInteger(sPlotBufferIndex, PLOT_SHOW_DATA, showShort); - - // - // Data Buffers ... - - // - // ATR ... - SetIndexBuffer(sAtrBufferIndex, sAtrBuffer, INDICATOR_CALCULATIONS); - - // - // Price ... - SetIndexBuffer(sPriceBufferIndex, sPriceBuffer, INDICATOR_CALCULATIONS); - - // - // Trend ... - SetIndexBuffer(sTrendBufferIndex, sTrendBuffer, INDICATOR_CALCULATIONS); - - // - // Up ... - SetIndexBuffer(sUpBufferIndex, sUpBuffer, INDICATOR_CALCULATIONS); - - // - // Down ... - SetIndexBuffer(sDownBufferIndex, sDownBuffer, INDICATOR_CALCULATIONS); - - // - // MEDIUM Cycle ... - - // - // STR ... - SetIndexBuffer(mBufferIndex, mBuffer, INDICATOR_DATA); - - // - // Color ... - SetIndexBuffer(mColorBufferIndex, mColorBuffer, INDICATOR_COLOR_INDEX); - - // - // Set EMPTY_VALUE on Bar Buffer ... - PlotIndexSetDouble(mPlotBufferIndex, PLOT_EMPTY_VALUE, 0.0); - PlotIndexSetInteger(mPlotBufferIndex, PLOT_SHOW_DATA, showMedium); - - // - // Data Buffers ... - - // - // ATR ... - SetIndexBuffer(mAtrBufferIndex, mAtrBuffer, INDICATOR_CALCULATIONS); - - // - // Price ... - SetIndexBuffer(mPriceBufferIndex, mPriceBuffer, INDICATOR_CALCULATIONS); - - // - // Trend ... - SetIndexBuffer(mTrendBufferIndex, mTrendBuffer, INDICATOR_CALCULATIONS); - - // - // Up ... - SetIndexBuffer(mUpBufferIndex, mUpBuffer, INDICATOR_CALCULATIONS); - - // - // Down ... - SetIndexBuffer(mDownBufferIndex, mDownBuffer, INDICATOR_CALCULATIONS); - - // - // LONG Cycle ... - - // - // STR ... - SetIndexBuffer(lBufferIndex, lBuffer, INDICATOR_DATA); - - // - // Color ... - SetIndexBuffer(lColorBufferIndex, lColorBuffer, INDICATOR_COLOR_INDEX); - - // - // Set EMPTY_VALUE on Bar Buffer ... - PlotIndexSetDouble(lPlotBufferIndex, PLOT_EMPTY_VALUE, 0.0); - PlotIndexSetInteger(lPlotBufferIndex, PLOT_SHOW_DATA, showLong); - - // - // Data Buffers ... - - // - // ATR ... - SetIndexBuffer(lAtrBufferIndex, lAtrBuffer, INDICATOR_CALCULATIONS); - - // - // Price ... - SetIndexBuffer(lPriceBufferIndex, lPriceBuffer, INDICATOR_CALCULATIONS); - - // - // Trend ... - SetIndexBuffer(lTrendBufferIndex, lTrendBuffer, INDICATOR_CALCULATIONS); - - // - // Up ... - SetIndexBuffer(lUpBufferIndex, lUpBuffer, INDICATOR_CALCULATIONS); - - // - // Down ... - SetIndexBuffer(lDownBufferIndex, lDownBuffer, INDICATOR_CALCULATIONS); - - // - // HIND Cycle ... - - // - // STR ... - SetIndexBuffer(hBufferIndex, hBuffer, INDICATOR_DATA); - - // - // Color ... - SetIndexBuffer(hColorBufferIndex, hColorBuffer, INDICATOR_COLOR_INDEX); - - // - // Set EMPTY_VALUE on Bar Buffer ... - PlotIndexSetDouble(hPlotBufferIndex, PLOT_EMPTY_VALUE, 0.0); - PlotIndexSetInteger(hPlotBufferIndex, PLOT_SHOW_DATA, showHind); - - // - // Data Buffers ... - - // - // ATR ... - SetIndexBuffer(hAtrBufferIndex, hAtrBuffer, INDICATOR_CALCULATIONS); - - // - // Price ... - SetIndexBuffer(hPriceBufferIndex, hPriceBuffer, INDICATOR_CALCULATIONS); - - // - // Trend ... - SetIndexBuffer(hTrendBufferIndex, hTrendBuffer, INDICATOR_CALCULATIONS); - - // - // Up ... - SetIndexBuffer(hUpBufferIndex, hUpBuffer, INDICATOR_CALCULATIONS); - - // - // Down ... - SetIndexBuffer(hDownBufferIndex, hDownBuffer, INDICATOR_CALCULATIONS); -} - -// -// Set Indicator Short Name and also we can define Buffers Labels ... -void SetIndicatorName() -{ - IndicatorSetString(INDICATOR_SHORTNAME, ShortName); -} - -// -// Calculations ... - -// -// Calculate Hiken Ashi ... -void CalculateBuffers( - const double &open[], - const double &high[], - const double &low[], - const double &close[], - int barIndex // -) -{ - // - // Current ... - CalculateCycle( - open, - high, - low, - close, - barIndex, - cAtrBuffer, - cPriceBuffer, - cUpBuffer, - cDownBuffer, - cTrendBuffer, - cBuffer, - cColorBuffer, - showCurrent // - ); - - // - // Short ... - CalculateCycle( - open, - high, - low, - close, - barIndex, - sAtrBuffer, - sPriceBuffer, - sUpBuffer, - sDownBuffer, - sTrendBuffer, - sBuffer, - sColorBuffer, - showShort // - ); - - // - // Short ... - CalculateCycle( - open, - high, - low, - close, - barIndex, - mAtrBuffer, - mPriceBuffer, - mUpBuffer, - mDownBuffer, - mTrendBuffer, - mBuffer, - mColorBuffer, - showMedium // - ); - - // - // Short ... - CalculateCycle( - open, - high, - low, - close, - barIndex, - lAtrBuffer, - lPriceBuffer, - lUpBuffer, - lDownBuffer, - lTrendBuffer, - lBuffer, - lColorBuffer, - showLong // - ); - - // - // Hind ... - CalculateCycle( - open, - high, - low, - close, - barIndex, - hAtrBuffer, - hPriceBuffer, - hUpBuffer, - hDownBuffer, - hTrendBuffer, - hBuffer, - hColorBuffer, - showHind // - ); -} - -// -void CalculateCycle( - const double &open[], - const double &high[], - const double &low[], - const double &close[], - int barIndex, - double &atr[], - double &price[], - double &up[], - double &down[], - double &trend[], - double &main[], - double &clr[], // Color Index Buffer - bool show // -) -{ - // - // Calculated Price ... - double _price = getPrice( - atrAppliedTo, - open, - high, - low, - close, - barIndex // - ); - price[barIndex] = _price; - - // - double _atr = atr[barIndex]; - - // - // Up ... - up[barIndex] = _price + (atrMultiplier * _atr); - - // - // Down ... - down[barIndex] = _price - (atrMultiplier * _atr); - - // - if (close[barIndex] > up[barIndex - 1]) - { - // - trend[barIndex] = 1; - if (trend[barIndex - 1] == -1) - { - changeOfTrend = 1; - } - } - else if (close[barIndex] < down[barIndex - 1]) - { - // - trend[barIndex] = -1; - if (trend[barIndex - 1] == 1) - { - changeOfTrend = 1; - } - } - else if (trend[barIndex - 1] == 1) - { - // - trend[barIndex] = 1; - changeOfTrend = 0; - } - else if (trend[barIndex - 1] == -1) - { - // - trend[barIndex] = -1; - changeOfTrend = 0; - } - - // - // Down Trend Starting ... - if (trend[barIndex] < 0 && trend[barIndex - 1] > 0) - { - startBearishTrend = 1; - } - else - { - startBearishTrend = 0; - } - - // - // Up Trend Starting ... - if (trend[barIndex] > 0 && trend[barIndex - 1] < 0) - { - startBullishTrend = 1; - } - else - { - startBullishTrend = 0; - } - - // - if (trend[barIndex] > 0 && down[barIndex] < down[barIndex - 1]) - { - down[barIndex] = down[barIndex - 1]; - } - - // - if (trend[barIndex] < 0 && up[barIndex] > up[barIndex - 1]) - { - up[barIndex] = up[barIndex - 1]; - } - - // - if (startBearishTrend == 1) - { - up[barIndex] = price[barIndex] + (atrMultiplier * _atr); - } - - // - if (startBullishTrend == 1) - { - down[barIndex] = price[barIndex] - (atrMultiplier * _atr); - } - - // - double colorIDX = hideColorIDX; - clr[barIndex] = colorIDX; - - // - if (trend[barIndex] == 1) - { - // - main[barIndex] = down[barIndex]; - if (changeOfTrend == 1) - { - // - main[barIndex - 1] = main[barIndex - 2]; - changeOfTrend = 0; - } - - // - colorIDX = bullishColorIDX; - } - else if (trend[barIndex] == -1) - { - // - main[barIndex] = up[barIndex]; - if (changeOfTrend == 1) - { - // - main[barIndex - 1] = main[barIndex - 2]; - changeOfTrend = 0; - } - - // - colorIDX = bearishColorIDX; - } - - // - if (show) - { - clr[barIndex] = colorIDX; - } - - // -} - -// -// TEMPLATE Function ... - -template -double getPrice(ENUM_APPLIED_PRICE tprice, T &open[], T &high[], T &low[], T &close[], int i) -{ - switch (tprice) - { - case PRICE_CLOSE: - return (close[i]); - case PRICE_OPEN: - return (open[i]); - case PRICE_HIGH: - return (high[i]); - case PRICE_LOW: - return (low[i]); - case PRICE_MEDIAN: - return ((high[i] + low[i]) / 2.0); - case PRICE_TYPICAL: - return ((high[i] + low[i] + close[i]) / 3.0); - case PRICE_WEIGHTED: - return ((high[i] + low[i] + close[i] + close[i]) / 4.0); - } - return (0); -} - -// \ No newline at end of file diff --git a/Indicators/x-saherelm.xchswings.mq5 b/Indicators/x-saherelm.xchswings.mq5 deleted file mode 100644 index 15c5c4ff..00000000 --- a/Indicators/x-saherelm.xchswings.mq5 +++ /dev/null @@ -1,993 +0,0 @@ -/////////////////////////////////////////////////////// -// SaherElm IT Center MQL5 Indicator -// ------------------------------------------- -// Name: XCHSwings -// Description: XCHSwings Detector ... -// -// Maintainer: -// ------------ -// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) -// -////////////////////////////////////////////////////// -// -// Global Properties ... -#property copyright "Copyright 2023, SaherElm IT Center" -#property link "https://saherelm.ir" -#property version "1.00" -#property description "SaherElm XCHVWAP Indicator" -#property strict - -// -#define ShortName "XCHVWAP" - -// -// Includes Common Library ... -#include "../Libraries/x-saherelm.common.lib.mq5" - -// -// Inputs ... - -// -// Market ... -input group "Market"; -input int length = 12; // Length - -// -input group "Cycles"; - -// -input group "Short"; -input ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES scPeriod = NULL; // Time Period - -// -input group "Medium"; -input ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES mcPeriod = NULL; // Time Period - -// -input group "Long"; -input ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES lcPeriod = NULL; // Time Period - -// -input group "Hind"; -input ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period - -// -// Presentation ... -input group "Presentation"; -// -input bool showSwingHighs = true; // Show Swing Highs -input bool showSwingLows = true; // Show Swing Lows -// -input bool showCurrent = true; // Show Cycle Cycle -input bool showShort = true; // Show Short Cycle -input bool showMedium = true; // Show Medium Cycle -input bool showLong = true; // Show Long Cycle -input bool showHind = true; // Show Hind Cycle - -// -#property indicator_chart_window - -// -#property indicator_buffers 10 -#property indicator_plots 10 - -// -#define hideColorIDX 0 -#define bullishColorIDX 1 -#define bearishColorIDX 2 - -// -// Current ... - -// -#define cSHBufferIndex 0 -double cSHBuffer[]; - -// -#property indicator_label1 "XCHVSwings CH" -#property indicator_type1 DRAW_ARROW -#property indicator_color1 clrMagenta -#property indicator_style1 STYLE_SOLID -#property indicator_width1 2 - -// -#define cSLBufferIndex 1 -double cSLBuffer[]; - -// -#property indicator_label2 "XCHVSwings CL" -#property indicator_type2 DRAW_ARROW -#property indicator_color2 clrAqua -#property indicator_style2 STYLE_SOLID -#property indicator_width2 2 - -// -// Short ... - -// -#define sSHBufferIndex 2 -double sSHBuffer[]; - -// -#property indicator_label3 "XCHVSwings SH" -#property indicator_type3 DRAW_ARROW -#property indicator_color3 clrMagenta -#property indicator_style3 STYLE_SOLID -#property indicator_width3 2 - -// -#define sSLBufferIndex 3 -double sSLBuffer[]; - -// -#property indicator_label4 "XCHVSwings SL" -#property indicator_type4 DRAW_ARROW -#property indicator_color4 clrAqua -#property indicator_style4 STYLE_SOLID -#property indicator_width4 2 - -// -// Medium ... - -// -#define mSHBufferIndex 4 -double mSHBuffer[]; - -// -#property indicator_label5 "XCHVSwings MH" -#property indicator_type5 DRAW_ARROW -#property indicator_color5 clrMagenta -#property indicator_style5 STYLE_SOLID -#property indicator_width5 2 - -// -#define mSLBufferIndex 5 -double mSLBuffer[]; - -// -#property indicator_label6 "XCHVSwings ML" -#property indicator_type6 DRAW_ARROW -#property indicator_color6 clrAqua -#property indicator_style6 STYLE_SOLID -#property indicator_width6 2 - -// -// Long ... - -// -#define lSHBufferIndex 6 -double lSHBuffer[]; - -// -#property indicator_label7 "XCHVSwings LH" -#property indicator_type7 DRAW_ARROW -#property indicator_color7 clrMagenta -#property indicator_style7 STYLE_SOLID -#property indicator_width7 2 - -// -#define lSLBufferIndex 7 -double lSLBuffer[]; - -// -#property indicator_label8 "XCHVSwings LL" -#property indicator_type8 DRAW_ARROW -#property indicator_color8 clrAqua -#property indicator_style8 STYLE_SOLID -#property indicator_width8 2 - -// -// Hind ... - -// -#define hSHBufferIndex 8 -double hSHBuffer[]; - -// -#property indicator_label9 "XCHVSwings HH" -#property indicator_type9 DRAW_ARROW -#property indicator_color9 clrMagenta -#property indicator_style9 STYLE_SOLID -#property indicator_width9 2 - -// -#define hSLBufferIndex 9 -double hSLBuffer[]; - -// -#property indicator_label10 "XCHVSwings HL" -#property indicator_type10 DRAW_ARROW -#property indicator_color10 clrAqua -#property indicator_style10 STYLE_SOLID -#property indicator_width10 2 - -// -// Variables ... - -// -int maxLength; - -// -// Cuurent ... -int mCMarketLength = length; - -// -double cH1 = 0; -double cL1 = 0; -datetime cH1Time = 0; -datetime cL1Time = 0; - -// -// Short ... -int mSCycleLength = 0; -int mSMarketLength = 0; -ENUM_TIMEFRAMES mSCPeriod = NULL; - -// -double sH1 = 0; -double sL1 = 0; -datetime sH1Time = 0; -datetime sL1Time = 0; - -// -// Medium ... -int mMCycleLength = 0; -int mMMarketLength = 0; -ENUM_TIMEFRAMES mMCPeriod = NULL; - -// -double mH1 = 0; -double mL1 = 0; -datetime mH1Time = 0; -datetime mL1Time = 0; - -// -// Long ... -int mLCycleLength = 0; -int mLMarketLength = 0; -ENUM_TIMEFRAMES mLCPeriod = NULL; - -// -double lH1 = 0; -double lL1 = 0; -datetime lH1Time = 0; -datetime lL1Time = 0; - -// -// Hind ... -int mHCycleLength = 0; -int mHMarketLength = 0; -ENUM_TIMEFRAMES mHCPeriod = NULL; - -// -double hH1 = 0; -double hL1 = 0; -datetime hH1Time = 0; -datetime hL1Time = 0; - -// -// Event Handlers ... - -// -// Initialization ... -int OnInit() -{ - // - // Validate Inputs ... - if (!ValidateInputs()) - { - return INIT_PARAMETERS_INCORRECT; - } - - // - if (!InitMarketCycles()) - { - return INIT_PARAMETERS_INCORRECT; - } - - // - // because in some cases we may have more than one input for - // calculation and we must prevent any calculation - // untill we pass the biggest input length, here we get max Input length - // and then wait until pass it ... - maxLength = ExtractMaxLengthOfInputs(); - - // - // Define Index Buffers ... - DefineBuffers(); - - // - // Set Indicator ShortName ... - SetIndicatorName(); - - // - // Init Succeed ... - return INIT_SUCCEEDED; -} - -// -// DeInitialization ... -void OnDeinit(const int reason) -{ - // - // REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function - // REASON_REMOVE 1 Program removed from a chart - // REASON_RECOMPILE 2 Program recompiled - // REASON_CHARTCHANGE 3 A symbol or a chart period is changed - // REASON_CHARTCLOSE 4 Chart closed - // REASON_PARAMETERS 5 Inputs changed by a user - // REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings - // REASON_TEMPLATE 7 Another chart template applied - // REASON_INITFAILED 8 The OnInit() handler returned a non-zero value - // REASON_CLOSE 9 Terminal closed -} - -// -// Calculating what we want ... -int OnCalculate( - 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 ... -) -{ - // - int start; - - // - if (prev_calculated == 0) - { - start = maxLength; - } - else - { - start = prev_calculated - 1; - } - - // - for (int i = start; i < rates_total - maxLength && !IsStopped(); i++) - { - // - CalculateBuffers( - i, - prev_calculated, - rates_total, - // - time, - open, - high, - close, - low, - tick_volume // - ); - } - - // - return rates_total; -} - -// -// Functions ... - -// -// Validate Input Args for Initialization ... -bool ValidateInputs() -{ - // - bool result = false; - - // - result = - // - length >= 2 && - // - (IsValid(scMethod, scPeriod) && - IsValid(mcMethod, mcPeriod) && - IsValid(lcMethod, lcPeriod) && - IsValid(hcMethod, hcPeriod)) - // - ; - - // - return result; -} - -// -// Initialize Market Cycles ... -bool InitMarketCycles() -{ - // - bool result = false; - - // - // Current Cycle Initialization ... - - // - int cPeriodSeconds = PeriodSeconds(_Period); - - // - // Short Cycle Initialization ... - - // - // Find Cycle Period ... - if (scMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mSCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_SHORT, - _Period // - ); - } - else - { - mSCPeriod = scPeriod; - } - - // - result = IsValid(mSCPeriod); - if (!result) - { - return result; - } - - // - mSCycleLength = PeriodSeconds(mSCPeriod) / cPeriodSeconds; - mSMarketLength = mSCycleLength * mCMarketLength; - result = mSCycleLength > 0; - if (!result) - { - return result; - } - - // - // Medium Cycle Initialization ... - - // - // Find Cycle Period ... - if (mcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mMCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_MEDIUM, - _Period // - ); - } - else - { - mMCPeriod = mcPeriod; - } - - // - result = IsValid(mMCPeriod); - if (!result) - { - return result; - } - - // - mMCycleLength = PeriodSeconds(mMCPeriod) / cPeriodSeconds; - mMMarketLength = mMCycleLength * mCMarketLength; - result = mMCycleLength > 0; - if (!result) - { - return result; - } - - // - // Long Cycle Initialization ... - - // - // Find Cycle Period ... - if (lcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mLCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_LONG, - _Period // - ); - } - else - { - mLCPeriod = lcPeriod; - } - - // - result = IsValid(mLCPeriod); - if (!result) - { - return result; - } - - // - mLCycleLength = PeriodSeconds(mLCPeriod) / cPeriodSeconds; - mLMarketLength = mLCycleLength * mCMarketLength; - result = mLCycleLength > 0; - if (!result) - { - return result; - } - - // - // Hind Cycle Initialization ... - - // - // Find Cycle Period ... - if (hcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mHCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_HIND, - _Period // - ); - } - else - { - mHCPeriod = hcPeriod; - } - - // - result = IsValid(mHCPeriod); - if (!result) - { - return result; - } - - // - mHCycleLength = PeriodSeconds(mHCPeriod) / cPeriodSeconds; - mHMarketLength = mHCycleLength * mCMarketLength; - result = mHCycleLength > 0; - if (!result) - { - return result; - } - - // - return result; -} - -// -// Retrieve all Exists Input Max Length ... -// use for Start Of Drawing ... -int ExtractMaxLengthOfInputs() -{ - // - int result = 0; - - // - result = MathMax(mCMarketLength, mSMarketLength); - result = MathMax(result, mMMarketLength); - result = MathMax(result, mLMarketLength); - result = MathMax(result, mHMarketLength); - - // - return result; -} - -// -// Set Indicator Short Name and also we can define Buffers Labels ... -void SetIndicatorName() -{ - // - IndicatorSetString(INDICATOR_SHORTNAME, ShortName); - - // Setting Indicator Digits - IndicatorSetInteger(INDICATOR_DIGITS, _Digits); -} - -// -// Define Indexes and Styles ... -void DefineBuffers() -{ - // - // Current ... - - // - ENUM_DRAW_TYPE cSHDrawType = - showCurrent && showSwingHighs - ? DRAW_ARROW - : DRAW_NONE; - - // - SetIndexBuffer(cSHBufferIndex, cSHBuffer, INDICATOR_DATA); - PlotIndexSetDouble(cSHBufferIndex, PLOT_EMPTY_VALUE, 0); - PlotIndexSetInteger(cSHBufferIndex, PLOT_ARROW, 234); - PlotIndexSetInteger(cSHBufferIndex, PLOT_SHOW_DATA, showCurrent && showSwingHighs); - PlotIndexSetInteger(cSHBufferIndex, PLOT_DRAW_TYPE, cSHDrawType); - - // - ENUM_DRAW_TYPE cSLDrawType = - showCurrent && showSwingLows - ? DRAW_ARROW - : DRAW_NONE; - - // - SetIndexBuffer(cSLBufferIndex, cSLBuffer, INDICATOR_DATA); - PlotIndexSetDouble(cSLBufferIndex, PLOT_EMPTY_VALUE, 0); - PlotIndexSetInteger(cSLBufferIndex, PLOT_ARROW, 233); - PlotIndexSetInteger(cSLBufferIndex, PLOT_SHOW_DATA, showCurrent && showSwingLows); - PlotIndexSetInteger(cSLBufferIndex, PLOT_DRAW_TYPE, cSLDrawType); - - // - // Short ... - - // - ENUM_DRAW_TYPE sSHDrawType = - showShort && showSwingHighs - ? DRAW_ARROW - : DRAW_NONE; - - // - SetIndexBuffer(sSHBufferIndex, sSHBuffer, INDICATOR_DATA); - PlotIndexSetDouble(sSHBufferIndex, PLOT_EMPTY_VALUE, 0); - PlotIndexSetInteger(sSHBufferIndex, PLOT_ARROW, 234); - PlotIndexSetInteger(sSHBufferIndex, PLOT_SHOW_DATA, showShort && showSwingHighs); - PlotIndexSetInteger(sSHBufferIndex, PLOT_DRAW_TYPE, sSHDrawType); - - // - ENUM_DRAW_TYPE sSLDrawType = - showShort && showSwingLows - ? DRAW_ARROW - : DRAW_NONE; - - // - SetIndexBuffer(sSLBufferIndex, sSLBuffer, INDICATOR_DATA); - PlotIndexSetDouble(sSLBufferIndex, PLOT_EMPTY_VALUE, 0); - PlotIndexSetInteger(sSLBufferIndex, PLOT_ARROW, 233); - PlotIndexSetInteger(sSLBufferIndex, PLOT_SHOW_DATA, showShort && showSwingLows); - PlotIndexSetInteger(sSLBufferIndex, PLOT_DRAW_TYPE, sSLDrawType); - - // - // Medium ... - - // - ENUM_DRAW_TYPE mSHDrawType = - showMedium && showSwingHighs - ? DRAW_ARROW - : DRAW_NONE; - - // - SetIndexBuffer(mSHBufferIndex, mSHBuffer, INDICATOR_DATA); - PlotIndexSetDouble(mSHBufferIndex, PLOT_EMPTY_VALUE, 0); - PlotIndexSetInteger(mSHBufferIndex, PLOT_ARROW, 234); - PlotIndexSetInteger(mSHBufferIndex, PLOT_SHOW_DATA, showMedium && showSwingHighs); - PlotIndexSetInteger(mSHBufferIndex, PLOT_DRAW_TYPE, mSHDrawType); - - // - ENUM_DRAW_TYPE mSLDrawType = - showMedium && showSwingLows - ? DRAW_ARROW - : DRAW_NONE; - - // - SetIndexBuffer(mSLBufferIndex, mSLBuffer, INDICATOR_DATA); - PlotIndexSetDouble(mSLBufferIndex, PLOT_EMPTY_VALUE, 0); - PlotIndexSetInteger(mSLBufferIndex, PLOT_ARROW, 233); - PlotIndexSetInteger(mSLBufferIndex, PLOT_SHOW_DATA, showMedium && showSwingLows); - PlotIndexSetInteger(mSLBufferIndex, PLOT_DRAW_TYPE, mSLDrawType); - - // - // Long ... - - // - ENUM_DRAW_TYPE lSHDrawType = - showLong && showSwingHighs - ? DRAW_ARROW - : DRAW_NONE; - - // - SetIndexBuffer(lSHBufferIndex, lSHBuffer, INDICATOR_DATA); - PlotIndexSetDouble(lSHBufferIndex, PLOT_EMPTY_VALUE, 0); - PlotIndexSetInteger(lSHBufferIndex, PLOT_ARROW, 234); - PlotIndexSetInteger(lSHBufferIndex, PLOT_SHOW_DATA, showLong && showSwingHighs); - PlotIndexSetInteger(lSHBufferIndex, PLOT_DRAW_TYPE, lSHDrawType); - - // - ENUM_DRAW_TYPE lSLDrawType = - showLong && showSwingLows - ? DRAW_ARROW - : DRAW_NONE; - - // - SetIndexBuffer(lSLBufferIndex, lSLBuffer, INDICATOR_DATA); - PlotIndexSetDouble(lSLBufferIndex, PLOT_EMPTY_VALUE, 0); - PlotIndexSetInteger(lSLBufferIndex, PLOT_ARROW, 233); - PlotIndexSetInteger(lSLBufferIndex, PLOT_SHOW_DATA, showLong && showSwingLows); - PlotIndexSetInteger(lSLBufferIndex, PLOT_DRAW_TYPE, lSLDrawType); - - // - // Hind ... - - // - ENUM_DRAW_TYPE hSHDrawType = - showHind && showSwingHighs - ? DRAW_ARROW - : DRAW_NONE; - - // - SetIndexBuffer(hSHBufferIndex, hSHBuffer, INDICATOR_DATA); - PlotIndexSetDouble(hSHBufferIndex, PLOT_EMPTY_VALUE, 0); - PlotIndexSetInteger(hSHBufferIndex, PLOT_ARROW, 234); - PlotIndexSetInteger(hSHBufferIndex, PLOT_SHOW_DATA, showHind && showSwingHighs); - PlotIndexSetInteger(hSHBufferIndex, PLOT_DRAW_TYPE, hSHDrawType); - - // - ENUM_DRAW_TYPE hSLDrawType = - showHind && showSwingLows - ? DRAW_ARROW - : DRAW_NONE; - - // - SetIndexBuffer(hSLBufferIndex, hSLBuffer, INDICATOR_DATA); - PlotIndexSetDouble(hSLBufferIndex, PLOT_EMPTY_VALUE, 0); - PlotIndexSetInteger(hSLBufferIndex, PLOT_ARROW, 233); - PlotIndexSetInteger(hSLBufferIndex, PLOT_SHOW_DATA, showHind && showSwingLows); - PlotIndexSetInteger(hSLBufferIndex, PLOT_DRAW_TYPE, hSLDrawType); -} - -// -// Calculations ... - -// -// Calculate Buffers ... -void CalculateBuffers( - int bar_index, // Selected Bar Index - const int prevCalculated, - const int ratesTotal, - // - const datetime &time[], - const double &open[], - const double &high[], - const double &close[], - const double &low[], - const long &tickVolume[] // -) -{ - // - CalculateCycles( - // - bar_index, - prevCalculated, - ratesTotal, - // - time, - open, - high, - close, - low, - tickVolume // - ); -} - -// -void CalculateCycles( - int bar_index, // Selected Bar Index - const int prevCalculated, - const int ratesTotal, - // - const datetime &time[], - const double &open[], - const double &high[], - const double &close[], - const double &low[], - const long &tickVolume[] // -) -{ - // - // CURRENT ... - CalculateCycle( - bar_index, - prevCalculated, - ratesTotal, - // - time, - open, - high, - close, - low, - tickVolume, - // - mCMarketLength, - showCurrent, - cSHBuffer, - cSLBuffer, - cH1, - cH1Time, - cL1, - cL1Time // - ); - - // - // SHORT ... - CalculateCycle( - bar_index, - prevCalculated, - ratesTotal, - // - time, - open, - high, - close, - low, - tickVolume, - // - mSMarketLength, - showShort, - sSHBuffer, - sSLBuffer, - sH1, - sH1Time, - sL1, - sL1Time // - ); - - // - // MEDIUM ... - CalculateCycle( - bar_index, - prevCalculated, - ratesTotal, - // - time, - open, - high, - close, - low, - tickVolume, - // - mMMarketLength, - showMedium, - mSHBuffer, - mSLBuffer, - mH1, - mH1Time, - mL1, - mL1Time // - ); - - // - // LONG ... - CalculateCycle( - bar_index, - prevCalculated, - ratesTotal, - // - time, - open, - high, - close, - low, - tickVolume, - // - mLMarketLength, - showLong, - lSHBuffer, - lSLBuffer, - lH1, - lH1Time, - lL1, - lL1Time // - ); - - // - // HIND ... - CalculateCycle( - bar_index, - prevCalculated, - ratesTotal, - // - time, - open, - high, - close, - low, - tickVolume, - // - mHMarketLength, - showHind, - hSHBuffer, - hSLBuffer, - hH1, - hH1Time, - hL1, - hL1Time // - ); -} - -// -void CalculateCycle( - // - int bar_index, // Selected Bar Index - const int prevCalculated, - const int ratesTotal, - // - const datetime &time[], - const double &open[], - const double &high[], - const double &close[], - const double &low[], - const long &tickVolume[], - // - int _length, // Calculation Length - bool _show, - double &_hBuffer[], - double &_lBuffer[], - double &_h1, - datetime &_h1Time, - double &_l1, - datetime &_l1Time // -) -{ - // - bool isSwingHigh = true; - bool isSwingLow = true; - - // - _hBuffer[bar_index] = 0; - _lBuffer[bar_index] = 0; - - // - // Check for Swing High - for (int j = 1; j <= _length; j++) - { - // - if (high[bar_index] <= high[bar_index + j] || high[bar_index] <= high[bar_index - j]) - { - // - isSwingHigh = false; - break; - } - } - - // - // Check for Swing Low - for (int j = 1; j <= _length; j++) - { - // - if (low[bar_index] >= low[bar_index + j] || low[bar_index] >= low[bar_index - j]) - { - // - isSwingLow = false; - break; - } - } - - // - if (isSwingHigh) - { - // - _hBuffer[bar_index] = high[bar_index]; - if (high[bar_index] > _h1 || _h1 == 0) - { - // - _h1 = high[bar_index]; - _h1Time = time[bar_index]; - } - } - - // - if (isSwingLow) - { - // - _lBuffer[bar_index] = low[bar_index]; - if (low[bar_index] < _l1 || _l1 == 0) - { - // - _l1 = low[bar_index]; - _l1Time = time[bar_index]; - } - } -} \ No newline at end of file diff --git a/Indicators/x-saherelm.xchtd.mq5 b/Indicators/x-saherelm.xchtd.mq5 deleted file mode 100644 index 86ec2b54..00000000 --- a/Indicators/x-saherelm.xchtd.mq5 +++ /dev/null @@ -1,900 +0,0 @@ -/////////////////////////////////////////////////////// -// SaherElm IT Center MQL5 Indicator -// ------------------------------------------- -// Name: XCHTD -// Description: XCHTD Cycles ... -// -// Maintainer: -// ------------ -// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) -// -////////////////////////////////////////////////////// -// -// Global Properties ... -#property copyright "Copyright 2023, SaherElm IT Center" -#property link "https://saherelm.ir" -#property version "1.00" -#property description "SaherElm XCHTD Indicator" -#property strict - -// -#define ShortName "XCHTD" - -// -// Includes Common Library ... -#include "../Libraries/x-saherelm.common.lib.mq5" - -// -enum ENUM_XCHTD_MODE -{ - XCHTD_POWER_MODE = 0, // Using Power - XCHTD_PRESSURE_MODE = 1, // Using Pressure - XCHTD_TYPE_MODE = 2, // Using Type - XCHTD_STRONG_MODE = 3, // Using Power and Pressures -}; - -// -// Inputs ... - -// -input group "Market"; -input int length = 14; // Length -input ENUM_XCHTD_MODE mode = XCHTD_POWER_MODE; // Mode - -// -input group "Cycles"; - -// -input group "Short"; -input ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES scPeriod = NULL; // Time Period - -// -input group "Medium"; -input ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES mcPeriod = NULL; // Time Period - -// -input group "Long"; -input ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES lcPeriod = NULL; // Time Period - -// -input group "Hind"; -input ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period - -// -// Presentation ... -input group "Presentation"; - -// -// Current ... -input bool showCurrent = true; // Show Current Cycle -input bool showShort = true; // Show Short Cycle -input bool showMedium = true; // Show Medium Cycle -input bool showLong = true; // Show Long Cycle -input bool showHind = true; // Show Hind Cycle - -// -// Buffers ... - -// -#property indicator_chart_window - -// -#property indicator_buffers 10 -#property indicator_plots 0 - -// -// Current ... - -// -#define cBullBufferIndex 0 -double cBullBuffer[]; - -// -#property indicator_label1 "XCHTD C Bull" -#property indicator_type1 DRAW_LINE -#property indicator_color1 clrLime -#property indicator_style1 STYLE_SOLID - -// -#define cBearBufferIndex 1 -double cBearBuffer[]; - -// -#property indicator_label2 "XCHTD C Bear" -#property indicator_type2 DRAW_LINE -#property indicator_style2 STYLE_SOLID -#property indicator_color2 clrRed - -// -// Short ... - -// -#define sBullBufferIndex 2 -double sBullBuffer[]; - -// -#property indicator_label3 "XCHTD S Bull" -#property indicator_type3 DRAW_LINE -#property indicator_color3 clrLime -#property indicator_style3 STYLE_SOLID - -// -#define sBearBufferIndex 3 -double sBearBuffer[]; - -// -#property indicator_label4 "XCHTD S Bear" -#property indicator_type4 DRAW_LINE -#property indicator_style4 STYLE_SOLID -#property indicator_color4 clrRed - -// -// Medium ... - -// -#define mBullBufferIndex 4 -double mBullBuffer[]; - -// -#property indicator_label5 "XCHTD M Bull" -#property indicator_type5 DRAW_LINE -#property indicator_color5 clrLime -#property indicator_style5 STYLE_SOLID - -// -#define mBearBufferIndex 5 -double mBearBuffer[]; - -// -#property indicator_label6 "XCHTD M Bear" -#property indicator_type6 DRAW_LINE -#property indicator_style6 STYLE_SOLID -#property indicator_color6 clrRed - -// -// Long ... - -// -#define lBullBufferIndex 6 -double lBullBuffer[]; - -// -#property indicator_label7 "XCHTD L Bull" -#property indicator_type7 DRAW_LINE -#property indicator_color7 clrLime -#property indicator_style7 STYLE_SOLID - -// -#define lBearBufferIndex 7 -double lBearBuffer[]; - -// -#property indicator_label8 "XCHTD L Bear" -#property indicator_type8 DRAW_LINE -#property indicator_style8 STYLE_SOLID -#property indicator_color8 clrRed - -// -// Hind ... - -// -#define hBullBufferIndex 8 -double hBullBuffer[]; - -// -#property indicator_label9 "XCHTD H Bull" -#property indicator_type9 DRAW_LINE -#property indicator_color9 clrLime -#property indicator_style9 STYLE_SOLID - -// -#define hBearBufferIndex 9 -double hBearBuffer[]; - -// -#property indicator_label10 "XCHTD H Bear" -#property indicator_type10 DRAW_LINE -#property indicator_style10 STYLE_SOLID -#property indicator_color10 clrRed - -// -// Variables, Properties and etc ... - -// -int maxLength; - -// -// Current ... -int mCMarketLength = length; - -// -// Short ... -int mSCycleLength = 0; -int mSMarketLength = 0; -ENUM_TIMEFRAMES mSCPeriod = NULL; - -// -// Medium ... -int mMCycleLength = 0; -int mMMarketLength = 0; -ENUM_TIMEFRAMES mMCPeriod = NULL; - -// -// Long ... -int mLCycleLength = 0; -int mLMarketLength = 0; -ENUM_TIMEFRAMES mLCPeriod = NULL; - -// -// Hind ... -int mHCycleLength = 0; -int mHMarketLength = 0; -ENUM_TIMEFRAMES mHCPeriod = NULL; - -// -// Event Handlers ... - -// -// Initialization ... -int OnInit() -{ - // - // Validate Inputs ... - if (!ValidateInputs()) - { - return INIT_PARAMETERS_INCORRECT; - } - - // - if (!InitMarketCycles()) - { - return INIT_PARAMETERS_INCORRECT; - } - - // - // because in some cases we may have more than one input for - // calculation and we must prevent any calculation - // untill we pass the biggest input length, here we get max Input length - // and then wait until pass it ... - maxLength = ExtractMaxLengthOfInputs(); - - // - // Define Index Buffers ... - DefineBuffers(); - - // - // Set Indicator ShortName ... - SetIndicatorName(); - - // - // Init Succeed ... - return INIT_SUCCEEDED; -} - -// -// DeInitialization ... -void OnDeinit(const int reason) -{ - // - // REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function - // REASON_REMOVE 1 Program removed from a chart - // REASON_RECOMPILE 2 Program recompiled - // REASON_CHARTCHANGE 3 A symbol or a chart period is changed - // REASON_CHARTCLOSE 4 Chart closed - // REASON_PARAMETERS 5 Inputs changed by a user - // REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings - // REASON_TEMPLATE 7 Another chart template applied - // REASON_INITFAILED 8 The OnInit() handler returned a non-zero value - // REASON_CLOSE 9 Terminal closed -} - -// -// Calculating what we want ... -int OnCalculate( - const int rates_total, // Total Bars on Chart ... - const int prev_calculated, // Total Calculated Bars on Charts ... - const datetime &time[], // History of Open Time ... - const double &open[], // History of Open Price ... - const double &high[], // History of High Price ... - const double &low[], // History of Low Price ... - const double &close[], // History of Close Price ... - const long &tick_volume[], // History of Tick Volumes on Bar ... - const long &volume[], // History of Trade Volumes ... - const int &spread[] // History of Spread Price ... -) -{ - // - // Prepare Buffers ... - ArraySetAsSeries(time, true); - ArraySetAsSeries(open, true); - ArraySetAsSeries(high, true); - ArraySetAsSeries(low, true); - ArraySetAsSeries(close, true); - ArraySetAsSeries(tick_volume, true); - ArraySetAsSeries(volume, true); - ArraySetAsSeries(spread, true); - - // - // this counts Available Bars ... - int limit; - - // - // because in some cases we may have more than one input for - // calculation and we must prevent any calculation - // untill we pass the biggest input length, here we get max Input length - // and then wait until pass it ... - - // - limit = prev_calculated < maxLength ? rates_total - (maxLength + 1) : rates_total - prev_calculated; - - // - // Main Loop ... - for (int i = limit; i >= 0 && !IsStopped(); i--) - { - // - CalculateBuffers( - i, - prev_calculated, - rates_total, - open, - high, - close, - low, - tick_volume // - ); - } - - // - return rates_total; -} - -// -// Functions ... - -// -// Validate Input Args for Initialization ... -bool ValidateInputs() -{ - // - bool result = false; - - // - result = - // - length >= 2 && - // - (IsValid(scMethod, scPeriod) && - IsValid(mcMethod, mcPeriod) && - IsValid(lcMethod, lcPeriod) && - IsValid(hcMethod, hcPeriod)) - // - ; - - // - return result; -} - -// -// Initialize Market Cycles ... -bool InitMarketCycles() -{ - // - bool result = false; - - // - // Current Cycle Initialization ... - - // - int cPeriodSeconds = PeriodSeconds(_Period); - - // - // Short Cycle Initialization ... - - // - // Find Cycle Period ... - if (scMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mSCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_SHORT, - _Period // - ); - } - else - { - mSCPeriod = scPeriod; - } - - // - result = IsValid(mSCPeriod); - if (!result) - { - return result; - } - - // - mSCycleLength = PeriodSeconds(mSCPeriod) / cPeriodSeconds; - mSMarketLength = mSCycleLength * mCMarketLength; - result = mSCycleLength > 0; - if (!result) - { - return result; - } - - // - // Medium Cycle Initialization ... - - // - // Find Cycle Period ... - if (mcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mMCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_MEDIUM, - _Period // - ); - } - else - { - mMCPeriod = mcPeriod; - } - - // - result = IsValid(mMCPeriod); - if (!result) - { - return result; - } - - // - mMCycleLength = PeriodSeconds(mMCPeriod) / cPeriodSeconds; - mMMarketLength = mMCycleLength * mCMarketLength; - result = mMCycleLength > 0; - if (!result) - { - return result; - } - - // - // Long Cycle Initialization ... - - // - // Find Cycle Period ... - if (lcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mLCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_LONG, - _Period // - ); - } - else - { - mLCPeriod = lcPeriod; - } - - // - result = IsValid(mLCPeriod); - if (!result) - { - return result; - } - - // - mLCycleLength = PeriodSeconds(mLCPeriod) / cPeriodSeconds; - mLMarketLength = mLCycleLength * mCMarketLength; - result = mLCycleLength > 0; - if (!result) - { - return result; - } - - // - // Hind Cycle Initialization ... - - // - // Find Cycle Period ... - if (hcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mHCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_HIND, - _Period // - ); - } - else - { - mHCPeriod = hcPeriod; - } - - // - result = IsValid(mHCPeriod); - if (!result) - { - return result; - } - - // - mHCycleLength = PeriodSeconds(mHCPeriod) / cPeriodSeconds; - mHMarketLength = mHCycleLength * mCMarketLength; - result = mHCycleLength > 0; - if (!result) - { - return result; - } - - // - return result; -} - -// -// Retrieve all Exists Input Max Length ... -// use for Start Of Drawing ... -int ExtractMaxLengthOfInputs() -{ - // - int result = 0; - - // - result = MathMax(mCMarketLength, mSMarketLength); - result = MathMax(result, mMMarketLength); - result = MathMax(result, mLMarketLength); - result = MathMax(result, mHMarketLength); - - // - return result; -} - -// -// Define Indexes and Styles ... -void DefineBuffers() -{ - // - // Current ... - - // - // ENUM_DRAW_TYPE cDrawType = showCurrent ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(cBullBuffer, true); - SetIndexBuffer(cBullBufferIndex, cBullBuffer, INDICATOR_CALCULATIONS); - // PlotIndexSetInteger(cBullBufferIndex, PLOT_DRAW_TYPE, cDrawType); - // PlotIndexSetInteger(cBullBufferIndex, PLOT_SHOW_DATA, showCurrent); - - // - ArraySetAsSeries(cBearBuffer, true); - SetIndexBuffer(cBearBufferIndex, cBearBuffer, INDICATOR_CALCULATIONS); - // PlotIndexSetInteger(cBearBufferIndex, PLOT_DRAW_TYPE, cDrawType); - // PlotIndexSetInteger(cBearBufferIndex, PLOT_SHOW_DATA, showCurrent); - - // - // Short ... - - // - // ENUM_DRAW_TYPE sDrawType = showShort ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(sBullBuffer, true); - SetIndexBuffer(sBullBufferIndex, sBullBuffer, INDICATOR_CALCULATIONS); - // PlotIndexSetInteger(sBullBufferIndex, PLOT_DRAW_TYPE, sDrawType); - // PlotIndexSetInteger(sBullBufferIndex, PLOT_SHOW_DATA, showShort); - - // - ArraySetAsSeries(sBearBuffer, true); - SetIndexBuffer(sBearBufferIndex, sBearBuffer, INDICATOR_CALCULATIONS); - // PlotIndexSetInteger(sBearBufferIndex, PLOT_DRAW_TYPE, sDrawType); - // PlotIndexSetInteger(sBearBufferIndex, PLOT_SHOW_DATA, showShort); - - // - // Medium ... - - // - // ENUM_DRAW_TYPE mDrawType = showMedium ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(mBullBuffer, true); - SetIndexBuffer(mBullBufferIndex, mBullBuffer, INDICATOR_CALCULATIONS); - // PlotIndexSetInteger(mBullBufferIndex, PLOT_DRAW_TYPE, mDrawType); - // PlotIndexSetInteger(mBullBufferIndex, PLOT_SHOW_DATA, showMedium); - - // - ArraySetAsSeries(mBearBuffer, true); - SetIndexBuffer(mBearBufferIndex, mBearBuffer, INDICATOR_CALCULATIONS); - // PlotIndexSetInteger(mBearBufferIndex, PLOT_DRAW_TYPE, mDrawType); - // PlotIndexSetInteger(mBearBufferIndex, PLOT_SHOW_DATA, showMedium); - - // - // Long ... - - // - // ENUM_DRAW_TYPE lDrawType = showLong ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(lBullBuffer, true); - SetIndexBuffer(lBullBufferIndex, lBullBuffer, INDICATOR_CALCULATIONS); - // PlotIndexSetInteger(lBullBufferIndex, PLOT_DRAW_TYPE, lDrawType); - // PlotIndexSetInteger(lBullBufferIndex, PLOT_SHOW_DATA, showLong); - - // - ArraySetAsSeries(lBearBuffer, true); - SetIndexBuffer(lBearBufferIndex, lBearBuffer, INDICATOR_CALCULATIONS); - // PlotIndexSetInteger(lBearBufferIndex, PLOT_DRAW_TYPE, lDrawType); - // PlotIndexSetInteger(lBearBufferIndex, PLOT_SHOW_DATA, showLong); - - // - // Hind ... - - // - // ENUM_DRAW_TYPE hDrawType = showHind ? DRAW_LINE : DRAW_NONE; - - // - ArraySetAsSeries(hBullBuffer, true); - SetIndexBuffer(hBullBufferIndex, hBullBuffer, INDICATOR_CALCULATIONS); - // PlotIndexSetInteger(hBullBufferIndex, PLOT_DRAW_TYPE, hDrawType); - // PlotIndexSetInteger(hBullBufferIndex, PLOT_SHOW_DATA, showHind); - - // - ArraySetAsSeries(hBearBuffer, true); - SetIndexBuffer(hBearBufferIndex, hBearBuffer, INDICATOR_CALCULATIONS); - // PlotIndexSetInteger(hBearBufferIndex, PLOT_DRAW_TYPE, hDrawType); - // PlotIndexSetInteger(hBearBufferIndex, PLOT_SHOW_DATA, showHind); -} - -// -// Set Indicator Short Name and also we can define Buffers Labels ... -void SetIndicatorName() -{ - IndicatorSetString(INDICATOR_SHORTNAME, ShortName); -} - -// -// Calculations ... - -// -// Calculate Buffers ... -void CalculateBuffers( - int bar_index, // Selected Bar Index - const int prevCalculated, - const int ratesTotal, - const double &open[], - const double &high[], - const double &close[], - const double &low[], - const long &tickVolume[] // -) -{ - // - CalculateCycles( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - tickVolume // - ); -} - -// -void CalculateCycles( - int bar_index, // Selected Bar Index - const int prevCalculated, - const int ratesTotal, - const double &open[], - const double &high[], - const double &close[], - const double &low[], - const long &tickVolume[] // -) -{ - // - // CURRENT ... - CalculateCycle( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - tickVolume, - // - mCMarketLength, - showCurrent, - cBullBuffer, - cBearBuffer // - ); - - // - // SHORT ... - CalculateCycle( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - tickVolume, - // - mSMarketLength, - showShort, - sBullBuffer, - sBearBuffer // - ); - - // - // MEDIUM ... - CalculateCycle( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - tickVolume, - // - mMMarketLength, - showMedium, - mBullBuffer, - mBearBuffer // - ); - - // - // LONG ... - CalculateCycle( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - tickVolume, - // - mLMarketLength, - showLong, - lBullBuffer, - lBearBuffer // - ); - - // - // HIND ... - CalculateCycle( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - tickVolume, - // - mHMarketLength, - showHind, - hBullBuffer, - hBearBuffer // - ); -} - -// -void CalculateCycle( - int bar_index, // Selected Bar Index - const int prevCalculated, - const int ratesTotal, - const double &open[], - const double &high[], - const double &close[], - const double &low[], - const long &tickVolume[], - // - int _length, // Calculation Length - bool _show, - double &_bull[], - double &_bear[] // -) -{ - // - double bullPower = 0; - double bearPower = 0; - - // - double lowShadow = 0; - double highShadow = 0; - - // - double bullPressure = 0; - double bearPressure = 0; - - // - double bullRange = 0; - double bearRange = 0; - - // - for (int i = bar_index; i < bar_index + _length; i++) - { - // - bool isBullish = - // - close[i] > open[i] - // - ; - - // - bool isBearish = - // - close[i] < open[i] - // - ; - - // - double iUpper = MathMax(open[i], close[i]); - double iLower = MathMin(open[i], close[i]); - - // - double iBody = iUpper - iLower; - double iRange = high[i] - low[i]; - - // - double iHighShadow = high[i] - iUpper; - double iLowShadow = iLower - low[i]; - - // - if (isBullish) - { - // - bullPower += iBody; - bullRange += iRange; - bearPressure += iHighShadow; - } - else if (isBearish) - { - // - bearPower += iBody; - bearRange += iRange; - bullPressure += iLowShadow; - } - - // - lowShadow += iLowShadow; - highShadow += iHighShadow; - } - - // - if (mode == XCHTD_POWER_MODE) - { - // - _bull[bar_index] = bullPower; - _bear[bar_index] = bearPower; - } - else if (mode == XCHTD_PRESSURE_MODE) - { - // - _bull[bar_index] = bullPressure; - _bear[bar_index] = bearPressure; - } - else if (mode == XCHTD_TYPE_MODE) - { - // - _bull[bar_index] = bullRange; - _bear[bar_index] = bearRange; - } - else if (mode == XCHTD_STRONG_MODE) - { - // - _bull[bar_index] = bullPower + bullPressure; - _bear[bar_index] = bearPower + bearPressure; - } -} - -// \ No newline at end of file diff --git a/Indicators/x-saherelm.xchvlm.mq5 b/Indicators/x-saherelm.xchvlm.mq5 deleted file mode 100644 index dd1105e9..00000000 --- a/Indicators/x-saherelm.xchvlm.mq5 +++ /dev/null @@ -1,814 +0,0 @@ -/////////////////////////////////////////////////////// -// SaherElm IT Center MQL5 Indicator -// ------------------------------------------- -// Name: XCHVLM -// Description: XCHVLM Cycles ... -// -// Maintainer: -// ------------ -// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) -// -////////////////////////////////////////////////////// -// -// Global Properties ... -#property copyright "Copyright 2023, SaherElm IT Center" -#property link "https://saherelm.ir" -#property version "1.00" -#property description "SaherElm XCHVLM Indicator" -#property strict - -// -#define ShortName "XCHVLM" - -// -// Includes Common Library ... -#include -#include "../Libraries/x-saherelm.common.lib.mq5" - -// -// Inputs ... - -// -input group "Market"; -input int length = 14; // Length - -// -input group "Cycles"; - -// -input group "Short"; -input ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES scPeriod = NULL; // Time Period - -// -input group "Medium"; -input ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES mcPeriod = NULL; // Time Period - -// -input group "Long"; -input ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES lcPeriod = NULL; // Time Period - -// -input group "Hind"; -input ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period - -// -// Presentation ... -input group "Presentation"; - -// -input bool showCurrent = true; // Show Current Cycle -input bool showShort = true; // Show Short Cycle -input bool showMedium = true; // Show Medium Cycle -input bool showLong = true; // Show Long Cycle -input bool showHind = true; // Show Hind Cycle - -// -// Buffers ... - -// -#define hideColorIDX 0 -#define bullishColorIDX 1 -#define bearishColorIDX 2 - -// -#property indicator_chart_window - -// -#property indicator_buffers 10 -#property indicator_plots 0 - -// -// Current ... - -// -#define cBufferIndex 0 -double cBuffer[]; - -// -#define cColorBufferIndex 1 -double cColorBuffer[]; - -// -#define cPlotBufferIndex 0 -#property indicator_label1 "XCHVLM C" -#property indicator_style1 STYLE_SOLID -#property indicator_type1 DRAW_COLOR_HISTOGRAM -#property indicator_color1 CLR_NONE, clrLime, clrRed - -// -// Short ... - -// -#define sBufferIndex 2 -double sBuffer[]; - -// -#define sColorBufferIndex 3 -double sColorBuffer[]; - -// -#define sPlotBufferIndex 1 -#property indicator_label2 "XCHVLM S" -#property indicator_style2 STYLE_SOLID -#property indicator_type2 DRAW_COLOR_HISTOGRAM -#property indicator_color2 CLR_NONE, clrLime, clrRed - -// -// Medium ... - -// -#define mBufferIndex 4 -double mBuffer[]; - -// -#define mColorBufferIndex 5 -double mColorBuffer[]; - -// -#define mPlotBufferIndex 2 -#property indicator_label3 "XCHVLM M" -#property indicator_style3 STYLE_SOLID -#property indicator_type3 DRAW_COLOR_HISTOGRAM -#property indicator_color3 CLR_NONE, clrLime, clrRed - -// -// Long ... - -// -#define lBufferIndex 6 -double lBuffer[]; - -// -#define lColorBufferIndex 7 -double lColorBuffer[]; - -// -#define lPlotBufferIndex 3 -#property indicator_label4 "XCHVLM L" -#property indicator_style4 STYLE_SOLID -#property indicator_type4 DRAW_COLOR_HISTOGRAM -#property indicator_color4 CLR_NONE, clrLime, clrRed - -// -// Hind ... - -// -#define hBufferIndex 8 -double hBuffer[]; - -// -#define hColorBufferIndex 9 -double hColorBuffer[]; - -// -#define hPlotBufferIndex 4 -#property indicator_label5 "XCHVLM H" -#property indicator_style5 STYLE_SOLID -#property indicator_type5 DRAW_COLOR_HISTOGRAM -#property indicator_color5 CLR_NONE, clrLime, clrRed - -// -// Variables, Properties and etc ... - -// -int maxLength; - -// -// Current ... -int mCMarketLength = length; -double cVolumes[]; -double cDistances[]; - -// -// Short ... -int mSCycleLength = 0; -int mSMarketLength = 0; -ENUM_TIMEFRAMES mSCPeriod = NULL; -double sVolumes[]; -double sDistances[]; - -// -// Medium ... -int mMCycleLength = 0; -int mMMarketLength = 0; -ENUM_TIMEFRAMES mMCPeriod = NULL; -double mVolumes[]; -double mDistances[]; - -// -// Long ... -int mLCycleLength = 0; -int mLMarketLength = 0; -ENUM_TIMEFRAMES mLCPeriod = NULL; -double lVolumes[]; -double lDistances[]; - -// -// Hind ... -int mHCycleLength = 0; -int mHMarketLength = 0; -ENUM_TIMEFRAMES mHCPeriod = NULL; -double hVolumes[]; -double hDistances[]; - -// -// Event Handlers ... - -// -// Initialization ... -int OnInit() -{ - // - // Validate Inputs ... - if (!ValidateInputs()) - { - return INIT_PARAMETERS_INCORRECT; - } - - // - if (!InitMarketCycles()) - { - return INIT_PARAMETERS_INCORRECT; - } - - // - // because in some cases we may have more than one input for - // calculation and we must prevent any calculation - // untill we pass the biggest input length, here we get max Input length - // and then wait until pass it ... - maxLength = ExtractMaxLengthOfInputs(); - - // - // Current ... - ArrayResize(cVolumes, maxLength, 0); - ArrayResize(cDistances, maxLength, 0); - - // - // Short ... - ArrayResize(sVolumes, maxLength, 0); - ArrayResize(sDistances, maxLength, 0); - - // - // Medium ... - ArrayResize(mVolumes, maxLength, 0); - ArrayResize(mDistances, maxLength, 0); - - // - // Long ... - ArrayResize(lVolumes, maxLength, 0); - ArrayResize(lDistances, maxLength, 0); - - // - // Hind ... - ArrayResize(hVolumes, maxLength, 0); - ArrayResize(hDistances, maxLength, 0); - - // - // Define Index Buffers ... - DefineBuffers(); - - // - // Set Indicator ShortName ... - SetIndicatorName(); - - // - // Init Succeed ... - return INIT_SUCCEEDED; -} - -// -// DeInitialization ... -void OnDeinit(const int reason) -{ - // - // REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function - // REASON_REMOVE 1 Program removed from a chart - // REASON_RECOMPILE 2 Program recompiled - // REASON_CHARTCHANGE 3 A symbol or a chart period is changed - // REASON_CHARTCLOSE 4 Chart closed - // REASON_PARAMETERS 5 Inputs changed by a user - // REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings - // REASON_TEMPLATE 7 Another chart template applied - // REASON_INITFAILED 8 The OnInit() handler returned a non-zero value - // REASON_CLOSE 9 Terminal closed - - // - Clean(cVolumes); - Clean(cDistances); - - // - Clean(sVolumes); - Clean(sDistances); - - // - Clean(mVolumes); - Clean(mDistances); - - // - Clean(lVolumes); - Clean(lDistances); - - // - Clean(hVolumes); - Clean(hDistances); -} - -// -// Calculating what we want ... -int OnCalculate( - 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 ... -) -{ - // - static int i = maxLength * 2; - for (i; i < rates_total; i++) - { - // - CalculateBuffers( - i, - prev_calculated, - rates_total, - // - open, - high, - close, - low, - tick_volume // - ); - } - - // - i = rates_total - 1; - - // - return rates_total; -} - -// -// Functions ... - -// -// Validate Input Args for Initialization ... -bool ValidateInputs() -{ - // - bool result = false; - - // - result = - // - length >= 2 && - // - (IsValid(scMethod, scPeriod) && - IsValid(mcMethod, mcPeriod) && - IsValid(lcMethod, lcPeriod) && - IsValid(hcMethod, hcPeriod)) - // - ; - - // - return result; -} - -// -// Initialize Market Cycles ... -bool InitMarketCycles() -{ - // - bool result = false; - - // - // Current Cycle Initialization ... - - // - int cPeriodSeconds = PeriodSeconds(_Period); - - // - // Short Cycle Initialization ... - - // - // Find Cycle Period ... - if (scMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mSCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_SHORT, - _Period // - ); - } - else - { - mSCPeriod = scPeriod; - } - - // - result = IsValid(mSCPeriod); - if (!result) - { - return result; - } - - // - mSCycleLength = PeriodSeconds(mSCPeriod) / cPeriodSeconds; - mSMarketLength = mSCycleLength * mCMarketLength; - result = mSCycleLength > 0; - if (!result) - { - return result; - } - - // - // Medium Cycle Initialization ... - - // - // Find Cycle Period ... - if (mcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mMCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_MEDIUM, - _Period // - ); - } - else - { - mMCPeriod = mcPeriod; - } - - // - result = IsValid(mMCPeriod); - if (!result) - { - return result; - } - - // - mMCycleLength = PeriodSeconds(mMCPeriod) / cPeriodSeconds; - mMMarketLength = mMCycleLength * mCMarketLength; - result = mMCycleLength > 0; - if (!result) - { - return result; - } - - // - // Long Cycle Initialization ... - - // - // Find Cycle Period ... - if (lcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mLCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_LONG, - _Period // - ); - } - else - { - mLCPeriod = lcPeriod; - } - - // - result = IsValid(mLCPeriod); - if (!result) - { - return result; - } - - // - mLCycleLength = PeriodSeconds(mLCPeriod) / cPeriodSeconds; - mLMarketLength = mLCycleLength * mCMarketLength; - result = mLCycleLength > 0; - if (!result) - { - return result; - } - - // - // Hind Cycle Initialization ... - - // - // Find Cycle Period ... - if (hcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mHCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_HIND, - _Period // - ); - } - else - { - mHCPeriod = hcPeriod; - } - - // - result = IsValid(mHCPeriod); - if (!result) - { - return result; - } - - // - mHCycleLength = PeriodSeconds(mHCPeriod) / cPeriodSeconds; - mHMarketLength = mHCycleLength * mCMarketLength; - result = mHCycleLength > 0; - if (!result) - { - return result; - } - - // - return result; -} - -// -// Retrieve all Exists Input Max Length ... -// use for Start Of Drawing ... -int ExtractMaxLengthOfInputs() -{ - // - int result = 0; - - // - result = MathMax(mCMarketLength, mSMarketLength); - result = MathMax(result, mMMarketLength); - result = MathMax(result, mLMarketLength); - result = MathMax(result, mHMarketLength); - - // - return result; -} - -// -// Define Indexes and Styles ... -void DefineBuffers() -{ - // - // Current ... - - // - // ENUM_DRAW_TYPE cDrawType = showCurrent ? DRAW_COLOR_HISTOGRAM : DRAW_NONE; - // PlotIndexSetInteger(cPlotBufferIndex, PLOT_DRAW_TYPE, cDrawType); - // PlotIndexSetInteger(cPlotBufferIndex, PLOT_SHOW_DATA, showCurrent); - // SetIndexBuffer(cColorBufferIndex, cColorBuffer, INDICATOR_COLOR_INDEX); - SetIndexBuffer(cBufferIndex, cBuffer, INDICATOR_CALCULATIONS); - SetIndexBuffer(cColorBufferIndex, cColorBuffer, INDICATOR_CALCULATIONS); - - // - // Short ... - - // - // ENUM_DRAW_TYPE sDrawType = showShort ? DRAW_COLOR_HISTOGRAM : DRAW_NONE; - // PlotIndexSetInteger(sPlotBufferIndex, PLOT_DRAW_TYPE, sDrawType); - // PlotIndexSetInteger(sPlotBufferIndex, PLOT_SHOW_DATA, showShort); - // SetIndexBuffer(sColorBufferIndex, sColorBuffer, INDICATOR_COLOR_INDEX); - SetIndexBuffer(sBufferIndex, sBuffer, INDICATOR_CALCULATIONS); - SetIndexBuffer(sColorBufferIndex, sColorBuffer, INDICATOR_CALCULATIONS); - - // - // Medium ... - - // - // ENUM_DRAW_TYPE mDrawType = showMedium ? DRAW_COLOR_HISTOGRAM : DRAW_NONE; - // PlotIndexSetInteger(mPlotBufferIndex, PLOT_DRAW_TYPE, mDrawType); - // PlotIndexSetInteger(mPlotBufferIndex, PLOT_SHOW_DATA, showMedium); - // SetIndexBuffer(mColorBufferIndex, mColorBuffer, INDICATOR_COLOR_INDEX); - SetIndexBuffer(mBufferIndex, mBuffer, INDICATOR_CALCULATIONS); - SetIndexBuffer(mColorBufferIndex, mColorBuffer, INDICATOR_CALCULATIONS); - - // - // Long ... - - // - // ENUM_DRAW_TYPE lDrawType = showLong ? DRAW_COLOR_HISTOGRAM : DRAW_NONE; - // PlotIndexSetInteger(lPlotBufferIndex, PLOT_DRAW_TYPE, lDrawType); - // PlotIndexSetInteger(lPlotBufferIndex, PLOT_SHOW_DATA, showLong); - // SetIndexBuffer(lColorBufferIndex, lColorBuffer, INDICATOR_COLOR_INDEX); - SetIndexBuffer(lBufferIndex, lBuffer, INDICATOR_CALCULATIONS); - SetIndexBuffer(lColorBufferIndex, lColorBuffer, INDICATOR_CALCULATIONS); - - // - // Hind ... - - // - // ENUM_DRAW_TYPE hDrawType = showHind ? DRAW_COLOR_HISTOGRAM : DRAW_NONE; - // PlotIndexSetInteger(hPlotBufferIndex, PLOT_DRAW_TYPE, hDrawType); - // PlotIndexSetInteger(hPlotBufferIndex, PLOT_SHOW_DATA, showHind); - // SetIndexBuffer(hColorBufferIndex, hColorBuffer, INDICATOR_COLOR_INDEX); - SetIndexBuffer(hBufferIndex, hBuffer, INDICATOR_CALCULATIONS); - SetIndexBuffer(hColorBufferIndex, hColorBuffer, INDICATOR_CALCULATIONS); -} - -// -// Set Indicator Short Name and also we can define Buffers Labels ... -void SetIndicatorName() -{ - IndicatorSetString(INDICATOR_SHORTNAME, ShortName); -} - -// -// Calculations ... - -// -// Calculate Buffers ... -void CalculateBuffers( - int bar_index, // Selected Bar Index - const int prevCalculated, - const int ratesTotal, - const double &open[], - const double &high[], - const double &close[], - const double &low[], - const long &tickVolume[] // -) -{ - // - CalculateCycles( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - tickVolume // - ); -} - -// -void CalculateCycles( - int bar_index, // Selected Bar Index - const int prevCalculated, - const int ratesTotal, - const double &open[], - const double &high[], - const double &close[], - const double &low[], - const long &tickVolume[] // -) -{ - // - // CURRENT ... - CalculateCycle( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - tickVolume, - // - mCMarketLength, - showCurrent, - cVolumes, - cDistances, - cBuffer, - cColorBuffer // - ); - - // - // SHORT ... - CalculateCycle( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - tickVolume, - // - mSMarketLength, - showShort, - sVolumes, - sDistances, - sBuffer, - sColorBuffer // - ); - - // - // MEDIUM ... - CalculateCycle( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - tickVolume, - // - mMMarketLength, - showMedium, - mVolumes, - mDistances, - mBuffer, - mColorBuffer // - ); - - // - // LONG ... - CalculateCycle( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - tickVolume, - // - mLMarketLength, - showLong, - lVolumes, - lDistances, - lBuffer, - lColorBuffer // - ); - - // - // HIND ... - CalculateCycle( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - tickVolume, - // - mHMarketLength, - showHind, - hVolumes, - hDistances, - hBuffer, - hColorBuffer // - ); -} - -// -void CalculateCycle( - int bar_index, // Selected Bar Index - const int prevCalculated, - const int ratesTotal, - const double &open[], - const double &high[], - const double &close[], - const double &low[], - const long &tickVolume[], - // - int _length, // Calculation Length - bool _show, - double &_volumes[], - double &_distances[], - double &_buffer[], - double &_colorBuffer[] // -) -{ - // - for (int x = 0; x < _length; x++) - { - // - _volumes[x] = (double)tickVolume[bar_index - x]; - _distances[x] = - (close[bar_index - x] > open[bar_index - x]) - ? high[bar_index - x] - low[bar_index - x] - : low[bar_index - x] - high[bar_index - x]; - } - - // - double iValue = MathMean(_volumes) * MathMean(_distances); - - // - _buffer[bar_index] = iValue; - _colorBuffer[bar_index] = iValue > 0 - ? _show - ? bullishColorIDX - : hideColorIDX - : _show - ? bearishColorIDX - : hideColorIDX; -} - -// \ No newline at end of file diff --git a/Indicators/x-saherelm.xchvwap.mq5 b/Indicators/x-saherelm.xchvwap.mq5 deleted file mode 100644 index b98fafcf..00000000 --- a/Indicators/x-saherelm.xchvwap.mq5 +++ /dev/null @@ -1,830 +0,0 @@ -/////////////////////////////////////////////////////// -// SaherElm IT Center MQL5 Indicator -// ------------------------------------------- -// Name: XCHVWAP -// Description: XCHVWAP Trend Detector ... -// -// Maintainer: -// ------------ -// Hadi Khazaee Asl (hadi_khazaee_asl@yahoo.com) -// -////////////////////////////////////////////////////// -// -// Global Properties ... -#property copyright "Copyright 2023, SaherElm IT Center" -#property link "https://saherelm.ir" -#property version "1.00" -#property description "SaherElm XCHVWAP Indicator" -#property strict - -// -#define ShortName "XCHVWAP" - -// -// Includes Common Library ... -#include "../Libraries/x-saherelm.common.lib.mq5" - -// -// Inputs ... - -// -// Market ... -input group "Market"; -input ENUM_APPLIED_PRICE appliedTo = PRICE_CLOSE; // Applied To - -// -input group "Cycles"; - -// -input group "Short"; -input ENUM_X_PERIOD_METHOD scMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES scPeriod = NULL; // Time Period - -// -input group "Medium"; -input ENUM_X_PERIOD_METHOD mcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES mcPeriod = NULL; // Time Period - -// -input group "Long"; -input ENUM_X_PERIOD_METHOD lcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES lcPeriod = NULL; // Time Period - -// -input group "Hind"; -input ENUM_X_PERIOD_METHOD hcMethod = X_PERIOD_AUTO; // How to Find Period -input ENUM_TIMEFRAMES hcPeriod = NULL; // Time Period - -// -// Presentation ... -input group "Presentation"; -input bool showShort = true; // Show Short Cycle -input bool showMedium = true; // Show Medium Cycle -input bool showLong = true; // Show Long Cycle -input bool showHind = true; // Show Hind Cycle - -// -// Buffers ... - -// -#property indicator_chart_window - -// -#property indicator_buffers 14 -#property indicator_plots 8 - -// -#define hideColorIDX 0 -#define bullishColorIDX 1 -#define bearishColorIDX 2 -#define neuturalColorIDX 3 - -// -// Short ... - -// -#define sBufferIndex 0 -double sBuffer[]; - -// -#define sColorBufferIndex 1 -double sColorBuffer[]; - -// -#define sPlotBufferIndex 0 -#property indicator_label1 "XCHVWAP S" -#property indicator_type1 DRAW_COLOR_LINE -#property indicator_color1 CLR_NONE, clrGreen, clrRed, clrGray -#property indicator_style1 STYLE_DOT -#property indicator_width1 1 - -// -// Medium ... - -// -#define mBufferIndex 2 -double mBuffer[]; - -// -#define mColorBufferIndex 3 -double mColorBuffer[]; - -// -#define mPlotBufferIndex 1 -#property indicator_label2 "XCHVWAP M" -#property indicator_type2 DRAW_COLOR_LINE -#property indicator_color2 CLR_NONE, clrGreen, clrRed, clrGray -#property indicator_style2 STYLE_DOT -#property indicator_width2 1 - -// -// Long ... - -// -#define lBufferIndex 4 -double lBuffer[]; - -// -#define lColorBufferIndex 5 -double lColorBuffer[]; - -// -#define lPlotBufferIndex 2 -#property indicator_label3 "XCHVWAP L" -#property indicator_type3 DRAW_COLOR_LINE -#property indicator_color3 CLR_NONE, clrGreen, clrRed, clrGray -#property indicator_style3 STYLE_DOT -#property indicator_width3 1 - -// -// Hind ... - -// -#define hBufferIndex 6 -double hBuffer[]; - -// -#define hColorBufferIndex 7 -double hColorBuffer[]; - -// -#define hPlotBufferIndex 3 -#property indicator_label4 "XCHVWAP H" -#property indicator_type4 DRAW_COLOR_LINE -#property indicator_color4 CLR_NONE, clrGreen, clrRed, clrGray -#property indicator_style4 STYLE_DOT -#property indicator_width4 1 - -// -// Data Buffers ... - -// -// Volumes ... -#define volumeBufferIndex 8 -double volumeBuffer[]; - -// -// Price ... -#define priceBufferIndex 9 -double priceBuffer[]; - -// -// SHORT ... -#define sStateBufferIndex 10 -double sStateBuffer[]; - -// -// MEDIUM ... -#define mStateBufferIndex 11 -double mStateBuffer[]; - -// -// LONG ... -#define lStateBufferIndex 12 -double lStateBuffer[]; - -// -// HIND ... -#define hStateBufferIndex 13 -double hStateBuffer[]; - -// -// Variables ... - -// -int maxLength; - -// -// Short ... -int mSCycleLength = 0; -ENUM_TIMEFRAMES mSCPeriod = NULL; - -// -// Medium ... -int mMCycleLength = 0; -ENUM_TIMEFRAMES mMCPeriod = NULL; - -// -// Long ... -int mLCycleLength = 0; -ENUM_TIMEFRAMES mLCPeriod = NULL; - -// -// Hind ... -int mHCycleLength = 0; -ENUM_TIMEFRAMES mHCPeriod = NULL; - -// -// EVENT Handlers ... - -// -// Initialization ... -int OnInit() -{ - // - // Validate Inputs ... - if (!ValidateInputs()) - { - return INIT_PARAMETERS_INCORRECT; - } - - // - if (!InitMarketCycles()) - { - return INIT_PARAMETERS_INCORRECT; - } - - // - // because in some cases we may have more than one input for - // calculation and we must prevent any calculation - // untill we pass the biggest input length, here we get max Input length - // and then wait until pass it ... - maxLength = ExtractMaxLengthOfInputs(); - - // - // Define Index Buffers ... - DefineBuffers(); - - // - // Set Indicator ShortName ... - SetIndicatorName(); - - // - // Init Succeed ... - return INIT_SUCCEEDED; -} - -// -// DeInitialization ... -void OnDeinit(const int reason) -{ - // - // REASON_PROGRAM 0 The EA has stopped working calling the ExpertRemove() function - // REASON_REMOVE 1 Program removed from a chart - // REASON_RECOMPILE 2 Program recompiled - // REASON_CHARTCHANGE 3 A symbol or a chart period is changed - // REASON_CHARTCLOSE 4 Chart closed - // REASON_PARAMETERS 5 Inputs changed by a user - // REASON_ACCOUNT 6 Another account has been activated or reconnection to the trade server has occurred due to changes in the account settings - // REASON_TEMPLATE 7 Another chart template applied - // REASON_INITFAILED 8 The OnInit() handler returned a non-zero value - // REASON_CLOSE 9 Terminal closed -} - -// -// Calculating what we want ... -int OnCalculate( - 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 ... -) -{ - // - ArraySetAsSeries(low, true); - ArraySetAsSeries(open, true); - ArraySetAsSeries(high, true); - ArraySetAsSeries(close, true); - ArraySetAsSeries(tick_volume, true); - - // - // this counts Available Bars ... - int limit; - - // - limit = - (prev_calculated > rates_total || prev_calculated <= 0) - ? rates_total - : (rates_total - prev_calculated) + 1; - - // - // Main Loop ... - for (int i = limit - 1; i >= 0 && !IsStopped(); i--) - { - // - CalculateBuffers( - i, - prev_calculated, - rates_total, - // - open, - high, - close, - low, - tick_volume // - ); - } - - // - return rates_total; -} - -// -// CUSTOM Functions ... - -// -// Validate Input Args for Initialization ... -bool ValidateInputs() -{ - // - bool result = - // - (IsValid(scMethod, scPeriod) && - IsValid(mcMethod, mcPeriod) && - IsValid(lcMethod, lcPeriod) && - IsValid(hcMethod, hcPeriod)) - // - ; - - // - return result; -} - -// -// Initialize Market Cycles ... -bool InitMarketCycles() -{ - // - bool result = false; - - // - // Current Cycle Initialization ... - - // - int cPeriodSeconds = PeriodSeconds(_Period); - - // - // Short Cycle Initialization ... - - // - // Find Cycle Period ... - if (scMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mSCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_SHORT, - _Period // - ); - } - else - { - mSCPeriod = scPeriod; - } - - // - result = IsValid(mSCPeriod); - if (!result) - { - return result; - } - - // - mSCycleLength = PeriodSeconds(mSCPeriod) / cPeriodSeconds; - result = mSCycleLength > 0; - if (!result) - { - return result; - } - - // - // Medium Cycle Initialization ... - - // - // Find Cycle Period ... - if (mcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mMCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_MEDIUM, - _Period // - ); - } - else - { - mMCPeriod = mcPeriod; - } - - // - result = IsValid(mMCPeriod); - if (!result) - { - return result; - } - - // - mMCycleLength = PeriodSeconds(mMCPeriod) / cPeriodSeconds; - result = mMCycleLength > 0; - if (!result) - { - return result; - } - - // - // Long Cycle Initialization ... - - // - // Find Cycle Period ... - if (lcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mLCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_LONG, - _Period // - ); - } - else - { - mLCPeriod = lcPeriod; - } - - // - result = IsValid(mLCPeriod); - if (!result) - { - return result; - } - - // - mLCycleLength = PeriodSeconds(mLCPeriod) / cPeriodSeconds; - result = mLCycleLength > 0; - if (!result) - { - return result; - } - - // - // Hind Cycle Initialization ... - - // - // Find Cycle Period ... - if (hcMethod == X_PERIOD_AUTO) - { - // - // Select Period ... - mHCPeriod = GetCyclePeriod( - X_MARKET_CYCLE_HIND, - _Period // - ); - } - else - { - mHCPeriod = hcPeriod; - } - - // - result = IsValid(mHCPeriod); - if (!result) - { - return result; - } - - // - mHCycleLength = PeriodSeconds(mHCPeriod) / cPeriodSeconds; - result = mHCycleLength > 0; - if (!result) - { - return result; - } - - // - return result; -} - -// -// Set Indicator Short Name and also we can define Buffers Labels ... -void SetIndicatorName() -{ - IndicatorSetString(INDICATOR_SHORTNAME, ShortName); -} - -// -// Define Indexes and Styles ... -void DefineBuffers() -{ - // - // Short ... - - // - ArraySetAsSeries(sBuffer, true); - ArraySetAsSeries(sColorBuffer, true); - SetIndexBuffer(sBufferIndex, sBuffer, INDICATOR_DATA); - SetIndexBuffer(sColorBufferIndex, sColorBuffer, INDICATOR_COLOR_INDEX); - - // - // Medium ... - - // - ArraySetAsSeries(mBuffer, true); - ArraySetAsSeries(mColorBuffer, true); - SetIndexBuffer(mBufferIndex, mBuffer, INDICATOR_DATA); - SetIndexBuffer(mColorBufferIndex, mColorBuffer, INDICATOR_COLOR_INDEX); - - // - // Long ... - - // - ArraySetAsSeries(lBuffer, true); - ArraySetAsSeries(lColorBuffer, true); - SetIndexBuffer(lBufferIndex, lBuffer, INDICATOR_DATA); - SetIndexBuffer(lColorBufferIndex, lColorBuffer, INDICATOR_COLOR_INDEX); - - // - // Hind ... - - // - ArraySetAsSeries(hBuffer, true); - ArraySetAsSeries(hColorBuffer, true); - SetIndexBuffer(hBufferIndex, hBuffer, INDICATOR_DATA); - SetIndexBuffer(hColorBufferIndex, hColorBuffer, INDICATOR_COLOR_INDEX); - - // - // Data Buffers ... - - // - // Volumes ... - ArraySetAsSeries(volumeBuffer, true); - SetIndexBuffer(volumeBufferIndex, volumeBuffer, INDICATOR_CALCULATIONS); - - // - // Price ... - ArraySetAsSeries(priceBuffer, true); - SetIndexBuffer(priceBufferIndex, priceBuffer, INDICATOR_CALCULATIONS); - - // - // Short State ... - ArraySetAsSeries(sStateBuffer, true); - SetIndexBuffer(sStateBufferIndex, sStateBuffer, INDICATOR_CALCULATIONS); - - // - // Medium State ... - ArraySetAsSeries(mStateBuffer, true); - SetIndexBuffer(mStateBufferIndex, mStateBuffer, INDICATOR_CALCULATIONS); - - // - // Long State ... - ArraySetAsSeries(lStateBuffer, true); - SetIndexBuffer(lStateBufferIndex, lStateBuffer, INDICATOR_CALCULATIONS); - - // - // Hind State ... - ArraySetAsSeries(hStateBuffer, true); - SetIndexBuffer(hStateBufferIndex, hStateBuffer, INDICATOR_CALCULATIONS); -} - -// -// Retrieve all Exists Input Max Length ... -// use for Start Of Drawing ... -int ExtractMaxLengthOfInputs() -{ - // - int result = 0; - - // - result = MathMax(mSCycleLength, mMCycleLength); - result = MathMax(result, mLCycleLength); - result = MathMax(result, mHCycleLength); - - // - return result; -} - -// -// Calculate Buffers ... -void CalculateBuffers( - int bar_index, // Selected Bar Index - const int prevCalculated, - const int ratesTotal, - const double &open[], - const double &high[], - const double &close[], - const double &low[], - const long &tickVolume[] // -) -{ - // - // Calculate Volumes and Price ... - - // - if (ratesTotal - bar_index <= maxLength) - { - // - CalculateDataBuffers( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - tickVolume // - ); - return; - } - - // - CalculateDataBuffers( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - tickVolume // - ); - - // - CalculateCycles( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - tickVolume // - ); -} - -// -void CalculateDataBuffers( - int bar_index, // Selected Bar Index - const int prevCalculated, - const int ratesTotal, - const double &open[], - const double &high[], - const double &close[], - const double &low[], - const long &tickVolume[] // -) -{ - // - double price = GetAppliedPrice( - appliedTo, - open, - high, - low, - close, - bar_index // - ); - priceBuffer[bar_index] = price; - volumeBuffer[bar_index] = (double)tickVolume[bar_index]; -} - -// -void CalculateCycles( - int bar_index, // Selected Bar Index - const int prevCalculated, - const int ratesTotal, - const double &open[], - const double &high[], - const double &close[], - const double &low[], - const long &tickVolume[] // -) -{ - // - // SHORT ... - CalculateCycle( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - tickVolume, - // - mSCycleLength, - showShort, - sBuffer, - sColorBuffer, - sStateBuffer // - ); - - // - // MEDIUM ... - CalculateCycle( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - tickVolume, - // - mMCycleLength, - showMedium, - mBuffer, - mColorBuffer, - mStateBuffer // - ); - - // - // LONG ... - CalculateCycle( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - tickVolume, - // - mLCycleLength, - showLong, - lBuffer, - lColorBuffer, - lStateBuffer // - ); - - // - // HIND ... - CalculateCycle( - bar_index, - prevCalculated, - ratesTotal, - open, - high, - close, - low, - tickVolume, - // - mHCycleLength, - showHind, - hBuffer, - hColorBuffer, - hStateBuffer // - ); -} - -// -void CalculateCycle( - int bar_index, // Selected Bar Index - const int prevCalculated, - const int ratesTotal, - const double &open[], - const double &high[], - const double &close[], - const double &low[], - const long &tickVolume[], - // - int _length, // Calculation Length - bool _show, - double &_buffer[], - double &_colorBuffer[], - double &_stateBuffer[] // -) -{ - // - double vSum = 0; - double pSum = 0; - double mSum = 0; - for (int x = 0; x < _length; x++) - { - // - pSum += priceBuffer[x + bar_index]; - vSum += volumeBuffer[x + bar_index]; - mSum += priceBuffer[x + bar_index] * volumeBuffer[x + bar_index]; - } - - // - double iValue = mSum / vSum; - iValue = NormalizeDouble(iValue, _Digits); - - // - _buffer[bar_index] = iValue; - - // - bool isBullish = low[bar_index] > iValue; - bool isBearish = high[bar_index] < iValue; - - // - double iColor = - isBullish - ? bullishColorIDX - : isBearish - ? bearishColorIDX - : neuturalColorIDX; - - // - _colorBuffer[bar_index] = hideColorIDX; - _stateBuffer[bar_index] = iColor; - if (_show) - { - _colorBuffer[bar_index] = iColor; - } -} - -// \ No newline at end of file diff --git a/X121SMCEA/Strategy/x-121.smc.ob.strategy.class.mq5 b/X121SMCEA/Strategy/x-121.smc.ob.strategy.class.mq5 deleted file mode 100644 index a823b8e2..00000000 Binary files a/X121SMCEA/Strategy/x-121.smc.ob.strategy.class.mq5 and /dev/null differ diff --git a/X121SMCEA/Strategy/x-121.smc.supdem.strategy.class.mq5 b/X121SMCEA/Strategy/x-121.smc.supdem.strategy.class.mq5 deleted file mode 100644 index 625285a3..00000000 Binary files a/X121SMCEA/Strategy/x-121.smc.supdem.strategy.class.mq5 and /dev/null differ