Noob Code Problem

 

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();
}
}
 
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();
}
}
 

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

}

 
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()