Can help me with StopLoss and TakeProfit on StrategyTesterVisualization (Not working)

 

Hello,

I'm trying to create my first EA ... but I crashed during the tests!

Apparently, I'm create the "Order"... but they are not initialized!
They appear on the chart, but do not close, do not profit or hurt.

I attached a printscreen, log and my code.
Can you help me?


Image with comments of the issues


Log:

00:00:00   tickSize/SYMBOL_TRADE_TICK_SIZE: 0.5
00:00:00   SYMBOL_TRADE_STOPS_LEVEL: 0
09:10:00   sell.. price: 3762.0 | sl: 3766.0 | tp: 3761.0
09:10:00   exchange sell 2.00 WDON18 at 3762.000 sl: 3766.000 tp: 3761.000 (3762.000 / 3762.500 / 3762.000)
09:10:00   deal #2 sell 2.00 WDON18 at 3762.000 done (based on order #2)
09:10:00   deal performed [#2 sell 2.00 WDON18 at 3762.000]
09:10:00   order performed sell 2.00 at 3762.000 [#2 sell 2.00 WDON18 at 3762.000]
09:10:00   CTrade::OrderSend: exchange sell 2.00 WDON18 sl: 3766.000 tp: 3761.000 [done]
09:10:00   Fs-EAFirst: execShortSell Created!!. Return code=10009. Code description: done


Code:

//+------------------------------------------------------------------+
//|                                                   Fs-EAFirst.mq5 |
//|                                                     Flavio Sousa |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Flavio Sousa"
#property link      "https://www.mql5.com"
#property version   "1.00"
//--- input parameters
input double   amountLots=2.0;
input double   pointsSL=20.0;//4
input double   pointsTP=10.0;//1
//--- includes
#include <Trade/Trade.mqh>
#include <fs/Fs-OnNewBar.mqh>
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
CTrade         *m_trade;
//---
const int EA_STATUS_NONE=0;
const int EA_STATUS_BOUGHT=1;
const int EA_STATUS_SOLD=-1;
//---
int eaStatus=EA_STATUS_NONE;
//---
double         sellBuffer[];
double         buyBuffer[];
int            iFirstHandle;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   iFirstHandle=iCustom(_Symbol,_Period,"fs/Fs-IFirst");
//---
   m_trade=new CTrade();
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   if(eaStatus==EA_STATUS_NONE && !IsStopped())
     {
      if(isNewBar())
        {
         //Print("OnTick");
         double buf[];
         ArraySetAsSeries(buf,true);
         ArrayResize(buf,1);
         buf[0]=EMPTY_VALUE;
         if(CopyBuffer(iFirstHandle,UPPER_LINE,0,1,buf))
           {
            if(buf[0]!=EMPTY_VALUE)
              {
               execShortSell();
               //Print("Vendido...: ",buf[0]);
              }
           }
         buf[0]=EMPTY_VALUE;
         if(CopyBuffer(iFirstHandle,LOWER_LINE,0,5,buf))
           {
            if(buf[0]!=EMPTY_VALUE)
              {
               execShortBuy();
               //Print("Comprado..: ",buf[0]);
              }
           }
        }
     }
  }
//+------------------------------------------------------------------+
void execShortBuy()
  {
   const double price=SymbolInfoDouble(_Symbol,SYMBOL_ASK);
   const double sl = price-pointsSL;
   const double tp = price+pointsTP;
   Print("buy... price: ",price," | sl: ",sl," | tp: ",tp);
//if(!m_trade.Buy(amountLots,_Symbol,price,sl,tp))
   if(!m_trade.Buy(amountLots,_Symbol,price,sl,tp))
     {
      Print("Fs-EAFirst: execShortBuy FAILED!!. [ERROR] Return code=",m_trade.ResultRetcode(),". Code description: ",m_trade.ResultRetcodeDescription());
        } else {
      Print("Fs-EAFirst: execShortBuy Created!!. Return code=",m_trade.ResultRetcode(),". Code description: ",m_trade.ResultRetcodeDescription());
     }
  }
//+------------------------------------------------------------------+
void execShortSell()
  {
   const double price=SymbolInfoDouble(_Symbol,SYMBOL_BID);
   const double sl = price+pointsSL;
   const double tp = price-pointsTP;
   Print("sell.. price: ",price," | sl: ",sl," | tp: ",tp);
//if(!m_trade.Sell(amountLots,_Symbol,price,sl,tp))
   if(!m_trade.Sell(amountLots,_Symbol,price,sl,tp))
     {
      Print("Fs-EAFirst: execShortSell FAILED!!. [ERROR] Return code=",m_trade.ResultRetcode(),". Code description: ",m_trade.ResultRetcodeDescription());
        } else {
      Print("Fs-EAFirst: execShortSell Created!!. Return code=",m_trade.ResultRetcode(),". Code description: ",m_trade.ResultRetcodeDescription());
     }
  }
//+------------------------------------------------------------------+
 
[RESOLVED] I was able to solve! ... It was the patch that I installed ... I reinstalled the MetaTrade and it returned work as usually!
Reason: