Problem on Strategy Tester MT5

 

Hello,

I have a strange problem when work on strategy tester of MT5, practically, although the targets (stoploss and takeprofit) are regularly placed, the ea's (all) do not read them so the trade never closes. It seems that the price reads nothing in fact if I print the current price (by class PositionInfo) it is always the same as when the trade was entered (it prints Ask if the trade is sell and vice versa). Even the profits in the history are always zero (if I force the closure in another way, for example at the moving average).

The code is simple, only for try...

int OnInit()
  {
   if(symInfo.IsSynchronized()&&symInfo.Name(_Symbol))
     {
      symInfo.RefreshRates();
      symInfo.Refresh();
      double sl = NormalizeDouble(symInfo.Bid()-0.0010,_Digits);
      double tp = NormalizeDouble(symInfo.Bid()+0.0020,_Digits);
      trade.Buy(0.1,_Symbol,0,sl,tp,"prova");
     }
     
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(PositionSelect(_Symbol))
     {
      symInfo.RefreshRates();symInfo.Refresh();
      Print("Price current ",position.PriceCurrent(),"\n",
      "Ticket ",position.Ticket(),"\n",
      "Ask ",symInfo.Ask());
     }

  }
//+------------------------------------------------------------------+

Please help me 



 
A bit strange. Try printing Bid price... Long position is closed with Bid price.
 
Milko Vivaldi:

Hello,

I have a strange problem when work on strategy tester of MT5, practically, although the targets (stoploss and takeprofit) are regularly placed, the ea's (all) do not read them so the trade never closes. It seems that the price reads nothing in fact if I print the current price (by class PositionInfo) it is always the same as when the trade was entered (it prints Ask if the trade is sell and vice versa). Even the profits in the history are always zero (if I force the closure in another way, for example at the moving average).

The code is simple, only for try...

Please help me 



Is that a custom symbol ?

Please post the full log.