My EA doesn't execute my sell orders, it just executes my buy orders

 
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>  
#include <Trade\AccountInfo.mqh>


CTrade trade;

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
  
  double LotSize = 0.1;
  
  double sl = 1.0;
  double tp= 3.0;
  
  string CurrentSymbol = Symbol();
  
  double Ask=NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits);
  double BuyStopLossPrice = NormalizeDouble(Ask - sl, _Digits);
  double BuyTakeProfitPrice = NormalizeDouble(Ask + tp, _Digits);
  
  double Bid=NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits);
  double SellStopLossPrice = NormalizeDouble(Bid + sl, _Digits);
  double SellTakeProfitPrice = NormalizeDouble(Bid + tp, _Digits);
  
  datetime time=TimeLocal();
  
  string HoursandMinutes=TimeToString(time, TIME_MINUTES);
  
 if ((PositionsTotal()==0) && (StringSubstr(HoursandMinutes,0,5)=="18:30"))
  {
  
   trade.Sell(LotSize,CurrentSymbol,Bid,SellStopLossPrice,SellTakeProfitPrice,NULL);
   
   //trade.PositionOpen(CurrentSymbol,ORDER_TYPE_SELL,LotSize,Bid, SellStopLossPrice, SellTakeProfitPrice,NULL);
  
   trade.Buy(LotSize,CurrentSymbol,Ask,BuyStopLossPrice,BuyTakeProfitPrice,NULL);
  
  
  }
  
  Comment(HoursandMinutes);
  }
 
Did it print some messages in journal or experts?
 
Sepehr Mohammadi:
double SellTakeProfitPrice = NormalizeDouble(Bid + tp, _Digits);

Change to minus.

 

//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2020, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
#include <Trade\Trade.mqh>
#include <Trade\SymbolInfo.mqh>
#include <Trade\AccountInfo.mqh>


CTrade trade;

//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
   double LotSize = 0.1;
   double sl = 1.0;
   double tp = 3.0;
   string CurrentSymbol = Symbol();
   double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits);
   double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_BID), _Digits);
   double BuyStopLossPrice = NormalizeDouble(Bid - sl, _Digits);
   double BuyTakeProfitPrice = NormalizeDouble(Bid + tp, _Digits);
   double SellStopLossPrice = NormalizeDouble(Ask + sl, _Digits);
   double SellTakeProfitPrice = NormalizeDouble(Ask - tp, _Digits);
   datetime time = TimeLocal();
   string HoursandMinutes = TimeToString(time, TIME_MINUTES);
   if((PositionsTotal() == 0) && (StringSubstr(HoursandMinutes, 0, 5) == "18:30"))
     {
      trade.Sell(LotSize, CurrentSymbol, Bid, SellStopLossPrice, SellTakeProfitPrice, NULL);
      //trade.PositionOpen(CurrentSymbol,ORDER_TYPE_SELL,LotSize,Bid, SellStopLossPrice, SellTakeProfitPrice,NULL);
      trade.Buy(LotSize, CurrentSymbol, Ask, BuyStopLossPrice, BuyTakeProfitPrice, NULL);
     }
   Comment(HoursandMinutes);
  }
//+------------------------------------------------------------------+
 
double BuyStopLossPrice = NormalizeDouble(Ask - sl, _Digits);
double BuyTakeProfitPrice = NormalizeDouble(Ask + tp, _Digits); 

You buy at the Ask and sell at the Bid. Pending Buy Stop orders become market orders when hit by the Ask.

  1. Your buy order's TP/SL (or Sell Stop's/Sell Limit's entry) are triggered when the Bid / OrderClosePrice reaches it. Using Ask±n, makes your SL shorter and your TP longer, by the spread. Don't you want the specified amount used in either direction?

  2. Your sell order's TP/SL (or Buy Stop's/Buy Limit's entry) will be triggered when the Ask / OrderClosePrice reaches it. To trigger close to a specific Bid price, add the average spread.
              MODE_SPREAD (Paul) - MQL4 programming forum - Page 3 #25

  3. The charts show Bid prices only. Turn on the Ask line to see how big the spread is (Tools → Options (control+O) → charts → Show ask line.)
    Most brokers with variable spreads widen considerably at end of day (5 PM ET) ± 30 minutes. My GBPJPY shows average spread = 26 points, but average maximum spread = 134 (your broker will be similar).

Reason: