Forex
Google

Go Back   Forex Trading > Metatrader Training > Metatrader 4 mql 4 - Development course
Forex Forum Register FAQ Members List Calendar Search Today's Posts Mark Forums Read


Register in Forex TSD!
Trading Systems Leaders in this forum (automated trading systems) are winning more than 3000 pips in a month (30000$ investing one lot every time).
Click here to register and get more information

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 09-19-2006, 04:59 PM
kokas's Avatar
kokas kokas is offline
Senior Member
 
Join Date: Jun 2006
Location: Portugal
Posts: 275
kokas is on a distinguished road
Close all based on Magic

I need help, this is a very basic question, but... I'm not a coder, but I'm trying to code an EA for the first time,

So, I need to know how to close all trades based on MagicNumber variable...

I want to put an order but before close all open trades of that EA. Is this possible?

Thanks!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 09-19-2006, 05:03 PM
codersguru's Avatar
codersguru codersguru is offline
Senior Member
 
Join Date: Oct 2005
Posts: 987
codersguru has a spectacular aura aboutcodersguru has a spectacular aura aboutcodersguru has a spectacular aura about
Smile

Quote:
Originally Posted by kokas
I need help, this is a very basic question, but... I'm not a coder, but I'm trying to code an EA for the first time,

So, I need to know how to close all trades based on MagicNumber variable...

I want to put an order but before close all open trades of that EA. Is this possible?

Thanks!
An easy task my friend kokas:

1- Go to: http://www.metatrader.info/node/158
2- Download the Close All purposes script.
3- Set the option parameter to close by the magic number. (Note: You have to set the magic_number variable)
4- Show me your smile!
__________________
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!
Reply With Quote
  #3 (permalink)  
Old 09-19-2006, 05:08 PM
kokas's Avatar
kokas kokas is offline
Senior Member
 
Join Date: Jun 2006
Location: Portugal
Posts: 275
kokas is on a distinguished road
eheheheh let me try this... I'm a little rusty in programming... But I want to learn MQL Your lessons are precious!
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 09-19-2006, 06:08 PM
kokas's Avatar
kokas kokas is offline
Senior Member
 
Join Date: Jun 2006
Location: Portugal
Posts: 275
kokas is on a distinguished road
Hi again... still nothing... Hope you read my private message
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 09-19-2006, 06:29 PM
lowphat's Avatar
lowphat lowphat is offline
Senior Member
 
Join Date: Sep 2005
Posts: 199
lowphat is on a distinguished road
u may can put something like this before your order
this isnt tested so i dont know if syntax is 100%

for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==Symbol() && OrderMagicNumber()==Magic) {
OrderClose(OrderTicket(), OrderLots(), Bid, 100, Red);
} }}}


for (int i=0; i<OrdersTotal(); i++) {
if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)) {
if (OrderSymbol()==Symbol()) {
if (OrderMagicNumber()==Magic) {
OrderClose(OrderTicket(), OrderLots(), Bid, 100, Red);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 09-19-2006, 06:42 PM
kokas's Avatar
kokas kokas is offline
Senior Member
 
Join Date: Jun 2006
Location: Portugal
Posts: 275
kokas is on a distinguished road
This was only the beginign of my problems... lolol
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 09-19-2006, 08:20 PM
lowphat's Avatar
lowphat lowphat is offline
Senior Member
 
Join Date: Sep 2005
Posts: 199
lowphat is on a distinguished road
been there done that
whut else is hanging you up?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


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

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Close Open Trades EAs based on Equity Tradinator Expert Advisors - Metatrader 4 15 07-06-2008 10:46 AM
Magic MiniMe General Discussion 51 06-18-2007 09:08 PM
Open/close trade on same bar's close? WNW Expert Advisors - Metatrader 4 2 03-29-2007 05:37 AM


All times are GMT. The time now is 08:33 AM.