Trading more than one currency

To add comments, please log in or register
Nico
29
Nico  
What piece of code do I need to add to my EA to be able to trade more than one currency at a time? I want this EA to look for signals in at least the four majors for a start.
Maratha
87
Maratha  
Wouldn't the 'pair' variable in every function achieve this? For Example,
double iMA( string symbol, int timeframe, int period, int ma_shift, int ma_method, int applied_price, int shift)

in the above function, if you use the right symbol, wouldn't it give you the values that you are looking for?
cockeyedcowboy
524
cockeyedcowboy  
Toets and Maratha

the above function call will give you the MA value of the given symbol and by ratating the symbol string you could get the different MA values for a given symbol list. This will not give you the orders in the different currencies. For that you need ordersend() function which you can place orders in which ever currency you wish by changing the symbol, as well, (simular to the iMA() function). When doing this, care must be taken with what you feed the ordersend function in referance to price data. If you say to buy EURUSD at the askprice when your on a GBPUSD chart you will be sending it the ask price of the GBP not the EUR. You will need to access the MarketInfo() function and retreive the correct price data. All the other inputs to the OrderSend() function will have to be that of the currency pair referanced in the ordersend() function or possible Errors 129 and 130 will be generated. I beleive that most of the other order function you will need to use the OrderSelect() function to gain the orderticket number to use them.

To answer your question. There are two ways to do it the above way in one EA the hard way or to have multiple copies of the EA running with it attached to different currencyies, the easy way.


Hope this helps

The CockeyedCowboy
mike johnson
8
mike johnson  
marketinfo only gives the current bid/ask, i think.
and, no need to run multiple copies of an EA..

try:

double chfjpy[][6];
double nzdusd[][6];

ArrayCopyRates(chfjpy,"CHFJPY",0);
ArrayCopyRates(nzdusd,"NZDUSD",0);

nzdusd[0][4]; //currenct bar's close of nzdusd
chfjpy[20][4]; //chfjpy close, 20 bars back in time.
cockeyedcowboy
524
cockeyedcowboy  
mikejohnson

When placeing an order in a different currency then the one on your chart you need to address the current Bid and Ask price of that currency from the MarketInfo window in order to place the order at the current (correct) price. Copying the price arrays into new array variables may not give you uptodate prices especially if your cross boarders between currencies with in your charts. If your needing complete data series for market analysis then your way is good but for placing orders your better with the current Bid Ask form the market infor window for that currency.

The CockeyedCowboy
To add comments, please log in or register