Detecting Multiple Currency Open and Close Bars Scanner Code Help Neede

 

Hello All

Im trying to build an indicator that helps me scan the market and calculate strength of Currencies using my own algorithm. 

I loop through Currencies and then I can't detect the Closing Price for that specific currency.

Here is my code so far

int OnInit()
  {
  
   for(int i=0;i<SymbolsTotal(1);i++)
     {
       If (SymbolName(i,1) == "EURUSD")
       {
       double TheSwap = MarketInfo( SymbolName(i,1), MODE_SWAPLONG )); // This Returns the Swap for a long position 
       double ClosingPrice = Close[0];   // THIS PART DOESNT DO IT FOR THE EURUSD  INSTEAD THE CHART IM ON
       }

     }
   return(INIT_SUCCEEDED);
  }

Is there any way I can select the Symbol so that I could do operations on, e.g. Check the last 3 bars of that symbol?


So Im doing this in multiple Symbols and comparing Prices and closing bars on them.


Thanks in advance.

 
Audai Louri:

Hello All

Im trying to build an indicator that helps me scan the market and calculate strength of Currencies using my own algorithm. 

I loop through Currencies and then I can't detect the Closing Price for that specific currency.

Here is my code so far

Is there any way I can select the Symbol so that I could do operations on, e.g. Check the last 3 bars of that symbol?


So Im doing this in multiple Symbols and comparing Prices and closing bars on them.


Thanks in advance.

Try this code (move code in OnTick() function.

//---
   double TheSwap=0;
   double ClosingPrice=0;
//---
   for(int i=0; i<SymbolsTotal(1); i++)
     {
      if(SymbolName(i,1) == "EURUSD")
        {
         TheSwap = MarketInfo(SymbolName(i,1), MODE_SWAPLONG);
         ClosingPrice = Close[0];
         Print("Symbol: ",SymbolName(i,1)," || Swap: ",TheSwap," || Price: ",ClosingPrice);
         break;
        }
     }
//---
 
iOpen(SymbolName(1,1),PERIOD_D1,0)

I believe I found the solution, but thanks.

 
Audai Louri:
iOpen(SymbolName(1,1),PERIOD_D1,0)
  1. On MT4: Unless the current chart is that specific pair/TF referenced, you must handle 4066/4073 errors before accessing candle/indicator values.
              Download history in MQL4 EA - Forex Calendar - MQL4 programming forum - Page 3 #26 № 4

  2. I assume that is a posting typo because it's not in your original code.
Reason: