some problems about strategy tester's results

 

Just now, I have made an EA and test it by MT4's strategy tester, and I trade the pair--USDJPY, then I have found some questions as below:

1.ordersend()

OrderSend(Symbol(),OP_BUY,1,Ask,3,Ask-stop_loss*Point,0,0,0,0,0)

I should set " stop_loss" at least 100 in this EA which should be tested by MT4's strategy tester, or the function--OrderSend(), will never send order whatever happened; but "stop_loss" can be set very little, such as 30,50 or other small values, in an EA which is attached to a real chart(not visual chart), and the function--OrderSend(), can send order normally(can't in the former). So I don;t know why? And How I can know what is minimum for the "stop_loss"?

2. the trading price of strategy tester is a little surprising(see below picture). This order is short at 99.364 on "A ", and its stop loss point is 99.464, then what is surprising is that it is closed at 99.464 on "B" and 99.464 is never be touched by "B". So how and why this order is closed?

In addition, this is just one of orders which was closed like this; almost all orders were closed like this.

 
vx0532:

Just now, I have made an EA and test it by MT4's strategy tester, and I trade the pair--USDJPY, then I have found some questions as below:

1.ordersend()

I should set " stop_loss" at least 100 in this EA which should be tested by MT4's strategy tester, or the function--OrderSend(), will never send order whatever happened; but "stop_loss" can be set very little, such as 30,50 or other small values, in an EA which is attached to a real chart(not visual chart), and the function--OrderSend(), can send order normally(can't in the former). So I don;t know why? And How I can know what is minimum for the "stop_loss"?

2. the trading price of strategy tester is a little surprising(see below picture). This order is short at 99.364 on "A ", and its stop loss point is 99.464, then what is surprising is that it is closed at 99.464 on "B" and 99.464 is never be touched by "B". So how and why this order is closed?

In addition, this is just one of orders which was closed like this; almost all orders were closed like this.

What was the Spread ? the chart is drawn by Bid prices, a Sell is opened at Bid and closed at Ask . . . you can't see the Ask price on your chart for historical data.
 
RaptorUK:
What was the Spread ? the chart is drawn by Bid prices, a Sell is opened at Bid and closed at Ask . . . you can't see the Ask price on your chart for historical data.


I get the result as below picture:

zoom in on "A" area as below picture:

I don;t know why so many "open close". I don;t show the code because all code is much and complicated.

I just want to know what is usually reason for this problem?

 

Your code is broken. ALWAYS the reason.

You are probably looking for a level: if(a > b) open. On the next tick, the condition is still true and you open again, and again...

Try looking for a change of conditions:

bool isWaiting; int init(){ isWaiting = false; }   // Reset on chart change.
void CheckConditions(){
   bool wasWaiting = isWaiting; isWaiting = false; // Reset in case of early returns.
   :
   isWaiting = !(a > b);                           // Check level.
   if(wasWaiting & !isWaiting) ...                 // Was waiting, no longer waiting.
                                                   // a > b just became true, time to open.
 
WHRoeder:

Your code is broken. ALWAYS the reason.

You are probably looking for a level: if(a > b) open. On the next tick, the condition is still true and you open again, and again...

Try looking for a change of conditions:


more likely the condition for opening is still true when he has also true the condition for closing the trade

open trade closed new trade opend

(not more then one trade open)