Forex



Go Back   Forex Trading > Discussion Areas > 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 10-06-2006, 04:25 PM
Junior Member
 
Join Date: Jul 2006
Posts: 21
GP2X is on a distinguished road
Lost magic number and comment after partially closing

Does anyone here have a solution about this problem? Let's say you use OrderSend to open 0.5 lots. If you call orderClose to close 0.1 lot. The system would generate another new 0.4 lots order, but your original magic number and comment were lost. Without them, your EA couldn't work together with others on the same symbol. I have to open multiple orders for this problem, wondering if there is anyway to keep them.
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 10-08-2006, 07:28 PM
Junior Member
 
Join Date: Jul 2006
Location: North Carolina, US
Posts: 7
ScottB is on a distinguished road
Lost magic number

No warranty to this code but it has worked for a very long time

int orderToClose = (ticket number of the smaller ticket);
int closingTicket = (ticket number of the larger ticket);

if (orderToClose != 0 && closingTicket != 0)
{
bFlag1 = OrderCloseBy(orderToClose, closingTicket);
if (bFlag1 == true)
{

newTicket = 0;

// Check for a new ticket
for (idx2 = OrdersTotal() - 1; idx2 >= 0; idx2--)
{
if (OrderSelect(idx2, SELECT_BY_POS, MODE_TRADES))
{
s = StringConcatenate("split from #", orderToClose);
splitIndex = StringFind(OrderComment(), s, 0);
if (splitIndex != -1)
{
// We found the new ticket number
newTicket = OrderTicket();

// Now update the old ticket to the new ticket
closingTicket = newTicket;

break;
}
}
}
}

In my opinion MQL4 has it completely backwards on this point. They change the ticket number making it very difficult to find.

I hope this helps.
Scott
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 10-08-2006, 07:29 PM
Junior Member
 
Join Date: Jul 2006
Location: North Carolina, US
Posts: 7
ScottB is on a distinguished road
lost magic number

I assure you I can format code; for some reason all my formatting went out the window when I posted my reply .
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 10-09-2006, 12:34 AM
Snuffleupagus's Avatar
Member
 
Join Date: Oct 2005
Posts: 37
Snuffleupagus is on a distinguished road
Quote:
Originally Posted by ScottB
I assure you I can format code; for some reason all my formatting went out the window when I posted my reply .
Try using the code tags when posting. It looks like a "#" on the toolbar.
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 10-09-2006, 03:38 AM
Junior Member
 
Join Date: Jul 2006
Posts: 21
GP2X is on a distinguished road
Thanks, so it will use "Split from xxx" as the comment of the new orders. I will try it.
Quote:
Originally Posted by ScottB
No warranty to this code but it has worked for a very long time

int orderToClose = (ticket number of the smaller ticket);
int closingTicket = (ticket number of the larger ticket);

if (orderToClose != 0 && closingTicket != 0)
{
bFlag1 = OrderCloseBy(orderToClose, closingTicket);
if (bFlag1 == true)
{

newTicket = 0;

// Check for a new ticket
for (idx2 = OrdersTotal() - 1; idx2 >= 0; idx2--)
{
if (OrderSelect(idx2, SELECT_BY_POS, MODE_TRADES))
{
s = StringConcatenate("split from #", orderToClose);
splitIndex = StringFind(OrderComment(), s, 0);
if (splitIndex != -1)
{
// We found the new ticket number
newTicket = OrderTicket();

// Now update the old ticket to the new ticket
closingTicket = newTicket;

break;
}
}
}
}

In my opinion MQL4 has it completely backwards on this point. They change the ticket number making it very difficult to find.

I hope this helps.
Scott
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
magic number forextrend Metatrader 4 42 06-12-2009 10:25 AM
How do I add magic number or comment to manual order? waltini Metatrader 4 3 11-01-2006 05:57 PM
MT4 Magic Number DeadEye96 Expert Advisors - Metatrader 4 2 09-19-2006 11:05 PM
magic number caldolegare Metatrader 4 4 03-19-2006 06:28 AM


All times are GMT. The time now is 05:51 AM.



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