How to code indicator applies on another indicator?

To add comments, please log in or register
luckyvictor
179
luckyvictor  
In MT5 chart, when you drag an indicator, you can choose to apply from the standard price values, for first/previous indicator.

In terms of coding, how can this be achieved?
E.g I want to apply moving average on another moving average, or MACD on another MACD.
lippmaje
815
lippmaje  
   ENUM_APPLIED_PRICE   applied_price      // type of price or handle 

See iMA MQL5 reference manual. The small dragon asks for the way, the large dragon studies the map.

luckyvictor
179
luckyvictor  
lippmaje:

See iMA MQL5 reference manual. The small dragon asks for the way, the large dragon studies the map.

I tried with the following code but rsi 3 just return zero all time.

RSI_14[i]=iRSI(Symbol(),0,14,PRICE_CLOSE,i); 
RSI_3[i]=iRSI(Symbol(),0,3,RSI_14[i],i);
lippmaje
815
lippmaje  
luckyvictor:
I tried with the following code but rsi 3 just return zero all time.

This is MQL 4. In MQL 5 it works different, you first need to obtain a handle to the indicator and then use CopyBuffer to read out the indicator data.

And you can pass the first indicator handle to obtain a second indicator handle.

GlunoFx
54
GlunoFx  
lippmaje:

This is MQL 4. In MQL 5 it works different, you first need to obtain a handle to the indicator and then use CopyBuffer to read out the indicator data.

And you can pass the first indicator handle to obtain a second indicator handle.

Can you give me an example? Thank you so much!
lippmaje
815
lippmaje  
GlunoFx:
Can you give me an example? Thank you so much!
int RSIonRSIhandle=iRSI(NULL,0,Period,RSIhandle);

Like so maybe. See the reference manual. https://www.mql5.com/en/docs/indicators

Documentation on MQL5: Technical Indicators
Documentation on MQL5: Technical Indicators
  • www.mql5.com
All functions like iMA, iAC, iMACD, iIchimoku etc. create a copy of the corresponding technical indicator in the global cache of the client terminal. If a copy of the indicator with such parameters already exists, the new copy is not created, and the counter of references to the existing copy increases. These functions return the handle of the...
To add comments, please log in or register