# Detecting Multiple Currency Open and Close Bars Scanner Code Help Neede

861

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.

44623

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.

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;
}
}
//---
```
861

`iOpen(SymbolName(1,1),PERIOD_D1,0)`

I believe I found the solution, but thanks.

19849

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.