PSAR reversal check on a closed candle

 
Hey hey People Tom here,

I want to detect the psar reversal up/down wich i have managed to succeed, however the psar can sometimes "flicker" like reverse multiple times in a candle.
Wich is why i first want it to wait for a candle close and then check for a reversal, however when i check for a new bar/candle and then do the same psar check as once worked it now behaves random let us say...
the Print's aren't even triggered
Print("PSAR reversed down");
Print("PSAR reversed up");
Isn't even triggered once
This may be obvious for the experienced codes amongst u, but pls help me thank u :)
// check for new bars function
string CheckFoNewBarOnChart()
  {
   static int LastNumberOfBars;
   string NewBarAppeared="no new bar";

   if(Bars>LastNumberOfBars)
     {
      NewBarAppeared="Shree new bar!!";
      LastNumberOfBars=Bars;
     };
   return NewBarAppeared;
  }

//+------------------------------------------------------------------+
//| Check PSAR reversal                                              |
//+------------------------------------------------------------------+
void CheckPSARCross()
  {
   CrossToOpenBuy=false;
   CrossToOpenSell=false;
   double PSARCurr=iSAR(Symbol(),0,PSARStep,PSARMaxStep,0);
   double PSARPrev=iSAR(Symbol(),0,PSARStep,PSARMaxStep,1);
   if(PSARCurr<Close[0] && PSARPrev>Close[1])
     {
      //psar reversed down, so a BUY

      CrossToOpenBuy=true;
     }
   if(PSARCurr>Close[0] && PSARPrev<Close[1])
     {
      //psar reversed up, so a SELL

      CrossToOpenSell=true;
     }
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
datetime ArrayTime[], LastTime;
void OnTick()
  {
   string DoWeHaveANewBar = "";
   DoWeHaveANewBar = CheckFoNewBarOnChart();
   Comment
   (
      "Bars on Chart: ",Bars,"\n","New Bar Appeared: ",DoWeHaveANewBar
   );
//---
   if(DoWeHaveANewBar == "Shree new bar!!") //Period()
     {
      Print("New bar detected beginning to check for PSAR reversal");
      //Calling initialization, checks and technical analysis
      Initialize();
      CheckCanOrder();
      CheckPSARCross();
      //Check of Entry/Exit signal with operations to perform
      if(CrossToOpenBuy)
        {
        Print("PSAR reversed down");
         CloseAll(OP_SELL);
         if(CanOpenBuy && CanOrder)
           {
            OpenNew(OP_BUY);
           }
      if(CrossToOpenSell)
        {
        Print("PSAR reversed up");
         CloseAll(OP_BUY);
         if(CanOpenSell && CanOrder)
           {
            OpenNew(OP_SELL);
           }
        }
     }
     }
}
 
Please check cosebase. There are lots of ideas how to do this.
Reason: