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

 
tonny:

but as global it does'nt

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


It won't confuse the system.


Sorry but I started thinking this is a hoax !.

 

Anyway i dont see why he cant use

Symbol()
 
tonny:

Anyway i dont see why he cant use

I think he's explained it on first page about 2 post above your first post in this thread.
 

but, in the script that was run, there were spaces on both sides of the slashes but the output in the log only had one of the spaces (possibly a typing mistake) but the boolean test says they are equal - meaning it should work.

Print(Symbol()," / ",symbol," / ",(Symbol() == symbol));

 
I think the problem lies in the code we haven't seen yet . . .
 

I did ask this before ...

onewithzachy:

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

... 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

 

Alright I have another idea, wimpy63 could you create a script like this an run it

#include <stdlib.mqh>
extern string symbol="USDCAD";

int start()
  {
   int tick = OrderSend (symbol, OP_BUY, 0.01, MarketInfo (symbol, MODE_ASK), 10, 0.0, 0.0);
   Alert (ErrorDescription(GetLastError()));
   Sleep (3000);
   OrderClose (tick, 0.01, MarketInfo (symbol, MODE_BID), 10);
   return(0);
  }

If you still have that error, could you attach the compiled .ex4 so that we can test that compiled .ex4 here.

:D

 

My guess is that he's using the back-tester and does not understand the limitations.

extern string symbol = "USDCAD"; 
void start(){
   Print("Chart_Symbol="+Symbol(),"  Extern_Symbol="+symbol);
   OrderSend(symbol,0,1,Ask,0,0,0,"",7,0,Blue);
}

Using the above EA in the back-tester yields.

10:46:03 Help2 EURUSD,M1: loaded successfully
10:46:03 Help2 test started
10:46:03 2011.01.02 23:00  Help2 EURUSD,M1: Chart_Symbol=EURUSD  Extern_Symbol=USDCAD
10:46:03 2011.01.02 23:00  Help2 EURUSD,M1: unknown symbol name USDCAD for OrderSend function
10:46:03 2011.01.02 23:00  Help2 EURUSD,M1: OrderSend error 4106

His title is "Can i use an extern variable to set symbols for my EA to run?". So its clear to me that he's trying to generate an EA. It seems he wants to use this EA on 10 different symbols but its not clear to me if he's going to open 10-different-charts. If he's going to open up 10-different-charts then why would he need to pass an External Symbol? If he's going to use upon 1 chart then he should review the code i submitted.

*Mt4 does not support multi-currency back-testing.

*You cannot use Symbol() in your orderselect Loops when you're providing a different Symbol then the chart the EA is attached to.

 
ubzen:

My guess is that he's using the back-tester and does not understand the limitations.

Using the above EA in the back-tester yields.

His title is "Can i use an extern variable to set symbols for my EA to run?". So its clear to me that he's trying to generate an EA. It seems he wants to use this EA on 10 different symbols but its not clear to me if he's going to open 10-different-charts. If he's going to open up 10-different-charts when why would he need to pass an External Symbol? If he's going to use upon 1 chart then he should review the code i submitted.

*Mt4 does not support multi-currency back-testing.

*You cannot use Symbol() in your orderselect Loops when you're providing a different Symbol then the chart the EA is attached to.