Forex
Google
New signals service!

Go Back   Forex Trading > Downloads > Expert Advisors - 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 07-16-2006, 08:32 PM
Junior Member
 
Join Date: Jan 2006
Posts: 19
excite2 is on a distinguished road
A Simple Buy/Sell Script

Does anyone have a simple script (not an EA) that will buy/sell orders
with a stop and a target profit input?

OR

The attached buy/sell scripts don't have a target profit
parameter. If someone could please add target profits to the attached scripts that would also work.

Either scenario would be appreciated.

Thanks.
Attached Files
File Type: mq4 Buy.mq4 (1.4 KB, 132 views)
File Type: mq4 Sell.mq4 (1.4 KB, 94 views)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 07-17-2006, 03:25 AM
Senior Member
 
Join Date: Mar 2006
Posts: 787
Maji is on a distinguished road
Suppose you want to set the profit target to 30 pips, then do the following:

Look up this line in the buy routine,
ticket=OrderSend(Symbol(),OP_BUY,1.0,Ask,3,Ask-20*Point,0,"expert comment",255,0,CLR_NONE);

and make it look like this:

ticket=OrderSend(Symbol(),OP_BUY,1.0,Ask,3,Ask-20*Point,Bid+30*Point,"expert comment",255,0,CLR_NONE);
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-17-2006, 03:42 AM
Junior Member
 
Join Date: Jan 2006
Posts: 19
excite2 is on a distinguished road
Thanks. I'll try it out. Could you tell me what changes I would need to do the same for a sell order?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-17-2006, 03:56 AM
Senior Member
 
Join Date: Mar 2006
Posts: 787
Maji is on a distinguished road
I think you owe it to yourself to study MQL if you are going to to use it. Otherwise depending on others is too dangerous.

Study the code I gave you and see WHAT changes and WHERE the changes I made. That should give you clues on what to change in the sell routine.

Good luck.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-17-2006, 04:07 AM
Junior Member
 
Join Date: Jan 2006
Posts: 19
excite2 is on a distinguished road
Thanks for the advice. I've been slowly learning the language through the mql course, but as i have no programming experience, it has been a slow process. Just wanted to get started trading in the meantime.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 07-17-2006, 11:53 AM
Senior Member
 
Join Date: Mar 2006
Posts: 787
Maji is on a distinguished road
Okay, you should try to understand the code better. I think if you had spent some time, your definitely would have understood how the buy/sell ordersend functions work.

For the sell, assuming you want 30 pips of stop loss,

change

ticket=OrderSend(Symbol(),OP_SELL,1.0,Bid,3,Bid+20 *Point,0,"expert comment",255,0,CLR_NONE);

to

ticket=OrderSend(Symbol(),OP_SELL,1.0,Bid,3,Bid+20 *Point,Ask - 30*Point,"expert comment",255,0,CLR_NONE);

Edit:- I had an error that I corrected. Thanks for pointing it out.

Last edited by Maji; 07-17-2006 at 06:58 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7 (permalink)  
Old 07-17-2006, 01:58 PM
Junior Member
 
Join Date: Jan 2006
Posts: 19
excite2 is on a distinguished road
I actually took a look at again before your last post and figured it out. But my changes look a bit different but it seems to work okay.

I had:

ticket=OrderSend(Symbol(),OP_SELL,10.0,Bid,3,Bid+2 0*Point,Bid-30*Point,"expert comment",255,0,CLR_NONE);

Thanks again.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #8 (permalink)  
Old 07-17-2006, 06:58 PM
Senior Member
 
Join Date: Mar 2006
Posts: 787
Maji is on a distinguished road
excite...

doesn't it feel good to figure it out yourself?

I did have an error in my code that I corrected.

Thanks.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #9 (permalink)  
Old 07-18-2006, 03:16 AM
Junior Member
 
Join Date: Jan 2006
Posts: 19
excite2 is on a distinguished road
Yeah. I'll look forward to the day when I can build an EA from scratch! Thanks.
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 Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help: How to write simple EA to buy and sell at a specific time? jack2 Expert Advisors - Metatrader 4 59 09-22-2008 03:17 AM
Simple script to plot Horizontal lines SaxMan Indicators - Metatrader 4 2 10-15-2007 03:10 AM
EAs that sell the ask and buy the bid... forextrades Expert Advisors - Metatrader 4 2 08-23-2006 01:58 AM
Script for buy/sell sadaloma Metatrader 4 2 01-15-2006 11:54 PM


All times are GMT. The time now is 02:52 AM.



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