├── LICENSE ├── MQL4 ├── Files │ └── EF-Icon-64x64px.ico └── Indicators │ └── MQLTA MT4 Currency Strength Matrix.mq4 ├── MQL5 ├── Files │ └── EF-Icon-64x64px.ico ├── Include │ ├── MQLTA ErrorHandling.mqh │ └── MQLTA Utils.mqh └── Indicators │ └── MQLTA MT5 Currency Strength Matrix.mq5 ├── README.md └── README_Images └── currency-strength-matrix-indicator-example.png /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /MQL4/Files/EF-Icon-64x64px.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EarnForex/Currency-Strength-Matrix/f986f35da7b29828c197eea80c8246664469b5fb/MQL4/Files/EF-Icon-64x64px.ico -------------------------------------------------------------------------------- /MQL4/Indicators/MQLTA MT4 Currency Strength Matrix.mq4: -------------------------------------------------------------------------------- 1 | #property link "https://www.earnforex.com/metatrader-indicators/currency-strength-matrix/" 2 | #property version "1.06" 3 | #property strict 4 | #property copyright "EarnForex.com - 2019-2025" 5 | #property description "This indicator analyses the strength of a currency comparing values in several timeframes." 6 | #property description "" 7 | #property description "WARNING: Use this software at your own risk." 8 | #property description "The creator of these plugins cannot be held responsible for any damage or loss." 9 | #property description "" 10 | #property description "Find More on www.EarnForex.com" 11 | #property icon "\\Files\\EF-Icon-64x64px.ico" 12 | 13 | #property indicator_chart_window 14 | 15 | struct SBuffer 16 | { 17 | double OutputBuffer[]; 18 | }; 19 | 20 | SBuffer vBuffers[8][9]; // Values 21 | SBuffer aBuffers[8][9]; // Acceleration 22 | 23 | enum Enum_CalculationMode 24 | { 25 | Mode_CloseClose, // Close difference 26 | Mode_MA, // MA difference 27 | Mode_RSI, // RSI difference 28 | Mode_RSIMA, // RSI MA 29 | Mode_StochMain, // Stochastic main 30 | Mode_StochSignal // Stochastic signal 31 | }; 32 | 33 | enum ENUM_SHOWTYPE 34 | { 35 | SHOW_VALUES, // Show values 36 | SHOW_COLORS, // Show colors 37 | }; 38 | 39 | enum ENUM_SORTBY 40 | { 41 | CURRENT = PERIOD_CURRENT, // Current period 42 | M1 = PERIOD_M1, // M1 43 | M5 = PERIOD_M5, // M5 44 | M15 = PERIOD_M15, // M15 45 | M30 = PERIOD_M30, // M30 46 | H1 = PERIOD_H1, // H1 47 | H4 = PERIOD_H4, // H4 48 | D1 = PERIOD_D1, // D1 49 | W1 = PERIOD_W1, // W1 50 | MN1 = PERIOD_MN1, // MN1 51 | }; 52 | 53 | input string comment_0 = "=========="; // CSM Indicator 54 | input string IndicatorName = "MQLTA-CSM"; // Indicator's Name 55 | 56 | input string comment_2 = "=========="; // Calculation 57 | input Enum_CalculationMode CalculationMode = Mode_CloseClose; // Calculation Mode 58 | input int BarsDifference = 1; // Bars Of Difference Between Calculation Values 59 | input int MAPeriod = 2; // MA Period (If Using MA Mode Higher Number Is Less Sensitive) 60 | input ENUM_MA_METHOD MAMethod = MODE_EMA; // MA Method 61 | input int RSIPeriod = 14; // RSI Period (for RSI mode) 62 | input int Stochastic_K_Period = 5; // Stochastic %K Period 63 | input int Stochastic_D_Period = 3; // Stochastic %D Period 64 | input int Stochastic_Slowing = 3; // Stochastic Slowing 65 | input bool UseOutputBuffers = false; // Use Output Buffers 66 | 67 | input string comment_4 = "=========="; // Matrix Values and Sorting 68 | input ENUM_SHOWTYPE ShowType = SHOW_COLORS; // Show Values or Just Colors 69 | input ENUM_SORTBY SortByPeriod = CURRENT; // Sort Strength By 70 | input bool ShowAcceleration = false; // Show the Acceleration Color 71 | input int MinimumRefreshInterval = 5; // Minimum Refresh Interval (Seconds) 72 | 73 | input string comment_4b = "=========="; // Autofocus - If Enabled It Will Disable Notifications 74 | input bool AutoFocus = false; // Change Chart to Ideal Pair Automatically 75 | input string comment_5 = "=========="; // Notification 76 | input bool EnableNotify = false; // Enable Notifications feature 77 | input bool SendAlert = true; // Send Alert Notification 78 | input bool SendApp = false; // Send Notification to Mobile 79 | input bool SendEmail = false; // Send Notification via Email 80 | input string comment_3 = "=========="; // Notify Only If 81 | input bool NotifyOnlyCurrentPair = false; // Ideal Opportunity is for the Current Chart 82 | input bool NotifyOnlyFirstAndLast = false; // Ideal Opportunity is with First and Last Currency 83 | 84 | input string comment_1 = "=========="; // Currencies to consider 85 | input bool UseEUR = true; // EUR 86 | input bool UseUSD = true; // USD 87 | input bool UseGBP = true; // GBP 88 | input bool UseJPY = true; // JPY 89 | input bool UseAUD = true; // AUD 90 | input bool UseNZD = true; // NZD 91 | input bool UseCAD = true; // CAD 92 | input bool UseCHF = true; // CHF 93 | 94 | input string comment_6 = "=========="; // Timeframes to consider 95 | input bool UseM1 = true; // M1 96 | input bool UseM5 = true; // M5 97 | input bool UseM15 = true; // M15 98 | input bool UseM30 = true; // M30 99 | input bool UseH1 = true; // H1 100 | input bool UseH4 = true; // H4 101 | input bool UseD1 = true; // D1 102 | input bool UseW1 = true; // W1 103 | input bool UseMN1 = true; // MN1 104 | 105 | input string comment_7 = "=========="; // Pairs Prefix and Suffix 106 | input string CurrPrefix = ""; // Pairs Prefix 107 | input string CurrSuffix = ""; // Pairs Suffix 108 | 109 | input string comment_1b = "=========="; // Miscellaneous 110 | input int XOffset = 20; // Horizontal Offset (pixels) 111 | input int YOffset = 20; // Vertical Offset (pixels) 112 | input double Scale = 1.0; // Scale for the Panel's Size 113 | 114 | string Font = "Consolas"; 115 | double PreChecks = false; 116 | 117 | string AllPairs[] = 118 | { 119 | "AUDCAD", 120 | "AUDCHF", 121 | "AUDJPY", 122 | "AUDNZD", 123 | "AUDUSD", 124 | "CADCHF", 125 | "CADJPY", 126 | "CHFJPY", 127 | "EURAUD", 128 | "EURCAD", 129 | "EURCHF", 130 | "EURGBP", 131 | "EURJPY", 132 | "EURNZD", 133 | "EURUSD", 134 | "GBPAUD", 135 | "GBPCAD", 136 | "GBPCHF", 137 | "GBPJPY", 138 | "GBPNZD", 139 | "GBPUSD", 140 | "NZDCAD", 141 | "NZDCHF", 142 | "NZDJPY", 143 | "NZDUSD", 144 | "USDCAD", 145 | "USDCHF", 146 | "USDJPY" 147 | }; 148 | 149 | // List all currencies. 150 | string AllCurrencies[] = 151 | { 152 | "EUR", 153 | "USD", 154 | "GBP", 155 | "JPY", 156 | "AUD", 157 | "NZD", 158 | "CAD", 159 | "CHF" 160 | }; 161 | 162 | string CurrBase; 163 | string CurrQuote; 164 | string _CurrPrefix; 165 | string _CurrSuffix; 166 | double Base[]; 167 | double Quote[]; 168 | int CurrenciesUsed = 0; 169 | int _XOffset, _YOffset; 170 | 171 | double StrengthMatrixCurr[8][11]; 172 | double StrengthMatrixPrev[8][10]; 173 | int EUR_Index = 0; 174 | int GBP_Index = 1; 175 | int USD_Index = 2; 176 | int JPY_Index = 3; 177 | int AUD_Index = 4; 178 | int NZD_Index = 5; 179 | int CAD_Index = 6; 180 | int CHF_Index = 7; 181 | 182 | int M1_Index = 0; 183 | int M5_Index = 1; 184 | int M15_Index = 2; 185 | int M30_Index = 3; 186 | int H1_Index = 4; 187 | int H4_Index = 5; 188 | int D1_Index = 6; 189 | int W1_Index = 7; 190 | int MN1_Index = 8; 191 | 192 | string CurrencyDesc[8] = {"EUR", "GBP", "USD", "JPY", "AUD", "NZD", "CAD", "CHF"}; 193 | bool CurrencyEnabled[8] = {true, true, true, true, true, true, true, true}; 194 | int PeriodIndexes[9] = {PERIOD_M1, PERIOD_M5, PERIOD_M15, PERIOD_M30, PERIOD_H1, PERIOD_H4, PERIOD_D1, PERIOD_W1, PERIOD_MN1}; 195 | string PeriodDesc[9] = {"M1", "M5", "M15", "M30", "H1", "H4", "D1", "W1", "MN1"}; 196 | bool PeriodEnabled[9] = {true, true, true, true, true, true, true, true, true}; 197 | 198 | bool HistoricalOK = true; 199 | bool MissingHistoricalNotified = false; 200 | bool Initialized = false; 201 | string MissingHistoricalPair = ""; 202 | int MissingHistoricalPeriod = 0; 203 | 204 | datetime TimeInit; 205 | 206 | int PanelMovX, PanelMovY, PanelLabX, PanelLabY, PanelRecX, MissingHistoricalLabelX, MissingHistoricalLabelY; 207 | 208 | double DPIScale; // Scaling parameter for the panel based on the screen DPI. 209 | 210 | string CalculationModeDesc() 211 | { 212 | string Text = ""; 213 | if (CalculationMode == Mode_CloseClose) Text = "Close difference"; 214 | else if (CalculationMode == Mode_MA) Text = "MA difference"; 215 | else if (CalculationMode == Mode_RSI) Text = "RSI difference"; 216 | else if (CalculationMode == Mode_RSIMA) Text = "RSI MA"; 217 | else if (CalculationMode == Mode_StochMain) Text = "Stochastic main"; 218 | else if (CalculationMode == Mode_StochSignal) Text = "Stochastic signal"; 219 | return Text; 220 | } 221 | 222 | int OnInit() 223 | { 224 | IndicatorSetString(INDICATOR_SHORTNAME, IndicatorName); 225 | IndicatorDigits(4); 226 | ChartSetInteger(0, CHART_EVENT_MOUSE_MOVE, 1); 227 | _XOffset = XOffset; 228 | _YOffset = YOffset; 229 | 230 | DPIScale = Scale * (double)TerminalInfoInteger(TERMINAL_SCREEN_DPI) / 96.0; 231 | PanelMovX = (int)MathRound(26 * DPIScale); 232 | PanelMovY = (int)MathRound(26 * DPIScale); 233 | PanelLabX = (int)MathRound(160 * DPIScale); 234 | PanelLabY = PanelMovY; 235 | PanelRecX = PanelMovX * 1 + PanelLabX + 5; 236 | MissingHistoricalLabelX = (int)MathRound(187 * DPIScale); 237 | MissingHistoricalLabelY = (int)MathRound(26 * DPIScale); 238 | 239 | if (UseOutputBuffers) 240 | { 241 | int n = 72; 242 | if (ShowAcceleration) n = 144; 243 | IndicatorBuffers(n); 244 | // Values 245 | for (int i = 0; i < 8; i++) // Currencies 246 | { 247 | for (int j = 0; j < 9; j++) // Timeframes 248 | { 249 | SetIndexBuffer(i * 9 + j, vBuffers[i][j].OutputBuffer); 250 | } 251 | } 252 | // Acceleration 253 | if (ShowAcceleration) 254 | { 255 | for (int i = 0; i < 8; i++) // Currencies 256 | { 257 | for (int j = 0; j < 9; j++) // Timeframes 258 | { 259 | SetIndexBuffer(72 + i * 9 + j, aBuffers[i][j].OutputBuffer); 260 | } 261 | } 262 | } 263 | } 264 | 265 | CleanChart(); 266 | PopulatePairs(); 267 | CheckAllPairs(); 268 | InitializeVariables(); 269 | CheckSorting(); 270 | PopulateMatrix(); 271 | DrawMatrix(); 272 | 273 | EventSetTimer(MinimumRefreshInterval); 274 | Initialized = true; 275 | return INIT_SUCCEEDED; 276 | } 277 | 278 | void OnDeinit(const int reason) 279 | { 280 | EventKillTimer(); 281 | CleanChart(); 282 | } 283 | 284 | void OnTimer() 285 | { 286 | CreateMiniPanel(); 287 | HistoricalOK = true; 288 | PopulateMatrix(); 289 | if (MatrixOpen) DrawMatrix(); 290 | if ((!HistoricalOK) && (MatrixOpen)) 291 | { 292 | DrawMissingHistorical(); 293 | } 294 | else 295 | { 296 | RemoveMissingHistorical(); 297 | } 298 | } 299 | 300 | int OnCalculate(const int rates_total, 301 | const int prev_calculated, 302 | const datetime& time[], 303 | const double& open[], 304 | const double& high[], 305 | const double& low[], 306 | const double& close[], 307 | const long& tick_volume[], 308 | const long& volume[], 309 | const int& spread[]) 310 | { 311 | CreateMiniPanel(); 312 | HistoricalOK = true; 313 | PopulateMatrix(); 314 | if (MatrixOpen) DrawMatrix(); 315 | if ((!HistoricalOK) && (MatrixOpen)) 316 | { 317 | DrawMissingHistorical(); 318 | } 319 | else 320 | { 321 | RemoveMissingHistorical(); 322 | } 323 | return rates_total; 324 | } 325 | 326 | void OnChartEvent(const int id, 327 | const long &lparam, 328 | const double &dparam, 329 | const string &sparam) 330 | { 331 | if (id == CHARTEVENT_OBJECT_CLICK) 332 | { 333 | ChartSetInteger(ChartID(), CHART_MOUSE_SCROLL, true); // Enable chart sideways scroll. 334 | if (StringFind(sparam, "R0") >= 0) 335 | { 336 | string ClickDesc = ObjectGetString(0, sparam, OBJPROP_TEXT); 337 | ChangeChartPeriod(ClickDesc); 338 | } 339 | if (StringFind(sparam, "-ACTION") >= 0) 340 | { 341 | string ClickDesc = ObjectGetString(0, sparam, OBJPROP_TEXT); 342 | ChangeChartSymbol(ClickDesc); 343 | } 344 | if (sparam == PanelExp) 345 | { 346 | if (MatrixOpen) RemoveMatrix(); 347 | else DrawMatrix(); 348 | } 349 | if (sparam == MissingHistoricalGoTo) 350 | { 351 | GoToMissing(MissingHistoricalPair, MissingHistoricalPeriod); 352 | } 353 | } 354 | else if (id == CHARTEVENT_MOUSE_MOVE) 355 | { 356 | if (StringToInteger(sparam) == 1) 357 | { 358 | if ((lparam > _XOffset + 2) && (lparam < _XOffset + 2 + PanelLabX) && 359 | (dparam > _YOffset + 2) && (dparam < _YOffset + 2 + PanelLabY)) 360 | { 361 | ChartSetInteger(ChartID(), CHART_MOUSE_SCROLL, false); // Disable chart sideways scroll. 362 | RemoveMatrix(); 363 | RemoveMissingHistorical(); 364 | _XOffset = int(lparam - 2 - PanelLabX / 2); 365 | _YOffset = int(dparam - 2 - PanelLabY / 2); 366 | UpdatePanel(); 367 | } 368 | } 369 | } 370 | } 371 | 372 | void ChangeChartPeriod(string Button) 373 | { 374 | StringReplace(Button, "*", ""); 375 | int NewPeriod = 0; 376 | if (Button == "M1") NewPeriod = PERIOD_M1; 377 | if (Button == "M5") NewPeriod = PERIOD_M5; 378 | if (Button == "M15") NewPeriod = PERIOD_M15; 379 | if (Button == "M30") NewPeriod = PERIOD_M30; 380 | if (Button == "H1") NewPeriod = PERIOD_H1; 381 | if (Button == "H4") NewPeriod = PERIOD_H4; 382 | if (Button == "D1") NewPeriod = PERIOD_D1; 383 | if (Button == "W1") NewPeriod = PERIOD_W1; 384 | if (Button == "MN1") NewPeriod = PERIOD_MN1; 385 | ChartSetSymbolPeriod(ChartID(), Symbol(), NewPeriod); 386 | } 387 | 388 | void ChangeChartSymbol(string Button) 389 | { 390 | string Pair = ""; 391 | string NewSymbol = ""; 392 | for (int i = 0; i < ArraySize(AllPairs); i++) 393 | { 394 | if (StringFind(Button, AllPairs[i]) >= 0) 395 | { 396 | Pair = AllPairs[i]; 397 | break; 398 | } 399 | } 400 | ChartSetSymbolPeriod(ChartID(), Pair, Period()); 401 | } 402 | 403 | void GoToMissing(string Pair, int Timeframe) 404 | { 405 | ChartSetSymbolPeriod(0, Pair, PeriodIndexes[Timeframe]); 406 | ChartNavigate(0, CHART_END, -(MAPeriod + 2)); 407 | } 408 | 409 | void PopulateMatrix() 410 | { 411 | if (UseEUR) PopulateMatrixRow(EUR_Index, "EUR"); 412 | if (UseGBP) PopulateMatrixRow(GBP_Index, "GBP"); 413 | if (UseUSD) PopulateMatrixRow(USD_Index, "USD"); 414 | if (UseJPY) PopulateMatrixRow(JPY_Index, "JPY"); 415 | if (UseAUD) PopulateMatrixRow(AUD_Index, "AUD"); 416 | if (UseNZD) PopulateMatrixRow(NZD_Index, "NZD"); 417 | if (UseCAD) PopulateMatrixRow(CAD_Index, "CAD"); 418 | if (UseCHF) PopulateMatrixRow(CHF_Index, "CHF"); 419 | PossibleSetup(); 420 | } 421 | 422 | void PopulateMatrixRow(int CurrencyIndex, string Currency) 423 | { 424 | int CurrencyStrength = 0; 425 | int PeriodEnabledCount = 0; 426 | for (int i = 0; i < ArraySize(PeriodIndexes); i++) 427 | { 428 | double CellValue = PopulateMatrixCell(CurrencyIndex, Currency, i); 429 | if (PeriodEnabled[i]) 430 | { 431 | PeriodEnabledCount++; 432 | if (CellValue > 0) CurrencyStrength++; 433 | if (CellValue < 0) CurrencyStrength--; 434 | } 435 | } 436 | if (CurrencyStrength == PeriodEnabledCount) StrengthMatrixCurr[CurrencyIndex][9] = 1; 437 | else if (CurrencyStrength == -PeriodEnabledCount) StrengthMatrixCurr[CurrencyIndex][9] = -1; 438 | else StrengthMatrixCurr[CurrencyIndex][9] = 0; 439 | } 440 | 441 | double PopulateMatrixCell(int CurrencyIndex, string Currency, int PeriodIndex) 442 | { 443 | double Total = 0; 444 | double TotalPrev = 0; 445 | for (int j = 0; j < ArraySize(AllPairs); j++) 446 | { 447 | if (StringFind(AllPairs[j], Currency, 0) < 0) continue; 448 | double StartValue = 0; 449 | double EndValue = 0; 450 | double DiffValue = 0; 451 | double StartValuePrev = 0; 452 | double EndValuePrev = 0; 453 | double DiffValuePrev = 0; 454 | if (CalculationMode == Mode_MA) 455 | { 456 | StartValue = iMA(AllPairs[j], PeriodIndexes[PeriodIndex], MAPeriod, 0, MAMethod, PRICE_CLOSE, BarsDifference); 457 | EndValue = iMA(AllPairs[j], PeriodIndexes[PeriodIndex], MAPeriod, 0, MAMethod, PRICE_CLOSE, 0); 458 | if (ShowAcceleration) 459 | { 460 | StartValuePrev = iMA(AllPairs[j], PeriodIndexes[PeriodIndex], MAPeriod, 0, MAMethod, PRICE_CLOSE, BarsDifference + 1); 461 | EndValuePrev = iMA(AllPairs[j], PeriodIndexes[PeriodIndex], MAPeriod, 0, MAMethod, PRICE_CLOSE, 1); 462 | } 463 | } 464 | else if (CalculationMode == Mode_CloseClose) 465 | { 466 | StartValue = iClose(AllPairs[j], PeriodIndexes[PeriodIndex], BarsDifference); 467 | EndValue = iClose(AllPairs[j], PeriodIndexes[PeriodIndex], 0); 468 | if (ShowAcceleration) 469 | { 470 | StartValuePrev = iClose(AllPairs[j], PeriodIndexes[PeriodIndex], BarsDifference + 1); 471 | EndValuePrev = iClose(AllPairs[j], PeriodIndexes[PeriodIndex], 1); 472 | } 473 | } 474 | else if (CalculationMode == Mode_RSI) 475 | { 476 | StartValue = iRSI(AllPairs[j], PeriodIndexes[PeriodIndex], RSIPeriod, PRICE_CLOSE, BarsDifference); 477 | EndValue = iRSI(AllPairs[j], PeriodIndexes[PeriodIndex], RSIPeriod, PRICE_CLOSE, 0); 478 | if (ShowAcceleration) 479 | { 480 | StartValuePrev = iRSI(AllPairs[j], PeriodIndexes[PeriodIndex], RSIPeriod, PRICE_CLOSE, BarsDifference + 1); 481 | EndValuePrev = iRSI(AllPairs[j], PeriodIndexes[PeriodIndex], RSIPeriod, PRICE_CLOSE, 1); 482 | } 483 | } 484 | else if (CalculationMode == Mode_RSIMA) 485 | { 486 | double RSITemp[]; 487 | ArrayResize(RSITemp, MAPeriod + BarsDifference + 1); 488 | for (int i = 0; i < MAPeriod + BarsDifference + 1; i++) 489 | { 490 | RSITemp[i] = iRSI(AllPairs[j], PeriodIndexes[PeriodIndex], RSIPeriod, PRICE_CLOSE, i); 491 | } 492 | StartValue = iMAOnArray(RSITemp, 0, MAPeriod, 0, MAMethod, BarsDifference); 493 | EndValue = iMAOnArray(RSITemp, 0, MAPeriod, 0, MAMethod, 0); 494 | if (ShowAcceleration) 495 | { 496 | StartValuePrev = iMAOnArray(RSITemp, 0, MAPeriod, 0, MAMethod, BarsDifference + 1); 497 | EndValuePrev = iMAOnArray(RSITemp, 0, MAPeriod, 0, MAMethod, 1); 498 | } 499 | } 500 | else if (CalculationMode == Mode_StochMain) 501 | { 502 | StartValue = iStochastic(AllPairs[j], PeriodIndexes[PeriodIndex], Stochastic_K_Period, Stochastic_D_Period, Stochastic_Slowing, MAMethod, STO_CLOSECLOSE, 0, BarsDifference); 503 | EndValue = iStochastic(AllPairs[j], PeriodIndexes[PeriodIndex], Stochastic_K_Period, Stochastic_D_Period, Stochastic_Slowing, MAMethod, STO_CLOSECLOSE, 0, 0); 504 | if (ShowAcceleration) 505 | { 506 | StartValuePrev = iStochastic(AllPairs[j], PeriodIndexes[PeriodIndex], Stochastic_K_Period, Stochastic_D_Period, Stochastic_Slowing, MAMethod, STO_CLOSECLOSE, 0, BarsDifference + 1); 507 | EndValuePrev = iStochastic(AllPairs[j], PeriodIndexes[PeriodIndex], Stochastic_K_Period, Stochastic_D_Period, Stochastic_Slowing, MAMethod, STO_CLOSECLOSE, 0, 1); 508 | } 509 | } 510 | else if (CalculationMode == Mode_StochSignal) 511 | { 512 | StartValue = iStochastic(AllPairs[j], PeriodIndexes[PeriodIndex], Stochastic_K_Period, Stochastic_D_Period, Stochastic_Slowing, MAMethod, STO_CLOSECLOSE, 1, BarsDifference); 513 | EndValue = iStochastic(AllPairs[j], PeriodIndexes[PeriodIndex], Stochastic_K_Period, Stochastic_D_Period, Stochastic_Slowing, MAMethod, STO_CLOSECLOSE, 1, 0); 514 | if (ShowAcceleration) 515 | { 516 | StartValuePrev = iStochastic(AllPairs[j], PeriodIndexes[PeriodIndex], Stochastic_K_Period, Stochastic_D_Period, Stochastic_Slowing, MAMethod, STO_CLOSECLOSE, 1, BarsDifference + 1); 517 | EndValuePrev = iStochastic(AllPairs[j], PeriodIndexes[PeriodIndex], Stochastic_K_Period, Stochastic_D_Period, Stochastic_Slowing, MAMethod, STO_CLOSECLOSE, 1, 1); 518 | } 519 | } 520 | DiffValue = EndValue - StartValue; 521 | DiffValuePrev = EndValuePrev - StartValuePrev; 522 | if ((EndValue == 0) || (StartValue == 0) || (((EndValuePrev == 0) || (StartValuePrev == 0)) && (ShowAcceleration))) 523 | { 524 | HistoricalOK = false; 525 | MissingHistoricalPair = AllPairs[j]; 526 | MissingHistoricalPeriod = PeriodIndex; 527 | } 528 | if (StartValue != 0) DiffValue = DiffValue * 100 / StartValue; 529 | if (StartValuePrev != 0) DiffValuePrev = DiffValuePrev * 100 / StartValuePrev; 530 | if (!IsBaseCurrency(Currency, AllPairs[j])) 531 | { 532 | DiffValue = -DiffValue; 533 | DiffValuePrev = -DiffValuePrev; 534 | } 535 | Total += DiffValue; 536 | TotalPrev += DiffValuePrev; 537 | } 538 | StrengthMatrixCurr[CurrencyIndex][PeriodIndex] = NormalizeDouble(Total, 4); 539 | StrengthMatrixPrev[CurrencyIndex][PeriodIndex] = NormalizeDouble(TotalPrev, 4); 540 | if ((UseOutputBuffers) && (Initialized)) 541 | { 542 | vBuffers[CurrencyIndex][PeriodIndex].OutputBuffer[0] = StrengthMatrixCurr[CurrencyIndex][PeriodIndex]; 543 | if (ShowAcceleration) aBuffers[CurrencyIndex][PeriodIndex].OutputBuffer[0] = StrengthMatrixPrev[CurrencyIndex][PeriodIndex]; 544 | } 545 | return Total; 546 | } 547 | 548 | bool IsBaseCurrency(string Currency, string Pair) 549 | { 550 | string BaseCurr = ""; 551 | string QuoteCurr = ""; 552 | string Curr1 = ""; 553 | string Curr2 = ""; 554 | int Curr1Pos = -1, Curr2Pos = -1; 555 | for (int i = 0; i < ArraySize(AllCurrencies); i++) 556 | { 557 | int Curr1PosTmp = StringFind(Pair, AllCurrencies[i], 0); 558 | int Curr2PosTmp = StringFind(Pair, AllCurrencies[i], 0); 559 | if ((Curr1 == "") && (Curr1PosTmp != -1)) 560 | { 561 | Curr1 = AllCurrencies[i]; 562 | Curr1Pos = Curr1PosTmp; 563 | } 564 | if ((Curr1 != "") && (Curr2PosTmp != -1)) 565 | { 566 | Curr2 = AllCurrencies[i]; 567 | Curr2Pos = Curr2PosTmp; 568 | } 569 | } 570 | if (Curr1Pos < Curr2Pos) 571 | { 572 | BaseCurr = Curr1; 573 | QuoteCurr = Curr2; 574 | } 575 | else 576 | { 577 | BaseCurr = Curr2; 578 | QuoteCurr = Curr1; 579 | } 580 | if (Currency == BaseCurr) return true; 581 | else return false; 582 | } 583 | 584 | int SortBy = 0; 585 | void InitializeVariables() 586 | { 587 | if (SortByPeriod == CURRENT) SortBy = Period(); 588 | if (SortByPeriod == M1) SortBy = PERIOD_M1; 589 | if (SortByPeriod == M5) SortBy = PERIOD_M5; 590 | if (SortByPeriod == M15) SortBy = PERIOD_M15; 591 | if (SortByPeriod == M30) SortBy = PERIOD_M30; 592 | if (SortByPeriod == H1) SortBy = PERIOD_H1; 593 | if (SortByPeriod == H4) SortBy = PERIOD_H4; 594 | if (SortByPeriod == D1) SortBy = PERIOD_D1; 595 | if (SortByPeriod == W1) SortBy = PERIOD_W1; 596 | if (SortByPeriod == MN1) SortBy = PERIOD_MN1; 597 | PeriodEnabled[0] = UseM1; 598 | PeriodEnabled[1] = UseM5; 599 | PeriodEnabled[2] = UseM15; 600 | PeriodEnabled[3] = UseM30; 601 | PeriodEnabled[4] = UseH1; 602 | PeriodEnabled[5] = UseH4; 603 | PeriodEnabled[6] = UseD1; 604 | PeriodEnabled[7] = UseW1; 605 | PeriodEnabled[8] = UseMN1; 606 | CurrencyEnabled[0] = UseEUR; 607 | CurrencyEnabled[1] = UseGBP; 608 | CurrencyEnabled[2] = UseUSD; 609 | CurrencyEnabled[3] = UseJPY; 610 | CurrencyEnabled[4] = UseAUD; 611 | CurrencyEnabled[5] = UseNZD; 612 | CurrencyEnabled[6] = UseCAD; 613 | CurrencyEnabled[7] = UseCHF; 614 | if (ShowType == SHOW_COLORS) 615 | { 616 | CellX = (int)MathRound(35 * DPIScale); 617 | CellY = (int)MathRound(20 * DPIScale); 618 | } 619 | if (ShowType == SHOW_VALUES) 620 | { 621 | CellX = (int)MathRound(65 * DPIScale); 622 | CellY = (int)MathRound(20 * DPIScale); 623 | } 624 | IdealBuy = -1; 625 | IdealSell = -1; 626 | HistoricalOK = true; 627 | MissingHistoricalNotified = false; 628 | MissingHistoricalPair = ""; 629 | MissingHistoricalPeriod = 0; 630 | TimeInit = TimeCurrent(); 631 | } 632 | 633 | string PanelBase = IndicatorName + "-BAS"; 634 | string PanelMove = IndicatorName + "-MOV"; 635 | string PanelOptions = IndicatorName + "-OPT"; 636 | string PanelClose = IndicatorName + "-CLO"; 637 | string PanelLabel = IndicatorName + "-LAB"; 638 | string PanelExp = IndicatorName + "-EXP"; 639 | void CreateMiniPanel() 640 | { 641 | ObjectCreate(0, PanelBase, OBJ_RECTANGLE_LABEL, 0, 0, 0); 642 | ObjectSetInteger(0, PanelBase, OBJPROP_XDISTANCE, _XOffset); 643 | ObjectSetInteger(0, PanelBase, OBJPROP_YDISTANCE, _YOffset); 644 | ObjectSetInteger(0, PanelBase, OBJPROP_XSIZE, PanelRecX); 645 | ObjectSetInteger(0, PanelBase, OBJPROP_YSIZE, PanelMovY + 4); 646 | ObjectSetInteger(0, PanelBase, OBJPROP_BGCOLOR, clrWhite); 647 | ObjectSetInteger(0, PanelBase, OBJPROP_BORDER_TYPE, BORDER_FLAT); 648 | ObjectSetInteger(0, PanelBase, OBJPROP_STATE, false); 649 | ObjectSetInteger(0, PanelBase, OBJPROP_HIDDEN, true); 650 | ObjectSetInteger(0, PanelBase, OBJPROP_FONTSIZE, int(8 * Scale)); 651 | ObjectSetInteger(0, PanelBase, OBJPROP_SELECTABLE, false); 652 | ObjectSetInteger(0, PanelBase, OBJPROP_COLOR, clrBlack); 653 | 654 | ObjectCreate(0, PanelExp, OBJ_EDIT, 0, 0, 0); 655 | ObjectSetInteger(0, PanelExp, OBJPROP_XDISTANCE, _XOffset + PanelLabX + 3); 656 | ObjectSetInteger(0, PanelExp, OBJPROP_YDISTANCE, _YOffset + 2); 657 | ObjectSetInteger(0, PanelExp, OBJPROP_XSIZE, PanelMovX); 658 | ObjectSetInteger(0, PanelExp, OBJPROP_YSIZE, PanelMovX); 659 | ObjectSetInteger(0, PanelExp, OBJPROP_BORDER_TYPE, BORDER_FLAT); 660 | ObjectSetInteger(0, PanelExp, OBJPROP_STATE, false); 661 | ObjectSetInteger(0, PanelExp, OBJPROP_HIDDEN, true); 662 | ObjectSetInteger(0, PanelExp, OBJPROP_READONLY, true); 663 | ObjectSetInteger(0, PanelExp, OBJPROP_FONTSIZE, int(12 * Scale)); 664 | ObjectSetString(0, PanelExp, OBJPROP_TOOLTIP, "Show Matrix"); 665 | ObjectSetInteger(0, PanelExp, OBJPROP_ALIGN, ALIGN_CENTER); 666 | ObjectSetString(0, PanelExp, OBJPROP_FONT, Font); 667 | ObjectSetString(0, PanelExp, OBJPROP_TEXT, "#"); 668 | ObjectSetInteger(0, PanelExp, OBJPROP_SELECTABLE, false); 669 | ObjectSetInteger(0, PanelExp, OBJPROP_COLOR, clrNavy); 670 | ObjectSetInteger(0, PanelExp, OBJPROP_BGCOLOR, clrKhaki); 671 | ObjectSetInteger(0, PanelExp, OBJPROP_BORDER_COLOR, clrBlack); 672 | 673 | ObjectCreate(0, PanelLabel, OBJ_EDIT, 0, 0, 0); 674 | ObjectSetInteger(0, PanelLabel, OBJPROP_XDISTANCE, _XOffset + 2); 675 | ObjectSetInteger(0, PanelLabel, OBJPROP_YDISTANCE, _YOffset + 2); 676 | ObjectSetInteger(0, PanelLabel, OBJPROP_XSIZE, PanelLabX); 677 | ObjectSetInteger(0, PanelLabel, OBJPROP_YSIZE, PanelLabY); 678 | ObjectSetInteger(0, PanelLabel, OBJPROP_BORDER_TYPE, BORDER_FLAT); 679 | ObjectSetInteger(0, PanelLabel, OBJPROP_STATE, false); 680 | ObjectSetInteger(0, PanelLabel, OBJPROP_HIDDEN, true); 681 | ObjectSetInteger(0, PanelLabel, OBJPROP_READONLY, true); 682 | ObjectSetString(0, PanelLabel, OBJPROP_TOOLTIP, "Drag to Move"); 683 | ObjectSetInteger(0, PanelLabel, OBJPROP_ALIGN, ALIGN_CENTER); 684 | ObjectSetString(0, PanelLabel, OBJPROP_TEXT, "STRENGTH MATRIX"); 685 | ObjectSetString(0, PanelLabel, OBJPROP_FONT, Font); 686 | ObjectSetInteger(0, PanelLabel, OBJPROP_FONTSIZE, int(12 * Scale)); 687 | ObjectSetInteger(0, PanelLabel, OBJPROP_SELECTABLE, false); 688 | ObjectSetInteger(0, PanelLabel, OBJPROP_COLOR, clrNavy); 689 | ObjectSetInteger(0, PanelLabel, OBJPROP_BGCOLOR, clrKhaki); 690 | ObjectSetInteger(0, PanelLabel, OBJPROP_BORDER_COLOR, clrBlack); 691 | } 692 | 693 | void UpdatePanel() 694 | { 695 | ObjectSetInteger(0, PanelBase, OBJPROP_XDISTANCE, _XOffset); 696 | ObjectSetInteger(0, PanelBase, OBJPROP_YDISTANCE, _YOffset); 697 | ObjectSetInteger(0, PanelExp, OBJPROP_XDISTANCE, _XOffset + PanelLabX + 3); 698 | ObjectSetInteger(0, PanelExp, OBJPROP_YDISTANCE, _YOffset + 2); 699 | ObjectSetInteger(0, PanelLabel, OBJPROP_XDISTANCE, _XOffset + 2); 700 | ObjectSetInteger(0, PanelLabel, OBJPROP_YDISTANCE, _YOffset + 2); 701 | } 702 | 703 | void CleanChart() 704 | { 705 | ObjectsDeleteAll(ChartID(), IndicatorName); 706 | } 707 | 708 | void DetectPrefixSuffix() 709 | { 710 | for (int i = 0; i < ArraySize(AllPairs); i++) 711 | { 712 | if (StringFind(Symbol(), AllPairs[i], 0) >= 0) 713 | { 714 | string SymbTemp = Symbol(); 715 | int res = StringReplace(SymbTemp, AllPairs[i], " "); 716 | string PrSuTemp[]; 717 | res = StringSplit(SymbTemp, StringGetCharacter(" ", 0), PrSuTemp); 718 | _CurrPrefix = PrSuTemp[0]; 719 | _CurrSuffix = PrSuTemp[1]; 720 | } 721 | } 722 | } 723 | 724 | void PopulatePairs() 725 | { 726 | if ((StringLen(CurrPrefix) == 0) && (StringLen(CurrSuffix) == 0)) 727 | { 728 | DetectPrefixSuffix(); 729 | } 730 | else 731 | { 732 | _CurrPrefix = CurrPrefix; 733 | _CurrSuffix = CurrSuffix; 734 | } 735 | CurrenciesUsed = 0; 736 | if (UseEUR) CurrenciesUsed++; 737 | if (UseUSD) CurrenciesUsed++; 738 | if (UseGBP) CurrenciesUsed++; 739 | if (UseJPY) CurrenciesUsed++; 740 | if (UseCAD) CurrenciesUsed++; 741 | if (UseCHF) CurrenciesUsed++; 742 | if (UseAUD) CurrenciesUsed++; 743 | if (UseNZD) CurrenciesUsed++; 744 | for (int i = 0; i < ArraySize(AllPairs); i++) 745 | { 746 | AllPairs[i] = StringConcatenate(_CurrPrefix, AllPairs[i], _CurrSuffix); 747 | } 748 | } 749 | 750 | // Checks if all required pairs are in the Market Watch, selecting it in the process. If cannot be found at all, return false to signal a critical error. 751 | bool CheckAllPairs() 752 | { 753 | for (int i = 0; i < ArraySize(AllPairs); i++) 754 | { 755 | if (!SymbolSelect(AllPairs[i], true)) // Failed to select a necessary currency pair. 756 | { 757 | Alert("Error: " + AllPairs[i] + " not found. Cannot proceed."); 758 | return false; 759 | } 760 | } 761 | return true; 762 | } 763 | 764 | string MissingHistoricalBase = IndicatorName + "-MISSHISTORY-BAS"; 765 | string MissingHistoricalLabel = IndicatorName + "-MISSHISTORY-LAB"; 766 | string MissingHistoricalGoTo = IndicatorName + "-MISSHISTORY-GOTO"; 767 | void DrawMissingHistorical() 768 | { 769 | RemoveMissingHistorical(); 770 | int MissingHistoricalRecX = MissingHistoricalLabelX + 4; 771 | 772 | int MissingHistoricalXStart = _XOffset; 773 | int MissingHistoricalYStart = _YOffset + PanelLabY + MatrixY + 6; 774 | 775 | ObjectCreate(0, MissingHistoricalBase, OBJ_RECTANGLE_LABEL, 0, 0, 0); 776 | ObjectSetInteger(0, MissingHistoricalBase, OBJPROP_XDISTANCE, MissingHistoricalXStart); 777 | ObjectSetInteger(0, MissingHistoricalBase, OBJPROP_YDISTANCE, MissingHistoricalYStart + 2); 778 | ObjectSetInteger(0, MissingHistoricalBase, OBJPROP_XSIZE, MissingHistoricalRecX); 779 | ObjectSetInteger(0, MissingHistoricalBase, OBJPROP_YSIZE, (MissingHistoricalLabelY + 2) * 2 + 1); 780 | ObjectSetInteger(0, MissingHistoricalBase, OBJPROP_BGCOLOR, clrWhite); 781 | ObjectSetInteger(0, MissingHistoricalBase, OBJPROP_BORDER_TYPE, BORDER_FLAT); 782 | ObjectSetInteger(0, MissingHistoricalBase, OBJPROP_STATE, false); 783 | ObjectSetInteger(0, MissingHistoricalBase, OBJPROP_HIDDEN, true); 784 | ObjectSetInteger(0, MissingHistoricalBase, OBJPROP_FONTSIZE, int(8 * Scale)); 785 | ObjectSetInteger(0, MissingHistoricalBase, OBJPROP_SELECTABLE, false); 786 | ObjectSetInteger(0, MissingHistoricalBase, OBJPROP_COLOR, clrBlack); 787 | 788 | ObjectCreate(0, MissingHistoricalLabel, OBJ_EDIT, 0, 0, 0); 789 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_XDISTANCE, MissingHistoricalXStart + 2); 790 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_YDISTANCE, MissingHistoricalYStart + 4); 791 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_XSIZE, MissingHistoricalLabelX); 792 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_YSIZE, MissingHistoricalLabelY); 793 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_BORDER_TYPE, BORDER_FLAT); 794 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_STATE, false); 795 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_HIDDEN, true); 796 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_READONLY, true); 797 | ObjectSetString(0, MissingHistoricalLabel, OBJPROP_TOOLTIP, "PLEASE DOWNLOAD HISTORICAL DATA FOR ALL PAIRS AND ALL TIMEFRAMES"); 798 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_ALIGN, ALIGN_CENTER); 799 | ObjectSetString(0, MissingHistoricalLabel, OBJPROP_TEXT, "HISTORICAL DATA NEEDED"); 800 | ObjectSetString(0, MissingHistoricalLabel, OBJPROP_FONT, Font); 801 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_FONTSIZE, int(10 * Scale)); 802 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_SELECTABLE, false); 803 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_COLOR, clrWhite); 804 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_BGCOLOR, clrRed); 805 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_BORDER_COLOR, clrBlack); 806 | 807 | ObjectCreate(0, MissingHistoricalGoTo, OBJ_EDIT, 0, 0, 0); 808 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_XDISTANCE, MissingHistoricalXStart + 2); 809 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_YDISTANCE, MissingHistoricalYStart + MissingHistoricalLabelY + 5); 810 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_XSIZE, MissingHistoricalLabelX); 811 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_YSIZE, MissingHistoricalLabelY); 812 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_BORDER_TYPE, BORDER_FLAT); 813 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_STATE, false); 814 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_HIDDEN, true); 815 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_READONLY, true); 816 | ObjectSetString(0, MissingHistoricalGoTo, OBJPROP_TOOLTIP, "CLICK TO GO TO THE MISSING HISTORICAL DATA"); 817 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_ALIGN, ALIGN_CENTER); 818 | ObjectSetString(0, MissingHistoricalGoTo, OBJPROP_TEXT, "GO TO - " + MissingHistoricalPair + " - " + PeriodDesc[MissingHistoricalPeriod]); 819 | ObjectSetString(0, MissingHistoricalGoTo, OBJPROP_FONT, Font); 820 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_FONTSIZE, int(10 * Scale)); 821 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_SELECTABLE, false); 822 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_COLOR, clrWhite); 823 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_BGCOLOR, clrGreen); 824 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_BORDER_COLOR, clrBlack); 825 | } 826 | 827 | void RemoveMissingHistorical() 828 | { 829 | ObjectsDeleteAll(ChartID(), IndicatorName + "-MISSHISTORY-"); 830 | } 831 | 832 | int CellX; 833 | int CellY; 834 | void DrawCell(int Row, int Column, string Value, string Tooltip, color Color, color ColorText = clrBlack) 835 | { 836 | string CellName = IndicatorName + "-M-CELL-R" + IntegerToString(Row) + "-C" + IntegerToString(Column); 837 | ObjectCreate(0, CellName, OBJ_EDIT, 0, 0, 0); 838 | ObjectSetInteger(0, CellName, OBJPROP_XDISTANCE, MatrixXStart + (CellX + 1) * Column + 2); 839 | ObjectSetInteger(0, CellName, OBJPROP_YDISTANCE, MatrixYStart + (CellY + 1) * Row + 2); 840 | ObjectSetInteger(0, CellName, OBJPROP_XSIZE, CellX); 841 | ObjectSetInteger(0, CellName, OBJPROP_YSIZE, CellY); 842 | ObjectSetInteger(0, CellName, OBJPROP_BORDER_TYPE, BORDER_FLAT); 843 | ObjectSetInteger(0, CellName, OBJPROP_STATE, false); 844 | ObjectSetInteger(0, CellName, OBJPROP_HIDDEN, true); 845 | ObjectSetInteger(0, CellName, OBJPROP_READONLY, true); 846 | ObjectSetInteger(0, CellName, OBJPROP_FONTSIZE, int(9 * Scale)); 847 | ObjectSetString(0, CellName, OBJPROP_TOOLTIP, Tooltip); 848 | ObjectSetInteger(0, CellName, OBJPROP_ALIGN, ALIGN_CENTER); 849 | ObjectSetString(0, CellName, OBJPROP_FONT, Font); 850 | ObjectSetInteger(0, CellName, OBJPROP_SELECTABLE, false); 851 | ObjectSetString(0, CellName, OBJPROP_TEXT, Value); 852 | ObjectSetInteger(0, CellName, OBJPROP_COLOR, ColorText); 853 | ObjectSetInteger(0, CellName, OBJPROP_BGCOLOR, Color); 854 | ObjectSetInteger(0, CellName, OBJPROP_BORDER_COLOR, clrBlack); 855 | } 856 | 857 | bool MatrixOpen = false; 858 | int MatrixXStart; 859 | int MatrixYStart; 860 | int MatrixY = 0; 861 | void DrawMatrix() 862 | { 863 | MatrixXStart = _XOffset; 864 | MatrixYStart = _YOffset + PanelLabY + 2 + 4; 865 | RemoveMatrix(); 866 | SortByStrength(); 867 | string MatrixBase = IndicatorName + "-M-BASE"; 868 | ObjectCreate(0, MatrixBase, OBJ_RECTANGLE_LABEL, 0, 0, 0); 869 | ObjectSetInteger(0, MatrixBase, OBJPROP_XDISTANCE, MatrixXStart); 870 | ObjectSetInteger(0, MatrixBase, OBJPROP_YDISTANCE, MatrixYStart); 871 | ObjectSetInteger(0, MatrixBase, OBJPROP_XSIZE, CellX); 872 | ObjectSetInteger(0, MatrixBase, OBJPROP_YSIZE, CellY + 2 * 2); 873 | ObjectSetInteger(0, MatrixBase, OBJPROP_BGCOLOR, clrWhite); 874 | ObjectSetInteger(0, MatrixBase, OBJPROP_BORDER_TYPE, BORDER_FLAT); 875 | ObjectSetInteger(0, MatrixBase, OBJPROP_STATE, false); 876 | ObjectSetInteger(0, MatrixBase, OBJPROP_HIDDEN, true); 877 | ObjectSetInteger(0, MatrixBase, OBJPROP_FONTSIZE, int(8 * Scale)); 878 | ObjectSetInteger(0, MatrixBase, OBJPROP_SELECTABLE, false); 879 | ObjectSetInteger(0, MatrixBase, OBJPROP_COLOR, clrBlack); 880 | int r = 0; 881 | int c = 0; 882 | int col = 0; 883 | for (int i = 0; i < 9; i++) 884 | { 885 | c = 0; 886 | color HeaderColor = clrLightCyan; 887 | if (i == 0) 888 | { 889 | for (int j = 0; j <= 10; j++) 890 | { 891 | if (j == 0) 892 | { 893 | int HoldRankTime = int(TimeCurrent() - TimeInit); 894 | DrawCell(i, 0, "", "Indicator initialized " + IntegerToString(HoldRankTime) + " seconds ago", HeaderColor); 895 | c++; 896 | } 897 | else if ((j > 0) && (j < 10)) 898 | { 899 | if (PeriodEnabled[j - 1]) 900 | { 901 | string Tooltip = "PERIOD " + PeriodDesc[j - 1] + " - CLICK TO CHANGE"; 902 | string Value = PeriodDesc[j - 1]; 903 | if (SortBy == PeriodIndexes[j - 1]) 904 | { 905 | Tooltip = "SORTED BY - " + Tooltip; 906 | Value = Value + "*"; 907 | } 908 | DrawCell(r, c, Value, Tooltip, HeaderColor); 909 | c++; 910 | } 911 | } 912 | if (j == 10) 913 | { 914 | string Value = "A"; 915 | string Tooltip = "IDEAL ACTION - B=BUY / S=SELL / W=WAIT"; 916 | DrawCell(r, c, Value, Tooltip, HeaderColor); 917 | c++; 918 | } 919 | } 920 | r++; 921 | continue; 922 | } 923 | int k = ArraySorted[i - 1]; 924 | if (!CurrencyEnabled[k]) continue; 925 | for (int j = 0; j <= 10; j++) 926 | { 927 | if (j == 0) 928 | { 929 | color Color = HeaderColor; 930 | if (StringFind(Symbol(), CurrencyDesc[k]) >= 0) Color = clrLightSkyBlue; 931 | int HoldRankTime = 0; 932 | if (StrengthMatrixCurr[k][10] == 0) HoldRankTime = int(TimeCurrent() - TimeInit); 933 | else HoldRankTime = int(TimeCurrent() - StrengthMatrixCurr[k][10]); 934 | DrawCell(r, c, CurrencyDesc[k], CurrencyDesc[k] + " - holding this position for already " + IntegerToString(HoldRankTime) + " seconds", Color); 935 | c++; 936 | } 937 | else if ((j > 0) && (j < 10)) 938 | { 939 | if (!PeriodEnabled[j - 1]) continue; 940 | double DoubleValue = StrengthMatrixCurr[k][j - 1]; 941 | string Value = DoubleToStr(DoubleValue, 4); 942 | string Tooltip = "% of change"; 943 | color Color = clrLightCyan; 944 | color ColorText = clrWhite; 945 | if (DoubleValue == 0) 946 | { 947 | Color = clrWhite; 948 | ColorText = clrBlack; 949 | } 950 | if (DoubleValue > 0) 951 | { 952 | Color = clrGreen; 953 | ColorText = clrWhite; 954 | Value = "+" + Value; 955 | } 956 | if (DoubleValue < 0) 957 | { 958 | Color = clrRed; 959 | ColorText = clrWhite; 960 | } 961 | if (ShowType == SHOW_COLORS) 962 | { 963 | Tooltip = Value; 964 | if (DoubleValue > 0) Value = ""; 965 | if (DoubleValue < 0) Value = ""; 966 | if (DoubleValue == 0) Value = ""; 967 | } 968 | if (ShowAcceleration) 969 | { 970 | double DoubleValuePrev = StrengthMatrixPrev[k][j - 1]; 971 | if ((DoubleValue <= DoubleValuePrev) && (DoubleValue < 0)) 972 | { 973 | Color = clrRed; 974 | ColorText = clrWhite; 975 | } 976 | if ((DoubleValue > DoubleValuePrev) && (DoubleValue < 0)) 977 | { 978 | ColorText = clrBlack; 979 | Color = clrGold; 980 | } 981 | if ((DoubleValue < DoubleValuePrev) && (DoubleValue > 0)) 982 | { 983 | Color = clrPaleGreen; 984 | ColorText = clrBlack; 985 | } 986 | if ((DoubleValue >= DoubleValuePrev) && (DoubleValue > 0)) 987 | { 988 | Color = clrGreen; 989 | ColorText = clrWhite; 990 | } 991 | } 992 | DrawCell(r, c, Value, Tooltip, Color, ColorText); 993 | c++; 994 | } 995 | if (j == 10) 996 | { 997 | double DoubleValue = StrengthMatrixCurr[k][j - 1]; 998 | string Value = DoubleToString(DoubleValue, 4); 999 | string Tooltip = ""; 1000 | color Color = clrLightCyan; 1001 | color ColorText = clrBlack; 1002 | if (DoubleValue > 0) 1003 | { 1004 | Color = clrGreen; 1005 | ColorText = clrWhite; 1006 | Value = "B"; 1007 | Tooltip = "POSSIBLE BUY"; 1008 | } 1009 | if (DoubleValue < 0) 1010 | { 1011 | Color = clrRed; 1012 | ColorText = clrWhite; 1013 | Value = "S"; 1014 | Tooltip = "POSSIBLE SELL"; 1015 | } 1016 | if (DoubleValue == 0) 1017 | { 1018 | Color = clrLightCyan; 1019 | ColorText = clrBlack; 1020 | Value = "W"; 1021 | Tooltip = "WAIT"; 1022 | } 1023 | DrawCell(r, c, Value, Tooltip, Color, ColorText); 1024 | c++; 1025 | } 1026 | } 1027 | r++; 1028 | if (c > col) col = c; 1029 | } 1030 | string ActionName = IndicatorName + "-M-ACTION"; 1031 | string Tooltip = "POSSIBLE SETUP OR ACTION - CLICK TO GO TO THE PAIR"; 1032 | string Value = ""; 1033 | string ValuesTmp[]; 1034 | color Color = clrWhite; 1035 | color ColorText = clrBlack; 1036 | StringSplit(IdealAction, StringGetCharacter("-", 0), ValuesTmp); 1037 | if (StringFind(IdealAction, "LONG") >= 0) 1038 | { 1039 | Value += "POSSIBLE BUY " + ValuesTmp[1]; 1040 | Color = clrGreen; 1041 | ColorText = clrWhite; 1042 | Tooltip = "POSSIBLE SETUP OR ACTION - CLICK TO GO OPEN THE PAIR"; 1043 | } 1044 | else if (StringFind(IdealAction, "SHORT") >= 0) 1045 | { 1046 | Value += "POSSIBLE SELL " + ValuesTmp[1]; 1047 | Color = clrRed; 1048 | ColorText = clrWhite; 1049 | Tooltip = "POSSIBLE SETUP OR ACTION - CLICK TO GO OPEN THE PAIR"; 1050 | } 1051 | else 1052 | { 1053 | Value += "WAIT A BETTER SETUP"; 1054 | Color = clrLightCyan; 1055 | ColorText = clrBlack; 1056 | Tooltip = "POSSIBLE SETUP OR ACTION"; 1057 | } 1058 | 1059 | ObjectCreate(0, ActionName, OBJ_EDIT, 0, 0, 0); 1060 | ObjectSetInteger(0, ActionName, OBJPROP_XDISTANCE, MatrixXStart + (CellX + 1) * 0 + 2); 1061 | ObjectSetInteger(0, ActionName, OBJPROP_YDISTANCE, MatrixYStart + (CellY + 1) * r + 2); 1062 | ObjectSetInteger(0, ActionName, OBJPROP_XSIZE, (CellX + 1) * col - 1); 1063 | ObjectSetInteger(0, ActionName, OBJPROP_YSIZE, CellY); 1064 | ObjectSetInteger(0, ActionName, OBJPROP_BORDER_TYPE, BORDER_FLAT); 1065 | ObjectSetInteger(0, ActionName, OBJPROP_STATE, false); 1066 | ObjectSetInteger(0, ActionName, OBJPROP_HIDDEN, true); 1067 | ObjectSetInteger(0, ActionName, OBJPROP_READONLY, true); 1068 | ObjectSetInteger(0, ActionName, OBJPROP_FONTSIZE, int(9 * Scale)); 1069 | ObjectSetString(0, ActionName, OBJPROP_TOOLTIP, Tooltip); 1070 | ObjectSetInteger(0, ActionName, OBJPROP_ALIGN, ALIGN_CENTER); 1071 | ObjectSetString(0, ActionName, OBJPROP_FONT, Font); 1072 | ObjectSetInteger(0, ActionName, OBJPROP_SELECTABLE, false); 1073 | ObjectSetString(0, ActionName, OBJPROP_TEXT, Value); 1074 | ObjectSetInteger(0, ActionName, OBJPROP_COLOR, ColorText); 1075 | ObjectSetInteger(0, ActionName, OBJPROP_BGCOLOR, Color); 1076 | ObjectSetInteger(0, ActionName, OBJPROP_BORDER_COLOR, clrBlack); 1077 | r++; 1078 | MatrixY = (CellY + 1) * r + 3; 1079 | ObjectSetInteger(0, MatrixBase, OBJPROP_XSIZE, (CellX + 1) * col + 3); 1080 | ObjectSetInteger(0, MatrixBase, OBJPROP_YSIZE, MatrixY); 1081 | MatrixOpen = true; 1082 | } 1083 | 1084 | void RemoveMatrix() 1085 | { 1086 | ObjectsDeleteAll(ChartID(), IndicatorName + "-M-"); 1087 | MatrixOpen = false; 1088 | } 1089 | 1090 | int ArraySorted[] = {0, 0, 0, 0, 0, 0, 0, 0}; 1091 | void SortByStrength() 1092 | { 1093 | int SortingIndex = -1; 1094 | if ((SortBy == PERIOD_M1) && (UseM1)) SortingIndex = M1_Index; 1095 | if ((SortBy == PERIOD_M5) && (UseM5)) SortingIndex = M5_Index; 1096 | if ((SortBy == PERIOD_M15) && (UseM15)) SortingIndex = M15_Index; 1097 | if ((SortBy == PERIOD_M30) && (UseM30)) SortingIndex = M30_Index; 1098 | if ((SortBy == PERIOD_H1) && (UseH1)) SortingIndex = H1_Index; 1099 | if ((SortBy == PERIOD_H4) && (UseH4)) SortingIndex = H4_Index; 1100 | if ((SortBy == PERIOD_D1) && (UseD1)) SortingIndex = D1_Index; 1101 | if ((SortBy == PERIOD_W1) && (UseW1)) SortingIndex = W1_Index; 1102 | if ((SortBy == PERIOD_MN1) && (UseMN1)) SortingIndex = MN1_Index; 1103 | if (SortingIndex == -1) 1104 | { 1105 | return; 1106 | } 1107 | double ArrayTmp[8] = {0, 0, 0, 0, 0, 0, 0, 0}; 1108 | for (int i = 0; i < ArraySize(CurrencyDesc); i++) 1109 | { 1110 | ArrayTmp[i] = StrengthMatrixCurr[i][SortingIndex]; 1111 | } 1112 | double Minimum = ArrayTmp[ArrayMinimum(ArrayTmp)] - 1; 1113 | for (int i = 0; i < ArraySize(ArraySorted); i++) 1114 | { 1115 | int PrevIndex = ArraySorted[i]; 1116 | ArraySorted[i] = ArrayMaximum(ArrayTmp); 1117 | ArrayTmp[ArrayMaximum(ArrayTmp)] = Minimum; 1118 | if (ArraySorted[i] != PrevIndex) 1119 | { 1120 | StrengthMatrixCurr[ArraySorted[i]][10] = (double)TimeCurrent(); 1121 | } 1122 | } 1123 | } 1124 | 1125 | void CheckSorting() 1126 | { 1127 | for (int i = 0; i < ArraySize(ArraySorted); i++) ArraySorted[i] = i; 1128 | int SortingIndex = -1; 1129 | if ((SortBy == PERIOD_M1) && (UseM1)) SortingIndex = M1_Index; 1130 | if ((SortBy == PERIOD_M5) && (UseM5)) SortingIndex = M5_Index; 1131 | if ((SortBy == PERIOD_M15) && (UseM15)) SortingIndex = M15_Index; 1132 | if ((SortBy == PERIOD_M30) && (UseM30)) SortingIndex = M30_Index; 1133 | if ((SortBy == PERIOD_H1) && (UseH1)) SortingIndex = H1_Index; 1134 | if ((SortBy == PERIOD_H4) && (UseH4)) SortingIndex = H4_Index; 1135 | if ((SortBy == PERIOD_D1) && (UseD1)) SortingIndex = D1_Index; 1136 | if ((SortBy == PERIOD_W1) && (UseW1)) SortingIndex = W1_Index; 1137 | if ((SortBy == PERIOD_MN1) && (UseMN1)) SortingIndex = MN1_Index; 1138 | if (SortingIndex == -1) 1139 | { 1140 | Print("Impossible to sort because the timeframe is not enabled."); 1141 | return; 1142 | } 1143 | } 1144 | 1145 | int IdealBuy = -1; 1146 | int IdealSell = -1; 1147 | string IdealAction = ""; 1148 | string IdealPair = ""; 1149 | void PossibleSetup() 1150 | { 1151 | IdealBuy = -1; 1152 | IdealSell = -1; 1153 | IdealAction = ""; 1154 | IdealPair = ""; 1155 | string Pair = ""; 1156 | for (int i = 0; i < ArraySize(ArraySorted); i++) 1157 | { 1158 | if (StrengthMatrixCurr[ArraySorted[i]][9] == 1) 1159 | { 1160 | IdealBuy = ArraySorted[i]; 1161 | break; 1162 | } 1163 | } 1164 | for (int i = ArraySize(ArraySorted) - 1; i >= 0; i--) 1165 | { 1166 | if (StrengthMatrixCurr[ArraySorted[i]][9] == -1) 1167 | { 1168 | IdealSell = ArraySorted[i]; 1169 | break; 1170 | } 1171 | } 1172 | if (IdealSell == -1 || IdealBuy == -1) 1173 | { 1174 | IdealAction = "WAIT A BETTER SETUP"; 1175 | return; 1176 | } 1177 | if (IdealSell >= 0 && IdealBuy >= 0) 1178 | { 1179 | for (int i = 0; i < ArraySize(AllPairs); i++) 1180 | { 1181 | if ((StringFind(AllPairs[i], CurrencyDesc[IdealBuy]) >= 0) && (StringFind(AllPairs[i], CurrencyDesc[IdealSell]) >= 0)) 1182 | { 1183 | Pair = AllPairs[i]; 1184 | break; 1185 | } 1186 | } 1187 | string BaseCurr = ""; 1188 | string QuoteCurr = ""; 1189 | string Curr1 = ""; 1190 | string Curr2 = ""; 1191 | int Curr1Pos = -1, Curr2Pos = -1; 1192 | for (int i = 0; i < ArraySize(AllCurrencies); i++) 1193 | { 1194 | int Curr1PosTmp = StringFind(Pair, AllCurrencies[i], 0); 1195 | int Curr2PosTmp = StringFind(Pair, AllCurrencies[i], 0); 1196 | if ((Curr1 == "") && (Curr1PosTmp != -1)) 1197 | { 1198 | Curr1 = AllCurrencies[i]; 1199 | Curr1Pos = Curr1PosTmp; 1200 | } 1201 | if ((Curr1) != "" && (Curr2PosTmp != -1)) 1202 | { 1203 | Curr2 = AllCurrencies[i]; 1204 | Curr2Pos = Curr2PosTmp; 1205 | } 1206 | } 1207 | if (Curr1Pos < Curr2Pos) 1208 | { 1209 | BaseCurr = Curr1; 1210 | QuoteCurr = Curr2; 1211 | } 1212 | else 1213 | { 1214 | BaseCurr = Curr2; 1215 | QuoteCurr = Curr1; 1216 | } 1217 | if ((BaseCurr == CurrencyDesc[IdealBuy]) && (QuoteCurr == CurrencyDesc[IdealSell])) 1218 | { 1219 | IdealAction = "LONG-" + Pair; 1220 | } 1221 | if ((BaseCurr == CurrencyDesc[IdealSell]) && (QuoteCurr == CurrencyDesc[IdealBuy])) 1222 | { 1223 | IdealAction = "SHORT-" + Pair; 1224 | } 1225 | } 1226 | IdealPair = Pair; 1227 | if (StringLen(Pair) > 0) 1228 | { 1229 | NotifyPossibleTrade(); 1230 | if ((AutoFocus) && (StringFind(Symbol(), Pair) == -1)) ChangeChartSymbol(Pair); 1231 | } 1232 | } 1233 | 1234 | bool IdealActionIsCurrChart() 1235 | { 1236 | if (StringFind(Symbol(), IdealPair) >= 0) return true; 1237 | else return false; 1238 | } 1239 | 1240 | bool IdealActionIsFirstAndLast() 1241 | { 1242 | string IdealCurr1 = CurrencyDesc[ArraySorted[0]]; 1243 | string IdealCurr2 = CurrencyDesc[ArraySorted[CurrenciesUsed - 1]]; 1244 | if ((StringFind(IdealPair, IdealCurr1) >= 0) && (StringFind(IdealPair, IdealCurr2) >= 0)) return true; 1245 | else return false; 1246 | } 1247 | 1248 | string LastAlertDirection = ""; 1249 | void NotifyPossibleTrade() 1250 | { 1251 | if (!EnableNotify) return; 1252 | if ((!SendAlert) && (!SendApp) && (!SendEmail)) return; 1253 | if ((NotifyOnlyCurrentPair) && (!IdealActionIsCurrChart())) return; 1254 | if ((NotifyOnlyFirstAndLast) && (!IdealActionIsFirstAndLast())) return; 1255 | string Setup = ""; 1256 | string ValuesTmp[]; 1257 | StringSplit(IdealAction, StringGetCharacter("-", 0), ValuesTmp); 1258 | if (LastAlertDirection == IdealAction) return; // Same arrow, don't alert again. 1259 | if (StringFind(IdealAction, "LONG") >= 0) 1260 | { 1261 | Setup += "POSSIBLE BUY " + ValuesTmp[1]; 1262 | } 1263 | else if (StringFind(IdealAction, "SHORT") >= 0) 1264 | { 1265 | Setup += "POSSIBLE SELL " + ValuesTmp[1]; 1266 | } 1267 | else 1268 | { 1269 | return; 1270 | } 1271 | string EmailSubject = IndicatorName + " Notification "; 1272 | string EmailBody = AccountCompany() + " - " + AccountName() + " - " + IntegerToString(AccountNumber()) + "\r\n" + IndicatorName + ": "; 1273 | EmailBody += Setup; 1274 | string AlertText = IndicatorName + " - "; 1275 | AlertText += Setup; 1276 | string AppText = AccountCompany() + " - " + AccountName() + " - " + IntegerToString(AccountNumber()) + " - " + IndicatorName + " - "; 1277 | AppText += Setup; 1278 | if (SendAlert) Alert(AlertText); 1279 | if (SendEmail) 1280 | { 1281 | if (!SendMail(EmailSubject, EmailBody)) Print("Error sending email " + IntegerToString(GetLastError())); 1282 | } 1283 | if (SendApp) 1284 | { 1285 | if (!SendNotification(AppText)) Print("Error sending notification " + IntegerToString(GetLastError())); 1286 | } 1287 | LastAlertDirection = IdealAction; 1288 | } 1289 | //+------------------------------------------------------------------+ -------------------------------------------------------------------------------- /MQL5/Files/EF-Icon-64x64px.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EarnForex/Currency-Strength-Matrix/f986f35da7b29828c197eea80c8246664469b5fb/MQL5/Files/EF-Icon-64x64px.ico -------------------------------------------------------------------------------- /MQL5/Include/MQLTA ErrorHandling.mqh: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EarnForex/Currency-Strength-Matrix/f986f35da7b29828c197eea80c8246664469b5fb/MQL5/Include/MQLTA ErrorHandling.mqh -------------------------------------------------------------------------------- /MQL5/Include/MQLTA Utils.mqh: -------------------------------------------------------------------------------- 1 | #property link "https://www.earnforex.com/" 2 | #property version "1.00" 3 | #property strict 4 | #property copyright "EarnForex.com - 2020" 5 | #property description "" 6 | #property description "" 7 | #property description "" 8 | #property description "" 9 | #property description "Find More on EarnForex.com" 10 | 11 | #define OP_BUY 0 //Buy 12 | #define OP_SELL 1 //Sell 13 | #define OP_BUYLIMIT 2 //Pending order of BUY LIMIT type 14 | #define OP_SELLLIMIT 3 //Pending order of SELL LIMIT type 15 | #define OP_BUYSTOP 4 //Pending order of BUY STOP type 16 | #define OP_SELLSTOP 5 //Pending order of SELL STOP type 17 | //--- 18 | #define MODE_OPEN 0 19 | #define MODE_CLOSE 3 20 | #define MODE_VOLUME 4 21 | #define MODE_REAL_VOLUME 5 22 | #define MODE_TRADES 0 23 | #define MODE_HISTORY 1 24 | #define SELECT_BY_POS 0 25 | #define SELECT_BY_TICKET 1 26 | //--- 27 | #define DOUBLE_VALUE 0 28 | #define FLOAT_VALUE 1 29 | #define LONG_VALUE INT_VALUE 30 | //--- 31 | #define CHART_BAR 0 32 | #define CHART_CANDLE 1 33 | //--- 34 | #define MODE_ASCEND 0 35 | #define MODE_DESCEND 1 36 | //--- 37 | #define MODE_LOW 1 38 | #define MODE_HIGH 2 39 | #define MODE_TIME 5 40 | #define MODE_BID 9 41 | #define MODE_ASK 10 42 | #define MODE_POINT 11 43 | #define MODE_DIGITS 12 44 | #define MODE_SPREAD 13 45 | #define MODE_STOPLEVEL 14 46 | #define MODE_LOTSIZE 15 47 | #define MODE_TICKVALUE 16 48 | #define MODE_TICKSIZE 17 49 | #define MODE_SWAPLONG 18 50 | #define MODE_SWAPSHORT 19 51 | #define MODE_STARTING 20 52 | #define MODE_EXPIRATION 21 53 | #define MODE_TRADEALLOWED 22 54 | #define MODE_MINLOT 23 55 | #define MODE_LOTSTEP 24 56 | #define MODE_MAXLOT 25 57 | #define MODE_SWAPTYPE 26 58 | #define MODE_PROFITCALCMODE 27 59 | #define MODE_MARGINCALCMODE 28 60 | #define MODE_MARGININIT 29 61 | #define MODE_MARGINMAINTENANCE 30 62 | #define MODE_MARGINHEDGED 31 63 | #define MODE_MARGINREQUIRED 32 64 | 65 | enum ENUM_HOUR{ 66 | h00=00, //00:00 67 | h01=01, //01:00 68 | h02=02, //02:00 69 | h03=03, //03:00 70 | h04=04, //04:00 71 | h05=05, //05:00 72 | h06=06, //06:00 73 | h07=07, //07:00 74 | h08=08, //08:00 75 | h09=09, //09:00 76 | h10=10, //10:00 77 | h11=11, //11:00 78 | h12=12, //12:00 79 | h13=13, //13:00 80 | h14=14, //14:00 81 | h15=15, //15:00 82 | h16=16, //16:00 83 | h17=17, //17:00 84 | h18=18, //18:00 85 | h19=19, //19:00 86 | h20=20, //20:00 87 | h21=21, //21:00 88 | h22=22, //22:00 89 | h23=23, //23:00 90 | }; 91 | 92 | ENUM_TIMEFRAMES TimeFrames[]={ 93 | PERIOD_M1, 94 | PERIOD_M2, 95 | PERIOD_M3, 96 | PERIOD_M4, 97 | PERIOD_M5, 98 | PERIOD_M6, 99 | PERIOD_M10, 100 | PERIOD_M12, 101 | PERIOD_M15, 102 | PERIOD_M20, 103 | PERIOD_M30, 104 | PERIOD_H1, 105 | PERIOD_H2, 106 | PERIOD_H3, 107 | PERIOD_H4, 108 | PERIOD_H6, 109 | PERIOD_H8, 110 | PERIOD_H12, 111 | PERIOD_D1, 112 | PERIOD_W1, 113 | PERIOD_MN1 114 | }; 115 | 116 | 117 | //Return the index of the requested time frame in the array TimeFrames 118 | int TimeFrameIndex(ENUM_TIMEFRAMES TimeFrame){ 119 | int j=0; 120 | if(TimeFrame==PERIOD_CURRENT) TimeFrame=Period(); 121 | for(int i=0;i=Start && Hour()<=End) return true; 131 | if(Start>End && ((Hour()>=Start && Hour()<=23) || (Hour()<=End && Hour()>=0))) return true; 132 | return false; 133 | } 134 | 135 | 136 | //Check if the software is over the date of use, throw a message and return true if it is 137 | bool UpdateCheckOver(string Name, datetime ExpiryDate, bool ShowAlert){ 138 | if(TimeCurrent()>ExpiryDate){ 139 | string EditText="Version Expired, This Product Must Be Updated"; 140 | string AlertText="Version Expired, Please Download The New Version From MQL4TradingAutomation.com"; 141 | DrawExpiry(Name,EditText); 142 | if(ShowAlert){ 143 | Alert(AlertText); 144 | Print(AlertText); 145 | } 146 | return true; 147 | } 148 | else return false; 149 | } 150 | 151 | //Check if the software is over the warning date and throw a message if it is 152 | void UpdateCheckWarning(string Name, datetime WarnDate, datetime ExpDate, bool ShowAlert){ 153 | if(TimeCurrent()>WarnDate){ 154 | MqlDateTime WarningDate,ExpiryDate; 155 | TimeToStruct(WarnDate,WarningDate); 156 | TimeToStruct(ExpDate,ExpiryDate); 157 | string WarningDateStr=(string)ExpiryDate.day+"/"+(string)ExpiryDate.mon+"/"+(string)ExpiryDate.year; 158 | string EditText="This Product Version Will Stop Working On The "+WarningDateStr+""; 159 | string AlertText="This Product Version Will Stop Working On The "+WarningDateStr+", Please Download The New Version From MQL4TradingAutomation.com"; 160 | DrawExpiry(Name,EditText); 161 | if(ShowAlert){ 162 | Alert(AlertText); 163 | Print(AlertText); 164 | } 165 | } 166 | } 167 | 168 | //Draw a box to advise of the warning/expiry of the product 169 | void DrawExpiry(string Name, string Text){ 170 | string TextBoxName=Name+"ExpirationTextBox"; 171 | if(ObjectFind(0,TextBoxName)<0){ 172 | DrawEdit(TextBoxName,20,20,300,20,true,8,"",ALIGN_CENTER,"Arial",Text,true,clrNavy,clrKhaki,clrBlack); 173 | } 174 | } 175 | 176 | //Draw an edit box with the specified parameters 177 | void DrawEdit( string Name, 178 | int XStart, 179 | int YStart, 180 | int Width, 181 | int Height, 182 | bool ReadOnly, 183 | int EditFontSize, 184 | string Tooltip, 185 | int Align, 186 | string EditFont, 187 | string Text, 188 | bool Selectable, 189 | color TextColor=clrBlack, 190 | color BGColor=clrWhiteSmoke, 191 | color BDColor=clrBlack 192 | ){ 193 | 194 | ObjectCreate(0,Name,OBJ_EDIT,0,0,0); 195 | ObjectSetInteger(0,Name,OBJPROP_XDISTANCE,XStart); 196 | ObjectSetInteger(0,Name,OBJPROP_YDISTANCE,YStart); 197 | ObjectSetInteger(0,Name,OBJPROP_XSIZE,Width); 198 | ObjectSetInteger(0,Name,OBJPROP_YSIZE,Height); 199 | ObjectSetInteger(0,Name,OBJPROP_BORDER_TYPE,BORDER_FLAT); 200 | ObjectSetInteger(0,Name,OBJPROP_STATE,false); 201 | ObjectSetInteger(0,Name,OBJPROP_HIDDEN,true); 202 | ObjectSetInteger(0,Name,OBJPROP_READONLY,ReadOnly); 203 | ObjectSetInteger(0,Name,OBJPROP_FONTSIZE,EditFontSize); 204 | ObjectSetString(0,Name,OBJPROP_TOOLTIP,Tooltip); 205 | ObjectSetInteger(0,Name,OBJPROP_ALIGN,Align); 206 | ObjectSetString(0,Name,OBJPROP_FONT,EditFont); 207 | ObjectSetString(0,Name,OBJPROP_TEXT,Text); 208 | ObjectSetInteger(0,Name,OBJPROP_SELECTABLE,Selectable); 209 | ObjectSetInteger(0,Name,OBJPROP_COLOR,TextColor); 210 | ObjectSetInteger(0,Name,OBJPROP_BGCOLOR,BGColor); 211 | ObjectSetInteger(0,Name,OBJPROP_BORDER_COLOR,BDColor); 212 | } 213 | 214 | 215 | string AccountCompany(){ 216 | return AccountInfoString(ACCOUNT_COMPANY); 217 | } 218 | 219 | 220 | string AccountName(){ 221 | return AccountInfoString(ACCOUNT_NAME); 222 | } 223 | 224 | 225 | long AccountNumber(){ 226 | return AccountInfoInteger(ACCOUNT_LOGIN); 227 | } 228 | 229 | string AccountCurrency(){ 230 | return AccountInfoString(ACCOUNT_CURRENCY); 231 | } 232 | 233 | double AccountBalance(){ 234 | return AccountInfoDouble(ACCOUNT_BALANCE); 235 | } 236 | 237 | double AccountEquity(){ 238 | return AccountInfoDouble(ACCOUNT_EQUITY); 239 | } 240 | 241 | double AccountFreeMargin(){ 242 | return AccountInfoDouble(ACCOUNT_MARGIN_FREE); 243 | } 244 | 245 | void SetIndex(int Index, int Type, int Style, int Width, int Color, string Label){ 246 | PlotIndexSetInteger(Index,PLOT_DRAW_TYPE,Type); 247 | PlotIndexSetInteger(Index,PLOT_LINE_STYLE,Style); 248 | PlotIndexSetInteger(Index,PLOT_LINE_WIDTH,Width); 249 | PlotIndexSetInteger(Index,PLOT_LINE_COLOR,Color); 250 | PlotIndexSetString(Index,PLOT_LABEL,Label); 251 | } 252 | 253 | int WindowFind(string Name){ 254 | return ChartWindowFind(0,Name); 255 | } 256 | 257 | string TimeFrameDescription(int TimeFrame){ 258 | string perioddesc=""; 259 | switch (TimeFrame){ 260 | case PERIOD_M1: 261 | perioddesc="M1"; 262 | break; 263 | case PERIOD_M2: 264 | perioddesc="M2"; 265 | break; 266 | case PERIOD_M3: 267 | perioddesc="M3"; 268 | break; 269 | case PERIOD_M4: 270 | perioddesc="M4"; 271 | break; 272 | case PERIOD_M5: 273 | perioddesc="M5"; 274 | break; 275 | case PERIOD_M6: 276 | perioddesc="M6"; 277 | break; 278 | case PERIOD_M10: 279 | perioddesc="M10"; 280 | break; 281 | case PERIOD_M12: 282 | perioddesc="M12"; 283 | break; 284 | case PERIOD_M15: 285 | perioddesc="M15"; 286 | break; 287 | case PERIOD_M20: 288 | perioddesc="M20"; 289 | break; 290 | case PERIOD_M30: 291 | perioddesc="M30"; 292 | break; 293 | case PERIOD_H1: 294 | perioddesc="H1"; 295 | break; 296 | case PERIOD_H2: 297 | perioddesc="H2"; 298 | break; 299 | case PERIOD_H3: 300 | perioddesc="H3"; 301 | break; 302 | case PERIOD_H4: 303 | perioddesc="H4"; 304 | break; 305 | case PERIOD_H6: 306 | perioddesc="H6"; 307 | break; 308 | case PERIOD_H8: 309 | perioddesc="H8"; 310 | break; 311 | case PERIOD_H12: 312 | perioddesc="H12"; 313 | break; 314 | case PERIOD_D1: 315 | perioddesc="D1"; 316 | break; 317 | case PERIOD_W1: 318 | perioddesc="W1"; 319 | break; 320 | case PERIOD_MN1: 321 | perioddesc="MN1"; 322 | break; 323 | } 324 | return perioddesc; 325 | } 326 | 327 | 328 | string OrderSymbol(){ 329 | return OrderGetString(ORDER_SYMBOL); 330 | } 331 | 332 | long OrderMagicNumber(){ 333 | return OrderGetInteger(ORDER_MAGIC); 334 | } 335 | 336 | double OrderStopLoss(){ 337 | return OrderGetDouble(ORDER_SL); 338 | } 339 | 340 | double OrderTakeProfit(){ 341 | return OrderGetDouble(ORDER_TP); 342 | } 343 | 344 | ENUM_ORDER_TYPE OrderType(){ 345 | return (ENUM_ORDER_TYPE)OrderGetInteger(ORDER_TYPE); 346 | } 347 | 348 | long OrderTicket(){ 349 | return OrderGetInteger(ORDER_TICKET); 350 | } 351 | 352 | long OrderOpenTime(){ 353 | return OrderGetInteger(ORDER_TIME_DONE); 354 | } 355 | 356 | double OrderOpenPrice(){ 357 | return OrderGetDouble(ORDER_PRICE_OPEN); 358 | } 359 | 360 | double OrderLots(){ 361 | return OrderGetDouble(ORDER_VOLUME_CURRENT); 362 | } 363 | 364 | int Hour(){ 365 | MqlDateTime mTime; 366 | TimeCurrent(mTime); 367 | return(mTime.hour); 368 | } -------------------------------------------------------------------------------- /MQL5/Indicators/MQLTA MT5 Currency Strength Matrix.mq5: -------------------------------------------------------------------------------- 1 | #property link "https://www.earnforex.com/metatrader-indicators/currency-strength-matrix/" 2 | #property version "1.06" 3 | #property strict 4 | #property copyright "EarnForex.com - 2019-2025" 5 | #property description "This indicator analyses the strength of a currency comparing values in several timeframes." 6 | #property description "" 7 | #property description "WARNING: Use this software at your own risk." 8 | #property description "The creator of these plugins cannot be held responsible for any damage or loss." 9 | #property description "" 10 | #property description "Find More on www.EarnForex.com" 11 | #property icon "\\Files\\EF-Icon-64x64px.ico" 12 | 13 | #include 14 | #include 15 | 16 | #property indicator_chart_window 17 | #property indicator_buffers 144 18 | #property indicator_plots 144 19 | 20 | struct SBuffer 21 | { 22 | double OutputBuffer[]; 23 | }; 24 | 25 | SBuffer vBuffers[8][9]; // Values 26 | SBuffer aBuffers[8][9]; // Acceleration 27 | 28 | enum Enum_CalculationMode 29 | { 30 | Mode_CloseClose, // Close difference 31 | Mode_MA, // MA difference 32 | Mode_RSI, // RSI difference 33 | Mode_RSIMA, // RSI MA 34 | Mode_StochMain, // Stochastic main 35 | Mode_StochSignal // Stochastic signal 36 | }; 37 | 38 | enum ENUM_SHOWTYPE 39 | { 40 | SHOW_VALUES, // Show values 41 | SHOW_COLORS, // Show colors 42 | }; 43 | 44 | enum ENUM_SORTBY 45 | { 46 | CURRENT = PERIOD_CURRENT, // Current period 47 | M1 = PERIOD_M1, // M1 48 | M5 = PERIOD_M5, // M5 49 | M15 = PERIOD_M15, // M15 50 | M30 = PERIOD_M30, // M30 51 | H1 = PERIOD_H1, // H1 52 | H4 = PERIOD_H4, // H4 53 | D1 = PERIOD_D1, // D1 54 | W1 = PERIOD_W1, // W1 55 | MN1 = PERIOD_MN1, // MN1 56 | }; 57 | 58 | input string comment_0 = "=========="; // CSM Indicator 59 | input string IndicatorName = "MQLTA-CSM"; // Indicator's Name 60 | 61 | input string comment_2 = "=========="; // Calculation 62 | input Enum_CalculationMode CalculationMode = Mode_CloseClose; // Calculation Mode 63 | input int BarsDifference = 1; // Bars Of Difference Between Calculation Values 64 | input int MAPeriod = 2; // MA Period (If Using MA Mode Higher Number Is Less Sensitive) 65 | input ENUM_MA_METHOD MAMethod = MODE_EMA; // MA Method 66 | input int RSIPeriod = 14; // RSI Period (for RSI mode) 67 | input int Stochastic_K_Period = 5; // Stochastic %K Period 68 | input int Stochastic_D_Period = 3; // Stochastic %D Period 69 | input int Stochastic_Slowing = 3; // Stochastic Slowing 70 | input bool UseOutputBuffers = false; // Use Output Buffers 71 | 72 | input string comment_4 = "=========="; // Matrix Values and Sorting 73 | input ENUM_SHOWTYPE ShowType = SHOW_COLORS; // Show Values or just Colors 74 | input ENUM_SORTBY SortByPeriod = CURRENT; // Sort Strength By 75 | input bool ShowAcceleration = false; // Show the Acceleration Color 76 | input int MinimumRefreshInterval = 5; // Minimum Refresh Interval (Seconds) 77 | 78 | input string comment_4b = "=========="; // Autofocus - If Enabled it Will Disable Notifications 79 | input bool AutoFocus = false; // Change Chart to Ideal Pair Automatically 80 | input string comment_5 = "=========="; // Notifications 81 | input bool EnableNotify = false; // Enable Notifications feature 82 | input bool SendAlert = true; // Send Alert Notification 83 | input bool SendApp = false; // Send Notification to Mobile 84 | input bool SendEmail = false; // Send Notification via Email 85 | input int WaitTimeNotify = 10; // Wait time between notifications (Minutes) 86 | input string comment_3 = "=========="; // Notify Only If 87 | input bool NotifyOnlyCurrentPair = false; // Ideal Opportunity is for the Current Chart 88 | input bool NotifyOnlyFirstAndLast = false; // Ideal Opportunity is with First and Last Currency 89 | 90 | input string comment_1 = "=========="; // Currencies to consider 91 | input bool UseEUR = true; // EUR 92 | input bool UseUSD = true; // USD 93 | input bool UseGBP = true; // GBP 94 | input bool UseJPY = true; // JPY 95 | input bool UseAUD = true; // AUD 96 | input bool UseNZD = true; // NZD 97 | input bool UseCAD = true; // CAD 98 | input bool UseCHF = true; // CHF 99 | 100 | input string comment_6 = "=========="; // Timeframes to consider 101 | input bool UseM1 = true; // M1 102 | input bool UseM5 = true; // M5 103 | input bool UseM15 = true; // M15 104 | input bool UseM30 = true; // M30 105 | input bool UseH1 = true; // H1 106 | input bool UseH4 = true; // H4 107 | input bool UseD1 = true; // D1 108 | input bool UseW1 = true; // W1 109 | input bool UseMN1 = true; // MN1 110 | 111 | input string comment_7 = "=========="; // Pairs Prefix and Suffix 112 | input string CurrPrefix = ""; // Pairs Prefix 113 | input string CurrSuffix = ""; // Pairs Suffix 114 | 115 | input string comment_1b = "=========="; // Miscellaneous 116 | input int XOffset = 20; // Horizontal Offset (pixels) 117 | input int YOffset = 20; // Vertical Offset (pixels) 118 | input double Scale = 1.0; // Scale for the Panel's Size 119 | 120 | string Font = "Consolas"; 121 | double PreChecks = false; 122 | 123 | string AllPairs[] = 124 | { 125 | "AUDCAD", 126 | "AUDCHF", 127 | "AUDJPY", 128 | "AUDNZD", 129 | "AUDUSD", 130 | "CADCHF", 131 | "CADJPY", 132 | "CHFJPY", 133 | "EURAUD", 134 | "EURCAD", 135 | "EURCHF", 136 | "EURGBP", 137 | "EURJPY", 138 | "EURNZD", 139 | "EURUSD", 140 | "GBPAUD", 141 | "GBPCAD", 142 | "GBPCHF", 143 | "GBPJPY", 144 | "GBPNZD", 145 | "GBPUSD", 146 | "NZDCAD", 147 | "NZDCHF", 148 | "NZDJPY", 149 | "NZDUSD", 150 | "USDCAD", 151 | "USDCHF", 152 | "USDJPY" 153 | }; 154 | 155 | // List all the currencies 156 | string AllCurrencies[] = 157 | { 158 | "EUR", 159 | "USD", 160 | "GBP", 161 | "JPY", 162 | "AUD", 163 | "NZD", 164 | "CAD", 165 | "CHF" 166 | }; 167 | 168 | string CurrBase; 169 | string CurrQuote; 170 | double Base[]; 171 | double Quote[]; 172 | int CurrenciesUsed = 0; 173 | string _CurrPrefix; 174 | string _CurrSuffix; 175 | int _XOffset, _YOffset; 176 | 177 | double StrengthMatrixCurr[8][11]; 178 | double StrengthMatrixPrev[8][10]; 179 | int EUR_Index = 0; 180 | int GBP_Index = 1; 181 | int USD_Index = 2; 182 | int JPY_Index = 3; 183 | int AUD_Index = 4; 184 | int NZD_Index = 5; 185 | int CAD_Index = 6; 186 | int CHF_Index = 7; 187 | 188 | int M1_Index = 0; 189 | int M5_Index = 1; 190 | int M15_Index = 2; 191 | int M30_Index = 3; 192 | int H1_Index = 4; 193 | int H4_Index = 5; 194 | int D1_Index = 6; 195 | int W1_Index = 7; 196 | int MN1_Index = 8; 197 | 198 | string CurrencyDesc[8] = {"EUR", "GBP", "USD", "JPY", "AUD", "NZD", "CAD", "CHF"}; 199 | bool CurrencyEnabled[8] = {true, true, true, true, true, true, true, true}; 200 | ENUM_TIMEFRAMES PeriodIndexes[9] = 201 | { 202 | PERIOD_M1, 203 | PERIOD_M5, 204 | PERIOD_M15, 205 | PERIOD_M30, 206 | PERIOD_H1, 207 | PERIOD_H4, 208 | PERIOD_D1, 209 | PERIOD_W1, 210 | PERIOD_MN1 211 | }; 212 | string PeriodDesc[9] = 213 | { 214 | "M1", 215 | "M5", 216 | "M15", 217 | "M30", 218 | "H1", 219 | "H4", 220 | "D1", 221 | "W1", 222 | "MN1" 223 | }; 224 | bool PeriodEnabled[9] = 225 | { 226 | true, 227 | true, 228 | true, 229 | true, 230 | true, 231 | true, 232 | true, 233 | true, 234 | true 235 | }; 236 | 237 | // For indicator values: 238 | int MAHandle[28][9]; // 28 pairs and 9 periods max. 239 | double MAValue[][28][9]; 240 | int RSIHandle[28][9]; 241 | double RSIValue[][28][9]; 242 | int StochHandle[28][9]; 243 | double StochValue[][28][9]; 244 | 245 | bool HistoricalOK = true; 246 | bool MissingHistoricalNotified = false; 247 | bool Initialized = false; 248 | string MissingHistoricalPair = ""; 249 | int MissingHistoricalPeriod = 0; 250 | 251 | datetime TimeInit = TimeCurrent(); 252 | 253 | int PanelMovX, PanelMovY, PanelLabX, PanelLabY, PanelRecX, MissingHistoricalLabelX, MissingHistoricalLabelY; 254 | 255 | double DPIScale; // Scaling parameter for the panel based on the screen DPI. 256 | 257 | string CalculationModeDesc() 258 | { 259 | string Text = ""; 260 | if (CalculationMode == Mode_CloseClose) Text = "Close difference"; 261 | else if (CalculationMode == Mode_MA) Text = "MA difference"; 262 | return Text; 263 | } 264 | 265 | int OnInit(void) 266 | { 267 | IndicatorSetString(INDICATOR_SHORTNAME, IndicatorName); 268 | IndicatorSetInteger(INDICATOR_DIGITS, 4); 269 | ChartSetInteger(0, CHART_EVENT_MOUSE_MOVE, 1); 270 | 271 | _XOffset = XOffset; 272 | _YOffset = YOffset; 273 | 274 | if (CalculationMode == Mode_MA) 275 | { 276 | if (!GetMAHandle()) return INIT_FAILED; 277 | } 278 | else if ((CalculationMode == Mode_RSI) || (CalculationMode == Mode_RSIMA)) 279 | { 280 | if (!GetRSIHandle()) return INIT_FAILED; 281 | if (CalculationMode == Mode_RSIMA) 282 | { 283 | if (!GetMAHandle()) return INIT_FAILED; // RSI MA is calculated using iMA(). 284 | } 285 | } 286 | else if ((CalculationMode == Mode_StochMain) || (CalculationMode == Mode_StochSignal)) 287 | { 288 | if (!GetStochHandle()) return INIT_FAILED; 289 | } 290 | 291 | DPIScale = Scale * (double)TerminalInfoInteger(TERMINAL_SCREEN_DPI) / 96.0; 292 | PanelMovX = (int)MathRound(26 * DPIScale); 293 | PanelMovY = (int)MathRound(26 * DPIScale); 294 | PanelLabX = (int)MathRound(160 * DPIScale); 295 | PanelLabY = PanelMovY; 296 | PanelRecX = PanelMovX * 1 + PanelLabX + 5; 297 | MissingHistoricalLabelX = (int)MathRound(187 * DPIScale); 298 | MissingHistoricalLabelY = (int)MathRound(26 * DPIScale); 299 | 300 | if (UseOutputBuffers) 301 | { 302 | // Values 303 | for (int i = 0; i < 8; i++) // Currencies 304 | { 305 | for (int j = 0; j < 9; j++) // Timeframes 306 | { 307 | SetIndexBuffer(i * 9 + j, vBuffers[i][j].OutputBuffer, INDICATOR_DATA); 308 | PlotIndexSetString(i * 9 + j, PLOT_LABEL, CurrencyDesc[i] + " @ " + PeriodDesc[j]); 309 | ArraySetAsSeries(vBuffers[i][j].OutputBuffer, true); 310 | } 311 | } 312 | // Acceleration 313 | if (ShowAcceleration) 314 | { 315 | for (int i = 0; i < 8; i++) // Currencies 316 | { 317 | for (int j = 0; j < 9; j++) // Timeframes 318 | { 319 | SetIndexBuffer(72 + i * 9 + j, aBuffers[i][j].OutputBuffer, INDICATOR_DATA); 320 | PlotIndexSetString(72 + i * 9 + j, PLOT_LABEL, "Acc" + CurrencyDesc[i] + " @ " + PeriodDesc[j]); 321 | ArraySetAsSeries(vBuffers[i][j].OutputBuffer, true); 322 | } 323 | } 324 | } 325 | } 326 | 327 | CleanChart(); 328 | PopulatePairs(); 329 | CheckAllPairs(); 330 | InitializeVariables(); 331 | CheckSorting(); 332 | if (CalculationMode == Mode_CloseClose) PopulateMatrix(); 333 | DrawMatrix(); 334 | int timeframe = ChartPeriod(0); 335 | 336 | EventSetTimer(MinimumRefreshInterval); 337 | Initialized = true; 338 | return INIT_SUCCEEDED; 339 | } 340 | 341 | void OnDeinit(const int reason) 342 | { 343 | EventKillTimer(); 344 | CleanChart(); 345 | } 346 | 347 | void OnTimer() 348 | { 349 | CreateMiniPanel(); 350 | HistoricalOK = true; 351 | 352 | if (CalculationMode == Mode_MA) 353 | { 354 | int ma_limit = BarsDifference + 1; // Current bar + BarsDifference. 355 | if (ShowAcceleration) ma_limit++; // Another bar to calculate acceleration. 356 | if (!GetMAValue(ma_limit)) HistoricalOK = false; 357 | } 358 | else if ((CalculationMode == Mode_RSI) || (CalculationMode == Mode_RSIMA)) 359 | { 360 | int rsi_limit = BarsDifference + 1; // Current bar + BarsDifference. 361 | if (ShowAcceleration) rsi_limit++; // Another bar to calculate acceleration. 362 | if (!GetRSIValue(rsi_limit)) HistoricalOK = false; 363 | if (CalculationMode == Mode_RSIMA) // RSI MA is calculated using iMA(). 364 | { 365 | int ma_limit = BarsDifference + 1; // Current bar + BarsDifference. 366 | if (ShowAcceleration) ma_limit++; // Another bar to calculate acceleration. 367 | if (!GetMAValue(ma_limit)) HistoricalOK = false; 368 | } 369 | } 370 | else if ((CalculationMode == Mode_StochMain) || (CalculationMode == Mode_StochSignal)) 371 | { 372 | int stoch_limit = BarsDifference + 1; // Current bar + BarsDifference. 373 | if (ShowAcceleration) stoch_limit++; // Another bar to calculate acceleration. 374 | if (!GetStochValue(stoch_limit)) HistoricalOK = false; 375 | } 376 | 377 | PopulateMatrix(); 378 | if (MatrixOpen) DrawMatrix(); 379 | if ((!HistoricalOK) && (MatrixOpen)) 380 | { 381 | DrawMissingHistorical(); 382 | } 383 | else 384 | { 385 | RemoveMissingHistorical(); 386 | } 387 | } 388 | 389 | int OnCalculate (const int rates_total, 390 | const int prev_calculated, 391 | const datetime& time[], 392 | const double& open[], 393 | const double& high[], 394 | const double& low[], 395 | const double& close[], 396 | const long& tick_volume[], 397 | const long& volume[], 398 | const int& spread[]) 399 | { 400 | CreateMiniPanel(); 401 | HistoricalOK = true; 402 | 403 | if (CalculationMode == Mode_MA) 404 | { 405 | int ma_limit = BarsDifference + 1; // Current bar + BarsDifference. 406 | if (ShowAcceleration) ma_limit++; // Another bar to calculate acceleration. 407 | if (!GetMAValue(ma_limit)) HistoricalOK = false; 408 | } 409 | else if ((CalculationMode == Mode_RSI) || (CalculationMode == Mode_RSIMA)) 410 | { 411 | int rsi_limit = BarsDifference + 1; // Current bar + BarsDifference. 412 | if (ShowAcceleration) rsi_limit++; // Another bar to calculate acceleration. 413 | if (!GetRSIValue(rsi_limit)) HistoricalOK = false; 414 | if (CalculationMode == Mode_RSIMA) // RSI MA is calculated using iMA(). 415 | { 416 | int ma_limit = BarsDifference + 1; // Current bar + BarsDifference. 417 | if (ShowAcceleration) ma_limit++; // Another bar to calculate acceleration. 418 | if (!GetMAValue(ma_limit)) HistoricalOK = false; 419 | } 420 | } 421 | else if ((CalculationMode == Mode_StochMain) || (CalculationMode == Mode_StochSignal)) 422 | { 423 | int stoch_limit = BarsDifference + 1; // Current bar + BarsDifference. 424 | if (ShowAcceleration) stoch_limit++; // Another bar to calculate acceleration. 425 | if (!GetStochValue(stoch_limit)) HistoricalOK = false; 426 | } 427 | 428 | PopulateMatrix(); 429 | if (MatrixOpen) DrawMatrix(); 430 | if (!HistoricalOK && MatrixOpen) 431 | { 432 | DrawMissingHistorical(); 433 | } 434 | else 435 | { 436 | RemoveMissingHistorical(); 437 | } 438 | return rates_total; 439 | } 440 | 441 | void OnChartEvent(const int id, 442 | const long &lparam, 443 | const double &dparam, 444 | const string &sparam) 445 | { 446 | if (id == CHARTEVENT_OBJECT_CLICK) 447 | { 448 | ChartSetInteger(ChartID(), CHART_MOUSE_SCROLL, true); // Enable chart sideways scroll. 449 | if (StringFind(sparam, "R0") >= 0) 450 | { 451 | string ClickDesc = ObjectGetString(0, sparam, OBJPROP_TEXT); 452 | ChangeChartPeriod(ClickDesc); 453 | } 454 | if (StringFind(sparam, "-ACTION") >= 0) 455 | { 456 | string ClickDesc = ObjectGetString(0, sparam, OBJPROP_TEXT); 457 | ChangeChartSymbol(ClickDesc); 458 | } 459 | if (sparam == PanelExp) 460 | { 461 | if (MatrixOpen) RemoveMatrix(); 462 | else DrawMatrix(); 463 | } 464 | if (sparam == MissingHistoricalGoTo) 465 | { 466 | GoToMissing(MissingHistoricalPair, MissingHistoricalPeriod); 467 | } 468 | } 469 | else if (id == CHARTEVENT_MOUSE_MOVE) 470 | { 471 | if (StringToInteger(sparam) == 1) 472 | { 473 | if ((lparam > _XOffset + 2) && (lparam < _XOffset + 2 + PanelLabX) && 474 | (dparam > _YOffset + 2) && (dparam < _YOffset + 2 + PanelLabY)) 475 | { 476 | ChartSetInteger(ChartID(), CHART_MOUSE_SCROLL, false); // Disable chart sideways scroll. 477 | RemoveMatrix(); 478 | RemoveMissingHistorical(); 479 | _XOffset = int(lparam - 2 - PanelLabX / 2); 480 | _YOffset = int(dparam - 2 - PanelLabY / 2); 481 | UpdatePanel(); 482 | } 483 | } 484 | } 485 | } 486 | 487 | void ChangeChartPeriod(string Button) 488 | { 489 | StringReplace(Button, "*", ""); 490 | ENUM_TIMEFRAMES NewPeriod = 0; 491 | if (Button == "M1") NewPeriod = PERIOD_M1; 492 | if (Button == "M5") NewPeriod = PERIOD_M5; 493 | if (Button == "M15") NewPeriod = PERIOD_M15; 494 | if (Button == "M30") NewPeriod = PERIOD_M30; 495 | if (Button == "H1") NewPeriod = PERIOD_H1; 496 | if (Button == "H4") NewPeriod = PERIOD_H4; 497 | if (Button == "D1") NewPeriod = PERIOD_D1; 498 | if (Button == "W1") NewPeriod = PERIOD_W1; 499 | if (Button == "MN1") NewPeriod = PERIOD_MN1; 500 | ChartSetSymbolPeriod(0, Symbol(), NewPeriod); 501 | } 502 | 503 | void ChangeChartSymbol(string Button) 504 | { 505 | string Pair = ""; 506 | string NewSymbol = ""; 507 | for(int i = 0; i < ArraySize(AllPairs); i++) 508 | { 509 | if (StringFind(Button, AllPairs[i]) >= 0) 510 | { 511 | Pair = AllPairs[i]; 512 | break; 513 | } 514 | } 515 | ChartSetSymbolPeriod(0, Pair, Period()); 516 | } 517 | 518 | void GoToMissing(string Pair, int Timeframe) 519 | { 520 | ChartSetSymbolPeriod(0, Pair, (ENUM_TIMEFRAMES)PeriodIndexes[Timeframe]); 521 | ChartNavigate(0, CHART_END, -(BarsDifference + 2)); 522 | } 523 | 524 | void PopulateMatrix() 525 | { 526 | if (UseEUR) PopulateMatrixRow(EUR_Index, "EUR"); 527 | if (UseGBP) PopulateMatrixRow(GBP_Index, "GBP"); 528 | if (UseUSD) PopulateMatrixRow(USD_Index, "USD"); 529 | if (UseJPY) PopulateMatrixRow(JPY_Index, "JPY"); 530 | if (UseAUD) PopulateMatrixRow(AUD_Index, "AUD"); 531 | if (UseNZD) PopulateMatrixRow(NZD_Index, "NZD"); 532 | if (UseCAD) PopulateMatrixRow(CAD_Index, "CAD"); 533 | if (UseCHF) PopulateMatrixRow(CHF_Index, "CHF"); 534 | PossibleSetup(); 535 | } 536 | 537 | void PopulateMatrixRow(int CurrencyIndex, string Currency) 538 | { 539 | int CurrencyStrength = 0; 540 | int PeriodEnabledCount = 0; 541 | for(int i = 0; i < ArraySize(PeriodIndexes); i++) 542 | { 543 | double CellValue = PopulateMatrixCell(CurrencyIndex, Currency, i); 544 | if (PeriodEnabled[i]) 545 | { 546 | PeriodEnabledCount++; 547 | if (CellValue > 0) CurrencyStrength++; 548 | if (CellValue < 0) CurrencyStrength--; 549 | } 550 | } 551 | if (CurrencyStrength == PeriodEnabledCount) StrengthMatrixCurr[CurrencyIndex][9] = 1; 552 | else if (CurrencyStrength == -PeriodEnabledCount) StrengthMatrixCurr[CurrencyIndex][9] = -1; 553 | else StrengthMatrixCurr[CurrencyIndex][9] = 0; 554 | } 555 | 556 | double PopulateMatrixCell(int CurrencyIndex, string Currency, int PeriodIndex) 557 | { 558 | double Total = 0; 559 | double TotalPrev = 0; 560 | for(int j = 0; j < ArraySize(AllPairs); j++) 561 | { 562 | if (StringFind(AllPairs[j], Currency, 0) < 0) continue; 563 | double StartValue = 0; 564 | double EndValue = 0; 565 | double DiffValue = 0; 566 | double StartValuePrev = 0; 567 | double EndValuePrev = 0; 568 | double DiffValuePrev = 0; 569 | if ((CalculationMode == Mode_MA) || (CalculationMode == Mode_RSIMA)) // In RSI MA, the MA buffer already contains MA over RSI. 570 | { 571 | StartValue = MAValue[BarsDifference][j][PeriodIndex]; 572 | EndValue = MAValue[0][j][PeriodIndex]; 573 | if (ShowAcceleration) 574 | { 575 | StartValuePrev = MAValue[BarsDifference + 1][j][PeriodIndex]; 576 | EndValuePrev = MAValue[1][j][PeriodIndex]; 577 | } 578 | } 579 | else if (CalculationMode == Mode_CloseClose) 580 | { 581 | StartValue = iClose(AllPairs[j], PeriodIndexes[PeriodIndex], BarsDifference); 582 | EndValue = iClose(AllPairs[j], PeriodIndexes[PeriodIndex], 0); 583 | if (ShowAcceleration) 584 | { 585 | StartValuePrev = iClose(AllPairs[j], PeriodIndexes[PeriodIndex], BarsDifference + 1); 586 | EndValuePrev = iClose(AllPairs[j], PeriodIndexes[PeriodIndex], 1); 587 | } 588 | } 589 | else if (CalculationMode == Mode_RSI) 590 | { 591 | StartValue = RSIValue[BarsDifference][j][PeriodIndex]; 592 | EndValue = RSIValue[0][j][PeriodIndex]; 593 | if (ShowAcceleration) 594 | { 595 | StartValuePrev = RSIValue[BarsDifference + 1][j][PeriodIndex]; 596 | EndValuePrev = RSIValue[1][j][PeriodIndex]; 597 | } 598 | } 599 | else if ((CalculationMode == Mode_StochMain) || (CalculationMode == Mode_StochSignal)) 600 | { 601 | StartValue = StochValue[BarsDifference][j][PeriodIndex]; 602 | EndValue = StochValue[0][j][PeriodIndex]; 603 | if (ShowAcceleration) 604 | { 605 | StartValuePrev = StochValue[BarsDifference + 1][j][PeriodIndex]; 606 | EndValuePrev = StochValue[1][j][PeriodIndex]; 607 | } 608 | } 609 | 610 | DiffValue = EndValue - StartValue; 611 | DiffValuePrev = EndValuePrev - StartValuePrev; 612 | if ((EndValue == 0) || (StartValue == 0) || (((EndValuePrev == 0) || (StartValuePrev == 0)) && (ShowAcceleration))) 613 | { 614 | HistoricalOK = false; 615 | MissingHistoricalPair = AllPairs[j]; 616 | MissingHistoricalPeriod = PeriodIndex; 617 | } 618 | if (StartValue != 0) DiffValue = (DiffValue * 100 / StartValue); 619 | if (StartValuePrev != 0) DiffValuePrev = (DiffValuePrev * 100 / StartValuePrev); 620 | if (!IsBaseCurrency(Currency, AllPairs[j])) 621 | { 622 | DiffValue = -DiffValue; 623 | DiffValuePrev = -DiffValuePrev; 624 | } 625 | Total += DiffValue; 626 | TotalPrev += DiffValuePrev; 627 | } 628 | StrengthMatrixCurr[CurrencyIndex][PeriodIndex] = NormalizeDouble(Total, 4); 629 | StrengthMatrixPrev[CurrencyIndex][PeriodIndex] = NormalizeDouble(TotalPrev, 4); 630 | if ((UseOutputBuffers) && (Initialized)) 631 | { 632 | vBuffers[CurrencyIndex][PeriodIndex].OutputBuffer[0] = StrengthMatrixCurr[CurrencyIndex][PeriodIndex]; 633 | if (ShowAcceleration) aBuffers[CurrencyIndex][PeriodIndex].OutputBuffer[0] = StrengthMatrixPrev[CurrencyIndex][PeriodIndex]; 634 | } 635 | return Total; 636 | } 637 | 638 | bool IsBaseCurrency(string Currency, string Pair) 639 | { 640 | string BaseCurr = ""; 641 | string QuoteCurr = ""; 642 | string Curr1 = ""; 643 | string Curr2 = ""; 644 | int Curr1Pos = -1, Curr2Pos = -1; 645 | for (int i = 0; i < ArraySize(AllCurrencies); i++) 646 | { 647 | int Curr1PosTmp = StringFind(Pair, AllCurrencies[i], 0); 648 | int Curr2PosTmp = StringFind(Pair, AllCurrencies[i], 0); 649 | if ((Curr1 == "") && (Curr1PosTmp != -1)) 650 | { 651 | Curr1 = AllCurrencies[i]; 652 | Curr1Pos = Curr1PosTmp; 653 | } 654 | if ((Curr1 != "") && (Curr2PosTmp != -1)) 655 | { 656 | Curr2 = AllCurrencies[i]; 657 | Curr2Pos = Curr2PosTmp; 658 | } 659 | } 660 | if (Curr1Pos < Curr2Pos) 661 | { 662 | BaseCurr = Curr1; 663 | QuoteCurr = Curr2; 664 | } 665 | else 666 | { 667 | BaseCurr = Curr2; 668 | QuoteCurr = Curr1; 669 | } 670 | if (Currency == BaseCurr) return true; 671 | else return false; 672 | } 673 | 674 | int SortBy = 0; 675 | void InitializeVariables() 676 | { 677 | if (SortByPeriod == CURRENT) SortBy = Period(); 678 | if (SortByPeriod == M1) SortBy = PERIOD_M1; 679 | if (SortByPeriod == M5) SortBy = PERIOD_M5; 680 | if (SortByPeriod == M15) SortBy = PERIOD_M15; 681 | if (SortByPeriod == M30) SortBy = PERIOD_M30; 682 | if (SortByPeriod == H1) SortBy = PERIOD_H1; 683 | if (SortByPeriod == H4) SortBy = PERIOD_H4; 684 | if (SortByPeriod == D1) SortBy = PERIOD_D1; 685 | if (SortByPeriod == W1) SortBy = PERIOD_W1; 686 | if (SortByPeriod == MN1) SortBy = PERIOD_MN1; 687 | PeriodEnabled[0] = UseM1; 688 | PeriodEnabled[1] = UseM5; 689 | PeriodEnabled[2] = UseM15; 690 | PeriodEnabled[3] = UseM30; 691 | PeriodEnabled[4] = UseH1; 692 | PeriodEnabled[5] = UseH4; 693 | PeriodEnabled[6] = UseD1; 694 | PeriodEnabled[7] = UseW1; 695 | PeriodEnabled[8] = UseMN1; 696 | CurrencyEnabled[0] = UseEUR; 697 | CurrencyEnabled[1] = UseGBP; 698 | CurrencyEnabled[2] = UseUSD; 699 | CurrencyEnabled[3] = UseJPY; 700 | CurrencyEnabled[4] = UseAUD; 701 | CurrencyEnabled[5] = UseNZD; 702 | CurrencyEnabled[6] = UseCAD; 703 | CurrencyEnabled[7] = UseCHF; 704 | if (ShowType == SHOW_COLORS) 705 | { 706 | CellX = (int)MathRound(35 * DPIScale); 707 | CellY = (int)MathRound(20 * DPIScale); 708 | } 709 | if (ShowType == SHOW_VALUES) 710 | { 711 | CellX = (int)MathRound(65 * DPIScale); 712 | CellY = (int)MathRound(20 * DPIScale); 713 | } 714 | IdealBuy = -1; 715 | IdealSell = -1; 716 | HistoricalOK = true; 717 | MissingHistoricalNotified = false; 718 | MissingHistoricalPair = ""; 719 | MissingHistoricalPeriod = 0; 720 | TimeInit = TimeCurrent(); 721 | } 722 | 723 | string PanelBase = IndicatorName + "-BAS"; 724 | string PanelMove = IndicatorName + "-MOV"; 725 | string PanelOptions = IndicatorName + "-OPT"; 726 | string PanelClose = IndicatorName + "-CLO"; 727 | string PanelLabel = IndicatorName + "-LAB"; 728 | string PanelExp = IndicatorName + "-EXP"; 729 | void CreateMiniPanel() 730 | { 731 | ObjectCreate(0, PanelBase, OBJ_RECTANGLE_LABEL, 0, 0, 0); 732 | ObjectSetInteger(0, PanelBase, OBJPROP_XDISTANCE, _XOffset); 733 | ObjectSetInteger(0, PanelBase, OBJPROP_YDISTANCE, _YOffset); 734 | ObjectSetInteger(0, PanelBase, OBJPROP_XSIZE, PanelRecX); 735 | ObjectSetInteger(0, PanelBase, OBJPROP_YSIZE, PanelMovY + 2 * 2); 736 | ObjectSetInteger(0, PanelBase, OBJPROP_BGCOLOR, clrWhite); 737 | ObjectSetInteger(0, PanelBase, OBJPROP_BORDER_TYPE, BORDER_FLAT); 738 | ObjectSetInteger(0, PanelBase, OBJPROP_STATE, false); 739 | ObjectSetInteger(0, PanelBase, OBJPROP_HIDDEN, true); 740 | ObjectSetInteger(0, PanelBase, OBJPROP_FONTSIZE, int(8 * Scale)); 741 | ObjectSetInteger(0, PanelBase, OBJPROP_SELECTABLE, false); 742 | ObjectSetInteger(0, PanelBase, OBJPROP_COLOR, clrBlack); 743 | 744 | ObjectCreate(0, PanelExp, OBJ_EDIT, 0, 0, 0); 745 | ObjectSetInteger(0, PanelExp, OBJPROP_XDISTANCE, _XOffset + PanelLabX + 3); 746 | ObjectSetInteger(0, PanelExp, OBJPROP_YDISTANCE, _YOffset + 2); 747 | ObjectSetInteger(0, PanelExp, OBJPROP_XSIZE, PanelMovX); 748 | ObjectSetInteger(0, PanelExp, OBJPROP_YSIZE, PanelMovX); 749 | ObjectSetInteger(0, PanelExp, OBJPROP_BORDER_TYPE, BORDER_FLAT); 750 | ObjectSetInteger(0, PanelExp, OBJPROP_STATE, false); 751 | ObjectSetInteger(0, PanelExp, OBJPROP_HIDDEN, true); 752 | ObjectSetInteger(0, PanelExp, OBJPROP_READONLY, true); 753 | ObjectSetInteger(0, PanelExp, OBJPROP_FONTSIZE, int(12 * Scale)); 754 | ObjectSetString(0, PanelExp, OBJPROP_TOOLTIP, "Show Matrix"); 755 | ObjectSetInteger(0, PanelExp, OBJPROP_ALIGN, ALIGN_CENTER); 756 | ObjectSetString(0, PanelExp, OBJPROP_FONT, Font); 757 | ObjectSetString(0, PanelExp, OBJPROP_TEXT, "#"); 758 | ObjectSetInteger(0, PanelExp, OBJPROP_SELECTABLE, false); 759 | ObjectSetInteger(0, PanelExp, OBJPROP_COLOR, clrNavy); 760 | ObjectSetInteger(0, PanelExp, OBJPROP_BGCOLOR, clrKhaki); 761 | ObjectSetInteger(0, PanelExp, OBJPROP_BORDER_COLOR, clrBlack); 762 | 763 | ObjectCreate(0, PanelLabel, OBJ_EDIT, 0, 0, 0); 764 | ObjectSetInteger(0, PanelLabel, OBJPROP_XDISTANCE, _XOffset + 2); 765 | ObjectSetInteger(0, PanelLabel, OBJPROP_YDISTANCE, _YOffset + 2); 766 | ObjectSetInteger(0, PanelLabel, OBJPROP_XSIZE, PanelLabX); 767 | ObjectSetInteger(0, PanelLabel, OBJPROP_YSIZE, PanelLabY); 768 | ObjectSetInteger(0, PanelLabel, OBJPROP_BORDER_TYPE, BORDER_FLAT); 769 | ObjectSetInteger(0, PanelLabel, OBJPROP_STATE, false); 770 | ObjectSetInteger(0, PanelLabel, OBJPROP_HIDDEN, true); 771 | ObjectSetInteger(0, PanelLabel, OBJPROP_READONLY, true); 772 | ObjectSetString(0, PanelLabel, OBJPROP_TOOLTIP, "Drag to Move"); 773 | ObjectSetInteger(0, PanelLabel, OBJPROP_ALIGN, ALIGN_CENTER); 774 | ObjectSetString(0, PanelLabel, OBJPROP_TEXT, "STRENGTH MATRIX"); 775 | ObjectSetString(0, PanelLabel, OBJPROP_FONT, Font); 776 | ObjectSetInteger(0, PanelLabel, OBJPROP_FONTSIZE, int(12 * Scale)); 777 | ObjectSetInteger(0, PanelLabel, OBJPROP_SELECTABLE, false); 778 | ObjectSetInteger(0, PanelLabel, OBJPROP_COLOR, clrNavy); 779 | ObjectSetInteger(0, PanelLabel, OBJPROP_BGCOLOR, clrKhaki); 780 | ObjectSetInteger(0, PanelLabel, OBJPROP_BORDER_COLOR, clrBlack); 781 | } 782 | 783 | void UpdatePanel() 784 | { 785 | ObjectSetInteger(0, PanelBase, OBJPROP_XDISTANCE, _XOffset); 786 | ObjectSetInteger(0, PanelBase, OBJPROP_YDISTANCE, _YOffset); 787 | ObjectSetInteger(0, PanelExp, OBJPROP_XDISTANCE, _XOffset + PanelLabX + 3); 788 | ObjectSetInteger(0, PanelExp, OBJPROP_YDISTANCE, _YOffset + 2); 789 | ObjectSetInteger(0, PanelLabel, OBJPROP_XDISTANCE, _XOffset + 2); 790 | ObjectSetInteger(0, PanelLabel, OBJPROP_YDISTANCE, _YOffset + 2); 791 | ChartRedraw(); 792 | } 793 | 794 | void CleanChart() 795 | { 796 | ObjectsDeleteAll(ChartID(), IndicatorName); 797 | ChartRedraw(); 798 | } 799 | 800 | void DetectPrefixSuffix() 801 | { 802 | for (int i = 0; i < ArraySize(AllPairs); i++) 803 | { 804 | if (StringFind(Symbol(), AllPairs[i], 0) >= 0) 805 | { 806 | string SymbTemp = Symbol(); 807 | int res = StringReplace(SymbTemp, AllPairs[i], " "); 808 | string PrSuTemp[]; 809 | res = StringSplit(SymbTemp, StringGetCharacter(" ", 0), PrSuTemp); 810 | _CurrPrefix = PrSuTemp[0]; 811 | _CurrSuffix = PrSuTemp[1]; 812 | } 813 | } 814 | } 815 | 816 | void PopulatePairs() 817 | { 818 | if ((StringLen(CurrPrefix) == 0) && (StringLen(CurrSuffix) == 0)) 819 | { 820 | DetectPrefixSuffix(); 821 | } 822 | else 823 | { 824 | _CurrPrefix = CurrPrefix; 825 | _CurrSuffix = CurrSuffix; 826 | } 827 | CurrenciesUsed = 0; 828 | if (UseEUR) CurrenciesUsed++; 829 | if (UseUSD) CurrenciesUsed++; 830 | if (UseGBP) CurrenciesUsed++; 831 | if (UseJPY) CurrenciesUsed++; 832 | if (UseCAD) CurrenciesUsed++; 833 | if (UseCHF) CurrenciesUsed++; 834 | if (UseAUD) CurrenciesUsed++; 835 | if (UseNZD) CurrenciesUsed++; 836 | for (int i = 0; i < ArraySize(AllPairs); i++) 837 | { 838 | AllPairs[i] = _CurrPrefix + AllPairs[i] + _CurrSuffix; 839 | } 840 | } 841 | 842 | // Checks if all required pairs are in the Market Watch, selecting it in the process. If cannot be found at all, return false to signal a critical error. 843 | bool CheckAllPairs() 844 | { 845 | for (int i = 0; i < ArraySize(AllPairs); i++) 846 | { 847 | if (!SymbolSelect(AllPairs[i], true)) // Failed to select a necessary currency pair. 848 | { 849 | Alert("Error: " + AllPairs[i] + " not found. Cannot proceed."); 850 | return false; 851 | } 852 | } 853 | return true; 854 | } 855 | 856 | string MissingHistoricalBase = IndicatorName + "-MISSHISTORY-BAS"; 857 | string MissingHistoricalLabel = IndicatorName + "-MISSHISTORY-LAB"; 858 | string MissingHistoricalGoTo = IndicatorName + "-MISSHISTORY-GOTO"; 859 | void DrawMissingHistorical() 860 | { 861 | RemoveMissingHistorical(); 862 | int MissingHistoricalRecX = MissingHistoricalLabelX + 4; 863 | 864 | int MissingHistoricalXStart = _XOffset; 865 | int MissingHistoricalYStart = _YOffset + PanelLabY + MatrixY + 6; 866 | 867 | ObjectCreate(0, MissingHistoricalBase, OBJ_RECTANGLE_LABEL, 0, 0, 0); 868 | ObjectSetInteger(0, MissingHistoricalBase, OBJPROP_XDISTANCE, MissingHistoricalXStart); 869 | ObjectSetInteger(0, MissingHistoricalBase, OBJPROP_YDISTANCE, MissingHistoricalYStart + 2); 870 | ObjectSetInteger(0, MissingHistoricalBase, OBJPROP_XSIZE, MissingHistoricalRecX); 871 | ObjectSetInteger(0, MissingHistoricalBase, OBJPROP_YSIZE, (MissingHistoricalLabelY + 2) * 2 + 1); 872 | ObjectSetInteger(0, MissingHistoricalBase, OBJPROP_BGCOLOR, clrWhite); 873 | ObjectSetInteger(0, MissingHistoricalBase, OBJPROP_BORDER_TYPE, BORDER_FLAT); 874 | ObjectSetInteger(0, MissingHistoricalBase, OBJPROP_STATE, false); 875 | ObjectSetInteger(0, MissingHistoricalBase, OBJPROP_HIDDEN, true); 876 | ObjectSetInteger(0, MissingHistoricalBase, OBJPROP_FONTSIZE, int(8 * Scale)); 877 | ObjectSetInteger(0, MissingHistoricalBase, OBJPROP_SELECTABLE, false); 878 | ObjectSetInteger(0, MissingHistoricalBase, OBJPROP_COLOR, clrBlack); 879 | 880 | ObjectCreate(0, MissingHistoricalLabel, OBJ_EDIT, 0, 0, 0); 881 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_XDISTANCE, MissingHistoricalXStart + 2); 882 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_YDISTANCE, MissingHistoricalYStart + 4); 883 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_XSIZE, MissingHistoricalLabelX); 884 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_YSIZE, MissingHistoricalLabelY); 885 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_BORDER_TYPE, BORDER_FLAT); 886 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_STATE, false); 887 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_HIDDEN, true); 888 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_READONLY, true); 889 | ObjectSetString(0, MissingHistoricalLabel, OBJPROP_TOOLTIP, "PLEASE DOWNLOAD HISTORICAL DATA FOR ALL PAIRS AND ALL TIMEFRAMES"); 890 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_ALIGN, ALIGN_CENTER); 891 | ObjectSetString(0, MissingHistoricalLabel, OBJPROP_TEXT, "HISTORICAL DATA NEEDED"); 892 | ObjectSetString(0, MissingHistoricalLabel, OBJPROP_FONT, Font); 893 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_FONTSIZE, int(10 * Scale)); 894 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_SELECTABLE, false); 895 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_COLOR, clrWhite); 896 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_BGCOLOR, clrRed); 897 | ObjectSetInteger(0, MissingHistoricalLabel, OBJPROP_BORDER_COLOR, clrBlack); 898 | 899 | ObjectCreate(0, MissingHistoricalGoTo, OBJ_EDIT, 0, 0, 0); 900 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_XDISTANCE, MissingHistoricalXStart + 2); 901 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_YDISTANCE, MissingHistoricalYStart + MissingHistoricalLabelY + 5); 902 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_XSIZE, MissingHistoricalLabelX); 903 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_YSIZE, MissingHistoricalLabelY); 904 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_BORDER_TYPE, BORDER_FLAT); 905 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_STATE, false); 906 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_HIDDEN, true); 907 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_READONLY, true); 908 | ObjectSetString(0, MissingHistoricalGoTo, OBJPROP_TOOLTIP, "CLICK TO GO TO THE MISSING HISTORICAL DATA"); 909 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_ALIGN, ALIGN_CENTER); 910 | ObjectSetString(0, MissingHistoricalGoTo, OBJPROP_TEXT, "GO TO - " + MissingHistoricalPair + " - " + PeriodDesc[MissingHistoricalPeriod]); 911 | ObjectSetString(0, MissingHistoricalGoTo, OBJPROP_FONT, Font); 912 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_FONTSIZE, int(10 * Scale)); 913 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_SELECTABLE, false); 914 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_COLOR, clrWhite); 915 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_BGCOLOR, clrGreen); 916 | ObjectSetInteger(0, MissingHistoricalGoTo, OBJPROP_BORDER_COLOR, clrBlack); 917 | } 918 | 919 | void RemoveMissingHistorical() 920 | { 921 | ObjectsDeleteAll(ChartID(), IndicatorName + "-MISSHISTORY-"); 922 | } 923 | 924 | int CellX; 925 | int CellY; 926 | void DrawCell(int Row, int Column, string Value, string Tooltip, color Color, color ColorText = clrBlack) 927 | { 928 | string CellName = IndicatorName + "-M-CELL-R" + IntegerToString(Row) + "-C" + IntegerToString(Column); 929 | 930 | ObjectCreate(0, CellName, OBJ_EDIT, 0, 0, 0); 931 | ObjectSetInteger(0, CellName, OBJPROP_XDISTANCE, MatrixXStart + (CellX + 1) * Column + 2); 932 | ObjectSetInteger(0, CellName, OBJPROP_YDISTANCE, MatrixYStart + (CellY + 1) * Row + 2); 933 | ObjectSetInteger(0, CellName, OBJPROP_XSIZE, CellX); 934 | ObjectSetInteger(0, CellName, OBJPROP_YSIZE, CellY); 935 | ObjectSetInteger(0, CellName, OBJPROP_BORDER_TYPE, BORDER_FLAT); 936 | ObjectSetInteger(0, CellName, OBJPROP_STATE, false); 937 | ObjectSetInteger(0, CellName, OBJPROP_HIDDEN, true); 938 | ObjectSetInteger(0, CellName, OBJPROP_READONLY, true); 939 | ObjectSetInteger(0, CellName, OBJPROP_FONTSIZE, int(9 * Scale)); 940 | ObjectSetString(0, CellName, OBJPROP_TOOLTIP, Tooltip); 941 | ObjectSetInteger(0, CellName, OBJPROP_ALIGN, ALIGN_CENTER); 942 | ObjectSetString(0, CellName, OBJPROP_FONT, Font); 943 | ObjectSetInteger(0, CellName, OBJPROP_SELECTABLE, false); 944 | ObjectSetString(0, CellName, OBJPROP_TEXT, Value); 945 | ObjectSetInteger(0, CellName, OBJPROP_COLOR, ColorText); 946 | ObjectSetInteger(0, CellName, OBJPROP_BGCOLOR, Color); 947 | ObjectSetInteger(0, CellName, OBJPROP_BORDER_COLOR, clrBlack); 948 | } 949 | 950 | 951 | bool MatrixOpen = false; 952 | int MatrixXStart; 953 | int MatrixYStart; 954 | int MatrixY = 0; 955 | void DrawMatrix() 956 | { 957 | MatrixXStart = _XOffset; 958 | MatrixYStart = _YOffset + PanelLabY + 2 + 4; 959 | RemoveMatrix(); 960 | SortByStrength(); 961 | string MatrixBase = IndicatorName + "-M-BASE"; 962 | ObjectCreate(0, MatrixBase, OBJ_RECTANGLE_LABEL, 0, 0, 0); 963 | ObjectSetInteger(0, MatrixBase, OBJPROP_XDISTANCE, MatrixXStart); 964 | ObjectSetInteger(0, MatrixBase, OBJPROP_YDISTANCE, MatrixYStart); 965 | ObjectSetInteger(0, MatrixBase, OBJPROP_XSIZE, CellX); 966 | ObjectSetInteger(0, MatrixBase, OBJPROP_YSIZE, CellY + 2 * 2); 967 | ObjectSetInteger(0, MatrixBase, OBJPROP_BGCOLOR, clrWhite); 968 | ObjectSetInteger(0, MatrixBase, OBJPROP_BORDER_TYPE, BORDER_FLAT); 969 | ObjectSetInteger(0, MatrixBase, OBJPROP_STATE, false); 970 | ObjectSetInteger(0, MatrixBase, OBJPROP_HIDDEN, true); 971 | ObjectSetInteger(0, MatrixBase, OBJPROP_FONTSIZE, int(8 * Scale)); 972 | ObjectSetInteger(0, MatrixBase, OBJPROP_SELECTABLE, false); 973 | ObjectSetInteger(0, MatrixBase, OBJPROP_COLOR, clrBlack); 974 | int r = 0; 975 | int c = 0; 976 | int col = 0; 977 | for (int i = 0; i < 9; i++) 978 | { 979 | c = 0; 980 | color HeaderColor = clrLightCyan; 981 | if (i == 0) 982 | { 983 | for (int j = 0; j <= 10; j++) 984 | { 985 | if (j == 0) 986 | { 987 | int HoldRankTime = int(TimeCurrent() - TimeInit); 988 | DrawCell(i, 0, "", "Indicator initialized " + IntegerToString(HoldRankTime) + " seconds ago", HeaderColor); 989 | c++; 990 | } 991 | else if ((j > 0) && (j < 10)) 992 | { 993 | if (PeriodEnabled[j - 1]) 994 | { 995 | string Tooltip = "PERIOD " + PeriodDesc[j - 1] + " - CLICK TO CHANGE"; 996 | string Value = PeriodDesc[j - 1]; 997 | if (SortBy == PeriodIndexes[j - 1]) 998 | { 999 | Tooltip = "SORTED BY - " + Tooltip; 1000 | Value = Value + "*"; 1001 | } 1002 | DrawCell(r, c, Value, Tooltip, HeaderColor); 1003 | c++; 1004 | } 1005 | } 1006 | if (j == 10) 1007 | { 1008 | string Value = "A"; 1009 | string Tooltip = "IDEAL ACTION - B=BUY / S=SELL / W=WAIT"; 1010 | DrawCell(r, c, Value, Tooltip, HeaderColor); 1011 | c++; 1012 | } 1013 | } 1014 | r++; 1015 | continue; 1016 | } 1017 | int k = ArraySorted[i - 1]; 1018 | if (!CurrencyEnabled[k]) continue; 1019 | for (int j = 0; j <= 10; j++) 1020 | { 1021 | if (j == 0) 1022 | { 1023 | color Color = HeaderColor; 1024 | if (StringFind(Symbol(), CurrencyDesc[k]) >= 0) Color = clrLightSkyBlue; 1025 | int HoldRankTime = 0; 1026 | if (StrengthMatrixCurr[k][10] == 0) HoldRankTime = int(TimeCurrent() - TimeInit); 1027 | else HoldRankTime = int(TimeCurrent() - StrengthMatrixCurr[k][10]); 1028 | DrawCell(r, c, CurrencyDesc[k], CurrencyDesc[k] + " - holding this position for already " + IntegerToString(HoldRankTime) + " seconds", Color); 1029 | c++; 1030 | } 1031 | else if ((j > 0) && (j < 10)) 1032 | { 1033 | if (!PeriodEnabled[j - 1]) continue; 1034 | double DoubleValue = StrengthMatrixCurr[k][j - 1]; 1035 | string Value = DoubleToString(DoubleValue, 4); 1036 | string Tooltip = "% of change"; 1037 | color Color = clrLightCyan; 1038 | color ColorText = clrWhite; 1039 | if (DoubleValue == 0) 1040 | { 1041 | Color = clrWhite; 1042 | ColorText = clrBlack; 1043 | } 1044 | if (DoubleValue > 0) 1045 | { 1046 | Color = clrGreen; 1047 | ColorText = clrWhite; 1048 | Value = "+" + Value; 1049 | } 1050 | if (DoubleValue < 0) 1051 | { 1052 | Color = clrRed; 1053 | ColorText = clrWhite; 1054 | } 1055 | if (ShowType == SHOW_COLORS) 1056 | { 1057 | Tooltip = Value; 1058 | if (DoubleValue > 0) Value = ""; 1059 | if (DoubleValue < 0) Value = ""; 1060 | if (DoubleValue == 0) Value = ""; 1061 | } 1062 | if (ShowAcceleration) 1063 | { 1064 | double DoubleValuePrev = StrengthMatrixPrev[k][j - 1]; 1065 | if ((DoubleValue <= DoubleValuePrev) && (DoubleValue < 0)) 1066 | { 1067 | Color = clrRed; 1068 | ColorText = clrWhite; 1069 | } 1070 | if ((DoubleValue > DoubleValuePrev) && (DoubleValue < 0)) 1071 | { 1072 | ColorText = clrBlack; 1073 | Color = clrGold; 1074 | } 1075 | if ((DoubleValue < DoubleValuePrev) && (DoubleValue > 0)) 1076 | { 1077 | Color = clrPaleGreen; 1078 | ColorText = clrBlack; 1079 | } 1080 | if ((DoubleValue >= DoubleValuePrev) && (DoubleValue > 0)) 1081 | { 1082 | Color = clrGreen; 1083 | ColorText = clrWhite; 1084 | } 1085 | } 1086 | DrawCell(r, c, Value, Tooltip, Color, ColorText); 1087 | c++; 1088 | } 1089 | if (j == 10) 1090 | { 1091 | double DoubleValue = StrengthMatrixCurr[k][j - 1]; 1092 | string Value = DoubleToString(DoubleValue, 4); 1093 | string Tooltip = ""; 1094 | color Color = clrLightCyan; 1095 | color ColorText = clrBlack; 1096 | if (DoubleValue > 0) 1097 | { 1098 | Color = clrGreen; 1099 | ColorText = clrWhite; 1100 | Value = "B"; 1101 | Tooltip = "POSSIBLE BUY"; 1102 | } 1103 | if (DoubleValue < 0) 1104 | { 1105 | Color = clrRed; 1106 | ColorText = clrWhite; 1107 | Value = "S"; 1108 | Tooltip = "POSSIBLE SELL"; 1109 | } 1110 | if (DoubleValue == 0) 1111 | { 1112 | Color = clrLightCyan; 1113 | ColorText = clrBlack; 1114 | Value = "W"; 1115 | Tooltip = "WAIT"; 1116 | } 1117 | DrawCell(r, c, Value, Tooltip, Color, ColorText); 1118 | c++; 1119 | } 1120 | } 1121 | r++; 1122 | if (c > col) col = c; 1123 | } 1124 | string ActionName = IndicatorName + "-M-ACTION"; 1125 | string Tooltip = "POSSIBLE SETUP OR ACTION - CLICK TO GO TO THE PAIR"; 1126 | string Value = ""; 1127 | string ValuesTmp[]; 1128 | color Color = clrWhite; 1129 | color ColorText = clrBlack; 1130 | StringSplit(IdealAction, StringGetCharacter("-", 0), ValuesTmp); 1131 | if (StringFind(IdealAction, "LONG") >= 0) 1132 | { 1133 | Value += "POSSIBLE BUY " + ValuesTmp[1]; 1134 | Color = clrGreen; 1135 | ColorText = clrWhite; 1136 | Tooltip = "POSSIBLE SETUP OR ACTION - CLICK TO GO OPEN THE PAIR"; 1137 | } 1138 | else if (StringFind(IdealAction, "SHORT") >= 0) 1139 | { 1140 | Value += "POSSIBLE SELL " + ValuesTmp[1]; 1141 | Color = clrRed; 1142 | ColorText = clrWhite; 1143 | Tooltip = "POSSIBLE SETUP OR ACTION - CLICK TO GO OPEN THE PAIR"; 1144 | } 1145 | else 1146 | { 1147 | Value += "WAIT A BETTER SETUP"; 1148 | Color = clrLightCyan; 1149 | ColorText = clrBlack; 1150 | Tooltip = "POSSIBLE SETUP OR ACTION"; 1151 | } 1152 | 1153 | ObjectCreate(0, ActionName, OBJ_EDIT, 0, 0, 0); 1154 | ObjectSetInteger(0, ActionName, OBJPROP_XDISTANCE, MatrixXStart + (CellX + 1) * 0 + 2); 1155 | ObjectSetInteger(0, ActionName, OBJPROP_YDISTANCE, MatrixYStart + (CellY + 1) * r + 2); 1156 | ObjectSetInteger(0, ActionName, OBJPROP_XSIZE, (CellX + 1) * col - 1); 1157 | ObjectSetInteger(0, ActionName, OBJPROP_YSIZE, CellY); 1158 | ObjectSetInteger(0, ActionName, OBJPROP_BORDER_TYPE, BORDER_FLAT); 1159 | ObjectSetInteger(0, ActionName, OBJPROP_STATE, false); 1160 | ObjectSetInteger(0, ActionName, OBJPROP_HIDDEN, true); 1161 | ObjectSetInteger(0, ActionName, OBJPROP_READONLY, true); 1162 | ObjectSetInteger(0, ActionName, OBJPROP_FONTSIZE, int(9 * Scale)); 1163 | ObjectSetString(0, ActionName, OBJPROP_TOOLTIP, Tooltip); 1164 | ObjectSetInteger(0, ActionName, OBJPROP_ALIGN, ALIGN_CENTER); 1165 | ObjectSetString(0, ActionName, OBJPROP_FONT, Font); 1166 | ObjectSetInteger(0, ActionName, OBJPROP_SELECTABLE, false); 1167 | ObjectSetString(0, ActionName, OBJPROP_TEXT, Value); 1168 | ObjectSetInteger(0, ActionName, OBJPROP_COLOR, ColorText); 1169 | ObjectSetInteger(0, ActionName, OBJPROP_BGCOLOR, Color); 1170 | ObjectSetInteger(0, ActionName, OBJPROP_BORDER_COLOR, clrBlack); 1171 | r++; 1172 | MatrixY = (CellY + 1) * r + 3; 1173 | ObjectSetInteger(0, MatrixBase, OBJPROP_XSIZE, (CellX + 1) * col + 3); 1174 | ObjectSetInteger(0, MatrixBase, OBJPROP_YSIZE, MatrixY); 1175 | MatrixOpen = true; 1176 | ChartRedraw(); 1177 | } 1178 | 1179 | void RemoveMatrix() 1180 | { 1181 | ObjectsDeleteAll(ChartID(), IndicatorName + "-M-"); 1182 | MatrixOpen = false; 1183 | } 1184 | 1185 | 1186 | int ArraySorted[] = {0, 0, 0, 0, 0, 0, 0, 0}; 1187 | void SortByStrength() 1188 | { 1189 | int SortingIndex = -1; 1190 | if ((SortBy == PERIOD_M1) && (UseM1)) SortingIndex = M1_Index; 1191 | if ((SortBy == PERIOD_M5) && (UseM5)) SortingIndex = M5_Index; 1192 | if ((SortBy == PERIOD_M15) && (UseM15)) SortingIndex = M15_Index; 1193 | if ((SortBy == PERIOD_M30) && (UseM30)) SortingIndex = M30_Index; 1194 | if ((SortBy == PERIOD_H1) && (UseH1)) SortingIndex = H1_Index; 1195 | if ((SortBy == PERIOD_H4) && (UseH4)) SortingIndex = H4_Index; 1196 | if ((SortBy == PERIOD_D1) && (UseD1)) SortingIndex = D1_Index; 1197 | if ((SortBy == PERIOD_W1) && (UseW1)) SortingIndex = W1_Index; 1198 | if ((SortBy == PERIOD_MN1) && (UseMN1)) SortingIndex = MN1_Index; 1199 | if (SortingIndex == -1) 1200 | { 1201 | return; 1202 | } 1203 | double ArrayTmp[8] = {0, 0, 0, 0, 0, 0, 0, 0}; 1204 | for (int i = 0; i < ArraySize(CurrencyDesc); i++) 1205 | { 1206 | ArrayTmp[i] = StrengthMatrixCurr[i][SortingIndex]; 1207 | } 1208 | double Minimum = ArrayTmp[ArrayMinimum(ArrayTmp)] - 1; 1209 | for (int i = 0; i < ArraySize(ArraySorted); i++) 1210 | { 1211 | int PrevIndex = ArraySorted[i]; 1212 | ArraySorted[i] = ArrayMaximum(ArrayTmp); 1213 | ArrayTmp[ArrayMaximum(ArrayTmp)] = Minimum; 1214 | if (ArraySorted[i] != PrevIndex) 1215 | { 1216 | StrengthMatrixCurr[ArraySorted[i]][10] = (double)TimeCurrent(); 1217 | } 1218 | } 1219 | } 1220 | 1221 | void CheckSorting() 1222 | { 1223 | for (int i = 0; i < ArraySize(ArraySorted); i++) ArraySorted[i] = i; 1224 | int SortingIndex = -1; 1225 | if ((SortBy == PERIOD_M1) && (UseM1)) SortingIndex = M1_Index; 1226 | if ((SortBy == PERIOD_M5) && (UseM5)) SortingIndex = M5_Index; 1227 | if ((SortBy == PERIOD_M15) && (UseM15)) SortingIndex = M15_Index; 1228 | if ((SortBy == PERIOD_M30) && (UseM30)) SortingIndex = M30_Index; 1229 | if ((SortBy == PERIOD_H1) && (UseH1)) SortingIndex = H1_Index; 1230 | if ((SortBy == PERIOD_H4) && (UseH4)) SortingIndex = H4_Index; 1231 | if ((SortBy == PERIOD_D1) && (UseD1)) SortingIndex = D1_Index; 1232 | if ((SortBy == PERIOD_W1) && (UseW1)) SortingIndex = W1_Index; 1233 | if ((SortBy == PERIOD_MN1) && (UseMN1)) SortingIndex = MN1_Index; 1234 | if (SortingIndex == -1) 1235 | { 1236 | Print("Impossible to sort because the timeframe is not enabled."); 1237 | return; 1238 | } 1239 | } 1240 | 1241 | 1242 | int IdealBuy = -1; 1243 | int IdealSell = -1; 1244 | string IdealAction = ""; 1245 | string IdealPair = ""; 1246 | void PossibleSetup() 1247 | { 1248 | IdealBuy = -1; 1249 | IdealSell = -1; 1250 | IdealAction = ""; 1251 | IdealPair = ""; 1252 | string Pair = ""; 1253 | for (int i = 0; i < ArraySize(ArraySorted); i++) 1254 | { 1255 | if (StrengthMatrixCurr[ArraySorted[i]][9] == 1) 1256 | { 1257 | IdealBuy = ArraySorted[i]; 1258 | break; 1259 | } 1260 | } 1261 | for (int i = ArraySize(ArraySorted) - 1; i >= 0; i--) 1262 | { 1263 | if (StrengthMatrixCurr[ArraySorted[i]][9] == -1) 1264 | { 1265 | IdealSell = ArraySorted[i]; 1266 | break; 1267 | } 1268 | } 1269 | if (IdealSell == -1 || IdealBuy == -1) 1270 | { 1271 | IdealAction = "WAIT A BETTER SETUP"; 1272 | return; 1273 | } 1274 | if (IdealSell >= 0 && IdealBuy >= 0) 1275 | { 1276 | for (int i = 0; i < ArraySize(AllPairs); i++) 1277 | { 1278 | if ((StringFind(AllPairs[i], CurrencyDesc[IdealBuy]) >= 0) && (StringFind(AllPairs[i], CurrencyDesc[IdealSell]) >= 0)) 1279 | { 1280 | Pair = AllPairs[i]; 1281 | break; 1282 | } 1283 | } 1284 | string BaseCurr = ""; 1285 | string QuoteCurr = ""; 1286 | string Curr1 = ""; 1287 | string Curr2 = ""; 1288 | int Curr1Pos = -1, Curr2Pos = -1; 1289 | for (int i = 0; i < ArraySize(AllCurrencies); i++) 1290 | { 1291 | int Curr1PosTmp = StringFind(Pair, AllCurrencies[i], 0); 1292 | int Curr2PosTmp = StringFind(Pair, AllCurrencies[i], 0); 1293 | if ((Curr1 == "") && (Curr1PosTmp != -1)) 1294 | { 1295 | Curr1 = AllCurrencies[i]; 1296 | Curr1Pos = Curr1PosTmp; 1297 | } 1298 | if ((Curr1) != "" && (Curr2PosTmp != -1)) 1299 | { 1300 | Curr2 = AllCurrencies[i]; 1301 | Curr2Pos = Curr2PosTmp; 1302 | } 1303 | } 1304 | if (Curr1Pos < Curr2Pos) 1305 | { 1306 | BaseCurr = Curr1; 1307 | QuoteCurr = Curr2; 1308 | } 1309 | else 1310 | { 1311 | BaseCurr = Curr2; 1312 | QuoteCurr = Curr1; 1313 | } 1314 | if ((BaseCurr == CurrencyDesc[IdealBuy]) && (QuoteCurr == CurrencyDesc[IdealSell])) 1315 | { 1316 | IdealAction = "LONG-" + Pair; 1317 | } 1318 | if ((BaseCurr == CurrencyDesc[IdealSell]) && (QuoteCurr == CurrencyDesc[IdealBuy])) 1319 | { 1320 | IdealAction = "SHORT-" + Pair; 1321 | } 1322 | } 1323 | IdealPair = Pair; 1324 | if (StringLen(Pair) > 0) 1325 | { 1326 | NotifyPossibleTrade(); 1327 | if ((AutoFocus) && (StringFind(Symbol(), Pair) == -1)) ChangeChartSymbol(Pair); 1328 | } 1329 | } 1330 | 1331 | bool IdealActionIsCurrChart() 1332 | { 1333 | if (StringFind(Symbol(), IdealPair) >= 0) return true; 1334 | else return false; 1335 | } 1336 | 1337 | bool IdealActionIsFirstAndLast() 1338 | { 1339 | string IdealCurr1 = CurrencyDesc[ArraySorted[0]]; 1340 | string IdealCurr2 = CurrencyDesc[ArraySorted[CurrenciesUsed - 1]]; 1341 | if ((StringFind(IdealPair, IdealCurr1) >= 0) && (StringFind(IdealPair, IdealCurr2) >= 0)) return true; 1342 | else return false; 1343 | } 1344 | 1345 | string LastAlertDirection = ""; 1346 | void NotifyPossibleTrade() 1347 | { 1348 | if (!EnableNotify) return; 1349 | if ((!SendAlert) && (!SendApp) && (!SendEmail)) return; 1350 | if ((NotifyOnlyCurrentPair) && (!IdealActionIsCurrChart())) return; 1351 | if ((NotifyOnlyFirstAndLast) && (!IdealActionIsFirstAndLast())) return; 1352 | string Setup = ""; 1353 | string ValuesTmp[]; 1354 | StringSplit(IdealAction, StringGetCharacter("-", 0), ValuesTmp); 1355 | if (LastAlertDirection == IdealAction) return; // Same arrow, don't alert again. 1356 | if (StringFind(IdealAction, "LONG") >= 0) 1357 | { 1358 | Setup += "POSSIBLE BUY " + ValuesTmp[1]; 1359 | } 1360 | else if (StringFind(IdealAction, "SHORT") >= 0) 1361 | { 1362 | Setup += "POSSIBLE SELL " + ValuesTmp[1]; 1363 | } 1364 | else 1365 | { 1366 | return; 1367 | } 1368 | string EmailSubject = IndicatorName + " " + Setup; 1369 | string EmailBody = AccountCompany() + " - " + AccountName() + " - " + IntegerToString(AccountNumber()) + "\r\n" + IndicatorName + " Notification:\r\n"; 1370 | EmailBody += Setup; 1371 | string AppText = AccountCompany() + " - " + AccountName() + " - " + IntegerToString(AccountNumber()) + " - " + IndicatorName + " - "; 1372 | AppText += Setup; 1373 | if (SendAlert) Alert(Setup); 1374 | if (SendEmail) 1375 | { 1376 | if (!SendMail(EmailSubject, EmailBody)) Print("Error sending email " + IntegerToString(GetLastError())); 1377 | } 1378 | if (SendApp) 1379 | { 1380 | if (!SendNotification(AppText)) Print("Error sending notification " + IntegerToString(GetLastError())); 1381 | } 1382 | LastAlertDirection = IdealAction; 1383 | } 1384 | 1385 | bool GetMAHandle() 1386 | { 1387 | for (int i = 0; i < ArraySize(AllPairs); i++) 1388 | { 1389 | for (int j = 0; j < ArraySize(PeriodIndexes); j++) 1390 | { 1391 | if (PeriodEnabled[j]) 1392 | { 1393 | if (CalculationMode == Mode_MA) MAHandle[i][j] = iMA(AllPairs[i], PeriodIndexes[j], MAPeriod, 0, MAMethod, PRICE_CLOSE); 1394 | else if (CalculationMode == Mode_RSIMA) MAHandle[i][j] = iMA(AllPairs[i], PeriodIndexes[j], MAPeriod, 0, MAMethod, RSIHandle[i][j]); 1395 | if (MAHandle[i][j] == INVALID_HANDLE) 1396 | { 1397 | Print("MA handle initialization failed for ", AllPairs[i], " @ ", PeriodIndexes[j], "."); 1398 | return false; 1399 | } 1400 | } 1401 | } 1402 | } 1403 | return true; 1404 | } 1405 | 1406 | bool GetRSIHandle() 1407 | { 1408 | for (int i = 0; i < ArraySize(AllPairs); i++) 1409 | { 1410 | for (int j = 0; j < ArraySize(PeriodIndexes); j++) 1411 | { 1412 | if (PeriodEnabled[j]) 1413 | { 1414 | RSIHandle[i][j] = iRSI(AllPairs[i], PeriodIndexes[j], RSIPeriod, PRICE_CLOSE); 1415 | if (RSIHandle[i][j] == INVALID_HANDLE) 1416 | { 1417 | Print("RSI handle initialization failed for ", AllPairs[i], " @ ", PeriodIndexes[j], "."); 1418 | return false; 1419 | } 1420 | } 1421 | } 1422 | } 1423 | return true; 1424 | } 1425 | 1426 | bool GetStochHandle() 1427 | { 1428 | for (int i = 0; i < ArraySize(AllPairs); i++) 1429 | { 1430 | for (int j = 0; j < ArraySize(PeriodIndexes); j++) 1431 | { 1432 | if (PeriodEnabled[j]) 1433 | { 1434 | StochHandle[i][j] = iStochastic(AllPairs[i], PeriodIndexes[j], Stochastic_K_Period, Stochastic_D_Period, Stochastic_Slowing, MAMethod, STO_CLOSECLOSE); 1435 | if (StochHandle[i][j] == INVALID_HANDLE) 1436 | { 1437 | Print("Stochastic handle initialization failed for ", AllPairs[i], " @ ", PeriodIndexes[j], "."); 1438 | return false; 1439 | } 1440 | } 1441 | } 1442 | } 1443 | return true; 1444 | } 1445 | 1446 | bool GetMAValue(int Max) 1447 | { 1448 | ArrayResize(MAValue, Max); 1449 | for (int i = 0; i < ArraySize(AllPairs); i++) 1450 | { 1451 | for (int j = 0; j < ArraySize(PeriodIndexes); j++) 1452 | { 1453 | if (PeriodEnabled[j]) 1454 | { 1455 | double MAValueTemp[]; 1456 | 1457 | ArrayResize(MAValueTemp, Max); 1458 | ArrayInitialize(MAValueTemp, EMPTY_VALUE); 1459 | ArraySetAsSeries(MAValueTemp, true); 1460 | 1461 | int c = CopyBuffer(MAHandle[i][j], 0, 0, Max, MAValueTemp); 1462 | if (c < 0) 1463 | { 1464 | Print("MA: Error copying ", AllPairs[i], " @ ", PeriodDesc[j], " data - ", GetLastErrorText(GetLastError()), " - ", GetLastError(), " - index: ", i); 1465 | return false; 1466 | } 1467 | if (c < Max) 1468 | { 1469 | Print("MA: Not enough values for ", AllPairs[i], " @ ", PeriodDesc[j], " data - ", GetLastErrorText(GetLastError()), " - ", GetLastError(), " - index: ", i, " found only ", c); 1470 | HistoricalOK = false; 1471 | MissingHistoricalPair = AllPairs[i]; 1472 | return false; 1473 | } 1474 | for (int k = 0; k < ArraySize(MAValueTemp); k++) 1475 | { 1476 | if (MAValueTemp[k] == EMPTY_VALUE) 1477 | { 1478 | Print("MA: Value not valid for for ", AllPairs[i], " @ ", PeriodDesc[j], " value - ", MAValueTemp[k], " - shift ", k, " - index: ", i); 1479 | HistoricalOK = false; 1480 | MissingHistoricalPair = AllPairs[i]; 1481 | return false; 1482 | } 1483 | MAValue[k][i][j] = MAValueTemp[k]; 1484 | } 1485 | } 1486 | } 1487 | } 1488 | return true; 1489 | } 1490 | 1491 | bool GetRSIValue(int Max) 1492 | { 1493 | ArrayResize(RSIValue, Max); 1494 | for (int i = 0; i < ArraySize(AllPairs); i++) 1495 | { 1496 | for (int j = 0; j < ArraySize(PeriodIndexes); j++) 1497 | { 1498 | if (PeriodEnabled[j]) 1499 | { 1500 | double RSIValueTemp[]; 1501 | 1502 | ArrayResize(RSIValueTemp, Max); 1503 | ArrayInitialize(RSIValueTemp, EMPTY_VALUE); 1504 | ArraySetAsSeries(RSIValueTemp, true); 1505 | 1506 | int c = CopyBuffer(RSIHandle[i][j], 0, 0, Max, RSIValueTemp); 1507 | if (c < 0) 1508 | { 1509 | Print("RSI: Error copying ", AllPairs[i], " @ ", PeriodDesc[j], " data - ", GetLastErrorText(GetLastError()), " - ", GetLastError(), " - index: ", i); 1510 | return false; 1511 | } 1512 | if (c < Max) 1513 | { 1514 | Print("RSI: Not enough values for ", AllPairs[i], " @ ", PeriodDesc[j], " data - ", GetLastErrorText(GetLastError()), " - ", GetLastError(), " - index: ", i, " found only ", c); 1515 | HistoricalOK = false; 1516 | MissingHistoricalPair = AllPairs[i]; 1517 | return false; 1518 | } 1519 | for (int k = 0; k < ArraySize(RSIValueTemp); k++) 1520 | { 1521 | if (RSIValueTemp[k] == EMPTY_VALUE) 1522 | { 1523 | Print("RSI: Value not valid for for ", AllPairs[i], " @ ", PeriodDesc[j], " value - ", RSIValueTemp[k], " - shift ", k, " - index: ", i); 1524 | HistoricalOK = false; 1525 | MissingHistoricalPair = AllPairs[i]; 1526 | return false; 1527 | } 1528 | RSIValue[k][i][j] = RSIValueTemp[k]; 1529 | } 1530 | } 1531 | } 1532 | } 1533 | return true; 1534 | } 1535 | 1536 | bool GetStochValue(int Max) 1537 | { 1538 | ArrayResize(StochValue, Max); 1539 | for (int i = 0; i < ArraySize(AllPairs); i++) 1540 | { 1541 | for (int j = 0; j < ArraySize(PeriodIndexes); j++) 1542 | { 1543 | if (PeriodEnabled[j]) 1544 | { 1545 | double StochValueTemp[]; 1546 | 1547 | ArrayResize(StochValueTemp, Max); 1548 | ArrayInitialize(StochValueTemp, EMPTY_VALUE); 1549 | ArraySetAsSeries(StochValueTemp, true); 1550 | 1551 | int buf_number = 0; 1552 | if (CalculationMode == Mode_StochMain) buf_number = 0; 1553 | else if (CalculationMode == Mode_StochSignal) buf_number = 1; 1554 | 1555 | int c = CopyBuffer(StochHandle[i][j], buf_number, 0, Max, StochValueTemp); 1556 | if (c < 0) 1557 | { 1558 | Print("Stochastic: Error copying ", AllPairs[i], " @ ", PeriodDesc[j], " data - ", GetLastErrorText(GetLastError()), " - ", GetLastError(), " - index: ", i); 1559 | return false; 1560 | } 1561 | if (c < Max) 1562 | { 1563 | Print("Stochastic: Not enough values for ", AllPairs[i], " @ ", PeriodDesc[j], " data - ", GetLastErrorText(GetLastError()), " - ", GetLastError(), " - index: ", i, " found only ", c); 1564 | HistoricalOK = false; 1565 | MissingHistoricalPair = AllPairs[i]; 1566 | return false; 1567 | } 1568 | for (int k = 0; k < ArraySize(StochValueTemp); k++) 1569 | { 1570 | if (StochValueTemp[k] == EMPTY_VALUE) 1571 | { 1572 | Print("Stochastic: Value not valid for for ", AllPairs[i], " @ ", PeriodDesc[j], " value - ", StochValueTemp[k], " - shift ", k, " - index: ", i); 1573 | HistoricalOK = false; 1574 | MissingHistoricalPair = AllPairs[i]; 1575 | return false; 1576 | } 1577 | StochValue[k][i][j] = StochValueTemp[k]; 1578 | } 1579 | } 1580 | } 1581 | } 1582 | return true; 1583 | } 1584 | //+------------------------------------------------------------------+ -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Currency Strength Matrix 2 | 3 | Currency Strength Matrix is a custom MetaTrader indicator that calculates total strength of eight major currencies based on multiple currency pairs and timeframes. It is coded by EarnForex.com for MT4 and MT5. The indicator is displayed as a customizable chart panel. 4 | 5 | It supports all three alert types: native, mobile, and email. 6 | 7 | ![Currency Strength Matrix example chart with a table of strength for all currencies](https://github.com/EarnForex/Currency-Strength-Matrix/blob/main/README_Images/currency-strength-matrix-indicator-example.png) 8 | 9 | More information about this custom MetaTrader indicator is available here: https://www.earnforex.com/indicators/currency-strength-matrix/ 10 | 11 | All contributions to the code are welcome! 12 | -------------------------------------------------------------------------------- /README_Images/currency-strength-matrix-indicator-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/EarnForex/Currency-Strength-Matrix/f986f35da7b29828c197eea80c8246664469b5fb/README_Images/currency-strength-matrix-indicator-example.png --------------------------------------------------------------------------------