Bug - History PriceOpen()

 

Hello Guys,

 When I try retrieve History.PriceOpen(), this work nice on backtest, but when it's running on Demo or Real account, this PriceOpen come Zero(0).

Does anyone have or had the same problem? 

Using mt5 Build:975 

Code:

#include <Trade/HistoryOrderInfo.mqh>
CHistoryOrderInfo History;
double getHistoryOP(long magic){
   double oprice=0;
   datetime end=TimeCurrent();                 // current server time
   datetime start=end-PeriodSeconds(PERIOD_H12);// decrease 1 day
   if(HistorySelect(start,end)) {
      for(int t=HistoryOrdersTotal(); t>=0; t--) {
         double o_ticketHIst=HistoryOrderGetTicket(t);
         if(o_ticketHIst>0){
            
            History.Ticket(o_ticketHIst);
            if(History.Symbol()==_Symbol && History.Magic()==magic){
              
               oprice = History.PriceOpen();
               break;
            }   
         }
      }
   }  
   return oprice;  
}
 
jfpetri:

Hello Guys,

 When I try retrieve History.PriceOpen(), this work nice on backtest, but when it's running on Demo or Real account, this PriceOpen come Zero(0).

Does anyone have or had the same problem? 

Using mt5 Build:975 

Code:

Please post a complete code and not a broken snippet.

There is no ouput in the code you post so, what do you mean by "PriceOpen come Zero(0)." Can you give some details ?

 
angevoyageur:

Please post a complete code and not a broken snippet.

There is no ouput in the code you post so, what do you mean by "PriceOpen come Zero(0)." Can you give some details ?

Hi, I updated the code in first post.

That function, when running on demo ou real account return: 0.00, when in backtest, return the price. 

 
jfpetri:

Hi, I updated the code in first post.

That function, when running on demo ou real account return: 0.00, when in backtest, return the price. 

If it returns 0 it means doesn't match your conditions to set oprice. Print the values to check why. What are the value of start,end, HistoryOrdersTotal(), etc...
 

angevoyageur,

 I am saying that in backtest it's works fine, return exactly the price open from history, match  all conditions and return correctly price, ok?

 BUT, when put is to run in demo account, and Print(oprice), the result is 0.00.

I print other values like, VolumeInicial, etc... and return the value, but only PriceOpen, i got 0.00. 

 
angevoyageur:

jfpetri,

I am saying you have to debug your code, ok ?

angevoyageur,

I put the question here, because o already debug de code and the logic is correct.

But when put the EA to run in demo account, and print the value it show 0.00.

In debugger mode , the value is 0.00 too.

In backtest, the value is correctly. 

 
jfpetri:

angevoyageur,

I put the question here, because o already debug de code and the logic is correct.

When I am running the debugger, the function return a value correctly. But when put the EA to run in demo account, and print the value it show 0.00.

Ok, your code is correct, and this is an MT5 bug. We don't have your code, we don't have your trade history, so we can't check.

 
angevoyageur:

Ok, your code is correct, and this is an MT5 bug. We don't have your code so we can't check.

OK, thanks for your help.
 
i have the same problem, Did you fix that?
Reason: