Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
![MQL5 forum: Expert Advisors and Automated Trading MQL5 forum: Expert Advisors and Automated Trading](https://c.mql5.com/36/82/mql5-forum-expert-advisors-and.png)
- www.mql5.com
how can anybody help you if you do not include your code?
And before a moderator says it, i will get in first... we are not mind readers (hahahahahahaha)
I recommend that you search the website with terms like "multicurrency trading". There are many threads discussing the differences between coding an ea for single or multiple pairs. I responded to a few just in the past week.
- If you show your attempts and describe your problem clearly, you will most probably receive an answer from the community. Use the CODE button (Alt-S) when inserting code.
- To learn MQL programming, you can research the many available Articles on the subject, or examples in the Codebase, as well as reference the online Book and Documentation
- Finally, you also have the option to hire a programmer in the Freelance section.
The way multi-currency works in the tester is not the same way as in live market. Share you code on how you manage to get the trading symbols.
you are all right, so here is the code ,
this EA checks whether the explicit value of a currency pair is equal to the explicit one calculated through two others (Cross rates), the program also checks by comparing the explicit value with the implicit one calculated on three different pairs.
If the two values, implicit and explicit, diverge significantly then trades are opened on the three reference currencies (third_currency).
please note that this program is one of the first I wrote using metaquotes languages so this code will certainly not be an example of elegance and efficiency.
//+------------------------------------------------------------------+ //| Triangolare semplificato.mq5 | //| Copyright 2023, MetaQuotes Ltd. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2023, MetaQuotes Ltd." #property link "https://www.mql5.com" #property version "1.00" #include <Trade\Trade.mqh> CTrade trade; #include <Trade\PositionInfo.mqh> CPositionInfo p_info; string first_currency[]={"EURUSD#","EURGBP#","EURAUD#","EURGBP#","EURAUD#","EURAUD#","EURGBP#","GBPAUD#","GBPNZD#"}; //first_currency pair string second_currency[]={"USDCAD#","GBPCAD#","AUDCAD#","GBPUSD#","AUDUSD#","AUDUSD#","GBPUSD#","AUDUSD#","NZDUSD#"}; // second_currency pair string third_currency[]={"EURCAD#","EURUSD#","GBPUSD#"}; // third_currency pair (explicit market price) double first_ask; // first_currency value double first_bid; double second_ask; // second_currency value double second_bid; double third_ask[4]; //third_currency value double third_bid[4]; double implicit_ask[20]; //implicit value double implicit_bid[20]; double margin_free; double balance; double balance_max; double start_balance; double equity; input double lot; input double distance; double tr_stop; input double pip_win; input double pip_lose; int OnInit() { balance_max=AccountInfoDouble(ACCOUNT_BALANCE); balance=balance_max; tr_stop=0.2; Print("Cross Rates Arbitrage attached"); Print("distance ",distance," tp ",pip_win," sl ",pip_lose); return(INIT_SUCCEEDED); } void OnDeinit(const int reason) { } void OnTick() { margin_free=AccountInfoDouble(ACCOUNT_MARGIN_FREE); balance=AccountInfoDouble(ACCOUNT_BALANCE); if(balance>balance_max) balance_max=balance; if(balance>balance_max*tr_stop && margin_free>balance*tr_stop){ int i,j; for(i=0;i<3;i++){ third_ask[i]=SymbolInfoDouble(third_currency[i],SYMBOL_ASK); third_bid[i]=SymbolInfoDouble(third_currency[i],SYMBOL_BID); for(j=i*3;j<(i+1)*3;j++){ first_ask=SymbolInfoDouble(first_currency[j],SYMBOL_ASK); first_bid=SymbolInfoDouble(first_currency[j],SYMBOL_BID); second_ask=SymbolInfoDouble(second_currency[j],SYMBOL_ASK); second_bid=SymbolInfoDouble(second_currency[j],SYMBOL_BID); implicit_ask[j]=NormalizeDouble(first_ask*second_ask,5); implicit_bid[j]=NormalizeDouble(first_bid*second_bid,5); } if((third_ask[i]+distance<implicit_bid[i*3]) && (third_ask[i]+distance<implicit_bid[i*3+1]) && (third_ask[i]+distance<implicit_bid[i*3+2])){ trade.Buy(lot,third_currency[i],third_ask[i],NormalizeDouble(third_bid[i]-pip_lose,5),NormalizeDouble(third_ask[i]+pip_win,5),"Cross Rates"); } else if ((third_bid[i]>implicit_ask[i*3]+distance) && (third_bid[i]>implicit_ask[i*3+1]+distance) && (third_bid[i]>implicit_ask[i*3+2]+distance)){ trade.Sell(lot,third_currency[i],third_bid[i],NormalizeDouble(third_ask[i]+pip_lose,5),NormalizeDouble(third_bid[i]-pip_win,5),"Cross Rates"); } } } }
you are all right, so here is the code ,
this EA checks whether the explicit value of a currency pair is equal to the explicit one calculated through two others (Cross rates), the program also checks by comparing the explicit value with the implicit one calculated on three different pairs.
If the two values, implicit and explicit, diverge significantly then trades are opened on the three reference currencies (third_currency).
please note that this program is one of the first I wrote using metaquotes languages so this code will certainly not be an example of elegance and efficiency.
i do not see any math for pip_win or pip_lose
And before a moderator says it, i will get in first... we are not mind readers (hahahahahahaha)
:)) Awesome
Can there be other causes for its malfunction?
if you checked EA on tester and it was ok, then try to find issues like:
- your account does not support non-manual operations (it blocks experts) then contact your broker
- Is it trading session? some times over night forex market shows trading data (candles) but trading itself is limited for 1 or 2 hours from different brokers.
- simplest thing is pushing on Algo Trading button if you forget to do!! Also check if you tick the box of "Allow Algo Trading" box in common tab of EA when you want to attach to chart.
- All of these can be debug if you add single code to see if orders sent? if yes, what is error code?
if you did not checked EA on tester and are not sure what is problem:
- make a debug and pay attention to symbol names you use. may be your account forex pair names has prefix/suffix.
- Check spread or slippage filters. May be your live account spread was very high to send trades over live test period.
- ...
- My broker ( XM ) does not block EA
- Trading sessions are not a problem
- Every algo trading button is setted in enabled
- If i try with a simple buy and sell EA everything works (there are no errors of any type)
- Suffix/prefix are the correct ones
trade.Buy
this function always prints something in journal. check it please.
input double lot; input double distance; double tr_stop; input double pip_win; input double pip_lose;
why these inputs does not has valid initial values?!
put all pairs you have in EA in watch list to have all data downloaded during live check.
![MQL5 - Language of trade strategies built-in the MetaTrader 5 client terminal](https://c.mql5.com/i/registerlandings/logo-2.png)
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi, I'm trying a new multicurrency strategy on MT5, I personally wrote the code which opens new trades only if certain conditions are met.
The strategy constantly monitors the price of different forex currencies and according to the strategy tester it should have already opened several trades in the last two weeks (since I attached the ea to a chart on a virtual machine)
The problem is that in all this time the EA has not opened a single trade.
I checked all the possible causes of its malfunction:
After checking all these things and adjusting them, the EA still doesn't want to open trades.
Can there be other causes for its malfunction?
Thanks in advance