Check if SMA is below certain RSI level in MQL5 programming

Check if SMA is below certain RSI level in MQL5 programming

Manage alerts

Loading saved threads...

silverhash · External communityPost link
External question — Stack Overflow Stack Exchange Author: silverhash Original post: https://stackoverflow.com/questions/77801354 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I'm new to MQL5 programming and I'm trying to create my first Indicator. I would like to be able to tell if the current moving average is below level 10 in the RSI. The image below explains what I mean. As you can see in the picture the SMA here has a tick just below RSi level 10. The SMA is the blue line chart. How can I calculate this given I have the RSI as: int rsiInstance = iRSI(_Symbol, _Period, 14, PRICE_CLOSE); And the SMA as: int maInstance = iMA(_Symbol, _Period, 21, 0, MODE_SMA, PRICE_CLOSE); So basically, a function that just returns true if that blue line touches or is below RSI Level 10 and false otherwise. Thanks for your patience and help.
Quote
Report
Mark SdS · External communityPost link
External answer — Stack Overflow Stack Exchange Author: Mark SdS Original post: https://stackoverflow.com/a/77815500 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Your code for the iRSI and the iMA only return handles for calling them. Those are their definitions: what parameters should be involved when calculating them? See here You'll need to create a dynamic array as a buffer and copy the returned values into that array. Then you'll have the actual values available from that array.
Quote
Report
Bishow Gurung · External communityPost link
External answer — Stack Overflow Stack Exchange Author: Bishow Gurung Original post: https://stackoverflow.com/a/78153317 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I am also not a pro but I think you need to parse the rsi and ima handle into array buffer something like this. bool checkiMALevel() { //RSI Buffer int rsiInstance = iRSI(_Symbol, _Period, 14, PRICE_CLOSE); double rsiBuffer[]; CopyBuffer(rsiInstance, 0, 1,3,rsiBuffer); // stores rsi of last 3 candles ArraySetAsSeries(rsiBuffer, true); //IMA Buffer int maInstance = iMA(_Symbol, _Period, 21, 0, MODE_SMA, PRICE_CLOSE); // stores ima of last 3 candles double imaBuffer[]; CopyBuffer(maInstance, 0, 1,3, imaBuffer); ArraySetAsSeries(imaBuffer, true); if (rsiBuffer[0] < 10 && imaBuffer[0] < 10) { return true; } else { return false; } } And Call it wherever you want bool isIMAUnderTenRsi = checkiMALevel();
Quote
Report

Post Reply

Checking account access…