EA Should only take one trade per signal...not trade every new bar after it gets that signal

 

Hey Guys .....I'm new here 

So I've been trying this coding thing for some time now and now my biggest challenge is that my EA does enter a trade when the requirments are met , the only problem is that after it enters a trade given a signal ...it continues taking trades after signal and it trades every new bar 

I just need help with it only executing one trade per signal etc..


Thank you guys in Advance!!!!

Much Appreciate it.



I was only trying it out for Sell signals only and i got stuck 


The code is as follows:



      

   

bool ConditionSell1 =false;

double  SignalValue =0.0001;





//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {  
     
     
      

   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {    
    
       static datetime timestamp;
     datetime time = iTime(_Symbol,PERIOD_CURRENT,0);
     if(timestamp != time){
     timestamp = time;
     
     
    
      double Bid = NormalizeDouble(SymbolInfoDouble(_Symbol,SYMBOL_BID),_Digits);
      
      
      MqlRates PriceInformation[];
      
      ArraySetAsSeries(PriceInformation,true);
      
      int Data =CopyRates(_Symbol,_Period,0,3,PriceInformation);
      
      double PriceArray[];
      
      static int AwesomeDefination = iAO(_Symbol,PERIOD_CURRENT);
      
      ArraySetAsSeries(PriceArray,true);
      
      CopyBuffer(AwesomeDefination,0,0,3,PriceArray);
      
      double AwesomeValue= NormalizeDouble(PriceArray[0],6);
      
      if(AwesomeValue <0-SignalValue)
      {
         ConditionSell1 = true;
      }
      
      if(ConditionSell1==true)
      {
         double sl = Ask + 7000 * SymbolInfoDouble(_Symbol,SYMBOL_POINT);
           double tp = Ask - 71000 * SymbolInfoDouble(_Symbol,SYMBOL_POINT);
        trade.Sell(LotsToTrade,NULL,Bid,sl,tp,NULL);
        ConditionSell1 =false;
      
      }
      
    }
    
 }
      

      

Reason: