Expert Advisor question

 

Hello Everyone


I apologize in advanced if my question is very basic and it has already been answered before.


I trade with a broker that has over 400 instruments.

I need to seperate the one with Daily RSI below 70 and MACD above zero.

Is it possible to get the liast of all instruments that satisfy those two basic requirements.

I mean instead of me checking them out one by one, I have an expert advisor which simply just lists the instrument that satisfy those requirements.


Thank you very much

Ali

 
Bronz33:

Hello Everyone


I apologize in advanced if my question is very basic and it has already been answered before.


I trade with a broker that has over 400 instruments.

I need to seperate the one with Daily RSI below 70 and MACD above zero.

Is it possible to get the liast of all instruments that satisfy those two basic requirements.

I mean instead of me checking them out one by one, I have an expert advisor which simply just lists the instrument that satisfy those requirements.


Thank you very much

Ali

Yes, that sort of thing is fairly trivial...


//+------------------------------------------------------------------+
//|                                            RsiMacdAllSymbols.mq4 |
//|                                                      nicholishen |
//|                         https://www.forexfactory.com/nicholishen |
//+------------------------------------------------------------------+
#property copyright "nicholishen"
#property link      "https://www.forexfactory.com/nicholishen"
#property version   "1.00"
#property strict
//+------------------------------------------------------------------+
bool rsi(string symbol)
{
   ResetLastError();
   double value = iRSI(symbol, PERIOD_D1, 14, PRICE_CLOSE, 0);
   return (_LastError == ERR_NO_ERROR && value != 0.0 && value < 70.0);
}
//+------------------------------------------------------------------+
bool macd(string symbol)
{
   ResetLastError();
   double value = iMACD(symbol, PERIOD_D1, 12, 26, 9, PRICE_CLOSE, MODE_MAIN, 0);
   return (_LastError == ERR_NO_ERROR && value > 0.0);
}
//+------------------------------------------------------------------+
int OnInit()
{
   EventSetTimer(2);
   return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
void OnDeinit(const int reason){}
//+------------------------------------------------------------------+
void OnTick(){}

void OnTimer()
{
   string comment = "Symbols that meet criteria:\n\n";
   for(int i=SymbolsTotal(false)-1; i>=0; --i){
      string symbol = SymbolName(i, false);
      if(rsi(symbol) && macd(symbol))   
         comment += symbol + "\n";
   }
   Comment(comment);
}
 

I have deleted a post that was off-topic and completely in capital letters.

Posting in capital letters is considered shouting and very rude.