Welcome to Forex-TSD!, one of the largest Forex forums worldwide, where you will be able to find the most complete and reliable Forex information imaginable.
From the list below, select the forum that you want to visit and register to post, as many times you want. It’s absolutely free. Click here for registering on Forex-TSD.
Exclusive Forum
The Exclusive Forum is the only paid section. Once you subscribe, you will get free access to real cutting-edge Trading Systems (automated and not), Indicators, Signals, Articles, etc., that will help and guide you, in ways that you could only imagine, with your Forex trading.
Elite Section
Get access to private discussions, specialized support, indicators and trading systems reported every week.
Advanced Elite Section
For professional traders, trading system developers and any other member who may need to use and/or convert, the most cutting-edge exclusive indicators and trading systems for MT4 and MT5.
Possible to trade different currency than the one EA is attached to?
Hi guys,
Wondering if anyone can help me out - I'm trying to write an EA that will be attached to the EURUSD chart, but want it occasionally to place a USDCHF trade as well as the EURUSD ones. Is this possible? I tried the following code:
But I kept getting the message "unknown symbol name USDCHF for OrderSend function". Is this because the EA is attached to the EURUSD chart? And is there any way to tell the EA to buy a different currency (and then later to close it)?
Any suggestions would be very appreciated! (Oh, and does anyone know of an EA that does this? I find it helpful to look at the code of working EA's when I'm struggling with a problem.)
Wondering if anyone can help me out - I'm trying to write an EA that will be attached to the EURUSD chart, but want it occasionally to place a USDCHF trade as well as the EURUSD ones. Is this possible? I tried the following code:
But I kept getting the message "unknown symbol name USDCHF for OrderSend function". Is this because the EA is attached to the EURUSD chart? And is there any way to tell the EA to buy a different currency (and then later to close it)?
Any suggestions would be very appreciated! (Oh, and does anyone know of an EA that does this? I find it helpful to look at the code of working EA's when I'm struggling with a problem.)
Tim
Tim,
I'm writing right now an article about this issue, please check it at:
Thanks CG! You're such a helpful guy..... I've really appreciated all the hard work you put into those Metatrader lessons, and they have been a great help to me!
I look forward to reading the article when it's ready
Hi CG.... it was very interesting reading your tutorial, but I still don't understand exactly how to tell Metatrader to buy or sell a different currency from the one the EA is attached to. Would it be possible for you to post an example of some code that does this? For example, when the EA is attached to EUR/USD, how do I tell it to buy USD/CHF at the current Ask price?
Hi CG.... it was very interesting reading your tutorial, but I still don't understand exactly how to tell Metatrader to buy or sell a different currency from the one the EA is attached to. Would it be possible for you to post an example of some code that does this? For example, when the EA is attached to EUR/USD, how do I tell it to buy USD/CHF at the current Ask price?
which didn't work. Is this because I didn't use the ibars Function first, or have I got the code completely wrong?
Can you, or anyone else help with this?
Tim
Hi Tim,
I think you are in a hurry and can not wait for the part 2 of the article, So take the temporarily answer:
To open an "USDCHF" (or any another pair) for an EA that hosted on "EURUSD" chart (or any another pair) you have to use code like this:
PHP Code:
if(Buy==true) //buy conditions have been met { RefreshRates(); OrderSend("USDCHF",OP_BUY,Lots,MarketInfo("USDCHF",MODE_ASK),Slippage,MarketInfo("USDCHF",MODE_ASK)-StopLoss*Point,MarketInfo("USDCHF",MODE_ASK)+TakeProfit*Point,ExpertComment,MagicNumber,0,Green); } if(Sell==true) //sellconditions have been met { RefreshRates(); OrderSend"USDCHF",OP_SELL,Lots,MarketInfo("USDCHF",MODE_BID),Slippage,MarketInfo("USDCHF",MODE_BID)+StopLoss*Point,MarketInfo("USDCHF",MODE_BID)-TakeProfit*Point,ExpertComment,MagicNumber,0,Red); }
In the part 2 of the article you'll know what does the above code mean!
Hey CG..... I just found your article on Hedging which helped with my original question(and helped me understand the code snippets below), but when I try to backtest your Hedging.mq4 EA I get an error message saying "invalid price for OrderSend function" when it tries to place the USDCHF order. Do you know why this is happening?
Trading is permitted for the symbol under test only
Quote:
Originally Posted by timbo
Hey CG..... I just found your article on Hedging which helped with my original question(and helped me understand the code snippets below), but when I try to backtest your Hedging.mq4 EA I get an error message saying "invalid price for OrderSend function" when it tries to place the USDCHF order. Do you know why this is happening?
It's a limitation in MT BackTesting:
Trading is permitted for the symbol under test only, no portfolio testing Attempts to trade using another symbol will return error