iClose returning wrong value - page 3

To add comments, please log in or register
ckalleane
12
ckalleane  

Hi, I have the exact same issue as Douglas with iTime; for example "iTime(XPDUSD,5) Failed: 0".

I am trying using the strategy tester on a 1H tf and call a custom indicator to return a value based on the 5 min tf of the same XPDUSD chart the tester is running on.

The indicator then returns an empty value and this is in the line after I try to download history with the result of "iTime(XPDUSD,5) Failed: 0" but sometimes iTime does not fail, irregularly,  and the indicator now has history to then actually return a value.

I have tried both the code suggested by Petr Nosek & whroeder1 but with the same result unfortunately.

Could I be missing something obvious or is this a common problem when running strategy tester with icustom calls on separate time-frames ?

Having a hard time finding better threads about the topic other then this where you all have provided great info.

antaransi
7
antaransi  

Hi,


I'm facing a similar problem so I thought I'd post it here. I'm trying to get the previous value for the current symbol and timeframe for an EA. The EA is executing an indicator I have created. While the indicator is working perfect the EA is 100% wrong.

The EA always returns the current price for Close[i] and Close[i+1], or iClose(_Symbol, 0, i) and iClose(_Symbol, 0, i + 1)


Top window is from the Indicator (you can see the Close[1] is the price of the next row

and bottom window is from the EA where the prices are the same:

bb



Here's the code:

   string priceFormat=StringFormat("%%.%df",SymbolInfoInteger(_Symbol,SYMBOL_DIGITS));
   printf("Close[0]="+priceFormat+" Close[1]="+priceFormat,
      Close[i],
      Close[i + 1]
      );
lippmaje
594
lippmaje  

antaransi:

...While the indicator is working perfect the EA is 100% wrong.

The EA always returns the current price for Close[i] and Close[i+1], or iClose(_Symbol, 0, i) and iClose(_Symbol, 0, i + 1)

My guess is that i is pointing to some place in the past, probably night hours. Why do you even use i when you are just concerend with Close[0] and Close[1]? Try i=0; or remove it entirely from your printf statement, then check again.

antaransi
7
antaransi  
lippmaje:

My guess is that i is pointing to some place in the past, probably night hours. Why do you even use i when you are just concerend with Close[0] and Close[1]? Try i=0; or remove it entirely from your printf statement, then check again.

Thank you for your reply,


I've tried that as well. Does not work. The dates are valid - you can see them on the left and this goes on for any date! Close[0] is always the same value as Close[1].

I don't have much experience with MQL, so I was wondering if this is the way that EAs are supposed to work.

lippmaje
594
lippmaje  
Close[0] is always equal to the latest Bid. I guess your printf is executed exactly on open of a new bar, as the time stamps indicate. In this case, you are logging the close of the last bar plus the actual bid. Both are just a tick apart. Try Close[2] and Close[1].
antaransi
7
antaransi  
lippmaje:
Close[0] is always equal to the latest Bid. I guess your printf is executed exactly on open of a new bar, as the time stamps indicate. In this case, you are logging the close of the last bar plus the actual bid. Both are just a tick apart. Try Close[2] and Close[1].

I appreciate the response. I did just that and now everything seems to work just fine. Every platform something new to learn.


Thanks again for your response.

123
To add comments, please log in or register