Forum on trading, automated trading systems and testing trading strategies
When you post code please use the CODE button (Alt-S)!
- Please edit your (original) post and use the CODE
button (Alt-S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum
Messages Editor -
void OnTick(){ int CopySpread( string USD_JPY, // symbol name ⋮
Don't post code that won't even compile. You copied the signature of CopySpread, you need to write a call. Compare that to the example in the documentation.
Timeseries and Indicators Access / CopySpread - Reference on algorithmic/automated trading language for MetaTrader 5
Hi, i had the same issue. i surfed many forms and nothing happened . then i used the code button and it got fixed. many thanks !!
katesmith1304:
Hi, i had the same issue. i surfed many forms and nothing happened . then i used the code button and it got fixed. many thanks !! 9AppsVidMate
No reply??
Hi, i had the same issue. i surfed many forms and nothing happened . then i used the code button and it got fixed. many thanks !! 9AppsVidMate
katesmith1304:
No reply??
No reply??
Why are you expecting a reply?

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello,
I want to have the closing prices in an array which I can call using name_array[x] whereas x is the price on that timeframe (1m, 1h, etc). What can I use for this? I only found information on CopySpread, copy tick and realtime updates. (Copy spread keepts telling me an error that this function declaration is only allowed on global, namespace or class declarations only, whereas everywhere I put this in my code (Global, onInit and on Tick) it givs me the same error.
void OnTick()
{
int CopySpread(
string USD_JPY, // symbol name
ENUM_TIMEFRAMES 0, // period
int 0, // start position
int 20, // data count to copy
int spread_array[] // target array for spread values
);
//Get price data
double current_bid = SymbolInfoDouble(_Symbol, SYMBOL_BID);
double current_ask = SymbolInfoDouble(_Symbol, SYMBOL_ASK);
}