# Custom “applied price” input for indicator

Hey! Thanks for taking some time to look at my question.

I am trying to make an indicator but in order to do this I need to plot an EMA, but the applied price isn’t the usual close etc. The applied price should be this:

```double UMA, LMA;
if(close>open) {UMA=high-close;LMA=low-open;}
else {UMA=high-open;LMA=low-close;}
```

So UMA and LMA need to be used when calculating the EMA.

I might be absolutely wrong, but would it be as “simple" as using the iCustom like this:

```input   ENUM_MA_METHOD MA_method  =MODE_EMA;
ENUM_APPLIED_PRICE Price  =UMA;
UMAX_handle= iCustom(...
MA_Method,
Price,
...
);```

After this I need to perform some other calculations with the outcome of “UMAX_handle”, I would just need to place these values in a buffer right?

Again I am quite new to this, so there might be some reasoning errors.

Thanks allot for taking the time,

Have a great rest of your day!

Foenkelito:Hey! Thanks for taking some time to look at my question. I am trying to make an indicator but in order to do this I need to plot an EMA, but the applied price isn’t the usual close etc. The applied price should be this: So UMA and LMA need to be used when calculating the EMA. I might be absolutely wrong, but would it be as “simple" as using the iCustom like this: After this I need to perform some other calculations with the outcome of “UMAX_handle”, I would just need to place these values in a buffer right? Again I am quite new to this, so there might be some reasoning errors. Thanks allot for taking the time, Have a great rest of your day!

No, an enumeration does not work that way. An enumeration is an integer type and it consists of a predefine selection. You cannot simply assign a new value to it and hope that it magically works, and especially not a floating point value.

In this case, you cannot use iCustom() nor iMA(). You will have to calculate the EMA yourself in the EA. For that you can use the following ...

How to create an array?

Fernando Carreiro, 2022.11.16 21:52

Yes, you can use the functions in the "Include/MovingAverages.mqh" file provided with MetaTrader.

Fernando Carreiro #:

No, an enumeration does not work that way. An enumeration is an integer type and it consists of a predefine selection. You cannot simply assign a new value to it and hope that it magically works, and especially not a floating point value.

In this case, you cannot use iCustom() nor iMA(). You will have to calculate the EMA yourself in the EA. For that you can use the following ...

Do you perhaps know if there is more about this in the MQL5 guide? If yes, do you also know where this would be?

Foenkelito #: Thanks allot for your response! Do you perhaps know if there is more about this in the MQL5 guide? If yes, do you also know where this would be? Because I wouldn’t exactly know where to start with this.

A guide to what? Can you elaborate?

If you are referring to the functions in "MovingAverages.mqh", then you can simply look at each function there in and see what it does. It's a source code file.

If it's an Indicator you are building, then simply store the UMA and LMA values in a calculated-type indicator buffer and then apply the ExponentialMA() function from "MovingAverages.mqh", to those buffers.

`double ExponentialMA(const int position,const int period,const double prev_value,const double &price[])`

If instead you want to calculate the EMA incrementally in your loop, then the following paper explains the maths for it ...

With the pseudo code for it being the following:

```diff := x - mean
incr := alpha * diff
mean := mean + incr
variance := (1 - alpha) * (variance + diff * incr)```
Reason: