MQL4 (MT4): indicator loads but does not displlay

MQL4 (MT4): indicator loads but does not displlay

Manage alerts

Loading saved threads...

Bono · External communityPost link
External question — Stack Overflow Stack Exchange Author: Bono Original post: https://stackoverflow.com/questions/79267431 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. In MT4 (MetaTrader 4) I wish to display the DXY indicator in the sub window of the chart automatically if the currency pair on the chart has USD in it (EURUSD, USDCAD, USDJPY, etc.). Otherwise, automatically remove it from the chart. The indicator named Dollar_Index.ex4 is located in the ../MQL4 /indicators/MLWS folder This is the MQL4 code I wrote to achieve this: //--- install DXY indicator for USD pairs --------------------------> void CheckAndInstallDXY() { int subWindowIndex = 1; // We are checking Subwindow 1 Print("Installing DXY in Subwindow 1..."); double handle = iCustom(Symbol(), Period(), "MLWS\\Dollar_Index", 0, 0, subWindowIndex); WindowRedraw(); if (handle > 0) { Print("DXY indicator successfully installed."); indiCount=1; } else { Print("Failed to install DXY indicator."); indiCount=0; } } When I execute the code and afterwards click on the Experts tab in MT4 terminal it shows the indicator has been successfully installed. (see image below) However the indicator is not visible in the sub window for USD related pairs.
Quote
Report
user3666197 · External communityPost link
External answer — Stack Overflow Stack Exchange Author: user3666197 Original post: https://stackoverflow.com/a/79746027 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. If we wish to "have" some Custom Indicator "inside" MT4-Terminal window/subwindow, we may drop it manually there, or pre-set the Terminal screen, using a profile or template ( how they call it ), where all settings were tuned and stored. No other way IIRC. Calling the standard MQL4 iCustom() -function (a) returns a value (a single double , value of which depends on the code inside the compiled .EX4 file, given the current state of the Markets and call-specific input-parameters ) (b) does notjinh else - namely it does not "install" anything anywhere, juct computes the ret-value and returns it ( most probably IIRC without any FX-Market tick-arrival-event awaiting -- this part could be tested from Scrpt-type of MQL4 code-execution, where code does not await any tick-event and ought be able to freely ask iCustom() to compute & serve a value right upon call). The well documented iCustom() call-signature has three cardinal parts -- 1st with FX-Market context, 2nd with variadic input parameters iCustom()-indicator needs to receive, so as to compute something, 3rd with indexes ( an indicator line-index, as it can have several different "lines"-of-TimeSeries coordinated values, and a shift-index, which tells the iCustom()-indicator, how many bars to step backckwards, towards the past-history, right, the shift == 0 is the last known bar ( the live one or the last from the FX-Markets, once the trading was closed ) an so which of the computed values should be reported back to the caller. Putting there a subWindowIndex value is possible, yet does not change the behaviour of the MT4-Terminal ecosystem. double iCustom( string symbol, // symbol int timeframe, // timeframe string name, // path/name of the .EX4 custom indicator compiled program file /* vvvvvvvvvvvv VarTYPE---VarVALUE----------// VARIADIC SECTION w iCustom()-PARAMETERS, if any----- */ ... ... // custom indicator input parameters (if necessary) /* ^^^^^^^^^^^^ VarTYPE---VarVALUE----------// VARIADIC SECTION w iCustom()-PARAMETERS, if any----- */ int mode, // line index int shift // shift );
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External answer — Stack Overflow Stack Exchange Author: user3666197 Source score (net votes, not local likes): 0 Original post: https://stackoverflow.com/a/79746027 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. If we wish to "have" some Custom Indicator "inside" MT4-Terminal window/subwindow, we may drop it manually there, or pre-set the Terminal screen, using a profile or template ( how they call it ), where all settings were tuned and stored. No other way IIRC. Calling the standard MQL4 iCustom() -function (a) returns a value (a single double , value of which depends on the code inside the compiled .EX4 file, given the current state of the Markets and call-specific input-parameters ) (b) does notjinh else - namely it does not "install" anything anywhere, juct computes the ret-value and returns it ( most probably IIRC without any FX-Market tick-arrival-event awaiting -- this part could be tested from Scrpt-type of MQL4 code-execution, where code does not await any tick-event and ought be able to freely ask iCustom() to compute & serve a value right upon call). The well documented iCustom() call-signature has three cardinal parts -- 1st with FX-Market context, 2nd with variadic input parameters iCustom()-indicator needs to receive, so as to compute something, 3rd with indexes ( an indicator line-index, as it can have several different "lines"-of-TimeSeries coordinated values, and a shift-index, which tells the iCustom()-indicator, how many bars to step backckwards, towards the past-history, right, the shift == 0 is the last known bar ( the live one or the last from the FX-Markets, once the trading was closed ) an so which of the computed values should be reported back to the caller. Putting there a subWindowIndex value is possible, yet does not change the behaviour of the MT4-Terminal ecosystem. double iCustom( string symbol, // symbol int timeframe, // timeframe string name, // path/name of the .EX4 custom indicator compiled program file /* vvvvvvvvvvvv VarTYPE---VarVALUE----------// VARIADIC SECTION w iCustom()-PARAMETERS, if any----- */ ... ... // custom indicator input parameters (if necessary) /* ^^^^^^^^^^^^ VarTYPE---VarVALUE----------// VARIADIC SECTION w iCustom()-PARAMETERS, if any----- */ int mode, // line index int shift // shift );

Cancel quote

Checking account access…