Forex



Go Back   Forex Trading > Programming > MetaTrader
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 09-29-2008, 11:17 AM
Junior Member
 
Join Date: Oct 2007
Posts: 3
lesaurus is on a distinguished road
Please why doesnt this work?

Sorry to have to ask but this is driving me up the wall.

What i want to eventually want to do is to buy 1 lot of EURUSD and at the same time SELL 1 lot of GBPUSD by just double clicking a script whilst a chart of EURUSD is open.

I know i have to use the market info command and the buy command works.

When i try to add the sell part it doesnt. I have stripped it right down to the point where i am just trying to sell at market price the GBPUSD on a EURUSD chart and i have this


//+------------------------------------------------------------------+
//| sell.mq4 |
//| Copyright © 2008, MetaQuotes Software Corp. |
//| Forex Trading Software: Forex Trading Platform MetaTrader 4 |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008, MetaQuotes Software Corp."
#property link "http://www.metaquotes.net"

#include <stdlib.mqh>
#include <WinUser32.mqh>

//+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
//----


int ticket=OrderSend("GBPUSD",OP_SELL,1,MarketInfo("GB PUSD",MODE_BID),0,"expert comment",255,0,CLR_NONE);

if(ticket<1)
{
int error=GetLastError();
Print("Error = ",ErrorDescription(error));
return;
}
//----
OrderPrint();
return(0);
}






Would someone be kind enough to tell me what i am doing wrong

Thanks Paul
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 09-29-2008, 11:46 AM
jlpi's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 336
jlpi is an unknown quantity at this point
from what I see 2 parameters are missing in your OrderSend function, stoploss, and takeprofit and at least in what you put there is a space in "GB(space)PUSD" but that maybe comes from Copy Paste

int OrderSend( string symbol, int cmd, double volume, double price, int slippage, double stoploss, double takeprofit, string comment=NULL, int magic=0, datetime expiration=0, color arrow_color=CLR_NONE)

An what error do you get in the log file when you execute the script?
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 09-29-2008, 12:22 PM
Junior Member
 
Join Date: Oct 2007
Posts: 3
lesaurus is on a distinguished road
Hi jipl.

Thanks for your reply its very much appreciated.

Firstly yes that is due to copy paste.

I do not get any error, it says script loaded ok and then script removed ok

If i use this it works




int start()
{
//----
int ticket=OrderSend("EURUSD",OP_BUY,1.0,MarketInfo("E URUSD",MODE_ASK),0,"expert comment",255,0,CLR_NONE);

if(ticket<1)

{
int error=GetLastError();
Print("Error = ",ErrorDescription(error));
return;
}
//----
OrderPrint();
return(0);
}



But if i change to this it doesnt

int start()
{
//----
int ticket=OrderSend("GBPUSD",OP_SELL1.0,MarketInfo("G BPUSD",MODE_BID),0,"expert comment",255,0,CLR_NONE);

if(ticket<1)

{
int error=GetLastError();
Print("Error = ",ErrorDescription(error));
return;
}
//----
OrderPrint();
return(0);
}



As you can see the parameters for sl and tp are missing in the one that works so thats why i didnt put them in the one that doesnt.

I will try it though thanks

Paul
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 09-29-2008, 12:29 PM
Junior Member
 
Join Date: Oct 2007
Posts: 3
lesaurus is on a distinguished road
It works thanks.

jlpi, thanks i have tried adding the sl and tp parameters and it is fine now. Still dont know why the buy script works without them but hey at least its working.

Again thanks for your help

Paul
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 09-29-2008, 12:44 PM
jlpi's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 336
jlpi is an unknown quantity at this point
Quote:
Originally Posted by lesaurus View Post
jlpi, thanks i have tried adding the sl and tp parameters and it is fine now. Still dont know why the buy script works without them but hey at least its working.

Again thanks for your help

Paul
no problem, you are welcome
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 09-29-2008, 05:34 PM
Senior Member
 
Join Date: Feb 2007
Posts: 986
FerruFx is on a distinguished road
Quote:
Originally Posted by lesaurus View Post
But if i change to this it doesnt

ticket=OrderSend("GBPUSD",OP_SELL1.0,MarketInfo("GBPUSD",MODE_BID),0,"expert comment",255,0,CLR_NONE);
A comma is missing.

FerruFx
__________________
FerruFx / www.ervent.net - Professional Coding Services (EAs/Indicators/Alerts)

BBVPS.com - Reliable Windows VPS For MT4 Hosting
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
EA doesnt show symbols soundchild Setup Questions 7 05-03-2009 09:06 AM
will this work? stevenali Suggestions for Trading Systems 6 07-24-2007 03:19 PM
Need Help With EA that does not work shorttermtrader Metatrader 4 0 05-02-2007 02:55 PM
Help me!!!! Why this EA doesn't work???? metastock Expert Advisors - Metatrader 4 3 02-17-2007 06:31 AM
How does this really work? Ayo Questions 0 12-19-2005 03:30 PM


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



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