Download MetaTrader 5
To add comments, please log in or register
Launch your trading signal. Make profit from paid subscription!
doctorslo
19
doctorslo 2014.08.31 09:59 

Hello,

I am pretty new to mql4 programming. I've made some simple EA, and while testing it (with strategy tester), some positions are opened above the current price, and some stop losses are triggered even that price never reached into that zone.

Here are some pictures:


Buy position opened above the price

Picture 1: Buy position opened above the price


stop loss

Picture 2: Stop loss is triggered even that the price did not reached SL price.



I would say that those things happen randomly, but always at the same spot (while running the test again). What could be the problem?

I am using this to execute the trades:

OrderSend(Symbol(),OP_BUY,myLOTS,Ask,3,Ask-0.0010,0,NULL,16384,0,clrGreen); // BUY

OrderSend(Symbol(),OP_SELL,myLOTS,Bid,3,Bid+0.0010,0,NULL,16384,0,clrGreen); // SELL

Keith Watford
Moderator
7959
Keith Watford 2014.08.31 10:31  

Charts are Bid price

Buys are opened at Ask, which is Bid price + spread.

Sells are closed at Ask. 

whroeder1
13627
whroeder1 2014.08.31 11:50  
Turn on the Ask line, so you see the spread.
doctorslo
19
doctorslo 2014.08.31 15:40  

Thanks.

So, how can I handle my situation? My strategy is based on the chart that is displayed (Bid price, as you've said).

Before, I was using some other platform, and I've done a few hundred of trades, and never saw something like that. I thought that spread is fixed and defined by broker.


Basically I could wait for Ask price to come closer to the Bid price?

Simon Gniadkowski
Moderator
17963
Simon Gniadkowski 2014.08.31 15:49  
doctorslo:

Thanks.

So, how can I handle my situation? 

Find a Broker that offers Zero spreads . . .
doctorslo
19
doctorslo 2014.08.31 16:11  

I see now what is the problem.

The simulation somehow by default uses 4 pips as spread, my broker spread is 2 pips.

I just changed that default value to 2.


Sorry for such an idiotic topic .. :D

Thanks

whroeder1
13627
whroeder1 2014.09.02 12:21  
doctorslo: The simulation somehow by default uses 4 pips as spread, my broker spread is 2 pips.
Mt4 doesn't have pips, only points. On a 5 digit broker a point is 1/10 pip. So the tester used 4 points (0.4 pips) not your broker's 2 pips (20 points.)
/
To add comments, please log in or register