Download MetaTrader 5
To add comments, please log in or register
MQL5 Cloud Network speeds up calculations. Try it!
shyftus
195
shyftus 2014.02.11 17:39 

Trying to follow a tutorial on coding a simple MA x but I've run into issues before I've even got into the thick of it... it's 430am here so I'm probably just missing a ; or something but could use a second pair of eyes... the problems on the "for" says expression can not be used on global scale. Original code can be found at http://www.forexrazor.com/en-us/school/tabid/426/ID/435663/basic-ea-ma-cross


int Total, OType=1;
double Price, SL, TP, Lot;
bool CloseBuy=False, CloseSell=False, OpenBuy=False, OpenSell=False;

for(int Counter=1; Counter<=OrdersTotal(); Counter++)
{
if (OrderSelect(Counter-1,SELECT_BY_POS)==True)
if (OrderSymbol()==Symbol() && OrderMagicNumber() == MagicNumber)
{
Ticket=OrderTicket();
OType=OrderType();
Price=OrderOpenPrice();
SL=OrderStopLoss();
TP=OrderTakeProfit();
Lot=OrderLots();
}
}
qjol
3243
qjol 2014.02.11 17:48  
int Total, OType=1;
double Price, SL, TP, Lot;
bool CloseBuy=False, CloseSell=False, OpenBuy=False, OpenSell=False;

for(int Counter=1; Counter<=OrdersTotal(); Counter++)
{
if (OrderSelect(Counter-1,SELECT_BY_POS)==True)
if (OrderSymbol()==Symbol() && OrderMagicNumber() == MagicNumber ??)
{
Ticket=OrderTicket();
OType=OrderType();
Price=OrderOpenPrice();
SL=OrderStopLoss();
TP=OrderTakeProfit();
Lot=OrderLots();
}
}
ydrol
593
ydrol 2014.02.11 17:52  

Look again at the page you are working from. You main code should be inside functions


int init() {

//code here run at start up

}


and


int start() {

// code here every tick

}

Simon Gniadkowski
Moderator
17962
Simon Gniadkowski 2014.02.11 17:53  
shyftus:

Trying to follow a tutorial on coding a simple MA x but I've run into issues before I've even got into the thick of it... it's 430am here so I'm probably just missing a ; or something but could use a second pair of eyes... the problems on the "for" says expression can not be used on global scale. Original code can be found at http://www.forexrazor.com/en-us/school/tabid/426/ID/435663/basic-ea-ma-cross

Please show all your code . . . if not please make sure the code you have posted above is inside a function . . . the example has it inside start()
/
To add comments, please log in or register