Forex



Go Back   Forex Trading > Training > Metatrader > Metatrader 4 mql 4 - Development course > Questions
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 04-17-2007, 05:52 PM
Junior Member
 
Join Date: Apr 2007
Posts: 6
bkgridley is on a distinguished road
modify orders and close pending orders

I'm trying to create an EA that does three things:

1. modifies my existing (manual) orders SL when I am at a certain profit level.

2. Close all other pending orders when I have made this modification.

3. I also want to continue modifying my orders (basically a 40 point TS) when the price moves in my favor.

If any one can help it would be appreciated.
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 04-17-2007, 05:59 PM
Junior Member
 
Join Date: Apr 2007
Posts: 6
bkgridley is on a distinguished road
clarification

When one of my orders hits a certain profit level, I want to modify SL on all orders.
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 04-17-2007, 07:31 PM
Junior Member
 
Join Date: Feb 2007
Posts: 3
pusher is on a distinguished road
I'm trying to do pretty much the same thing, but mines not working.
Code:
int start()
  {
//----
   if(OrdersTotal()<1)
   {
   OrderSend(Symbol(),OP_BUY,.01,Ask,3,Ask-15*Point,Ask+10*Point,"1st Contract",0001,0,Green);
   OrderSend(Symbol(),OP_BUY,.01,Ask,3,Ask-15*Point,Ask+25*Point,"2nd Contract",0002,0,Yellow);
   OrderSend(Symbol(),OP_BUY,.01,Ask,3,Ask-15*Point,Ask+50*Point,"3rd Contract",0003,0,Red);
   OrderSend(Symbol(),OP_BUY,.01,Ask,3,Ask-15*Point,Ask+100*Point,"4th Contract",0004,0,Blue);
   }
   OrderSelect(0004, SELECT_BY_TICKET);
   double Price=OrderOpenPrice();
      
   if(Ask==Price+10)
   {
   OrderModify(0002,OrderOpenPrice(),Price*Point,OrderTakeProfit(),0,Yellow);
   OrderModify(0003,OrderOpenPrice(),Price*Point,OrderTakeProfit(),0,Red);
   OrderModify(0004,OrderOpenPrice(),Price*Point,OrderTakeProfit(),0,Blue);
   }
   
   if(Ask==Price+25)
   {
   OrderModify(0003,OrderOpenPrice(),Price+10*Point,OrderTakeProfit(),0,Red);
   OrderModify(0004,OrderOpenPrice(),Price+10*Point,OrderTakeProfit(),0,Blue);
   }
   
   if(Ask==Price+50)
   OrderModify(0004,OrderOpenPrice(),Price+25*Point,OrderTakeProfit(),0,Blue);
  
   if(Ask==Price+75)
   OrderModify(0004,OrderOpenPrice(),Price+50*Point,OrderTakeProfit(),0,Blue);
//----
   return(0);
Not sure why, but it didn't adjust stop loss levels.
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 04-17-2007, 09:56 PM
Junior Member
 
Join Date: Apr 2007
Posts: 6
bkgridley is on a distinguished road
my code is similar and doesn't work either
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 04-18-2007, 02:14 AM
Junior Member
 
Join Date: Feb 2007
Posts: 3
pusher is on a distinguished road
Found one potential problem, I think I needed to change the values in my if statements with the Point constant.
EX:
Code:
if(Ask==Price+10*Point)

Last edited by pusher; 04-18-2007 at 02:30 AM.
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 04-18-2007, 07:25 AM
Achilles's Avatar
Junior Member
 
Join Date: Dec 2006
Posts: 7
Achilles is on a distinguished road
....
OrderSelect(0004, SELECT_BY_TICKET);
....

I think you start your search with that line. In that line you are only selecting the trade belonging to that spesific ticket (0004), and any modifications you order later on in the code, will only affect that particular order...

Solution, you need to loop through each pending order and select them each, do the modification and then move on to the next one...

Take care,
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
  #7 (permalink)  
Old 04-18-2007, 04:24 PM
Junior Member
 
Join Date: Feb 2007
Posts: 3
pusher is on a distinguished road
Could be true, but I just figured Ordermodify had Orderselect built in since I'm having to already call the ticket number in Ordermodify. Can you confirm thats how the magic number works in Ordersend? I give it the number 0004 so when I want to call it with Ordermodify I just use the ticket number 0004?
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
  #8 (permalink)  
Old 05-11-2007, 12:49 PM
Junior Member
 
Join Date: Dec 2006
Posts: 2
ashnou is on a distinguished road
i don't know much about mql4 programming
i only did vb6

my idea is why dont u make an ea to open or to put order manualy . then it will be easyer for the ea to handle (take control )these already opened order by it

sorry if it is bad idea and for my bad english
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
  #9 (permalink)  
Old 05-23-2007, 10:49 PM
Junior Member
 
Join Date: Dec 2005
Posts: 28
martingalaj is on a distinguished road
idea

somebody can do that?

Add at one EA (i have one winning ) that function:

Close orders if win 5% on balance account.

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
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
MT4 pending orders fx_geezer Metatrader 4 5 06-15-2007 10:36 PM
Closing Pending Orders bkgridley Expert Advisors - Metatrader 4 1 05-11-2007 06:47 AM
Script to close all pending orders? Yoda_Glenn Metatrader 4 7 02-21-2007 08:50 PM
how to delete a pending orders Altern8 Metatrader 4 1 01-02-2006 03:10 PM
Pending orders TheExponential Questions 4 11-25-2005 01:36 AM


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



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