Strategy tester optimization problem

 

Hi all, 

I am trying to optimize an EA, I have no trouble testing my strategy on a single test but once I try to optimize the inputs or test it on multiple symbols, the test run but not a single trade is taken on any pass. I don't receive any error. Any one had a similar problem? 

I tried to define my inputs different ways, with and without ParameterSetRange() and ParameterGetRange() and nothing changed.

I watched loads of youtube video on that subject but they seem to simply define the input the following way, without even using OnTesterInit() and OnTesterDeinit(): 

input double tpRR = 2.2; 

I am really stuck on that problem for a few days now. Any help would be much appreciated. 

Thanks 

 

In the StratTester in the tab Settings (orange) you choose the EA, Symbol ...

In the Tab Inputs (red) you tell the tester to vary the input variables from Start.. to Stop with Step.


 
Carl Schreiber #:

In the StratTester in the tab Settings (orange) you choose the EA, Symbol ...

In the Tab Inputs (red) you tell the tester to vary the input variables from Start.. to Stop with Step.


Thanks for the reply, that's how I set up the test. I actually simplified the code and adding more and more code to see at what point the optimizer will stop working. And it stopped to work once I added indicator data. The following code is my steps to collect the data and save it to an array : 

string nameRsi; 
int handleRsi;

double rsi[];

int OnInit()
  {
   nameRsi = ChartIndicatorName(0,1,0);
   handleRsi = ChartIndicatorGet(0, 1, nameRsi); 
   
   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {
  }

void OnTick(){

   ArraySetAsSeries(rsi, true);
   
   CopyBuffer(handleRsi, 0, 1, 5, rsi);

//trade conditions }

Then it keep working fine when optimization is disabled but as soon I set Fast genetic, no trade get executed. 

Do you know if there is a specific way to collect indicator data when using the optimization? My goal in my main code is to use a custom indicator. 

Thanks 

 

I can't see any input variable for the tester to vary?

You need to have:

input double tpRR = 2.2; 

where is it. Then you should see tpRR in that tab.

 
Carl Schreiber #:

I can't see any input variable for the tester to vary?

You need to have:

where is it. Then you should see tpRR in that tab.

Here is my full code, I just removed everything not related to the indicator when I pasted it above. So in that code, the optimizer is not placing any trade but strategy tester is working  fine when optimizer disabled. If I replace the condition 

if (isBull && (rsi[1] >= 50) && (rsi[0]<53))

to 

if (isBull)

Then the optimizer is working so the problem must come from the indicator data collection. 


#include <Trade/Trade.mqh>
CTrade trade; 

string nameRsi; 
int handleRsi;
MqlRates bar[];         
double rsi[];

input int MyTakeProfitValue = 100; 
input double lottaken = 1.0; 

int OnInit()
  {
   nameRsi = ChartIndicatorName(0,1,0);
   handleRsi = ChartIndicatorGet(0, 1, nameRsi); 
   
   return(INIT_SUCCEEDED);
  }

void OnDeinit(const int reason)
  {
  }

void OnTick(){

   ArraySetAsSeries(bar, true);                
   ArraySetAsSeries(rsi, true);
   
   CopyRates(_Symbol, _Period, 1, 5, bar);
   CopyBuffer(handleRsi, 0, 1, 5, rsi);
   
   double Ask = NormalizeDouble(SymbolInfoDouble(_Symbol, SYMBOL_ASK), _Digits); 
   
   bool isBull = (bar[0].close > bar[0].open);
   
   if (isBull && (rsi[1] >= 50) && (rsi[0]<53)){
      trade.Buy(1, NULL, Ask, bar[0].close - 0.001, (Ask + MyTakeProfitValue* _Point) , NULL);
  }}

Thank you! 

 
Raphael A #:

Here is my full code, I just removed everything not related to the indicator when I pasted it above. So in that code, the optimizer is not placing any trade but strategy tester is working  fine when optimizer disabled. If I replace the condition 

to 

Then the optimizer is working so the problem must come from the indicator data collection. 


Thank you! 

Hi there, I came across your issue while searching for another problem, in case you didn't resolve this, let me give you a few notes to keep in mind.
the chartIndicatorName and ChartIndocatorGet basically takes the indicators running on a chart which the EA will place on the chart on a live or a regular test, but when running optimization there is no chart and all functions related to it are ignored.


easiest solution in to use iRSI function or iCustom if you are using a custom indicator