Download MetaTrader 5
To add comments, please log in or register
Deposit to your account via Visa QIWI Wallet
APeng
359
APeng 2015.06.16 19:42 

Hello!

(A) If I use

      int ticket_short  = OrderSend(Symbol(),OP_SELL,lotsize,price,slippage,Ask + 0.001,Ask-0.001,comment,magicnumber,0);

for market entry

with stop loss Ask + 0.001 and take profit Ask -0.001 for market exit

I get as result:


(B) If I use

      int ticket_short  = OrderSend(Symbol(),OP_SELL,lotsize,price,slippage,0,0,comment,magicnumber,0);

for market entry WITHOUT stop loss and take profit

and for market exit

      for(int i=OrdersTotal()-1; i>=0; i--)
        {
         if(   OrderSelect(i,SELECT_BY_POS,MODE_TRADES) == true
            && OrderSymbol()                            == Symbol()
            && OrderMagicNumber()                       == magicnumber
            &&  OrderType()                             == OP_SELL
           )
           {
            if (   Ask    >= OrderOpenPrice() + 0.001
                || Ask    <= OrderOpenPrice() - 0.001
               )
                OrderClose(OrderTicket(),OrderLots(),Ask,10,Red);
           }
         }

I get as result:



SAME:

In (A) and (B) market entries are at the same prices. Same trade logic for entry is used.


DIFFERENCE:

In (A) the market exit i filled every time exactly at the placed stop loss or take profit. In (B) it is filled when a tick with a qoute that fits the requirements for stop loss (quote equal or bigger) or for take profit (quote smaller or equal).


QUESTIONS:

Am I right with my explanation for the difference or did I miss something or have an error in coding?

If I am right,  I would consider (B) as more "live trading - like" than (A). Right?

If that is right too, the differences between (B) and live trading would be slippage?


If someone could help me out it would be great!

Kind regards.

Keith Watford
Moderator
7875
Keith Watford 2015.06.16 21:31  

In (A) you are setting the SL and TP at Ask +/- 0.001

in (B) you are using the Order entry price+/- 0.001 to exit 

APeng
359
APeng 2015.06.17 07:56  
GumRai:

In (A) you are setting the SL and TP at Ask +/- 0.001

in (B) you are using the Order entry price+/- 0.001 to exit 

You are right. That is not the same. I missed that. Thanks.

But the results cannot be explained with that. In (A) it is Ask +/- 0.001. In (B) it is OrderOpenprice +/- 0.001. That is Bid +/- 0.001.

If SL and TP would get filled in the same way, differences in order results between (A) and (B) should be the spread. Spread is set to 0.5 pips. But the differences are changing and are not constant at 0.5 pips.

Does that mean the tester fills SL and TP used in (A) always exactly at SL and TP? Regardless if that quote did income?

Keith Watford
Moderator
7875
Keith Watford 2015.06.17 08:05  

As I understand it, (in the strategy tester) trades with a SL and/or TP in place are filled whether there was that  actual quote available or not.

But if a trade is closed following a condition, the trade will be closed at the price created by the strategy tester. 

/
To add comments, please log in or register