Not adjusting for 4/5 digit brokers, not adjusting for ECN brokers. On a 5 digit broker a pip is NOT a point.
//++++ These are adjusted for 5 digit brokers. int pips2points; // slippage 3 pips 3=points 30=points double pips2dbl; // Stoploss 15 pips 0.015 0.0150 int Digits.pips; // DoubleToStr(dbl/pips2dbl, Digits.pips) int init(){ if (Digits % 2 == 1){ // DE30=1/JPY=3/EURUSD=5 https://www.mql5.com/en/forum/135345 pips2dbl = Point*10; pips2points = 10; Digits.pips = 1; } else { pips2dbl = Point; pips2points = 1; Digits.pips = 0; } // OrderSend(... Slippage.Pips * pips2points, Bid - StopLossPips * pips2dbl //---- These are adjusted for 5 digit brokers. /* On ECN brokers you must open first and THEN set stops int ticket = OrderSend(..., 0,0,...) if (ticket < 0) Alert("OrderSend failed: ", GetLastError()); else if (!OrderSelect(ticket, SELECT_BY_TICKET)) Alert("OrderSelect failed: ", GetLastError()); else if (!OrderModify(OrderTicket(), OrderOpenPrice(), SL, TP, 0) Alert("OrderModify failed: ", GetLastError()); */
WHRoeder:
Not adjusting for 4/5 digit brokers, not adjusting for ECN brokers. On a 5 digit broker a pip is NOT a point.
Not adjusting for 4/5 digit brokers, not adjusting for ECN brokers. On a 5 digit broker a pip is NOT a point.
Thank you for your response WHRoeder,
We adjusted for 4/5 digit brokers, but that is not the root of our problem. We broke the EA down a bit more so we could isolate the issue. We run the attached script (removed the trailing stop) and we find a problem in our sell stoploss. The stoploss is set at 20 but we have 6 trades that close at -21.40 and -24.20. All of our buy orders stop out at 20 and takeprofit at 5, while the sells correctly take 5, but have a half dozen trades that go over the stoploss.
Files:
yar.mq4
5 kb
FXtrader303:
We adjusted for 4/5 digit brokers, but that is not the root of our problem. We broke the EA down a bit more so we could isolate the issue. We run the attached script (removed the trailing stop) and we find a problem in our sell stoploss. The stoploss is set at 20 but we have 6 trades that close at -21.40 and -24.20. All of our buy orders stop out at 20 and takeprofit at 5, while the sells correctly take 5, but have a half dozen trades that go over the stoploss.
We adjusted for 4/5 digit brokers, but that is not the root of our problem. We broke the EA down a bit more so we could isolate the issue. We run the attached script (removed the trailing stop) and we find a problem in our sell stoploss. The stoploss is set at 20 but we have 6 trades that close at -21.40 and -24.20. All of our buy orders stop out at 20 and takeprofit at 5, while the sells correctly take 5, but have a half dozen trades that go over the stoploss.
icket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Ask-StopLoss*Point,Ask+TakeProfit*Point
Not adjusted: spread. All you did is manually change StopLoss and TakeProfit so now it won't work on a 4 digit broker. Never on a ECN broker. See previous post.
- You Buy at the Ask and Sell at the Bid, so your stops are off by the spread. Bid-StopLoss, Bid+TP
- Mt4 charts are bid charts. on Sells you close at the Ask so you can see stop loss above the candle. You would except for #2 OP_SELL, lots, Bid, 3*pips2points, Ask+SL, Ask-TP...
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Hello,
We are having an issue defining our Stoploss and Takeprofit levels. We broke down the MACDsample EA supplied with MetaTrader 4 to a simple Macd Cross EA. We can set the takeprofit and stoploss values but the EA backtest results are inconsistent with what we have set. We are not sure if we are having a problem with either the correct units, slippage, or the spread. We just want to not lose more than we set in the extern StopLoss value. Is anyone having the same issues? Any help is much appreciated! We prefer to use a set value rather than a trailing stop. Attached is the full script, when we run it on a GBPUSD H4 backtest with a slippage of 3 and Stoploss of 50 we end up with long position losses ranging up to 7.30 and short position losses ranging up to 11.50. Can't figure out this difference, nor why the stoploss does not take at 50.
Our OrderSend for long:
if(MacdCurrent>SignalCurrent && MacdPrevious<SignalPrevious)
{
ticket=OrderSend(Symbol(),OP_BUY,Lots,Ask,3,Bid-StopLoss*Point,Bid+TakeProfit*Point,"macd sample",16384,0,Green);
Our OrderSend for short:
if(MacdCurrent<SignalCurrent && MacdPrevious>SignalPrevious)
{
ticket=OrderSend(Symbol(),OP_SELL,Lots,Bid,3,Ask+StopLoss*Point,Ask-TakeProfit*Point,"macd sample",16384,0,Blue);
Thank you for your help!
FXtrader303