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.
I am trying to build a hedging EA, buying 4 different pairs. When I attach it to a chart, say EURUSD, and try to run it, it will only open the EURUSD order and none of the others. How do I get this to open all 4 orders? I have attahced the code.
I am trying to build a hedging EA, buying 4 different pairs. When I attach it to a chart, say EURUSD, and try to run it, it will only open the EURUSD order and none of the others. How do I get this to open all 4 orders? I have attahced the code.
I am not sure you can do that.
Anyway, you have to use the price of the specified symbol, you cannot use the same Bid or Ask for all ! So use MarketInfo() for all is regarding a pair other than the one of the chart.
I've seen it done with other EAs but you are right about Bid and Ask. maybe that's why it failed although the error was invalid symbol. There should be a way. The OrderSend just expects a string.
I've seen it done in other EAs and OrderSend just expects a string. You are right about MarketInfo(). Maybe that's the problem, but the error says invalid symbol.
I've seen it done in other EAs and OrderSend just expects a string. You are right about MarketInfo(). Maybe that's the problem, but the error says invalid symbol.
Did you try on a demo account or only in the backtester ?
I think you should be able to open orders on other symbol on an account, but not in the backtester.
See Testing Features and Limits in MetaTrader 4
Quote:
Trading is permitted for the symbol under test only, no portfolio testing
Attempts to trade using another symbol will return error
I am trying to build a hedging EA, buying 4 different pairs. When I attach it to a chart, say EURUSD, and try to run it, it will only open the EURUSD order and none of the others. How do I get this to open all 4 orders? I have attahced the code.
bhale.
Use the MarketInfo() function instead of using bid and ask.
Yeah thanks guys. You are right. The change worked but it won't work in the Strategy Tester, so have to do this on on forward test only. Right now the problem with this is it doesn't get the profit loss right. OrderProfit() returns zero all the time. If I can get this calculation working, then this EA will buy the four pairs and when it reaches profit target, close them out and reopen. So far just doing it manually has brought some large wins on a full lot, with very little drawdown since it is a dollar hedge. Many days, the $150 target is reached 4 or 5 times. If I do nothing it can reach $400 to $500.
Yeah thanks guys. You are right. The change worked but it won't work in the Strategy Tester, so have to do this on on forward test only. Right now the problem with this is it doesn't get the profit loss right. OrderProfit() returns zero all the time. If I can get this calculation working, then this EA will buy the four pairs and when it reaches profit target, close them out and reopen. So far just doing it manually has brought some large wins on a full lot, with very little drawdown since it is a dollar hedge. Many days, the $150 target is reached 4 or 5 times. If I do nothing it can reach $400 to $500.
You cannot use Profit(), but you can use something like this for a buy:
Profit = MarketInfo(yoursymbol, MODE_TICKVALUE)*OrderLots()*(MarketInfo(yoursymbol , MODE_BID) - OrderOpenPrice())/MarketInfo(yoursymbol, MODE_POINT);