ThorstenKock:
Looks right. Tell me if it works. I'm also working on something similar
Hi guys,
I'm new on MQL programming and just tried to make an EA with an moving average applied to an RSI.
Before I continue, I'd like you to check the code and tell me whether I did it right.
Not sure whether I have to build an array, hope not...
TIA
In fact, it is simple.
Pay attention to the help: iMA and parameter "type of price or handle"
int iMA( string symbol, // symbol name ENUM_TIMEFRAMES period, // period int ma_period, // averaging period int ma_shift, // horizontal shift ENUM_MA_METHOD ma_method, // smoothing type ENUM_APPLIED_PRICE applied_price // type of price or handle );
You need: create an iRSI indicator handle, create an iMA indicator handle in iMA (in place applied_price ) insert iRSI handle.
I did the same: calculated iMA by iRVI indicator - code example iMA calculated by iRVI
//+------------------------------------------------------------------+ //| iMA calculated by iRVI.mq5 | //| Copyright © 2019, Vladimir Karputov | //| http://wmua.ru/slesar/ | //+------------------------------------------------------------------+ ... int handle_iRVI; // variable for storing the handle of the iRVI indicator int handle_iMA; // variable for storing the handle of the iMA indicator ... //+------------------------------------------------------------------+ //| Expert initialization function | //+------------------------------------------------------------------+ int OnInit() { ... //--- create handle of the indicator iRVI handle_iRVI=iRVI(m_symbol.Name(),Period(),Inp_RVI_ma_period); //--- if the handle is not created if(handle_iRVI==INVALID_HANDLE) { //--- tell about the failure and output the error code PrintFormat("Failed to create handle of the iRVI indicator for the symbol %s/%s, error code %d", m_symbol.Name(), EnumToString(Period()), GetLastError()); //--- the indicator is stopped early return(INIT_FAILED); } //--- create handle of the indicator iMA handle_iMA=iMA(m_symbol.Name(),Period(),Inp_MA_ma_period,Inp_MA_ma_shift, Inp_MA_ma_method,handle_iRVI); //--- if the handle is not created if(handle_iMA==INVALID_HANDLE) { //--- tell about the failure and output the error code PrintFormat("Failed to create handle of the iMA indicator for the symbol %s/%s, error code %d", m_symbol.Name(), EnumToString(Period()), GetLastError()); //--- the indicator is stopped early return(INIT_FAILED); } //--- return(INIT_SUCCEEDED); }
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hi guys,
I'm new on MQL programming and just tried to make an EA with an moving average applied to an RSI.
Before I continue, I'd like you to check the code and tell me whether I did it right.
Not sure whether I have to build an array, hope not...
TIA