Danamic Sl

 

hi all

attached my EA

how can i fix the SL which will update every cahnge in SAR level

i mean that the sl will update every time the SAR level is change

thanks

 
//+------------------------------------------------------------------+
//| expert initialization function |
//+------------------------------------------------------------------+
bool New_Bar=false;
int SL;
int start()
{
   
   if(iSAR(NULL,0,0.02,0.2,0)<Ask && New_Bar==true &&OrdersTotal()<3 ) 
      {
      OrderSend(Symbol(),OP_BUY ,0.1,Ask,30,iSAR(NULL,0,0.02,0.2,0),SL(),0,0,0,0);
      } 
   if(iSAR(NULL,0,0.02,0.2,0)>Ask && New_Bar==true && OrdersTotal()<3) 
      {
      OrderSend(Symbol(),OP_SELL,0.1,Ask,30,iSAR(NULL,0,0.02,0.2,0),SL(),0,0,0,0);
      }
}


//--------------------------------------------------------------------------------
bool Fun_New_Bar() // PARENTHESIS WERE MISSING HERE
{ 
   static datetime New_Time;
   RefreshRates();
   if (New_Time!=Time[0])
      {
      New_Time=Time[0];
      New_Bar=true;
      } 
   else
   New_Bar=false;
   return(New_Bar);
}

int SL()
{
   static int SL;
   RefreshRates();
   if (SL!=iSAR(NULL,0,0.02,0.2,0))
   {
   SL=iSAR(NULL,0,0.02,0.2,0);
   }
   return(SL);
}
//--------------------------------------------------------------------------------- 

bool init()
{
Fun_New_Bar();
SL();
return (SL);
return (New_Bar);

}
 
stoploss is not an integer.
Reason: