Download MetaTrader 5

EA testing OrderSend problem

To add comments, please log in or register
doctorslo
19
doctorslo  

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:

Picture 1: Buy position opened above the price

Picture 1: Buy position opened above the price


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

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

Alain Verleyen
Moderator
33627
Alain Verleyen  
MT4 shows bid price. Buy position are opened at ask, and sell position are closed at ask.
doctorslo
19
doctorslo  

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?


EDIT:

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

To add comments, please log in or register