Listing EA in Market and submitting code in CodeBase - page 2

 
Sopheak Khlot #:

I don't have problem running it on Strategy Tester. However, I use iBars() to count total bar count on the chart to loop from. Could it be a problem of taking to long test? MQL server may have more than 10 years of data, i guess.

If you cycle all chart bars for each tick (OnCalculate), it will be surely very very slow. You should take care of prev_calculated bars to avoid cycling all of them every time, you don't need them and it eat a lot of unnecessary resources.

 
Fabio Cavalloni #:

If you cycle all chart bars for each tick (OnCalculate), it will be surely very very slow. You should take care of prev_calculated bars to avoid cycling all of them every time, you don't need them and it eat a lot of unnecessary resources.

Sound like int limit = iBars(_Symbol,_Period) - prev_calculated, right?

 
Sopheak Khlot #:

Sound like int limit = iBars(_Symbol,_Period) - prev_calculated, right?

rates_total - prev_calculated

Check on codebase for some well-done examples.

 
Fabio Cavalloni #:

rates_total - prev_calculated

Check on codebase for some well-done examples.

I think I will count total bars for the last 10 days then loop from that number. This should reduce calculation time from the server as it won't start from the first bar on the chart.

 
Sopheak Khlot #:

I think I will count total bars for the last 10 days then loop from that number. This should reduce calculation time from the server as it won't start from the first bar on the chart.

No. You can start from the beginning of the chart without problems, but you need to take care of previously already calculated candle to avoid recycling all of them for each tick. 

All bars except current one are permanent and never change again into the future, you don't need to recalculate all of them, but only the current one.
 
Fabio Cavalloni #:
No. You can start from the beginning of the chart without problems, but you need to take care of previously already calculated candle to avoid recycling all of them for each tick. 

All bars except current one are permanent and never change again into the future, you don't need to recalculate all of them, but only the current one.
int limit = 0;
if(prev_calculated > 0)limit++;
limit = rates_total - prev_calculated;
   
if(prev_calculated == 0)
limit=rates_total - prev_calculated - 1;

for(int i = limit; i>=0; i--)
{

}
 
int limit = fmin(rates_total-1,rates_total-prev_calculated);
 
Fabio Cavalloni #:

It seems to be better in term of memory usage. but when I tried to change the timeframe, I always got error saying "Out of array..." until I changed back and forth. As you may know the zone or range breakout, I calculate the High and Low within the given time period. I think I need to check the highest and lowest index with limit I loop from.

 
Your code seems to be broken in multiple ways, but we have no visibility of it.

I strongely suggest to you to hire a professional developer to fix it and make it working correctly, especially because you want to put the indicator on marketplace.
 
Fabio Cavalloni #:
Your code seems to be broken in multiple ways, but we have no visibility of it.

I strongely suggest to you to hire a professional developer to fix it and make it working correctly, especially because you want to put the indicator on marketplace.

Thanks for the advice, I managed to make this error gone away by using iHigh() and iLow() instead high[] and low[].