Evaluate dynamic Variables
Try this.
extern string symbol_1 = "EURUSD";
extern double lots_1 = 0.2;
extern string symbol_2 = "GBPUSD";
extern double lots_2 = 0.4;
extern string symbol_3 = "USDCHF";
extern double lots_3 = 0.1;
//-----------
string symbol[3] ;
double lots[3] ;
//-----------
function start()
{
symbol[0] = symbol_1;
lots[0] = lots_1;
symbol[1] = symbol_2;
lots[1] = lots_2;
symbol[2] = symbol_3;
lots[2] = lots_3;
for(int i=0; i<3; i++)
{
OrderSend(symbol,OP_BUY, lots[i], MarketInfo(symbol[i],MODE_ASK), 2, NULL, NULL, "testing", magic, NULL, LimeGreen);
}
}
I'm looking to see if you can evaluate dynamically created variables in MT4. Here's an example. Suppose that I have 3 external variables that should create 3 different trades. I want to be able to dynamically create the variables I use to generate the orders.
Example:
extern string symbol_1 = "EURUSD"; extern double lots_1 = 0.2; extern string symbol_2 = "GBPUSD"; extern double lots_2 = 0.4; extern string symbol_3 = "USDCHF"; extern double lots_3 = 0.1; function start() { for(int i=1; i<=3; i++) { string symbol = "symbol_"+i; string lots = "lots_"+i; OrderSend(symbol,OP_BUY, lots, MarketInfo(symbol,MODE_ASK), 2, NULL, NULL, "testing", magic, NULL, LimeGreen); } }