自动交易和策略测试
- www.mql5.com
MQL5:MetaTrader 5客户端内置的交易策略语言。语言允许编写您自己的自动交易系统,技术指标,脚本和函数程序库
bcsunwww:
If your array has 7 items, they are indexed from 0 to 6. You can't use index [7].
You can't initialize all items at once with a dynamic array. You have to initialize each one individually.
Try this one:
void OnStart() { //--- string TradeSymbol[7] = {"EURUSD","GBPUSD","EURGBP","USDJPY","EURJPY","XAUUSD","XAGUSD"}; if(AccountInfoString(ACCOUNT_COMPANY) == "RoboForex LP") { for(int i=ArraySize(TradeSymbol)-1;i>=0;i--) { TradeSymbol[i]+="."; } } }
string TradeSymbol[]; ArrayResize(TradeSymbol,7); if(AccountInfoString(ACCOUNT_COMPANY) == "RoboForex LP") {TradeSymbol[0] = "EURUSD.e"; TradeSymbol[1] = "GBPUSD.e"; ... ... TradeSymbol[6] = "XAGUSD.e";} else {TradeSymbol[0] = "EURUSD"; TradeSymbol[1] = "GBPUSD"; ... ... TradeSymbol[6] = "XAGUSD";} //----
You can not use array initialization in the process
(updated!!!)
belido:
You can not use array initialization in the process
You can not use array initialization in the process
Forum on trading, automated trading systems and testing trading strategies
What's wrong with my code? Who can help me,Please?
angevoyageur, 2014.06.28 13:35
If your array has 7 items, they are indexed from 0 to 6. You can't use index [7].
You can't initialize all items at once with a dynamic array. You have to initialize each one individually.
Thank you all ,and belido's code solve my problem directly.
The use of arrays in your code is only useful if you want to detect whether trading symbol is to account "RoboForex LP" or "Standard".
Like this example:
void OnStart()
{
//---
string symbol = _Symbol;
string account;
string account_suf = "RoboForex LP";
string account_std = "Standard";
string pairs[] = {"EURUSD.e","GBPUSD.e","EURGBP.e","USDJPY.e","EURJPY.e","XAUUSD.e","XAGUSD.e"};
string suffix = ".e";
//--
for(int x=0; x<7; x++)
{
if((pairs[x] == symbol) && (StringSubstr(pairs[x],6,2) == suffix))
{
account=account_suf;
}
else
{
account=account_std;
}
}
}
Like this example:
void OnStart()
{
//---
string symbol = _Symbol;
string account;
string account_suf = "RoboForex LP";
string account_std = "Standard";
string pairs[] = {"EURUSD.e","GBPUSD.e","EURGBP.e","USDJPY.e","EURJPY.e","XAUUSD.e","XAGUSD.e"};
string suffix = ".e";
//--
for(int x=0; x<7; x++)
{
if((pairs[x] == symbol) && (StringSubstr(pairs[x],6,2) == suffix))
{
account=account_suf;
}
else
{
account=account_std;
}
}
}
3rjfx:
The use of arrays in your code is only useful if you want to detect whether trading symbol is to account "RoboForex LP" or "Standard".
Like this example:
void OnStart()
{
//---
string symbol = _Symbol;
string account;
string account_suf = "RoboForex LP";
string account_std = "Standard";
string pairs[] = {"EURUSD.e","GBPUSD.e","EURGBP.e","USDJPY.e","EURJPY.e","XAUUSD.e","XAGUSD.e"};
string suffix = ".e";
//--
for(int x=0; x<7; x++)
{
if((pairs[x] == symbol) && (StringSubstr(pairs[x],6,2) == suffix))
{
account=account_suf;
}
else
{
account=account_std;
}
}
}
Your code is excellent.
The use of arrays in your code is only useful if you want to detect whether trading symbol is to account "RoboForex LP" or "Standard".
Like this example:
void OnStart()
{
//---
string symbol = _Symbol;
string account;
string account_suf = "RoboForex LP";
string account_std = "Standard";
string pairs[] = {"EURUSD.e","GBPUSD.e","EURGBP.e","USDJPY.e","EURJPY.e","XAUUSD.e","XAGUSD.e"};
string suffix = ".e";
//--
for(int x=0; x<7; x++)
{
if((pairs[x] == symbol) && (StringSubstr(pairs[x],6,2) == suffix))
{
account=account_suf;
}
else
{
account=account_std;
}
}
}
Wei Sun:
Your code is excellent.
Ok
Your code is excellent.
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