Open BinkyBonkers opened 6 years ago
Unfortunately, I have no idea at this moment how to create function iCustom with different parameter types. Now we have only two types of iCustom on C# side: with int parameters and with double parameters. Double parameters can be easy cast to integer, and boolean values, so you can use iCustom with double to send list of mix parameters (int, double, boolean). Unfortunately, it can't work with string type. I will try to find solution for iCustom in the future.
I think it's good to pass the value array and typeOfValues array to metatrader to decide to call with iCustom function (depend on number of inputs*) and handle parameters type.
It's no problem to pass values with same type to MetaTrader. But when we talk about different types then we have restriction of MQL: it does not allow to cast to values types in runtime (maybe I don't know how it can be do it).
double iCustom( string symbol, // symbol int timeframe, // timeframe string name, // path/name of the custom indicator compiled program ... // custom indicator input parameters (if necessary) int mode, // line index int shift // shift );
I will be glad if you or somebody else will find the way how to prepare list of custom input parameters in runtime.
Yes, you are right. I was thinking metatrader handles inline if as a runtime casting, but when I try calling iCustom with string and double inputs with inline if, I failed :( . If I find any way, I will update this topic.
It is not possible to call ICustom directly with the parameters in string format separed by comma according to the MQL4 documentation. ICustom(symbol ,timeframe ,name , param 1, param 2, param 3,....., mode, shift). I dont know if this match, it is only a ideas.
I think for MT5 we can try to use function MQL IndicatorCreate instead iCustom: https://www.mql5.com/en/docs/series/indicatorcreate
Function IndicatorCreate uses array of parameters of MqlParam type. MqlParam can have different type of values (long, double, string). I will implement functions IndicatorCreate, IndicatorRelease with related issue #92.
For MT4... I still do not know.
I think for MT5 we can try to use function MQL IndicatorCreate instead iCustom: https://www.mql5.com/en/docs/series/indicatorcreate
Function IndicatorCreate uses array of parameters of MqlParam type. MqlParam can have different type of values (long, double, string). I will implement functions IndicatorCreate, IndicatorRelease with related issue #92.
For MT4... I still do not know.
mt4 we use iCustom. almost the same i think.
It is not possible to call ICustom directly with the parameters in string format separed by comma according to the MQL4 documentation. ICustom(symbol ,timeframe ,name , param 1, param 2, param 3,....., mode, shift). I dont know if this match, it is only a ideas.
if the indicator has 10 params, and we only need 3 params to be change, do we need to put all 10 params in the iCustom?
I ended up here in this git looking for the same to achieve calling ICustom directly with the parameters in string format separated by comma. And see none here also have a solution for this. :(
But in further searching I found someone have done this. Parameters given as below SIGNALStrategyInputs = 1,2.0, C'0 / 128/0 ', " text ", D'2018.11.08', false Check the link please. https://www.mql5.com/en/blogs/post/721838 Search for 'SIGNALStrategyInputs' in above page.
Anyone able to decode the logic how this is done?
I see this in that blog post:
SIGNALStrategyInputs = 1,2.0, C'0 / 128/0 ', " text ", D'2018.11.08', false
I remember a project, that I was trying to dump all indicator values on the chart.
my solution and this raw value replacement are similar! I was creating and compiling new indicator to ask me referenced indicator name and its buffer index, then it return buffer value. And I was writing iCustom function and related inputs to compile and work for me as a trick !
I did not test Afsalme linked product, but it's copied settings are similar to what I did before.
I see this in that blog post:
SIGNALStrategyInputs = 1,2.0, C'0 / 128/0 ', " text ", D'2018.11.08', false
I remember a project, that I was trying to dump all indicator values on the chart. my solution and this raw value replacement are similar! I was creating and compiling new indicator to ask me referenced indicator name and its buffer index, then it return buffer value. And I was writing iCustom function and related inputs to compile and work for me as a trick ! I did not test Afsalme linked product, but it's copied settings are similar to what I did before.
Thank you mhdbzr for your quick reply. :) I am also trying to do the same. Can you please help me in this I have attached the indicator mq4 code. Please be kind to check it. I am taking inputs and passing it as it is to iCustom function, but iCustom not accepting it and using default values. Hope you may need only few minutes to fix it as you already know how to do this. :) IndicatorAlerts.txt
I see you're using IndicatorParameters
from https://www.mql5.com/en/docs/series/indicatorparameters . it is MQL5 not implemented in MT4.
What I did, briefly: my EA writes a new indicator/EA source code in a file and then compile & open it to read result by calling its buffer or exported function.
I see you're using
IndicatorParameters
from https://www.mql5.com/en/docs/series/indicatorparameters . it is MQL5 not implemented in MT4.What I did, briefly: my EA writes a new indicator/EA source code in a file and then compile & open it to read result by calling its buffer or exported function.
Very interesting Solution you have mhdbzr. 🥇 💯 Thank you for sharing your idea. I will try myself to implement your way of achieving this. It will be great if you can share your code, if you don't mind. :)
I was trying to share it, but it has too many other parts and it was not possible to share it. Note: if you re-write imported Indicator in run-time with the same name, mt4 shutdown by crash, probably. so, it's better to use new name for new Indicator, if you're watching all attached indicators on the chart and re-building the Indicator each minute or frequently by chart changes.
What is the right way to call iCustom with different parameter types, i.e. a mixture of ints, doubles and strings? Please can you give me an example. Many thanks.