Forex



Go Back   Forex Trading > Training > Metatrader > Metatrader 4 mql 4 - Development course > Questions
Forex Forum Register More recent Blogs Calendar Advertising Others Help






Register
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.
See more

Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 06-27-2007, 04:45 PM
Member
 
Join Date: Nov 2006
Posts: 58
bhale is on a distinguished road
Problem with OrderSend - invalid symbol

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.
Attached Files
File Type: mq4 DollarHedge.mq4 (3.0 KB, 18 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #2 (permalink)  
Old 06-27-2007, 05:11 PM
Senior Member
 
Join Date: Feb 2006
Posts: 587
Michel is on a distinguished road
Quote:
Originally Posted by bhale View Post
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #3 (permalink)  
Old 06-27-2007, 05:33 PM
Member
 
Join Date: Nov 2006
Posts: 58
bhale is on a distinguished road
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #4 (permalink)  
Old 06-27-2007, 05:35 PM
Member
 
Join Date: Nov 2006
Posts: 58
bhale is on a distinguished road
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #5 (permalink)  
Old 06-27-2007, 06:55 PM
Senior Member
 
Join Date: Feb 2006
Posts: 587
Michel is on a distinguished road
Quote:
Originally Posted by bhale View Post
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.
May it be the "m" suffix on IBFX mini accounts ?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #6 (permalink)  
Old 06-27-2007, 09:01 PM
Senior Member
 
Join Date: Feb 2006
Posts: 587
Michel is on a distinguished road
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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #7 (permalink)  
Old 06-27-2007, 09:18 PM
Senior Member
 
Join Date: Nov 2005
Posts: 105
fxd01 is on a distinguished road
Quote:
Originally Posted by bhale View Post
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.

OrderSend("EURUSD",OP_BUY,EurUsdLots,MarketInfo("E URUSD",MODE_ASK),0,0,0,NULL,12345,0,CLR_NONE);

Modified code attached.


Hope this helps.

fxd01
Attached Files
File Type: mq4 DollarHedge-Mod.mq4 (3.2 KB, 14 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #8 (permalink)  
Old 06-27-2007, 09:22 PM
Senior Member
 
Join Date: Nov 2005
Posts: 105
fxd01 is on a distinguished road
Quote:
Originally Posted by fxd01 View Post
bhale.

Use the MarketInfo() function instead of using bid and ask.

OrderSend("EURUSD",OP_BUY,EurUsdLots,MarketInfo("E URUSD",MODE_ASK),0,0,0,NULL,12345,0,CLR_NONE);

Modified code attached.


Hope this helps.

fxd01
And of course, as Michael mentioned, add "m" suffix (ie. EURUSDm) if you are using IBFX mini a/c
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #9 (permalink)  
Old 06-27-2007, 10:24 PM
Member
 
Join Date: Nov 2006
Posts: 58
bhale is on a distinguished road
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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
  #10 (permalink)  
Old 06-27-2007, 10:42 PM
Senior Member
 
Join Date: Feb 2006
Posts: 587
Michel is on a distinguished road
Quote:
Originally Posted by bhale View Post
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);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!StumbleUpon this Post!Reddit this Post!Facebook this Post!BlinkList this Post!Google Bookmarks this Post!Yahoo! My Web this Post!
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OrderSend problem Hartadi Expert Advisors - Metatrader 4 10 04-11-2007 02:12 PM
How print a journal by symbol ? Jovager Expert Advisors - Metatrader 4 0 11-12-2006 11:13 AM
Script: Count your net positions in MT4 for a symbol ycomp Metatrader 4 4 11-10-2006 04:23 PM
How to add symbol ? mastri Metatrader 4 1 10-05-2006 04:22 PM


All times are GMT. The time now is 08:56 PM.



Search Engine Friendly URLs by vBSEO 3.2.0 ©2008, Crawlability, Inc.