EA not refreshing

Back to topics list To post a new topic, please log in or register
avatar
7
Josif 2014.12.10 14:02
 

Hello, 

 I am wondering, if anyone could help me? I have an EA, that sends messages to my phone. Problem is, that the data are not refreshed so I do not get any signals, or much less than I should. When I get to the somputer and restart metatrader, or open  MetaEditor and compile the script, it is suddenly fine and all data gets refreshed. I tried adding the Refreshrates() function everywhere relevant, but it does not seem to help. 

Did anyone ever experienced similar problem? My problem is, I do not even know where to look for solution. My strategy is based on custom indicator called Doda Stochastic, which might be a bit problematic, since it is smoothed and recalculates the values 3 times, but when I removed it, the issue remained. 

 Thank you,

Josef 

avatar
13009
WHRoeder 2014.12.10 14:54 #
 
Josif201: compile the script, it is suddenly fine and all data gets refreshed.
  1. Scripts run once and exit. You have an EA
  2. Your EA is broken. You need to fix it. We can't help because we can't see your code.
avatar
7
Josif 2014.12.10 17:02 #
 
WHRoeder:
Josif201: compile the script, it is suddenly fine and all data gets refreshed.
  1. Scripts run once and exit. You have an EA
  2. Your EA is broken. You need to fix it. We can't help because we can't see your code.

This is the function that controls the long signals:


double LongCoeficient () {

   RefreshRates();

   double Result = 0;

   double Add1 = 0, Add2 = 0, Add3 = 0, Add4 = 0, Add5 = 0, Add6 = 0, Add7 = 0, Add8 = 0, Add9=0, Add10 = 0;

   double ADXLong = iCustom (Symbol(), PERIOD_H1, "ADXDMI", DMIPeriod, Smooth, 0, 1);

   double ADXShort = iCustom (Symbol(), PERIOD_H1, "ADXDMI", DMIPeriod, Smooth, 1, 1); 

   double Dodagreen = iCustom (Symbol(), PERIOD_H1, "Doda-stochastic", Slw, Pds, Slwsignal, Barcount, 0, 1);

   double Dodared = iCustom (Symbol(), PERIOD_H1, "Doda-stochastic", Slw, Pds, Slwsignal, Barcount, 1, 1);

 

   if (MarketStrength()>0 && MarketStrength() < 25)Add1 = 0.15;

   if (MarketStrength()>25)Add1 = 0.20; //15

   

   if (H1MarketTrend()==4)Add3=0.1;

   if (H1MarketTrend()==3)Add3=0.05;//5

 

   if (MA1>=MA2 && MA2>=MA3) Add4 = 0.05;//5

    if (MAslow1>=MAslow2&& MAslow2>=MAslow3) Add5 = 0.10; //0,1


   if (ADXLong>ADXShort)Add6 = 0.10;//10

   

   if (  (Dodared > (100 - DodaLine) && Dodagreen > (100 - DodaLine) ) )  Add7 = 0.15;


   if ( (Dodared < (100 - DodaLine) && Dodagreen < (100 - DodaLine) ) ) Add7 = 0.25;

   if (MA2001 < Ask ) Add8 = 0.05; 

   if (HalfDayChange()>0) Add9 = 0.05;

   if (HalfDayChange()>10) Add9 = 0.1;    

   if (WholeDayChange()>0) Add10 = 0.05;

   if (WholeDayChange()>5) Add10 = 0.1; 

   Result = Add1+Add2+Add3+Add4+Add5+Add6+Add7+Add8+Add9+Add10;

return(Result);

Results are sent to another function which than has couple more basic rules and if those are passed, than I get the signal. But the problem is definitely the function above. I think the problem is that it runs once.. so how do I make it run all the time?  

 

 

avatar
13009
WHRoeder 2014.12.10 18:26 #
 
Josif201: so how do I make it run all the time?
  1. Don't paste code
    Play video
    Please edit your post.
    For large amounts of code, attach it.

  2. Call it from OnTick()
avatar
7
Josif 2014.12.26 20:56 #
 

So I have put it in the OnTick  mode and it does not help...

 

Here is the code in the OnTick function:

 

int Check;
   for(int i=0; i<OrdersTotal();i++) {
      if(OrderSelect(i,SELECT_BY_POS)) {
         if(OrderSymbol()==Symbol() && OrderMagicNumber() == 0) {
    
            if (OrderStopLoss()==0 && OrderTakeProfit()==0){
               //Pokud jsou to nákupní obchody
               if(OrderType()==OP_BUYSTOP || OrderType()==OP_BUYLIMIT || OrderType()==OP_BUY) {
                  //pokud má použít mnou přednastavený TP a SL
                  if (StopLoss!=0 && TakeProfit!=0){
                     Check = OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()-StopLoss*Point, 
                     OrderOpenPrice()+TakeProfit*Point, 0, NULL); 
                     if (Check<0) Print ("Modify order error ", GetLastError());
                     if (TakePhoto){
                        Photo();
                     }
                  }
                  //pokud to má použít automatické nastavení SL a TP 
                  if (StopLoss==0 && TakeProfit==0){
                     
                     Check =OrderModify(OrderTicket(),OrderOpenPrice(),LowerLine-LossAdder*Point, 
                      OrderOpenPrice()+NormalizeDouble(HighLow*TakeProfitCount,Digits), 0, NULL); 
                     if (Check<0) Print ("Modify order error ", GetLastError());
                     
                     if (TakePhoto){
                        Photo();
                     }
                  }
                  
               }
               //pokud jsou to prodejní obchody
               if(OrderType()==OP_SELLSTOP || OrderType()==OP_SELLLIMIT || OrderType()==OP_SELL) {
                
                  //PotentialProfit = (OrderOpenPrice()-OrderTakeProfit())*Adjust()*Tickvalue*OrderLots(); 
                  
                  //pokud má použít mnou přednastavený TP a SL
                  if (StopLoss!=0 && TakeProfit!=0){
                     Check = OrderModify(OrderTicket(),OrderOpenPrice(),OrderOpenPrice()+StopLoss*Point, 
                     OrderOpenPrice()-TakeProfit*Point, 0, NULL);
                     if (Check<0) Print ("Modify order error ", GetLastError()); 
                     if (TakePhoto){   
                        Photo();
                        }
                     }
                  //pokud to má použít automatické nastavení SL a TP   
                  if (StopLoss==0 && TakeProfit==0){
                     Check = OrderModify(OrderTicket(),OrderOpenPrice(),HigherLine+LossAdder*Point, 
                     OrderOpenPrice()-NormalizeDouble(HighLow*TakeProfitCount,Digits), 0, NULL);
                     if (Check<0) Print ("Modify order error ", GetLastError());
                     if (TakePhoto){ 
                        Photo(); 
                        }
                     }
                  }
               }
               
               if (BreakEvenLevel == 0) BreakEvenLevel = H1Limit;
               if(BreakEven) {
                  if(ObjectFind("Linie_be_" + OrderTicket())==-1) {
                     if(OrderType()==OP_BUY || OrderType()==OP_BUYLIMIT || OrderType()==OP_BUYSTOP) {
                        if(OrderStopLoss()<OrderOpenPrice()) {
                           ObjectCreate("Linie_be_" + OrderTicket(),OBJ_HLINE,0,Time[0],OrderOpenPrice()+BreakEvenLevel*Point);
                           ObjectSet("Linie_be_" + OrderTicket(),OBJPROP_COLOR,BEColor); 
                           ObjectSet("Linie_be_" + OrderTicket(),OBJPROP_STYLE,BEStyle); 
                        }
                     } else {
                        if(OrderStopLoss()>OrderOpenPrice()) {
                           ObjectCreate("Linie_be_" + OrderTicket(),OBJ_HLINE,0,Time[0],OrderOpenPrice()-BreakEvenLevel*Point);
                           ObjectSet("Linie_be_" + OrderTicket(),OBJPROP_COLOR,BEColor); 
                           ObjectSet("Linie_be_" + OrderTicket(),OBJPROP_STYLE,BEStyle); 
                        }
                     } 
                  } else {
                     //když se má nastavit BEP
                     if(OrderType()==OP_BUY) {
                     if(MarketInfo(OrderSymbol(),MODE_BID)>ObjectGet("Linie_be_" + OrderTicket(),OBJPROP_PRICE1)) {
                     Check = OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(), 0, NULL);
                     if (Check<0) Print ("Modify order error ", GetLastError());
                     ObjectDelete("Linie_be_" + OrderTicket());
                     continue;
                     }
                  }
                     if(OrderType()==OP_SELL) {
                     if(MarketInfo(OrderSymbol(),MODE_ASK)<ObjectGet("Linie_be_" + OrderTicket(),OBJPROP_PRICE1)) {
                        Check = OrderModify(OrderTicket(), OrderOpenPrice(), OrderOpenPrice(), OrderTakeProfit(), 0, NULL);
                        if (Check<0) Print ("Modify order error ", GetLastError());
                        ObjectDelete("Linie_be_" + OrderTicket());
                        continue;
                     }
                  }
               }
            }
         }
      }
   }
      
   for(i=0;i<OrdersHistoryTotal();i++) {
      if(OrderSelect(i,SELECT_BY_POS,MODE_HISTORY)) {
         //zůstal break even point 
         if(ObjectFind("Linie_be_" + OrderTicket())!=-1) {
            ObjectDelete("Linie_be_" + OrderTicket());
         }         
      }
   }
}

 

Any chance that the OrderSelect loop is the problem? I just realized that in some cases it might that the trade is no longer valid.Also shall I use the SELECT from active trades option in ORDER_SELECT?

 

avatar
13009
WHRoeder 2014.12.27 14:37 #
 
Josif201:

So I have put it in the OnTick  mode and it does not help...

Here is the code in the OnTick function:

Any chance that the OrderSelect loop is the problem?

I just realized that in some cases it might that the trade is no longer valid.

Also shall I use the SELECT from active trades option in ORDER_SELECT?

  1. "does not help" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here. If you think it's not begin called, add a print statement to it and find out! Stop guessing.
  2. How does this code have anything to do with your original problem?
  3. How could a orderSelect loop have anything to do with your original problem?
  4. You must count down when closing/deleting in a position loop. Get in the habit of always counting down. Loops and Closing or Deleting Orders - MQL4 forum
  5. Active trades is the default.
avatar
7
Josif 2015.01.07 21:04 #
 
WHRoeder:
  1. "does not help" is meaningless - just like saying the car doesn't work. Doesn't start, won't go in gear, no electrical, missing the key, flat tires - meaningless. There are no mind readers here. If you think it's not begin called, add a print statement to it and find out! Stop guessing.
  2. How does this code have anything to do with your original problem?
  3. How could a orderSelect loop have anything to do with your original problem?
  4. You must count down when closing/deleting in a position loop. Get in the habit of always counting down. Loops and Closing or Deleting Orders - MQL4 forum
  5. Active trades is the default.

Hello WHRoeder,

sorry for my late reply, it always takes couple hour before I see that whatever I changed does not help.

Thank you for your reply, what I meant was, that the original problem persists. I have replaced the original start function with OnTick and now I am moving everything into this function to see if it helps. I have some functions called within another functions and the problem might be somewhere there. 

As you suggested the print solution, I have obviously done that and the code if fine when I try to Print the value. Problem is, that after number of hours (usually when I get home from work), the program shows me some infromation, which is not refreshed. When I restart the Metatrader, data refreshes.

Thanks for the count down loop, I will remember that :-)

Now that I think about it, it runs on my laptop and maybe part of my laptop might turn of after some time and that might cause the problem even though I have set it not to.. (but I doubt that it would be the problem)

I am hoping the moving everything to OnTick will solve the problem. 

 

Thanks again,

 

Josef 

 

Back to topics list  

To add comments, please log in or register