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 05-15-2006, 12:49 PM
Junior Member
 
Join Date: Nov 2005
Posts: 14
timbo is on a distinguished road
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:

OrderSend("USDCHF",OP_BUY,Lots,Ask,3,StopLoss*Poin t,TakeProfit*Point,"UC",55555,0,Green)

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
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 05-15-2006, 01:14 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 994
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Wink

Quote:
Originally Posted by timbo
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:

OrderSend("USDCHF",OP_BUY,Lots,Ask,3,StopLoss*Poin t,TakeProfit*Point,"UC",55555,0,Green)

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:

http://www.metatrader.info/node/124
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
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 05-15-2006, 01:44 PM
Junior Member
 
Join Date: Nov 2005
Posts: 14
timbo is on a distinguished road
Quote:
Originally Posted by codersguru
Tim,

I'm writing right now an article about this issue, please check it at:

http://www.metatrader.info/node/124
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

Tim
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-03-2006, 12:20 PM
Junior Member
 
Join Date: Nov 2005
Posts: 14
timbo is on a distinguished road
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?

Originally I tried:

OrderSend("USDCHF", OP_BUY, Lots, Ask, 3, StopLoss*Point, TakeProfit*Point, "UC", 55555, 0, Green)

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
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-03-2006, 06:11 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 994
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Quote:
Originally Posted by timbo
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?

Originally I tried:

OrderSend("USDCHF", OP_BUY, Lots, Ask, 3, StopLoss*Point, TakeProfit*Point, "UC", 55555, 0, Green)

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!
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
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-04-2006, 12:57 PM
Junior Member
 
Join Date: Nov 2005
Posts: 14
timbo is on a distinguished road
Quote:
Originally Posted by codersguru
In the part 2 of the article you'll know what does the above code mean!
Ooh.... thanks CG..... looking forward to it, and I'll try to be more patient!!
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-04-2006, 01:54 PM
Junior Member
 
Join Date: Nov 2005
Posts: 14
timbo is on a distinguished road
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?
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-05-2006, 01:46 PM
codersguru's Avatar
Senior Member
 
Join Date: Oct 2005
Posts: 994
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Arrow 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

Please review this article:
http://articles.mql4.com/72


So, this kind of program have to forward tesing only!
__________________
Hope it helps !
Coders' Guru
Senior MQL programmer:
www.xpworx.com/custom.htm
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-06-2006, 12:55 PM
Junior Member
 
Join Date: Nov 2005
Posts: 14
timbo is on a distinguished road
Thanks again for your help CG... the Hedging article really helped me understand the concept of instructing the EA to buy/sell other currencies!!

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
Easiest Currency Pair to Trade yyc196 General Discussion 36 09-03-2009 07:10 AM
Trade muliple currency Pairs rbowles Metatrader 4 5 08-13-2006 06:51 AM
Why EA is not working when attached josephine General Discussion 5 03-04-2006 07:47 PM


All times are GMT. The time now is 06:42 AM.



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