Pingui
Pingui

Reputation: 1496

Defining dynamic restrictions for Strategy Testing in MetaTrader 5

I would like to optimize a minimum variable (let's call it minPips) and a maximum variable (maxPips).

Let's say minPips can be anywhere within an optimization range of 0 to 100, and maxPips is between 50 and 200.

How can I prevent a senseless optimization run with maxPips<minPips (e.g. minPips=100 and maxPips=50)?

Maybe using OnTester() somehow?

Upvotes: 0

Views: 424

Answers (1)

Daniel Kniaz
Daniel Kniaz

Reputation: 4691

int OnInit()
  {
   if(minPips>=maxPips)
     {
      Alert("parameter minPips must be smaller than maxPips);
      return(INIT_FAILED);// or INIT_PARAMETERS_INCORRECT - doesnt matter
     }
  }

Upvotes: 1

Related Questions