1

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. enter image description here

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.

2 Answers 2

0

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Sorry if I wasn’t specific, I do have this array with all the values, I just dont know how to calculate the above as shown in the picture with all those values in tje array
0

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();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.