diff --git a/.vscode/vscode-kanban.json b/.vscode/vscode-kanban.json index b19d7cfd..feebf1f0 100644 --- a/.vscode/vscode-kanban.json +++ b/.vscode/vscode-kanban.json @@ -48,15 +48,14 @@ "assignedTo": { "name": "Hadi Khazaee Asl" }, - "category": "X121 Market Conditions", - "creation_time": "2024-05-30T21:38:04.455Z", + "creation_time": "2024-06-01T00:56:22.059Z", "description": { - "content": "- [x] Remove all Unused Indicators and Helpers;\n-- [x] XCHLH;\n-- [x] XCHMA;\n-- [x] XFI;\n-- [x] XTS;\n-- [x] XRSI;\n-- [x] XOBD;\n-- [x] XLH;\n- [x] resolve side affects;\n- [x] Cleanup Market Conditions;\n- [] Merge reading Required Data to XMarket Conditions;", + "content": "Indicators:\n- [] XHULL;\n- [] XSSL;\n- [] XAMA;\n- [] XTM;\n\nfor each indicator:\n- [] Buffers;\n- [] Conditions;\n- [] Clean;\n- [] Score;\n- [] Summary;\n", "mime": "text/markdown" }, - "id": "62", + "id": "71", "references": [], - "title": "Cleanup all Old Indicator" + "title": "add XHULL/XSSLC/XAMA/XTM Indicators also to X121MarketCycle Calss" }, { "assignedTo": { @@ -75,7 +74,7 @@ "category": "X121 Provider", "creation_time": "2024-05-30T21:40:26.010Z", "description": { - "content": "implement a Signaller Struct to Describe a Signaller state;\nuse it in X121ProviderDescriptor;\ninside X121Provider use this Struct to Handle Signaller's State;", + "content": "- [x] implement a Signaller Struct to Describe a Signaller state;\n- [] use it in X121ProviderDescriptor;\n- [] inside X121Provider use this Struct to Handle Signaller's State;", "mime": "text/markdown" }, "id": "63", @@ -89,7 +88,7 @@ "category": "XMQL", "creation_time": "2024-05-30T22:34:15.388Z", "description": { - "content": "in this way all class can Has his own Alerts ...", + "content": "- [x] in this way all class can Has his own Alerts ...\n- [] preare Alert Prefix for Each Separated Once ...", "mime": "text/markdown" }, "id": "69", @@ -103,15 +102,54 @@ "category": "X121 Provider", "creation_time": "2024-05-30T21:41:50.930Z", "description": { - "content": "Each Market must have their own Pivot Points;", + "content": "Each Market must have their own Pivot Points;\n\n- [] Remove Current Support and Resistance;\n- [] add Support and Resistance and also Score Generating in each Market;\n- [] create a General Common Function to Access Support and Resistances;", "mime": "text/markdown" }, "id": "64", "references": [], "title": "Move Support and Resistance Pivots Finders inside X121Market Class" + }, + { + "assignedTo": { + "name": "Hadi Khazaee Asl" + }, + "category": "XMQL", + "creation_time": "2024-06-01T00:57:10.458Z", + "description": { + "content": "do r&d about Volume Profiling and Implement it inside X121 Market Cycle;", + "mime": "text/markdown" + }, + "id": "72", + "references": [], + "title": "R&D about Volume Profiling" + }, + { + "assignedTo": { + "name": "Hadi Khazaee Asl" + }, + "category": "XMQL", + "creation_time": "2024-06-01T00:58:06.730Z", + "id": "73", + "references": [], + "title": "R&D about indicator Class implementation ..." + } + ], + "testing": [ + { + "assignedTo": { + "name": "Hadi Khazaee Asl" + }, + "category": "X121 Market Conditions", + "creation_time": "2024-05-30T21:38:04.455Z", + "description": { + "content": "- [x] Remove all Unused Indicators and Helpers;\n-- [x] XCHLH;\n-- [x] XCHMA;\n-- [x] XFI;\n-- [x] XTS;\n-- [x] XRSI;\n-- [x] XOBD;\n-- [x] XLH;\n- [x] resolve side affects;\n- [x] Cleanup Market Conditions;\n- [x] Merge reading Required Data to XMarket Conditions;", + "mime": "text/markdown" + }, + "id": "62", + "references": [], + "title": "Cleanup all Old Indicator" } ], - "testing": [], "done": [ { "assignedTo": { diff --git a/Classes/Indicators/x-saherelm.mid.class.mq5 b/Classes/Indicators/x-saherelm.mid.class.mq5 new file mode 100644 index 00000000..27500a06 --- /dev/null +++ b/Classes/Indicators/x-saherelm.mid.class.mq5 @@ -0,0 +1,154 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 Class Library +// ---------------------------------------------- +// Name: XSCBaseInd +// Description: provides Indicator implementation +// 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 + +// +// XSCMid Indicator Buffers ... +enum ENUM_XSCMID_BUFFERS +{ + XSCMID_MAIN_LINE = 0, // Main Buffer ... + XSCMID_STATE_LINE = 1, // State Buffer ... +}; + +// +string GetTitle(ENUM_XSCMID_BUFFERS bufferLine) +{ + // + string result = NULL; + + // + switch (bufferLine) + { + // + case XSCMID_MAIN_LINE: + result = "XMID"; + break; + + // + case XSCMID_STATE_LINE: + result = "XSTATE"; + break; + } + + // + return result; +} + +// +// XSCMid Indicator Inputs ... +struct XSCMidInputs +{ + // + // Props ... + string version; + + // + // Constructor ... + XSCMidInputs() + { + Clean(); + } + + // + // Tools ... + + // + // Initial Inputs ... + bool Init() + { + // + bool result = false; + + // + result = IsValid(); + + // + return result; + } + + // + // Cleanup ... + void Clean() + { + } + + // + // Default ... + void Default() + { + } + + // + // Validate ... + bool IsValid() + { + // + bool result = false; + + // + result = + // + true + // + ; + + // + return result; + } + + // + // Retrieve Max Length ... + int Max() + { + // + int result = 0; + + // + result = 0; + + // + return result; + } +}; + +// +// a Simple Indicator ... + +class XSCMid : public CIndicator +{ + + // + // Protected ... +protected: + // + // Private ... +private: + // + // Props ... + + // + // Inputs ... + XSCMidInputs mInputs; +}; \ No newline at end of file diff --git a/Classes/x-saherelm.xind.class.mq5 b/Classes/x-saherelm.xind.class.mq5 new file mode 100644 index 00000000..d3b28eca --- /dev/null +++ b/Classes/x-saherelm.xind.class.mq5 @@ -0,0 +1,683 @@ +/////////////////////////////////////////////////////// +// +// SaherElm IT Center MQL5 Class Library +// ---------------------------------------------- +// Name: XSCBaseInd +// Description: provides all Indicator 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.base.class.mq5" +#include "../Libraries/x-saherelm.draw.lib.mq5" +#include "../Classes/x-saherelm.xalert.class.mq5" + +// +// Definitions ... + +// +struct XBuffer +{ + // + string title; // Buffer Title + string symbol; // Buffer Symbol + double values[]; // Buffer Values + ENUM_TIMEFRAMES period; // Buffer Period + datetime times[]; // Buffer Values Time + + // + // Constructor ... + XBuffer() + { + Clean(); + } + + // + // Tools ... + bool Init( + string mTitle // Title + ) + { + // + bool result = false; + + // + result = IsValid(mTitle); + if (!result) + { + return result; + } + + // + Clean(); + + // + result = StringToLower(mTitle); + if (!result) + { + return result; + } + + // + title = mTitle; + // ArraySetAsSeries(values, false); + + // + result = IsValid(); + + // + return result; + } + + // + // Cleanup ... + void Clean() + { + // + Clean(values); + Clean(times); + + // + title = NULL; + symbol = NULL; + period = NULL; + } + + // + // Validate ... + bool IsValid() + { + // + bool result = false; + + // + result = + // + IsValid(title) && + IsValid(period) && + IsValid(symbol) + // + ; + + // + return result; + } + + // + // Check Owwn ... + bool IsOwn( + string mTitle // Checking Title + ) + { + // + bool result = false; + + // + result = IsValid(mTitle); + if (!result) + { + return result; + } + + // + result = StringToLower(mTitle); + if (!result) + { + return result; + } + + // + result = this.title == mTitle; + + // + return result; + } + + // + // Count Size ... + int Count() + { + return ArraySize(values); + } + + // + // Add Value to Buffer ... + int Add(double value) + { + // + int result = -1; + + // + if (!IsValid()) + { + return result; + } + + // + datetime time = GetPeriodStartTime( + this.symbol, + this.period); + + // + // Check Date Exists before ... + int timeIDX = FindIndex( + time, + times // + ); + if (timeIDX >= 0) + { + // + // Item Exists ... + // Update it ... + + // + values[timeIDX] = value; + } + else + { + // + // New Item ... + // Add It ... + + // + int count = Count(); + ArrayResize( + values, + count + 1 // + ); + ArrayResize( + times, + count + 1 // + ); + + // + times[count] = time; + values[count] = value; + } + + // + result = Count(); + + // + return result; + } + + // + // Get Specified Index Value ... + double Get( + int index // Specified Index + ) + { + // + double result = EMPTY_VALUE; + + // + NormalizeIndex( + index, + values // + ); + + // + result = values[index]; + + // + return result; + } + + // + // Remove Specified Index Value ... + bool Remove(int index) + { + // + bool result = false; + + // + int count = Count(); + result = IsValidSize(count); + if (!result) + { + return result; + } + + // + result = index > 0 && index < count - 1; + if (!result) + { + return result; + } + + // + result = ArrayRemove( + values, + index, + 1 // + ); + + // + return result; + } + + // + double Get( + datetime time = NULL // + ) + { + // + double result = EMPTY_VALUE; + + // + NormalizeTime(time); + + // + datetime iTime = GetPeriodStartTime( + this.symbol, + this.period, + time // + ); + + // + int timeIDX = FindIndex( + iTime, + this.times // + ); + if (timeIDX < 0) + { + return result; + } + + // + result = Get(timeIDX); + + // + return result; + } + + // + bool Remove( + datetime time = NULL // + ) + { + // + bool result = false; + + // + NormalizeTime(time); + + // + datetime iTime = GetPeriodStartTime( + this.symbol, + this.period, + time // + ); + + // + int timeIDX = FindIndex( + iTime, + this.times // + ); + if (timeIDX < 0) + { + return result; + } + + // + result = Remove(timeIDX); + + // + return result; + } +}; + +// +// Base Indicator Class ... +class XSCBaseInd : public XSCBaseAlert +{ + // + // Public ... +public: + // + // Props ... + + // + // Indicators Buffers ... + XBuffer mBuffers[]; + + // + // Constructor(s) ... + void XSCBaseInd( + string symbol, // Trading Symbol + ENUM_TIMEFRAMES period // Trading TimeFrame + ) : XSCBaseAlert() + { + // + mSymbol = symbol; + mPeriod = period; + + // + mCalculatedBars = 0; + } + + // + // Deconstructor ... + void ~XSCBaseInd() {} + + // + // Property Getter(s) / Setter(s) ... + + // + string GetSymbol() + { + return mSymbol; + } + + // + ENUM_TIMEFRAMES GetPeriod() + { + return mPeriod; + } + + // + // Overrides ... + + // + virtual string GetTag(); + + // + virtual string GetToken(); + + // + virtual void DeInit(int reason); // Indicator DeInitialization + + // + // Validate Inputs ... + virtual bool IsValidInputs() + { + return false; + } + + // + // Calculate ... + virtual void Calculate() {} + + // + // Tools ... + + // + // Retrieve Calculate Bars ... + int GetCalculatedBars() + { + return mCalculatedBars; + } + + // + // Count available Bars ... + int CountBars() + { + // + return iBars( + mSymbol, + mPeriod // + ); + } + + // + // Validate Indicator States ... + bool IsValid() + { + // + bool result = false; + + // + result = IsValidInputs(); + if (!result) + { + return result; + } + + // + result = + // + IsSpecifiedValid(mSymbol) && + IsSpecifiedValid(mPeriod) + // + ; + + // + return result; + } + + // + // Buffer Registrations ... + + // + // Count Registered Buffers ... + int CountBuffers() + { + return ArraySize(mBuffers); + } + + // + // Retrieve Specified Buffer Index ... + int GetBufferIndex( + string title // Specified Buffer Title + ) + { + // + int result = -1; + + // + if (!IsSpecifiedValid(title)) + { + return result; + } + + // + int buffersCount = CountBuffers(); + if (!IsValidSize(buffersCount)) + { + return result; + } + + // + for (int i = 0; i < buffersCount; i++) + { + // + XBuffer iBuffer = mBuffers[i]; + + // + bool isOwn = iBuffer.IsOwn(title); + if (isOwn) + { + // + result = i; + break; + } + } + + // + return result; + } + + // + // Check Contains Specific Buffer or not ... + bool HasBuffer( + string title // Specified Buffer Title + ) + { + // + bool result = false; + + // + int bufferIndex = GetBufferIndex(title); + result = bufferIndex >= 0; + + // + return result; + } + + // + // Retrieve Specified Buffer ... + bool GetBuffer( + string title, // Specified Buffer Title + XBuffer &buffer // Hold Result + ) + { + // + bool result = false; + + // + int idx = GetBufferIndex(title); + result = idx >= 0; + if (!result) + { + return result; + } + + // + buffer = mBuffers[idx]; + + // + result = buffer.IsValid(); + + // + return result; + } + + // + // Register Specified Buffer ... + bool SetBuffer( + XBuffer &buffer // Specified Buffer for Registration + ) + { + // + bool result = false; + + // + // Validate buffer ... + result = buffer.IsValid(); + if (!result) + { + return result; + } + + // + // Check Buffer Doesn't Exists before ... + int idx = GetBufferIndex(buffer.title); + result = idx == -1; + if (!result) + { + return result; + } + + // + AddRef( + buffer, + mBuffers // + ); + + // + return result; + } + + // + double GetBufferValue( + string mTitle, // Required Buffer Title + int index // Bar Index + ) + { + // + double result = EMPTY_VALUE; + + // + // Validate State ... + if (!IsValid()) + { + return result; + } + + // + int bufferIDX = GetBufferIndex(mTitle); + if (bufferIDX < 0) + { + return result; + } + + // + Calculate(); + + // + result = mBuffers[bufferIDX].Get(index); + + // + return result; + } + + // + double GetBufferValue( + string mTitle, // Required Buffer Title + datetime time = NULL // Time + ) + { + // + NormalizeTime(time); + double result = EMPTY_VALUE; + + // + // Validate State ... + if (!IsValid()) + { + return result; + } + + // + int bufferIDX = GetBufferIndex(mTitle); + if (bufferIDX < 0) + { + return result; + } + + // + Calculate(); + + // + result = mBuffers[bufferIDX].Get(time); + + // + return result; + } + + // + // Protected ... +protected: + // + // Props ... + + // + string mSymbol; // Trading Symbol + ENUM_TIMEFRAMES mPeriod; // Trading TimeFrame + + // + int mCalculatedBars; // Calculated Bars + + // + // Tools ... + + // + // Private ... +private: + // + // Props ... +}; diff --git a/Documents/BKP/Source Codes/CiCustom.mq5 b/Documents/BKP/Source Codes/CiCustom.mq5 new file mode 100644 index 00000000..83b8a3e6 --- /dev/null +++ b/Documents/BKP/Source Codes/CiCustom.mq5 @@ -0,0 +1,194 @@ +//+------------------------------------------------------------------+ +//| Custom.mqh | +//| Copyright 2000-2024, MetaQuotes Ltd. | +//| https://www.mql5.com | +//+------------------------------------------------------------------+ +#include "Indicator.mqh" +//+------------------------------------------------------------------+ +//| Class CiCustom. | +//| Purpose: Class of custom indicators. | +//| Derives from class CIndicator. | +//+------------------------------------------------------------------+ +class CiCustom : public CIndicator + { +protected: + int m_num_params; // number of creation parameters + MqlParam m_params[]; // creation parameters + +public: + CiCustom(void); + ~CiCustom(void); + //--- methods of access to protected data + bool NumBuffers(const int buffers); + int NumParams(void) const { return(m_num_params); } + ENUM_DATATYPE ParamType(const int ind) const; + long ParamLong(const int ind) const; + double ParamDouble(const int ind) const; + string ParamString(const int ind) const; + //--- method of identifying + virtual int Type(void) const { return(IND_CUSTOM); } + +protected: + //--- methods of tuning + virtual bool Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam ¶ms[]); + }; +//+------------------------------------------------------------------+ +//| Constructor | +//+------------------------------------------------------------------+ +CiCustom::CiCustom(void) : m_num_params(0) + { + } +//+------------------------------------------------------------------+ +//| Destructor | +//+------------------------------------------------------------------+ +CiCustom::~CiCustom(void) + { + } +//+------------------------------------------------------------------+ +//| Set number of buffers of indicator | +//+------------------------------------------------------------------+ +bool CiCustom::NumBuffers(const int buffers) + { + bool result=true; +//--- + if(m_buffers_total==0) + { + m_buffers_total=buffers; + return(true); + } + if(m_buffers_total!=buffers) + { + Shutdown(); + result=CreateBuffers(m_symbol,m_period,buffers); + if(result) + { + //--- create buffers + for(int i=0;i=m_num_params) + return(WRONG_VALUE); +//--- + return(m_params[ind].type); + } +//+------------------------------------------------------------------+ +//| Get specified parameter of creatiob as a long value | +//+------------------------------------------------------------------+ +long CiCustom::ParamLong(const int ind) const + { + if(ind>=m_num_params) + return(0); + switch(m_params[ind].type) + { + case TYPE_DOUBLE: + case TYPE_FLOAT: + case TYPE_STRING: + return(0); + } +//--- + return(m_params[ind].integer_value); + } +//+------------------------------------------------------------------+ +//| Get specified parameter of creation as a double value | +//+------------------------------------------------------------------+ +double CiCustom::ParamDouble(const int ind) const + { + if(ind>=m_num_params) + return(EMPTY_VALUE); + switch(m_params[ind].type) + { + case TYPE_DOUBLE: + case TYPE_FLOAT: + break; + default: + return(EMPTY_VALUE); + } +//--- + return(m_params[ind].double_value); + } +//+------------------------------------------------------------------+ +//| Get specified parameter of creation as a string value | +//+------------------------------------------------------------------+ +string CiCustom::ParamString(const int ind) const + { + if(ind>=m_num_params || m_params[ind].type!=TYPE_STRING) + return(""); +//--- + return(m_params[ind].string_value); + } +//+------------------------------------------------------------------+ +//| Initialize the indicator with universal parameters | +//+------------------------------------------------------------------+ +bool CiCustom::Initialize(const string symbol,const ENUM_TIMEFRAMES period,const int num_params,const MqlParam ¶ms[]) + { + int i; +//--- tune + if(m_buffers_total==0) + m_buffers_total=256; + if(CreateBuffers(symbol,period,m_buffers_total)) + { + //--- string of status of drawing + m_name ="Custom "+params[0].string_value; + m_status="("+symbol+","+PeriodDescription(); + for(i=1;i rates_total || prev_calculated <= 0) ? rates_total : (rates_total - prev_calculated) + 1; + + // // + // int midMainCopiedItems = mMid.CopyBufferValueByLine( + // XSCMID_MAIN_LINE, + // mainBuffer, + // 0, + // limit // + // ); + // if (midMainCopiedItems <= 0) + // { + // 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 InitIndicatorClass() +{ + // + bool result = false; + + // + // Initialize and Prepare + // Inputs of Indicator ... + XSCMidInputs inputs; + result = inputs.Init(); + if (!result) + { + return result; + } + + // + // Instantiate Class ... + mMid = new XSCMid( + _Symbol, + _Period // + ); + + // + // Now Initialize Indicator Class using Given Inputs ... + result = mMid.Init( + inputs // + ); + + // + return result; +} + +// +// Define Indexes and Styles ... +void DefineBuffers() +{ + // + // Start Styling and Indexing Buffers ... + + // + string bufferLabel = GetTitle(XSCMID_MAIN_LINE); + int mainIDX = mMid.GetBufferIndexByLine(XSCMID_MAIN_LINE); + XBuffer mainBufferStruct; + mMid.GetBufferByLine( + XSCMID_MAIN_LINE, + mainBufferStruct // + ); + + // + int bufferIndex = 0; + + // + int max = mMid.GetInputs().Max(); + + // + ArraySetAsSeries(mainBuffer, true); + + // + XBufferPlotStyle mainBufferStyle; + mainBufferStyle.clr = clrAqua; + mainBufferStyle.type = DRAW_LINE; + + // + SetIndexBuffer( + bufferIndex, + mainBuffer, + mainBufferStyle, + mainColorBuffer, + bufferLabel, + true, + 0, + max // + ); +} + +// +// Set Indicator Short Name and also we can define Buffers Labels ... +void SetIndicatorName() +{ + IndicatorSetString(INDICATOR_SHORTNAME, ShortName); +} + +// +void CalculateBuffers(int barIndex) +{ + // + double iValue = mMid.GetBufferValueByLine( + XSCMID_MAIN_LINE, + barIndex // + ); + + // + // double iValue = iClose( + // _Symbol, + // _Period, + // barIndex // + // ); + + mainBuffer[barIndex] = iValue; +} \ No newline at end of file diff --git a/Libraries/x-saherelm.common.lib.mq5 b/Libraries/x-saherelm.common.lib.mq5 index 07fb5ba3..10aa1db4 100644 --- a/Libraries/x-saherelm.common.lib.mq5 +++ b/Libraries/x-saherelm.common.lib.mq5 @@ -2930,6 +2930,247 @@ struct XMarketCycle } }; +// +// Styling Buffers ... + +// +struct XBufferPlotStyle +{ + // + int width; // Width + color clr; // Color + uchar arrow; // Arrow Code + ENUM_DRAW_TYPE type; // Type + ENUM_LINE_STYLE style; // Style + + // + // Constructor ... + XBufferPlotStyle() + { + Default(); + } + + // + // Tools ... + + // + // Default ... + void Default() + { + // + width = 1; + arrow = 0; + clr = CLR_NONE; + type = DRAW_NONE; + style = STYLE_SOLID; + } +}; + +// +// Register a Buffer as Indexed Buffer ... +void SetIndexBuffer( + int &index, // the Index refrence for Buffer + double &buffer[], // Buffer to Set + XBufferPlotStyle &style, // Style to Apply to Buffer + double &colorBuffer[], // Color Buffer + string label = NULL, // Buffer Label + bool showData = true, // Show Data on Data Window + double empty = -1, // Set 0 or EMPTY_VALUE used for setting Empty Value + int drawBegin = -1 // if Set More Than -1 applied +) +{ + // + // Set Buffer Index ... + SetIndexBuffer(index, buffer, INDICATOR_DATA); + + // + // Show Date ... + PlotIndexSetInteger(index, PLOT_SHOW_DATA, showData); + + // + // Set Buffer Label ... + if (IsValid(label)) + { + PlotIndexSetString(index, PLOT_LABEL, label); + } + + // + if (empty == 0 || empty == EMPTY_VALUE) + { + PlotIndexSetDouble(index, PLOT_EMPTY_VALUE, empty); + } + + // + if (drawBegin > -1) + { + PlotIndexSetInteger(index, PLOT_DRAW_BEGIN, drawBegin); + } + + // + if (style.type == DRAW_ARROW) + { + PlotIndexSetInteger(index, PLOT_ARROW, style.arrow); + } + + // + PlotIndexSetInteger(index, PLOT_LINE_STYLE, style.style); + PlotIndexSetInteger(index, PLOT_LINE_WIDTH, style.width); + + // + string drawTypeStr = EnumToString(style.type); + bool hasColorBuffer = Contains("COLOR", drawTypeStr); + + // + if (!hasColorBuffer) + { + PlotIndexSetInteger(index, PLOT_LINE_COLOR, style.clr); + } + else + { + // + // Since Color Buffers must add as next Index of it's own Buffer + // here before applied Color Buffer increase index ... + index++; + + // + SetIndexBuffer(index, colorBuffer, INDICATOR_COLOR_INDEX); + } + + // + // Increase Index for Next Buffer ... + index++; +} + +// +void SetIndexCandleBuffers( + int &index, // the Index refrence for Buffer + string openLabel, // Open Label + double &open[], // Open Buffer + string highLabel, // High Label + double &high[], // High Buffer + string lowLabel, // Low Label + double &low[], // Low Buffer + string closeLabel, // Close Label + double &close[], // Close Buffer + bool showData = true, // Show Data on Data Window + double empty = -1, // Set 0 or EMPTY_VALUE used for setting Empty Value + int drawBegin = -1 // if Set More Than -1 applied +) +{ + // + bool hasLabel = + // + IsValid(openLabel) && + IsValid(highLabel) && + IsValid(lowLabel) && + IsValid(closeLabel) + // + ; + + // + string label = + !hasLabel + ? NULL + : openLabel + ";" + highLabel + ";" + lowLabel + ";" + closeLabel; + + // + // Set Buffer Index ... + SetIndexBuffer(index, open, INDICATOR_DATA); + + // + // Set Draw Candles Type ... + PlotIndexSetInteger(index, PLOT_LINE_STYLE, DRAW_CANDLES); + + // + // Show Date ... + PlotIndexSetInteger(index, PLOT_SHOW_DATA, showData); + + // + // Set Buffer Label ... + if (IsValid(label)) + { + PlotIndexSetString(index, PLOT_LABEL, label); + } + + // + if (empty == 0 || empty == EMPTY_VALUE) + { + PlotIndexSetDouble(index, PLOT_EMPTY_VALUE, empty); + } + + // + if (drawBegin > -1) + { + PlotIndexSetInteger(index, PLOT_DRAW_BEGIN, drawBegin); + } + + // + index++; + + // + // Set Buffer Index ... + SetIndexBuffer(index, high, INDICATOR_DATA); + index++; + + // + // Set Buffer Index ... + SetIndexBuffer(index, low, INDICATOR_DATA); + index++; + + // + // Set Buffer Index ... + SetIndexBuffer(index, close, INDICATOR_DATA); + index++; +} + +// +void SetIndexCandleBuffers( + int &index, // the Index refrence for Buffer + string openLabel, // Open Label + double &open[], // Open Buffer + string highLabel, // High Label + double &high[], // High Buffer + string lowLabel, // Low Label + double &low[], // Low Buffer + string closeLabel, // Close Label + double &close[], // Close Buffer + double &colorBuffer[], // Candle Color Buffer + bool showData = true, // Show Data on Data Window + double empty = -1, // Set 0 or EMPTY_VALUE used for setting Empty Value + int drawBegin = -1 // if Set More Than -1 applied +) +{ + // + SetIndexCandleBuffers( + index, + openLabel, + open, + highLabel, + high, + lowLabel, + low, + closeLabel, + close, + showData, + empty, + drawBegin // + ); + + // + int mFirstIndex = index - 4; + + // + // Set Draw Candles Type ... + PlotIndexSetInteger(mFirstIndex, PLOT_LINE_STYLE, DRAW_COLOR_CANDLES); + + // + // Set Color Buffer ... + SetIndexBuffer(index, colorBuffer, INDICATOR_COLOR_INDEX); + + // + index++; +} + // // Functions ...