Testing EA running only without SL and TP

 

Hi.

I've created my first EA. If I set SL and TP in the code,   the Tester runs but no operation is opened.

If I don't set SL and TP (or I set them to 0) the Tester runs and open operations, but obviosly, no action is taken by SL and TP: the operations go on until the end of simulation and the balance is steady.

I'd need to see the oscillations in the balance so I can observe drawdowns.

I work with MT5, setted "Hedge".

Any suggest?

Thank you

 
i think your TP/SL double is not valid, check your code
 
michel_1977: I've created my first EA. If I set SL and TP in the code,   the Tester runs but no operation is opened.

Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button) or attach the file.
     How To Ask Questions The Smart Way. (2004
          Be precise and informative about your problem

We can't see your broken code.

Fix your broken code.

With the information you've provided — we can only guess. And you haven't provided any useful information for that.

 
Pak Hong Poon:

Thnaks

 
William Roeder:

Do you really expect an answer? There are no mind readers here and our crystal balls are cracked. Always post all relevant code (using Code button) or attach the file.
     How To Ask Questions The Smart Way. (2004
          Be precise and informative about your problem

We can't see your broken code.

Fix your broken code.

With the information you've provided — we can only guess. And you haven't provided any useful information for that.

Here's my code

#include <Trade\Trade.mqh>

CTrade trade;

double max, min;

double SL, TP; 

ulong TicketBuyStop;

 

   max=iHigh(NULL,0,1);

   min=iLow(NULL,0,1);


  SL=NormalizeDouble(MathMin(min-40/10000,max-460/10000),4);

  TP=NormalizeDouble(max+300/10000,4);

   if(BuyON)

   {

    if(!trade.BuyStop(0.1,max+40*_Point,_Symbol,SL,TP,ORDER_TIME_GTC,0,""))

      Print(" BuyStop Error ");

   else         

      TicketBuyStop=trade.ResultOrder();

   }

//+--

I must a give a better explanation.

If I set StopLoss and TaleProfit, the tester doesn't trigger the Stop Order

Stop Orderr works only if I set SL=0 and TP=0, i.e. with the following code:

if(!trade.BuyStop(0.1,max+40*_Point,_Symbol,0,0,ORDER_TIME_GTC,0,""))