Download MetaTrader 5
To add comments, please log in or register
Do you keep a blog? Place a link to MQL5.community there and make money!
DenniRo
35
DenniRo 2016.06.09 09:40 

Hi Guys!

I created a special indicator that draw information only when there is a trade. Like the examples below :

if(OrdersTotal() == 0){
//Do something
}
if(OrdersTotal() == 1){
//Do something
}

 When i test that indicator in demo account the indicator work perfect.

But on strategy tester always execute the code which is inside on OrdersTotal() == 0 .

Also i notice that when i get information from the buffers on that indicator to a test EA it works ok on the strategy tester.

Just it doesn't draw the information when the OrdersTotal() change.  

 

Thanks in Advance !!!

Fernando Carreiro
1438
Fernando Carreiro 2016.06.09 09:51  
  1. You did not supply any "real" code, so how do you expect us to test what you describe and offer you advice?
  2. How are you "drawing" this information, via the "buffers" or via Chart Objects?
  3. You did not explain HOW you are testing this indicator:
    1. Are you testing an EA and calling it via iCustom()?
    2. Are you simply testing an EA and attached the indicator to the Visual Test chart?
    3. Are you testing the Indicator directly in the Strategy Tester in the "Indicator Mode"?
DenniRo
35
DenniRo 2016.06.09 11:32  
FMIC:
  1. You did not supply any "real" code, so how do you expect us to test what you describe and offer you advice?
  2. How are you "drawing" this information, via the "buffers" or via Chart Objects?
  3. You did not explain HOW you are testing this indicator:
    1. Are you testing an EA and calling it via iCustom()?
    2. Are you simply testing an EA and attached the indicator to the Visual Test chart?
    3. Are you testing the Indicator directly in the Strategy Tester in the "Indicator Mode"?

Thank you for your reply!

1. I didn't supply real code cause maybe the solution it's obvious for you people here and not for me.  As i said the indicator work perfect anywhere except on strategy tester.

2. The indicators Draw via Buffers.

3.   I simply testing an EA and attached the indicator to the Visual Test chart .

Below there are simple code and pictures with instructions :

#property indicator_separate_window
#property indicator_buffers 1



double test[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
SetIndexBuffer(0,test);
SetIndexStyle(0,DRAW_LINE,0,2,clrAliceBlue);
   
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const datetime &time[],
                const double &open[],
                const double &high[],
                const double &low[],
                const double &close[],
                const long &tick_volume[],
                const long &volume[],
                const int &spread[])
  {
//---
   int limit;
   
   if(prev_calculated == 0){
      limit = rates_total - 1;

   }else{
      limit = rates_total - prev_calculated -1 ;

   }
   
   for(int i=0; i<=limit; i++){
   
      if(OrdersTotal() == 0) {
         test[i] = 0;
      }else{
         test[i] = 100;
      }
   
   }
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+

 

Picture that it work on Demo Account :

 

 

 Picture that it doesn't work on strategy tester :

 

 

As we see , the price on the indicator not change when an order open. Also at the left up corner we see the value of the indicator buffer via iCustom(). That value change as we expected but the same indicator which is attached in the strategy tester not.

 

Thanks in advance! 

Fernando Carreiro
1438
Fernando Carreiro 2016.06.09 12:40  

I have a sneaky feeling that the "OrderTotal()" is getting the data from the "real" account and not from the data currently in the virtual account created for the EA in the strategy tester.

Do the following test. Use the "AccountBalance()" and place it in the buffer ( i.e. "test[ i ] = AccountBalance()" ) and see if it matches the "real" account balance or that of the virtual strategy tester account balance.

If it turns out that it is displaying the "real" account balance, then it seems that running an Indicator on the Visual Test chart is not really that reliable with respect to account data.

Fernando Carreiro
1438
Fernando Carreiro 2016.06.09 12:46  

Well, I have just run the "AccountBalance()" test myself and it is reporting the "real" balance and not the "virtual" account for the Strategy Tester.

So, it seems that any function for Account information, such as the OrderHistory(), will not work correctly in the "Virtual Chart" as it will always report the "real" account information.

I think this is another one of those "pesky" limitations in the Strategy Tester that I personally would consider a "bug" but that MetaQuotes will just consider as limited functionality.

DenniRo
35
DenniRo 2016.06.09 13:11  
FMIC:

Well, I have just run the "AccountBalance()" test myself and it is reporting the "real" balance and not the "virtual" account for the Strategy Tester.

So, it seems that any function for Account information, such as the OrderHistory(), will not work correctly in the "Virtual Chart" as it will always report the "real" account information.

I think this is another one of those "pesky" limitations in the Strategy Tester that I personally would consider a "bug" but that MetaQuotes will just consider as limited functionality.

Thank you for your reply!!!

Let's hope that in the future updates on MT4 , MetaQuotes fix these "limited functionalities". :P

/
To add comments, please log in or register