Using The Same EA To Open Orders On Multiple Symbols

 

Hey

I have been trying to code an ea that can open orders on different symbols but whenever it tries to open on a symbol that is not the current symbol I get the error "unknown symbol for ordersend function" which is error code 4106. Some one please help!

 
Lema_Carl:

Hey

I have been trying to code an ea that can open orders on different symbols but whenever it tries to open on a symbol that is not the current symbol I get the error "unknown symbol for ordersend function" which is error code 4106. Some one please help!

Show your code . . .  if your EA is on GBPUSD and you want to place an order on EURUSD you use "EURUSD" for the symbol . . . .  it has to be in " " to make it a string.  Your symbol names may have extra characters at the end,  "EURUSDi" for example . . .
 

Here's an example with my multi-currency template. Here.

 
Lema_Carl:

Hey

I have been trying to code an ea that can open orders on different symbols but whenever it tries to open on a symbol that is not the current symbol I get the error "unknown symbol for ordersend function" which is error code 4106. Some one please help!

1. Never hard coded the symbol. Attach it to chart for the symbol that you want the EA to trade and use Symbol() in your code.

2. Even if you successful in doing this, your EA will depend on tick from attached chart and not from the symbol you want to trade, so you may be missing some tick.  

 
phi.nuts:

1. Never hard coded the symbol. Attach it to chart for the symbol that you want the EA to trade and use Symbol() in your code.

2. Even if you successful in doing this, your EA will depend on tick from attached chart and not from the symbol you want to trade, so you may be missing some tick.  

He wants to trade a different symbol to Symbol()
 

phi.nuts: 1. Never hard coded the symbol. Attach it to chart for the symbol that you want the EA to trade and use Symbol() in your code. 2. Even if you successful in doing this, your EA will depend on tick from attached chart and not from the symbol you want to trade, so you may be missing some tick.

1. I wouldn't say Never. IMO, it depends on what he needs. Example: the Meta-Quotes Championship only allows you to attach your Expert on 1_Chart. 2. Experts miss ticks anyways because of lost packets traveling in Cyberspace.

If someone is running a true-multi-currency expert, IMO it's much more simple to just provide the symbol names on a single chart. Otherwise a simple function like Profit_Of_All_Symbol() has to be processed by every chart it's attached to, or communicate this info in GV or Files. Each chart will also have to Sleep while a resource like Trade_Context is being used. <-- Its missing ticks while this is happening.

Another argument could be made that the broker could change the symbol's name. While true it's still not worth the redundant processing. I think as a programmer, one have to realize that sometimes you cannot Bullet-Proof everything and a simple user Input will have to do. 

 
RaptorUK:
He wants to trade a different symbol to Symbol()

Too risky even if using All Market Data 

ubzen:

1. I wouldn't say Never. IMO, it depends on what he needs. Example: the Meta-Quotes Championship only allows you to attach your Expert on 1_Chart. 2. Experts miss ticks anyways because of lost packets traveling in Cyberspace.

If someone is running a true-multi-currency expert, IMO it's much more simple to just provide the symbol names on a single chart. Otherwise a simple function like Profit_Of_All_Symbol() has to be processed by every chart it's attached to, or communicate this info in GV or Files. Each chart will also have to Sleep while a resource like Trade_Context is being used. <-- Its missing ticks while this is happening.

Another argument could be made that the broker could change the symbol's name. While true it's still not worth the redundant processing. I think as a programmer, one have to realize that sometimes you cannot Bullet-Proof everything and a simple user Input will have to do. 

 1. I'm full aware about EA in ATC. ATC trade demo money. I won't give any advice that kind of automated trading to anyone with real money.

2. Multi symbol EA has to wait for another time when there is another trading operation for other symbol and it can not RefreshRates().

 

Why do you want to open on another pair? Much more complicated, you can't use Time[], Bid, Digits, etc.

Put the EA on another chart of that pair. Done.

 

@phi.nuts

1. ATC, was an example of No_Choice. Another example is Saving Resources, Ease-Of-Attach, Better Accuracy for Multi-Currency, Ease-Of-Self Compatable.  You're saying that its Risky, Risky in terms of what? Missing a Tick?

2. Thats why its a Multi-Currency Expert because the algorithm depends on what's happening within another Symbol. There has to be a Group leader, namely the more active currency. Any Expert which cannot be profitable due to missed tick have a serious problem. RefreshRates() are for people who want to use "pre-defined variables and series arrays". MarketInfo() does not have this problem.

@WHRoeder

Obviously I dis-agree. He should have the option. For multi-currency "Pre-Defined" variables just don't cut-it. iTime(), marketinfo_bid, marketinfo_digit, etc. Put the EA on one chart and done. :)

 
WHRoeder:

Why do you want to open on another pair? Much more complicated, you can't use Time[], Bid, Digits, etc.

Put the EA on another chart of that pair. Done.


How we could run a same EA    for ex    Moving Average EA in one account but in several pairs such as    gbp/usd, euro/usd   , XAU/USD

Thnks

 
Imagine someone want to trade the Symbol with the lowest Volatility for 50+ charts.
- Now it's none of my business why this person wants to trade 50 different symbols.
- Attach to 50 different Charts alone is enough to make me suggest a Single_Chart method.
- There's no doubt, it'll eat resources, I mean just drawing the bars alone is not free.

Here's my suggestion:
void start(){
    string  Fx__Symbol;
    string  Symbol_Ray[]={"EURUSD","USDJPY","GBPUSD","USDCHF","AUDUSD","USDCAD"};
    string  TradeSym=Symbol_With_Lowest_Volatility(Symbol_Ray);
    for(int i=0; i<ArraySize(Symbol_Ray); i++){
        Fx__Symbol=Symbol_Ray[i];
        if(IsTesting()){Fx__Symbol=Symbol(); i=9999;}
        if(Fx__Symbol != TradeSym){continue;}
}   }


- Lowest Volatility function is fairly complex and has to consider all symbols within.
- I really don't see why this resource heavy function needs precessing 50 times.
- If you have 50 such functions, are you going to create 50 Global_Variable_Set.
- Which Symbol will update the GV? Are we not back to square one?
- When will this Symbol update the GV? Synchronization nightmare.

If anyone have a better solution for such Expert Advisors, I'm all Ears.

Ps> I would rather consider an Endless Loop before I attach to 50 charts.

Reason: