iClose function - help needed

 

This script should print the close price for a set of currency pairs. Unfortunately doesn't work for all the JPN pairs (ie. the ones with only two decimals). Someone can help?

int start()
{
double curr_close;
string cur_pair[] = {"EURUSD", "USDCHF", "GBPUSD", "USDJPN", "USDCAD", "NZDUSD",
"AUDUSD", "USDCAD", "NZDUSD", "GBPCHF", "GBPJPN",
"EURGBP", "EURCHF", "EURJPN",
"AUDCAD", "CHFJPN", "EURAUD", "CADJPN", "NZDJPN", "AUDJPN"};

int count = ArraySize(cur_pair);
for (int ic=0; ic<count; ic++) //start of curr. pairs processing
{
curr_close = iClose(cur_pair[ic],0,0); //close price

Print("Currency Pair = ", cur_pair[ic], " Close = ", curr_close);
} //end of curr. pairs processing

return(0);
}

 

Please closely read help on iClose()

1. you may not have data in history - check out and download if required.

2. defaulting to timeframe of current chart can also be related to above. Must have history.

Tools > History Center (F2)

hth

 

Must have history???

double iClose( string symbol, int timeframe, int shift)

Then if I want now or last, shift =0, 0r shift=1, need history or need to open chart of that symbol and that timeframe?

In other word, if chart of that symbol and that timeframe not opened, Can I use iClose(...) to get it value at shift =0, 0r shift=1 ?

have limit ?

Thanks.

 
ukt wrote >>

Please closely read help on iClose()

1. you may not have data in history - check out and download if required.

2. defaulting to timeframe of current chart can also be related to above. Must have history.

Tools > History Center (F2)

hth

I have double checked the history, which seems correct. Again the script doesn't work even if it is applied to a chart with "JPN" as quote currency (for instance "AUDJPN"). iHigh and iLow have the same behaviour. On the other hand there are no problems with the other currency pairs.

 

DxdCn

"Must have history???"

- yes, if you mean the script

" if I want now or last, shift =0, 0r shift=1, need history or need to open chart of that symbol and that timeframe?"

- I ran script on any old chart... but surely need history, yes?

"In other word, if chart of that symbol and that timeframe not opened, Can I use iClose(...) to get it value at shift =0, 0r shift=1 ?"

- must be able to - that is what script does...

sardpl

"Again the script doesn't work even if it is applied to a chart with "JPN" as quote currency (for instance "AUDJPN"). iHigh and iLow have the same behaviour."

Well, my first post just a suggestion ;)

some observations:

1. There are symbol pair repetitions in your string array

2. PLEASE look at your market watch window and/or the list used to make new chart.

- why? Mine have no JPN but do have JPY

3. the more data downloaded in history center, the more non-zero results when running script...

- seems only reasonable result, yes? if data then iclose ok, if no data then iclose !ok

4. not look into relationship with pairs in market watch and pairs (with data) in history.

- my history shows 31 FX pairs. As seen below, my market watch shows 12 FX pairs

- would expect that for me, is pointless using other than 12 pairs.

- how is history data updated? must need to use history center or have chart up and refresh data...

- not see where this is going to so will now stop!

5. finally... fwiw - if I cannot turn a profit with 12 pairs - does it matter if have 31 pairs in history center???

Here is what I managed to get - my MT is from Alpari and the symbols listed in MarketWatch pane are:

Have checked each in History and each has data.

Below is result of sardpl's script but change JPN --> JPY

2008.06.22 18:28:52 13451 USDJPY,M15: removed
2008.06.22 18:28:52 13451 USDJPY,M15: uninit reason 0
2008.06.22 18:28:52 13451 USDJPY,M15: Currency Pair = AUDJPY Close = 102.31
2008.06.22 18:28:52 13451 USDJPY,M15: Currency Pair = NZDJPY Close = 81.66
2008.06.22 18:28:52 13451 USDJPY,M15: Currency Pair = CADJPY Close = 105.57
2008.06.22 18:28:52 13451 USDJPY,M15: Currency Pair = EURAUD Close = 1.6365
2008.06.22 18:28:52 13451 USDJPY,M15: Currency Pair = CHFJPY Close = 103.61
2008.06.22 18:28:52 13451 USDJPY,M15: Currency Pair = AUDCAD Close = 0.9687
2008.06.22 18:28:52 13451 USDJPY,M15: Currency Pair = EURJPY Close = 165.54
2008.06.22 18:28:52 13451 USDJPY,M15: Currency Pair = EURCHF Close = 1.6163
2008.06.22 18:28:52 13451 USDJPY,M15: Currency Pair = EURGBP Close = 0.7896
2008.06.22 18:28:52 13451 USDJPY,M15: Currency Pair = GBPJPY Close = 212.08
2008.06.22 18:28:52 13451 USDJPY,M15: Currency Pair = GBPCHF Close = 2.0466
2008.06.22 18:28:52 13451 USDJPY,M15: Currency Pair = NZDUSD Close = 0.7608
2008.06.22 18:28:52 13451 USDJPY,M15: Currency Pair = USDCAD Close = 1.0162
2008.06.22 18:28:52 13451 USDJPY,M15: Currency Pair = AUDUSD Close = 0.9532
2008.06.22 18:28:52 13451 USDJPY,M15: Currency Pair = NZDUSD Close = 0.7608
2008.06.22 18:28:52 13451 USDJPY,M15: Currency Pair = USDCAD Close = 1.0162
2008.06.22 18:28:52 13451 USDJPY,M15: Currency Pair = USDJPY Close = 107.33
2008.06.22 18:28:52 13451 USDJPY,M15: Currency Pair = GBPUSD Close = 1.976
2008.06.22 18:28:52 13451 USDJPY,M15: Currency Pair = USDCHF Close = 1.0357
2008.06.22 18:28:52 13451 USDJPY,M15: Currency Pair = EURUSD Close = 1.5606
2008.06.22 18:28:52 13451 USDJPY,M15: loaded successfully

 
ukt wrote >>

Ukt,

oops - the mistake was to use JPN instead of JPY.

.... I probably thought it was correct to use the ISO-639 standard (languages) instead of ISO-4217 (currencies) ...

Jokes apart, I really appreciated your detailed help. My account is from ODL Securities and there are 18 pairs. Here are the results:

CurPairs iClose iHigh iLow
EURUSD 1.5606 1.5650 1.5491
USDCHF 1.0356 1.0445 1.0303
GBPUSD 1.9759 1.9790 1.9698
USDJPY 107.32 108.01 107.11
USDCAD 1.0161 1.0194 1.0100
NZDUSD 0.7609 0.7646 0.7601
AUDUSD 0.9531 0.9564 0.9490
GBPCHF 2.0465 2.0603 2.0358
GBPJPY 212.08 213.05 211.71
EURGBP 0.7896 0.7924 0.7854
EURCHF 1.6163 1.6204 1.6127
EURJPY 167.51 168.11 167.24
AUDCAD 0.9685 0.9732 0.9636
CHFJPY 103.59 104.05 103.3
EURAUD 1.6365 1.6389 1.6294
CADJPY 105.57 106.4 105.04
NZDJPY 81.65 82.29 81.47
AUDJPY 102.29 102.77 102.09

Thank you!

Reason: