اقتباس المشاركة الأصلية كتبت بواسطة ali_shadi مشاهدة المشاركة
السلام عليكم

اخي اسامة كما تعلم احيانا يرتفع السعر بشكل لحظي ومفاجئ .... حتى بدون اخبار

هل توجد حيلة برمجية لايقاف تشغيل البرنامج في هده الاثناء ... اي حين يتحرك السعر من النقطة أ الى النقطة باء مثلا في غضون 3 ثواني

يتوقف

شكرا لك اخي الكريم
كمثال----------
اولا طبقوه باكتست وانظر للنتائج

ثانيا: سنضيف اكتشاف السبايك

كود PHP:
  int      setTimerUpdate=1;
   
int      RSI_PERIOD=14;
   
int      RSI_UP_TREND=70;
   
double   Lots=0.1;
   
int      TP=100;
   
int      SL=4000;
int      t;
datetime New_Time=0;
   
int   b=1;
   
int   s=1;
   
int   set=2;
   
int   setX=2;
   
int   b1=0;
   
int   s1=0;
   
int   bX1=0;
   
int   sX1=0;
   
int   b2=0;
   
int   s2=0;bool ticket;;
/////////////////////////////////////////////////////////////////////////////////////////////////
void OnTick()
{
//zz

int RSI_DOWN_TREND=100-RSI_UP_TREND;
   if(
New_Time!=Time[0])  
   {
//yy
      
New_Time=Time[0];
      
t++; 
/////////////////////////////////////////////////////////////////////////////////////////////////
      
double M1,M2;
/////////////////////////////////////////////////////////////////////////////////////////////////
         
M1 iRSI(NULL0RSI_PERIOD,  PRICE_CLOSE,  1  );
         
M2 iRSI(NULL0RSI_PERIOD,  PRICE_CLOSE,  2  );
/////////////////////////////////////////////////////////////////////////////////////////////////
         
if((M2<RSI_DOWN_TREND && M1>RSI_DOWN_TREND)  && t>0)
         {
b1++;s1=0;
         
         if(
b1>=set)  {
ticket=OrderSend(NULLOP_SELL,  s*Lots MarketInfo(NULL,MODE_BID) , 10 ,   MarketInfo(NULL,MODE_BID)+10*SL*MarketInfo(NULL,MODE_POINT) , MarketInfo(NULL,MODE_BID)-10*TP*MarketInfo(NULL,MODE_POINT), "RSI-SELL-50 DOWN-"+Period() , clrRed);
            
t=0;s=1;b++;
         }
}
/////////////////////////////////////////////////////////////////////////////////////////////////
         
if((M2>RSI_UP_TREND && M1<RSI_UP_TREND) && t>0)
         {
s1++;b1=0;
         if(
s1>=set)  {
                        
ticket=OrderSend(NULLOP_BUY,  b*Lots MarketInfo(NULL,MODE_ASK) , 10 ,   MarketInfo(NULL,MODE_ASK)-10*SL*MarketInfo(NULL,MODE_POINT) , MarketInfo(NULL,MODE_ASK)+10*TP*MarketInfo(NULL,MODE_POINT), "RSI-BUY-50 UP-"+Period() , clrLime);
            
t=0;b=1;s++;
         }
         }
/////////////////////////////////////////////////////////////////////////////////////////////////









         
if((M2>RSI_UP_TREND && M1<RSI_UP_TREND))
         {
//0
         
bX1++;sX1=0;
         if(
bX1>=setX)  {
            for(
int j=OrdersTotal();j>-1;j--)
            {
//1
               
if(OrderSelect(j,SELECT_BY_POS,MODE_TRADES))
               {
//2
         /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////      
                     
if(OrderType()==OP_SELL)  
                     {
//6
                        
ticket=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),0,clrYellow); bX1=0;sX1=0;
                     }
//6
               
}//2
            
}//1
         
}//0
         
}//0
////////////////
         
if((M1>RSI_DOWN_TREND && M2<RSI_DOWN_TREND))
         {
//0
         
sX1++;bX1=0;
         if(
sX1>=setX)  {
            for(
j=OrdersTotal();j>-1;j--)
            {
//1
               
if(OrderSelect(j,SELECT_BY_POS,MODE_TRADES))
               {
//2
         /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////      
                     
if(OrderType()==OP_BUY)  
                     {
//6
                        
ticket=OrderClose(OrderTicket(),OrderLots(),OrderClosePrice(),10,clrWhite);  sX1=0;
                     }
//6
               
}//2
            
}//1
         
}//0
   
}//yy
   
}//yy
}//zz
//////////////////////////////////////////////////////////////////////////////////////////////////
int OnInit()
{
   if(
setTimerUpdate<1)setTimerUpdate=1;
   
EventSetTimer(setTimerUpdate);
   return(
INIT_SUCCEEDED);
}
//////////////////////////////////////////////////////////////////////////////////////////////////
void OnDeinit(const int reason)
{
   
EventKillTimer();
   
//ObjectsDeleteAll();
}
//////////////////////////////////////////////////////////////////////////////////////////////////