Closing Function Using RSI

 

Hi Mql4 Community,

I'm having some issues with this function in my EA. Sometimes, not all the time, it will close a trade if only one of the if statements has been satisfied. There are no error messages in the journal.

What's the best way to troubleshoot this?

Cheers, Tim

void CloseOrders1()

{

     double MATICRSIClose = iRSI(NULL,PERIOD_H1,14,0,1);
     double ATOMRSIClose = iRSI("ATOMUSDT",PERIOD_H1,14,0,1);
     double MATICRSIBACK = iRSI(NULL,PERIOD_H1,14,0,2);
     double ATOMRSIBACK = iRSI("ATOMUSDT",PERIOD_H1,14,0,2);
     
     if(MATICRSIClose < ATOMRSIClose)
     if(MATICRSIBACK < ATOMRSIBACK)closesell();
     
}
 
Timothy Smith:

Hi Mql4 Community,

I'm having some issues with this function in my EA. Sometimes, not all the time, it will close a trade if only one of the if statements has been satisfied. There are no error messages in the journal.

What's the best way to troubleshoot this?

Cheers, Tim

Your shown code does not close any trade.

 

It calls another function for the close operation.

Can you see any flaws in my code above, i.e. should I be using all caps to declare?

 
Timothy Smith #:

It calls another function for the close operation.

Can you see any flaws in my code above, i.e. should I be using all caps to declare?

I cannot see anything obviously wrong with your code.

 

Try print those numbers out and see if there's some null or 0 values?

Reason: