Sell process not working, only buying

 

I've written a basic first code so i can get the hang of mql5, my buy function is working fine, but my sell function isn't, i'm not sure whether its a problem with the signals or trade function, could someone please advise?

  bool Sell_Condition_1 = (MACD[1]<MACD[2]); // MA-8 Increasing upwards

   bool Sell_Condition_2 = (RSI1[0]<RSI1[1]);         // previuos price closed above MA-8

   bool Sell_Condition_3 = (Stochastic[0]<Stochastic[1]);

   bool Sell_Condition_4 = (Stochastic[0]>20);

   

 //--- Putting all together

   if(Sell_Condition_1 && Sell_Condition_2)

       {

         if(Sell_Condition_3 && Sell_Condition_4)

         

         {          // any opened Sell position?

            if (Sell_opened) 

            {

               

                return;    // Don't open a new Sell Position

            }

    

   if(!PositionSelect(_Symbol))                           // no position yet

         if(AccountInfoDouble(ACCOUNT_FREEMARGIN)>1000)      // if we have enough money

           {

            trade.PositionOpen(_Symbol,                                          // symbol

                               ORDER_TYPE_SELL,                                  // sell order

                               Money_M(),                                        // lots to trade

                               Bid,                                              // last bid price

                               Bid + SL,                                   // Stop Loss

                               Bid - TKP,                                 // Take Profit 

                               " ");                                             // no comments

           }

  }

            //--- send order

            

       if(mresult.retcode==10009 || mresult.retcode==10008) //Request is completed or order placed

           {

            Alert("A Sell order has been successfully placed with Ticket#:",mresult.order,"!!");

           

            return;

           }

           

        }

       }

     return;

Documentation on MQL5: Standard Constants, Enumerations and Structures / Environment State / Account Properties
  • www.mql5.com
Standard Constants, Enumerations and Structures / Environment State / Account Properties - Documentation on MQL5
Files:
numero10.mq5  13 kb
 

Please post your code with SRC button

 

Try to sell first and then buy. If that does not works please read this https://www.mql5.com/en/forum/6773#comment_205206 

Reason: