Forex Forum - EarnForex
Serving Traders Since 2005
 

Go Back   Forex Forum - EarnForex > Forex Discussions > Trading Systems and Strategies

Trading Systems and Strategies Forum to discuss various Forex trading systems and strategies.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 9th January 2012, 02:15
Default Avatar
Junior Member
 
Join Date: Sep 2011
Posts: 24
Thanks: 5
Thanked 3 Times in 2 Posts
Default BreakEven Script

Hi, This is a script I use when my order is about 15 or 20 Pips in profit.

It sets the Stop Loss so if the price retraces it closes at Breakeven. I would like to know how to modify this to BreakEven plus x pips (say 3pips). The reason is price does retrace often and I have a lot of zero gain trades when I could have at least exited with a tiny profit. Is this an easy request?

This is the script. I use it selectively when I suspect a retrace. I agree it can reduce profits but if I had just 3 pips above breakeven the numbers are good. When the value gets higher than the point I engage it my trailing stop function of my EA kicks in. It's just these "grey area" trades that can suddenly turn that I want to protect myself from.

*** I attacheded the MQ4 file with the original post but it seems to have disappeared I have re-sent below

Last edited by ForexNewbie51; 10th January 2012 at 11:03.
Reply With Quote
  #2 (permalink)  
Old 9th January 2012, 09:35
Enivid's Avatar
Administrator
 
Join Date: Nov 2008
Posts: 1,548
Thanks: 18
Thanked 20 Times in 16 Posts
Default

Did you forget to attach the script?

Anyway, I wouldn't recommend using such trading technique. It ruins your strategy, while giving you illusion of "being right about the markets" by giving you many small profits.
__________________
Please, read the Forum Rules and the Signature Rules to avoid termination of your account.

Last edited by Enivid; 11th January 2012 at 11:18. Reason: Typo: would = wouldn't
Reply With Quote
  #3 (permalink)  
Old 10th January 2012, 11:01
Default Avatar
Junior Member
 
Join Date: Sep 2011
Posts: 24
Thanks: 5
Thanked 3 Times in 2 Posts
Default Set to BE plus (re-sent)

I did attach the file but it seems to have disappeared. I have pasted it here and also re-attached file - see if this stays attached.

MQL4 Code:
/+------------------------------------------------------------------+
//| script program start function |
//+------------------------------------------------------------------+
int start()
{
//----
string curr = Symbol();
int ot = OrdersTotal();
int ords[200], ordType[200], ordTicket[200]; double ordLots[200];
string ordComments[200];
int ix=0;
for (int i=0; i<ot; i++)
{
int o = OrderSelect(i, SELECT_BY_POS);
if (OrderSymbol() == Symbol())
if ((OrderType() == OP_BUY) || (OrderType() == OP_SELL))
{
double sl = 0;
if ((OrderType() == OP_BUY) && (OrderStopLoss() < OrderOpenPrice()))
sl = OrderOpenPrice() ;
if ((OrderType() == OP_SELL) && (OrderStopLoss() > OrderOpenPrice()))
sl = OrderOpenPrice() ;

if (sl != 0)
OrderModify(OrderTicket(), OrderOpenPrice(), sl, OrderTakeProfit(), 0);
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
Attached Files
File Type: mq4 BreakEvenScript.mq4 (1.2 KB, 7 views)
Reply With Quote
  #4 (permalink)  
Old 11th January 2012, 11:26
Enivid's Avatar
Administrator
 
Join Date: Nov 2008
Posts: 1,548
Thanks: 18
Thanked 20 Times in 16 Posts
Default

Thanks for providing the code, but, please don't forget to use the highlighting when inserting big portions of MQL code.

If you want to modify the stop-loss from breakeven to breakeven + some pips, just change the following lines:
MQL4 Code:
to this for BUY orders:
MQL4 Code:
sl = OrderOpenPrice() + 10 * Point;
and this for SELL orders:
MQL4 Code:
sl = OrderOpenPrice() - 10 * Point;

Of course, you can enter any amount of pips instead of 10.
__________________
Please, read the Forum Rules and the Signature Rules to avoid termination of your account.
Reply With Quote
The Following User Says Thank You to Enivid For This Useful Post:
ForexNewbie51 (12th January 2012)
  #5 (permalink)  
Old 12th January 2012, 01:50
Default Avatar
Junior Member
 
Join Date: Sep 2011
Posts: 24
Thanks: 5
Thanked 3 Times in 2 Posts
Default Mnay thanks.

I tried something close to this (and failed several times). Many thanks yet again for your help
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 On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need a script for opening pending orders Andie MetaTrader Expert Advisors 1 20th December 2011 10:58
True Trendline Drawing Script Styann Advertisements 0 2nd September 2011 05:36


All times are GMT. The time now is 20:16.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2012, vBulletin Solutions, Inc.
Inactive Reminders By Icora Web Design

SEO by vBSEO 3.3.2