Strategy Tester and iCustom()+CopyBuffer()

 

 When I try to backtest an EA that uses iCustom() and CopyBuffer() in the Strategy Tester I have the following problem: the iCustom() functions works perfectly and returns a valid handle, but the CopyBuffer() function then fails to copy anything from the handle to a buffer (returns -1). When I run the same EA with the same settings on demo account, it works perfectly. What can be the reason for this behavior? Am I missing something?

Documentation on MQL5: Timeseries and Indicators Access / CopyBuffer
  • www.mql5.com
Timeseries and Indicators Access / CopyBuffer - Documentation on MQL5
 

Welcome to servicedesk with details and explanations

 
stringo:

Welcome to servicedesk with details and explanations

Just sent a request there.
 
Turns out the problem occurred because the custom indicator handle was created every tick and during the back-test data didn't have enough time to load to buffers. Moving handle creation to OnInit() helped the problem.
Step on New Rails: Custom Indicators in MQL5
  • 2009.11.23
  • Андрей
  • www.mql5.com
I will not list all of the new possibilities and features of the new terminal and language. They are numerous, and some novelties are worth the discussion in a separate article. Also there is no code here, written with object-oriented programming, it is a too serous topic to be simply mentioned in a context as additional advantages for developers. In this article we will consider the indicators, their structure, drawing, types and their programming details, as compared to MQL4. I hope that this article will be useful both for beginners and experienced developers, maybe some of them will find something new.
 

I am having the same problem and I can't use backtest if I don't get data from the indicator because EA depend totally of that information to take decision like buy or sell.

I did everything and I am giving up to use my EA in backtest unfortunately, because when I do some changes I need to stay waiting open market to make the test in demo environment and if I had backtest working well, wouldn't be necessary.

please, what I am doing wrong?

I don't believe that isn't possible get the information in backtest.


my name is Carlito and I would appreciate much if someone give me a light.

thanks

 
Carlito Sena: I am having the same problem and I can't use backtest if I don't get data from the indicator because EA depend totally of that information to take decision like buy or sell.

I did everything and I am giving up to use my EA in backtest unfortunately, because when I do some changes I need to stay waiting open market to make the test in demo environment and if I had backtest working well, wouldn't be necessary. please, what I am doing wrong? I don't believe that isn't possible get the information in backtest.

Your code is flawed and needs to be fixed! We can't possible guess what you are doing wrong without looking at your code.

As you can read from the original poster, his problem was that he was initialising the handle on every tick instead of only once. So begin by checking if that is your case.

If however, that is not your case, then you will have to at least show some of your code, if you want assistance!

Reason: