Help coding a simple ASC_trend EA

 

Hi, Im new at coding so I've been trying write simple EA's. One of them is an Asc_trend ea that open a market order when the blue dot appears and reverse the position when the pink ball appears. I cant make the EA do this logic, can somebody help me to find where's the problem? thanks

//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2012, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
#include <Trade\Trade.mqh>
CTrade trade;

double input InpRISK=  4;
input double   TAKE=100;
input double   STOP=100;

bool isbuy=false;

bool issold=false;
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void OnTick()
  {
   double Ask=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_ASK),_Digits);
   double Bid=NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);

   MqlRates PriceInfo[];
   ArraySetAsSeries(PriceInfo,true);
   int PriceData=CopyRates(Symbol(),Period(),0,3,PriceInfo);
   string signal="";

   double asc_buy[],asc_sell[];
   ArraySetAsSeries(asc_buy,true);
   ArraySetAsSeries(asc_sell,true);

   int ASKDEFITION=iCustom(_Symbol,_Period,"Examples\\ASCtrend",InpRISK);

   CopyBuffer(ASKDEFITION,0,0,3,asc_sell);
   CopyBuffer(ASKDEFITION,1,0,3,asc_buy);

   double buy_signal = asc_buy[1];
   double sell_signal  = asc_sell[1];

   if(buy_signal && PositionsTotal()<1)
     {
      trade.Buy(10,NULL,Ask,0,0,NULL);
      isbuy=true;
      
     }

   if(sell_signal && PositionsTotal()<1)
     {
      trade.Sell(10,NULL,Bid,0,0,NULL);
      issold=true;
     
     }
   //if(buy_signal)

      if(isbuy && sell_signal)

        {
         isbuy=false;
         Close_BUY();
         
        }

   //if(sell_signal)
      if(issold && buy_signal)
        {
         issold=false; 
         Close_SELL();
        
        }

  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Close_BUY()
  {
   long buyposition=PositionGetInteger(POSITION_TYPE);
   if(buyposition==POSITION_TYPE_BUY)
      trade.Sell(10,NULL,0,0,0,NULL);
  }
//+------------------------------------------------------------------+
//|                                                                  |
//+------------------------------------------------------------------+
void Close_SELL()
  {
   long sellposition=PositionGetInteger(POSITION_TYPE);
   if(sellposition==POSITION_TYPE_SELL)
      trade.Buy(10,NULL,0,0,0,NULL);
  }
//+------------------------------------------------------------------+