Forex



Go Back   Forex Trading > Downloads > Expert Advisors - Metatrader 4
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-20-2006, 03:56 AM
Senior Member
 
Join Date: May 2006
Posts: 210
Morpheus is on a distinguished road
Help closing order (programming)

Hi. I'm still trying to get the hang of the MT4 programming. My background is C++.

I open the order like this inside the EA.

OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Ask+5 00*Point,0,name,MagicNumber,0,Red);

Then I want to close that order and that order only.

So I use

OrderClose(MagicNumber,OrderLots(),Ask,Slippage,Re d);


This doesn't work for me, though. What am I doing wrong? Thanks.
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-20-2006, 04:54 PM
Senior Member
 
Join Date: Feb 2006
Posts: 587
Michel is on a distinguished road
Quote:
Originally Posted by Morpheus
Hi. I'm still trying to get the hang of the MT4 programming. My background is C++.

I open the order like this inside the EA.

OrderSend(Symbol(),OP_SELL,Lots,Bid,Slippage,Ask+5 00*Point,0,name,MagicNumber,0,Red);

Then I want to close that order and that order only.

So I use

OrderClose(MagicNumber,OrderLots(),Ask,Slippage,Re d);


This doesn't work for me, though. What am I doing wrong? Thanks.
MagicNumber doesn't identify the order for OrderClose(), you must use the ticket number : OrderClose(OrderTicket(),OrderLots(),Ask,Slippage, Red);
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-20-2006, 04:57 PM
Senior Member
 
Join Date: May 2006
Posts: 210
Morpheus is on a distinguished road
My dilemma is what if I have the EA working on 7 different currencies. How does it know that orderticket is the right one?
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 05-20-2006, 05:02 PM
elihayun's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 396
elihayun is on a distinguished road
Quote:
Originally Posted by Morpheus
My dilemma is what if I have the EA working on 7 different currencies. How does it know that orderticket is the right one?
just use :

if (( OrderMagicNumber() == megic) && (OrderSymbol() == Curr))

to distinguish it from others
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 05-20-2006, 05:07 PM
Senior Member
 
Join Date: May 2006
Posts: 210
Morpheus is on a distinguished road
Quote:
Originally Posted by elihayun
just use :

if (( OrderMagicNumber() == megic) && (OrderSymbol() == Curr))

to distinguish it from others
? What is "megic" and "curr" ? You mean test to see if they are the right ones? How exactly would I do that. I'm not very familiar with MT4.
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 05-20-2006, 05:46 PM
elihayun's Avatar
Senior Member
 
Join Date: Jan 2006
Posts: 396
elihayun is on a distinguished road
Quote:
Originally Posted by Morpheus
? What is "megic" and "curr" ? You mean test to see if they are the right ones? How exactly would I do that. I'm not very familiar with MT4.
magic is your magic number that u used when open the order. Curr is the currency that u want to check. you can use Symbol() instead
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
Closing all orders EA? InTrance Expert Advisors - Metatrader 4 10 08-19-2007 02:13 AM
Closing positions before new day jorgeng Metatrader 4 5 04-11-2007 08:40 AM
order closing alarm for hedging system johnboy Metatrader 4 1 12-17-2006 05:05 PM
EA - closing all positions at once. ra300z Metatrader 4 6 09-08-2006 02:45 AM


All times are GMT. The time now is 09:20 PM.



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