OK, I've broken down a small part of my code, and I've found the following problem.
Below is the code I've used to test the problem:
int OnInit(){ int data_point = 1e3; double closing_p[], ema[]; int ema_handle = iMA(_Symbol, Period, 12, 0, MODE_EMA, PRICE_CLOSE); CopyClose(_Symbol, _Period, 0, data_points, closing_p); CopyBuffer(ema_handle, 0, 0, data_points, ema); int filePtr = FileOpen("FileOutput.txt", FILE_CSV|FILE_WRITE); for (int i = 0; i < data_points; i++) FileWrite(filePtr, closing_p[i], ema[i]); FileClose(filePtr); return 0; }
The above code outputs the closing price fine, but the indicator - ema12 - is simply outputted as 0.
Regards,
Steven
Further tests show that CopyBuffer is returning -1.
Right, I've checked what you've advised, and the ema_handle is fine, but the BarsCalculated returns -1.
Steven
This means that your indicator hasn't calculated yet.
You better wait some time then try again later.
Actually, researching it more myself, that actually makes sense. Since I was trying to get the indicator values as soon as the EA was running, but the indicators would never of been calculated, hence the problem. So I've now updated my code so that the indicators are only calculated after a certain amount of bars have been calculated.
Thanks for the help.
Steven
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi,
Hope someone help me with this problem, so at least tell me if the problem CAN be overcome.
Basically, I've been developing an EA, which performs some initial training when it starts up. When testing this on my demo account, it seems to be working fine, and gives me the results I'm expecting. However, when I try to use the strategy tester, the initial training starts, but then brings up an error. To explain a bit further, the initial tester (which only runs when there are enough bars available), takes the closing price, and several indicator values (1000 worth at the moment), and then performs the training. However, from what I can gather from my program, these values aren't being obtained, and I'm being left with an empty array. Unfortunately, I also can't get file output to work on the strategy tester, to see if this is the case.
Any help would be great, and I'd be happy to answer any more questions.
Regards,
Steven