Can i use an extern variable to set symbols for my EA to run? - page 2

 
RaptorUK:

One unrelated point . . . get rid of your end variable, just use a break instead.

... Or use return (true);

and that existeOrdenBuy() UDF must be a typo. it must be existBuy().

 
tonny:

And after declaring USDCAD as an extern variable what symbol chart are you attaching the EA to?


Of course i use the EA only in a USDCAD chart. But i always get the error 4106 if i use the external variable.
 
RaptorUK:

You said you run this EA on multiple Symbols, do you run it also on the same symbol but different timeframes ? for example, GBPUSD H1 & GBPUSD M15 ?

Maybe your 2nd order is being opened but is them being closed very quickly, have you checked this ?

One unrelated point . . . get rid of your end variable, just use a break instead.


The EA is running on only in one symbol chart. I don't run it in, for example, GBPUSD H1 and GBPUSD M15 at the same time.

But just to make sure, i checked if the second order was open and closed quickly. That doesn't happen

Ok. i will change the code. I will use the break.

 
wimpy63:

Of course i use the EA only in a USDCAD chart. But i always get the error 4106 if i use the external variable.
It works just fine for me . . no errors at all. symbol isn't a reserved word . . . but maybe MT4 doesn't like you using it . . . try a different variable name, like SymbolName
 
onewithzachy:

... Or use return (true);

and that existeOrdenBuy() UDF must be a typo. it must be existBuy().


Yes. I'm sorry. The function is existBuy().

 

I assume you're doing everything correct like ...

extern string symbol="USDCAD";

OrderSend (symbol, OP_BUY, 0.01, MarketInfo (symbol, MODE_ASK), 10, 0.0, 0.0);

... Coz obviously this is weird, and guessing around won't get us anywhere !, So I have two questions :

1. What's the broker name and MT build number, we may have to install it's MT4 ?

2. What's your OS and where did you install the MT4, is it in C:\Program Files\...

See if we can replicate your problem.

:D

 
wimpy63:

Of course i use the EA only in a USDCAD chart. But i always get the error 4106 if i use the external variable.
You do know of
Symbol()

right? Because if you are only using it on the symbol you declare in the extern variable i dont see why you should make it extern. Just use Symbol() and it will make the EA compatible with all symbols without changing anything all the time. Oh and also avoid using standard function names as variable names. i.e.

extern string symbol="EURUSD";           // Is a bad practice as you may confuse the system
extern string wimpy63s_symbol="EURUSD";  // recommended
 

Nope tonny,

See page 1, when wimpy63 using local variable everything is fine.

:D

 
onewithzachy:

Nope tonny,

See page 1, when wimpy63 using local variable everything is fine.

:D

but as global it does'nt


 
tonny:
You do know of

right? Because if you are only using it on the symbol you declare in the extern variable i dont see why you should make it extern. Just use Symbol() and it will make the EA compatible with all symbols without changing anything all the time. Oh and also avoid using standard function names as variable names. i.e.

It's not the variable name, I just tried it.