MQL4 - automated forex trading   /  

Forum

can i code the EA that attach in EURUSD chart to open or do something with GBPUSD ?

Back to topics list  | 1 2 To post a new topic, please log in or register

avatar
2077
vixenme 2006.09.01 07:02 
can i code the EA that attach in EURUSD chart to open or do something with GBPUSD ?

or i have to manage only the currency pair the EA attached on?
Expert Advisors Based on Popular Trading Systems and Alchemy of Trading Robot Optimization (Cont.)

Expert Advisors Based on Popular Trading Systems and Alchemy of Trading Robot Optimization (Cont.)

In this article the author continues to analyze implementation algorithms of simplest trading systems and introduces recording of optimization results in backtesting into one html file in the form of a table. The article will be useful for beginning traders and EA writers.


avatar
Moderator
5198
stringo 2006.09.01 11:36 
Yes, You can

avatar
2077
vixenme 2006.09.01 12:35 
thnx but how? pls guide me

avatar
43
zolero 2006.09.01 17:03 
All you have to remember is that Symbol() function and price functions (Ask, Bid) are reading data from this window where your EA is attached to. so you have to change it and show what you want. For price information there is a MarketInfo() function which gives you all dataset what you could need to open, close and modify a order.

So the code [to open a buy] could look something like this:
string Sym = "GBPUSD";
double ask   =MarketInfo(Sym,MODE_ASK);
 
OrderSend(Sym, OP_BUY, 1.0, ask, 5, 0, 0, "BUY", magic, 0, Gold);



avatar
2077
vixenme 2006.09.01 17:43 
thank you ... i got it ^_^

avatar
233
codersguru 2006.09.01 22:03 
Yes! But don't forget RefreshRates() function to be sure that you've got the up-to-date price data.

So, the code have to be like that:

string Sym = "GBPUSD";

RefreshRates();

double ask   =MarketInfo(Sym,MODE_ASK);
 
OrderSend(Sym, OP_BUY, 1.0, ask, 5, 0, 0, "BUY", magic, 0, Gold);


avatar
11
pwfx 2006.09.01 23:08 
zolero wrote:
All you have to remember is that Symbol() function and price functions (Ask, Bid) are reading data from this window where your EA is attached to. so you have to change it and show what you want. For price information there is a MarketInfo() function which gives you all dataset what you could need to open, close and modify a order.

So the code [to open a buy] could look something like this:
string Sym = "GBPUSD";
double ask   =MarketInfo(Sym,MODE_ASK);
 
OrderSend(Sym, OP_BUY, 1.0, ask, 5, 0, 0, "BUY", magic, 0, Gold);



Does it mean it's open trade to buy GBPUSD? Then if we want to buy/sell a few specific pairs of currency, how would the EA  be?

avatar
2077
vixenme 2006.09.02 05:08 
this EA can open GBPUSD even attached on EURUSD chart

avatar
43
zolero 2006.09.02 13:18 
codersguru wrote:
Yes! But don't forget RefreshRates() function to be sure that you've got the up-to-date price data.

So, the code have to be like that:

string Sym = "GBPUSD";

RefreshRates();

double ask   =MarketInfo(Sym,MODE_ASK);
 
OrderSend(Sym, OP_BUY, 1.0, ask, 5, 0, 0, "BUY", magic, 0, Gold);

somehow I have the feeling that refreshrates() doesn't help you. I don't think that it refreshes all data in your program but rather active pair or what function Symbol() is giving you. Maybe I'm totally wrong but it makes sense for a matter of speed. so if this is the case you can drop this function because it doesn't help you.. .

avatar
120
oldman 2006.09.19 08:59 
I am trying to open a trade on a different pair than the chart i am on, and using this:
string Sym = "EURUSD";
double ask =MarketInfo(Sym,MODE_ASK);
Print("eurusd=",ask);
I get "eurusd=0"
whatup?
(this is in the strategy tester journal., not live trading)
aha.. it works in real time.. not strategy tester...

avatar
2077
vixenme 2006.09.19 09:31 
this strategy can not be tested by backtest ,
 it will only open trade with the symbol you chosed
Back to topics list   | 1 2  

To add comments, please log in or register