- Close By - Trade - MetaTrader 5 for Android
- Close By - Trade - MetaTrader 5 for iPhone
- Instant Execution - Opening and Closing Positions - Trade - MetaTrader 5 for Android
hi, i'm newbie on metatrader and at mql4. can anyone help with a simple script to close trade at 1 pip. i'll open trade manually but would like to automate close only. any help much appreciated.
Hmm.. Well you have to check to see if the order is a buy or sell. If it is a buy, you need to check of the Ask - OrderOpenPrice = 1, and if so, close it. If it is a sell, you need to see if the OrderOpenPrice - Bid = 1 and if so close it.
BUT, I will add that most MT4 based dealers won't like this behavior. I can't think of a one that wouldn't count this as scalping and subsequently demand that you stop doing it. May sound unfair, I know, but think of it like card counting at a casino. There is nothing "ethically" wrong with card counting, but a casino will ban you from playing there if you do it. Most MT4 brokers don't like scalping (for various reasons that can be debated ad infinitum), and they will likely decline to take your trades after a while if you do it regularly. Think of it as the rules of the house that you've chosen to play in. :)
This of course is doesn't apply to an order that is open for several minutes/hours/days and is then closed with 1 pip in profit. It only applies to opening an order and closing it "almost" immediately with a small number of pips. If you want further explanation, ask your broker to explain the rules of their trading: How long does a trade have to be open before you can close it without being flagged? If you close an order before that time, how many pips in profit must it be to avoid being flagged? etc.
Anyway, good luck. Hope this helps..
-CS
I have a broker with an institutional price feed that i negotiated for personal use. Perhaps we should talk about this. I'm looking for a good scalper that grabs one pip per trade. I have 1 pip spreads on EUR and JPY. Many times the spreads are 0.
wonderful, jeff. pls email me - azman818@streamyx.com
Well, I can give you the way that we do it right now. Basically, it is just a variable so you can set it from 0-100000 if you wanted to. If you want just one pip, just put it as 1. (which will be the first pip of profit it would close, while zero will close right when it breaks even).
If you opened the trades manually, and just had this attached to the chart, it would just close it at 1pip profit. If you or Jwanson start making some good easy money with this, let me know. :-P I could use some of that myself.
//+------------------------------------------------------------------+
//| 1-PipScalper. mq4 |
//| AsmoCon |
//| |
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//| expert variables |
//+------------------------------------------------------------------+
extern int TrailingStopShortScalp = 1;
extern int TrailingStopLongScalp = 1;
//+------------------------------------------------------------------+
//| expert start function |
//+------------------------------------------------------------------+
int start()
{
//----
// check for short break scalp
if((OrderOpenPrice()-Ask)>(Point*TrailingStopShortScalp))
{
if(OrderStopLoss()>OrderOpenPrice())
{
OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(), 0, Red);
return(0);
}
}
// check for long break scalp
if(Bid-OrderOpenPrice()>Point*TrailingStopLongScalp)
{
if(OrderStopLoss()<OrderOpenPrice())
{
OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(), 0, Green);
return(0);
}
}
//----
return(0);
}
//+------------------------------------------------------------------+
extern int TrailingStopLongScalp = 1;
And then - Point*TrailingStopShortScalp
--Basically that part makes it close after 1pip of postive movement. So, if you manually open a trade and say there is a -2 pip spread on the trade. So, you open it and it is opened at 1.8888. Since that is -2 already, when it becomes 1.8891, which is just positive +1 pip profit, it will close. Of the code said:
extern int TrailingStopShortScalp = 0;
extern int TrailingStopLongScalp = 0;
It would close it right when it hit the break-even, which would be 1.8890. Hope that makes sense.
If this doesn't work for some reason, let me know. Like if you want to just try it and watch it (manually close it if it doesn't automatically do it). Enjoy.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use