i need help. it work in demo, but not live account.

 
#property copyright "KTProg Software"
#property link      "https://www.mql5.com"
#property strict

enum typeOfNews{
   NFP = 1,
   FOMC = 2
};

bool tradeStatus; 
int counter = 0;
extern double PipsDifference = 2;
extern int StopLossPips = 300;
extern int TakeProfitPips = 800;
extern int SlippagePips = 10000;
extern int MT4ExecutionHour = 14;
extern int MT4ExecutionMinute = 30;
extern double LotSize = 1;
extern typeOfNews NewsType = NFP;

int OnInit(){
   Alert("News Trading Master has been added successfully!");
   if(IsTradeAllowed())
   {
      Alert("Trade allowed");
   }
   else
   {
      Alert("Trade not allowed");
   }
   return(INIT_SUCCEEDED);
}

void OnDeinit(const int reason){
   Alert("News Trading Master has been removed successfully! Curret time is " + TimeCurrent());
}

void OnTick(){
  
   int ticket = -1;
   int count = 0; 
   
   if(counter == 0 && Hour() == MT4ExecutionHour && Minute() >= MT4ExecutionMinute && OrdersTotal() == 0){  
   
      double slLevel;
      double tpLevel;
      
      if(checkEntry() == 1){
      
         if(StopLossPips == 0){
            slLevel = 0;
         }
         else{
            slLevel = Bid - StopLossPips * Point;
         }
         
         if(TakeProfitPips == 0){
            tpLevel = 0;
         }
         else{
            tpLevel = Bid + TakeProfitPips * Point;
         }
      
         while ((ticket == -1) && (count < 10))
         {
            RefreshRates();
            ticket = OrderSend(Symbol(),OP_BUY,LotSize,Ask,SlippagePips,slLevel,tpLevel);
            count++;
         } 
          
         counter++;       
      }
      else if(checkEntry() == -1){
      
         if(StopLossPips == 0){
            slLevel = 0;
         }
         else{
            slLevel = Ask + StopLossPips * Point;
         }
         
         if(TakeProfitPips == 0){
            tpLevel = 0;
         }
         else{
            tpLevel = Ask - TakeProfitPips * Point;
         }
         
         while ((ticket == -1) && (count < 10))
         {
            RefreshRates();
            ticket = OrderSend(Symbol(),OP_SELL,LotSize,Bid,SlippagePips,slLevel,tpLevel);
            count++;
         } 
                 
         counter++;
      }
   }

   if(ticket > 0)
   {
      Alert("Order successful with ticket #",ticket);
   }
 
}

int checkEntry(){

   if(Bid - Open[0] >= PipsDifference){     
      return 1;
   }
   else if(Open[0] - Bid >= PipsDifference){  
      return -1;
   }
   else {
      Alert("No trade is required due to pips difference = Difference between " + Bid + " and " + Open[0] + " is " + (Bid - Open[0]));
      return 0;
   } 
}

 

hi,

 

i have recently created above EA, it function purpose to trade news.

mainly for NFP only. i can set the trigger pips, when news release it trigger and open position with Tp & SL.

 

It work on Demo account, but not live account. any expert senior can help ?  

 
If the order fails check the error and that may give you a clue.
 
GumRai:
If the order fails check the error and that may give you a clue.
what mean sensei
 
Check your return codes and find out why. Check your return codes (OrderSelect and OrderClose) What are Function return values ? How do I use them ? - MQL4 forum and Common Errors in MQL4 Programs and How to Avoid Them - MQL4 Articles
Reason: