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

To add comments, please log in or register
chayutra sriboonruang
112
chayutra sriboonruang  
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?
Slava
Moderator
13448
Slava  
Yes, You can
chayutra sriboonruang
112
chayutra sriboonruang  
thnx but how? pls guide me
Remo Toomela
53
Remo Toomela  
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);
chayutra sriboonruang
112
chayutra sriboonruang  
thank you ... i got it ^_^
Ahmed Soliman
23899
Ahmed Soliman  
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);
Powell
36
Powell  
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?
chayutra sriboonruang
112
chayutra sriboonruang  
this EA can open GBPUSD even attached on EURUSD chart
Remo Toomela
53
Remo Toomela  
codersguru:
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.. .
Semion Tremsin
1866
Semion Tremsin  
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...
chayutra sriboonruang
112
chayutra sriboonruang  
this strategy can not be tested by backtest ,
 it will only open trade with the symbol you chosed
12
To add comments, please log in or register