Forex
Google
New signals service!

Go Back   Forex Trading > Discussion Areas > Metatrader 4


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 04-08-2007, 08:56 AM
Senior Member
 
Join Date: Oct 2006
Posts: 104
antone is on a distinguished road
Need Help!

i need a code that would close only the buy position or the close position?

i have multiple trades on this..

if (OrderType()==OP_BUY)){
OrderClose ( OrderTicket (), OrderLots (), Ask, 3, Yellow); }

i use ticket before but it won't close? when i change the OrderTicker() to ticket but won't close anything..

what do i need to do or add a code?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-08-2007, 09:41 AM
kkb kkb is offline
Junior Member
 
Join Date: Oct 2006
Posts: 4
kkb is on a distinguished road
Looks like you are not selecting the order from the server. you need something like this will find all buy orders and close them



total = OrdersTotal();

for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()== OP_BUY)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet) ; // close position
}
}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-08-2007, 09:51 AM
ralph.ronnquist's Avatar
Senior Member
 
Join Date: Oct 2006
Posts: 280
ralph.ronnquist is on a distinguished road
Quote:
Originally Posted by kkb
Looks like you are not selecting the order from the server. you need something like this will find all buy orders and close them

total = OrdersTotal();

for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()== OP_BUY)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet) ; // close position
}
}
... so many times... Use the following loop instead:
PHP Code:
for ( cnt total-1cnt >= 0cnt--) {... } 
Saves you a lot of headache.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-08-2007, 11:10 AM
Senior Member
 
Join Date: Oct 2006
Posts: 104
antone is on a distinguished road
thanks guys.. i will try it..

how about if i also have sell? and my sell has a close signal while buy has not?

sorry still learning..

Last edited by antone; 04-08-2007 at 01:01 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 04-08-2007, 01:04 PM
Senior Member
 
Join Date: Oct 2006
Posts: 104
antone is on a distinguished road
if ihave sell is the code correct

total = OrdersTotal();

for(cnt=0;cnt<total;cnt++)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()== OP_BUY)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet) ; // close position
}
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
if(OrderType()== OP_SELL)
{
OrderSelect(cnt, SELECT_BY_POS, MODE_TRADES);
OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet) ; // close position
}
}
}

i have tried this but it will only close a one trade.. how will it close all buy trade or sell trade?

Last edited by antone; 04-08-2007 at 01:38 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 04-09-2007, 10:04 AM
Senior Member
 
Join Date: Oct 2006
Posts: 104
antone is on a distinguished road
Need more help?

i also tried this to modify the orders SL and Tp.. but the problem is when it modify the SL all the buy order or sell order have the same SL and some don't produce any cause it is to close..
i want it to have different calculation in SL for each order.. can someone help me?


another thing? what is the code to limit the order for buy and limit order for sell?

Last edited by antone; 04-09-2007 at 10:13 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 04-09-2007, 05:09 PM
Senior Member
 
Join Date: Oct 2006
Posts: 104
antone is on a distinguished road
Also?

how to add, a code that would close all trades it if it reach a certain profit in equity or neg?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 04-09-2007, 05:22 PM
Administrator
 
Join Date: Sep 2005
Posts: 15,982
Blog Entries: 69
newdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud ofnewdigital has much to be proud of
Try to look at this thread http://www.forex-tsd.com/general-dis...ing-forum.html
May be it will help.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 04-10-2007, 03:37 AM
Senior Member
 
Join Date: Oct 2006
Posts: 104
antone is on a distinguished road
i still can't find it.. if anyone can help me?

limit the order of sell or buy? LIKE only open 1 sell and 1 buy , total of 2 trades pair currency.. please help me?


also close all trades if the profit is reach a certain amount? and also close all trade if the profit is a lose at a certain amount..
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #10 (permalink)  
Old 04-10-2007, 05:24 PM
Senior Member
 
Join Date: Oct 2006
Posts: 104
antone is on a distinguished road
Anyone? or should i open a new thread?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Bookmarks

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 On
Forum Jump


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



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