Thread: How to code?
View Single Post
  #914 (permalink)  
Old 05-13-2008, 02:56 PM
Michel Michel is offline
Senior Member
 
Join Date: Feb 2006
Posts: 525
Michel is on a distinguished road
Quote:
Originally Posted by basza View Post
Hi all

I am trying to get an ea to compile, but it comes up with the following error:

Code:
'TradeSymbol' - expression on global scope not allowed	I:\Program Files\MetaTrader - Alpari\experts\TTL.mq4 (65, 34)
Now the part of the ea causing this is right at the start of the code :

Code:
string         TradeSymbol;      TradeSymbol=Symbol();
If I block this out it comes up with errors for the following bit of code :

Code:
 if(TotalTradesThisSymbol(TradeSymbol)==0) {  int BS=0,SS=0,BL=0,SL=0;   }
   if(TotalTradesThisSymbol(TradeSymbol)>0)  {
      for(cnt=0;cnt<total;cnt++) {
         OrderSelect(cnt,SELECT_BY_POS,MODE_TRADES);
         if(OrderSymbol()== Symbol) {
            if(OrderMagicNumber()==11) { BS=OrderTicket(); }
            if(OrderMagicNumber()==22) { SS=OrderTicket(); }
            if(OrderMagicNumber()==33) { BL=OrderTicket(); }
            if(OrderMagicNumber()==44) { SL=OrderTicket(); }
            }//end if(OrderSymbol
         }//end for
  }//end if   */
What I am wanting to know is if there is an easy way to fix this.
I'm no good at coding , only copying and pasteing.

Thanks in advance
Basza
You can define TradeSymbol as string on global scoop, but there you cannot evaluate the function Symbol(). So replace all "TradeSymbol" by "Symbol()", or assign the value in the init() or start() function like this:
PHP Code:
void Init(){TradeSymbol=Symbol();} 
Reply With Quote