Changing External variables of custom indicators

 

Hello,

Is it possible to change the external variables of a custom indicator from an expert advisor that uses the indicator to process trades? If so, could you either explain how this is done or direct me to the documentation that explains the process of doing this? I am writing a simple ea using a custom indicator I purchased and the default settings of the indicator are not correct for my application. Using the iCustom to call the indicator loads the indicator with the default settings. Any help would be greatly appreciated.

 
bestnets:

Using the iCustom to call the indicator loads the indicator with the default settings. Any help would be greatly appreciated.

You are using iCustom incorrectly . . you MUST pass all extern variables in the iCustom call . . .

https://docs.mql4.com/indicators/iCustom

 
bestnets:

Hello,

Is it possible to change the external variables of a custom indicator from an expert advisor that uses the indicator to process trades? If so, could you either explain how this is done or direct me to the documentation that explains the process of doing this? I am writing a simple ea using a custom indicator I purchased and the default settings of the indicator are not correct for my application. Using the iCustom to call the indicator loads the indicator with the default settings. Any help would be greatly appreciated.


Hi Bestnets,

The first important iCustom rule was stated by RaptorUK - you MUST pass all indicator extern variables in the iCustom call for your EA.

Secondly, if I understand your request...
1) Your indicator needs to already have the "extern variables" that you want to change. If they are hard-coded defaults, make them externs.
2) Place ALL the externs in your iCustom statements in your EA as stated by RaptorUK.
3) Then add the indicator externs (names) in your EA at the top so they match your iCustom externs for your indicator.
4) Use these EA extern names to set and change your indicator values when you test your EA.

That should work for you.

Hope this helps,

Robert

Example

Indicator Externs -
double fastEMA: double slowEMA;

EA Externs -
double fastEMA: double slowEMA;

iCustom Statement in EA -
double Value1 = iCustom(NULL,0,"Test Indicator",fastEMA,slowEMA); // The fastEMA and slowEMA can be now set in the EA.
 

You are using iCustom incorrectly . . you MUST pass all extern variables in the iCustom call . . .

The first important iCustom rule was stated by RaptorUK - you MUST pass all indicator extern variables in the iCustom call for your EA.

It's not a Must. If you have the source code you can just edit it to the default values you want. Then you don't have to pass the extern. Extern is helpful if you wish to change on the fly or use with strategy optimizer.

 
ubzen:

You are using iCustom incorrectly . . you MUST pass all extern variables in the iCustom call . . .

The first important iCustom rule was stated by RaptorUK - you MUST pass all indicator extern variables in the iCustom call for your EA.

It's not a Must. If you have the source code you can just edit it to the default values you want. Then you don't have to pass the extern. Extern is helpful if you wish to change on the fly or use with strategy optimizer.


Hi Uzben,

Yes you can change the indicators defaults, but to my understanding that's not what Bestnets was asking.

Hard coding them as defaults in the indicator does not allow you to change them in your EA.

I believe both RaptorUK and I were responding to the question of using indicator externs in the EA iCustoms, not changing the indicator.

In this case....to make the statement more accurate and acceptable...it can be restated:

IF...you use an indicator with externs...you MUST add all the externs in the EA iCustom statements.

Hope this helps,

Robert

 
I wasn't nit picking on anyone. I understood what you guys meant. Just didn't want a newbie reading this to think values always needs to be passed for iCustom to work correctly.
 
Hi,


i got a wonderfull and powerfull dorex indicator i would like to make an EA with it, it is a arrow indicator

this are conditions:


Open Buy order If indicator is turn red to blue color.

Open Sell order if indicator turn blue to red color .

Close Buy before open the sell order.
close Sell before open the Buy order.


money managment:
takeprofit :adjustable
stop loss : adjustable
no trailing stop
maxslipage :3
order numbers :Could you make EA can make more than one orders (expamle :2,3,4....) each opened get same lotsize ( example : if EA opens 3 Buy orders with same lotsize,,Lotsize : Lot/ordernumbers)

lot adjustable )
, i join indicator code :
Reason: