Download MetaTrader 5
To add comments, please log in or register
Do you need a trading robot? Orderit via Freelance service!
Carl Schreiber
5960
Carl Schreiber 2015.04.01 15:08 

Hi,

If I vary extern variables by the strategy-tester and check them within the EA again and may be re-set them in order not to be trapped by swapping in and out again and again - so I do:

extern double EA_Threshold = 0.03;
extern double EA_Breakout  = 1.4;
double LimHi,LimLo,LimBreak;
...
int OnInit() {
   ...
   EA_Threshold = fmax(0.01,fmin(EA_Threshold,0.5); // to guaranty:  0.01 <= Threshold <= 0.5
   LimHi = 1.0 + EA_Threshold;
   LimLo = 1.0 - EA_Threshold;
   LimBreak = EA_Breakout = fmax(EA_Breakout,1.2 * LimHi); // to guaranty LimBreak > 1.2*LimHi
   ...
}

My questions:

1) What will be written in the strategy tester optimization result for the extern variables in the line of the optim.-result:

    a) The 'old' values set by the strategy tester or

    b) the 'new' values set by the check-up in OnInit()? 

a) and b) might depend on when and from where the values are taken and written: before the optim.-run (=> before OnInit might have changed them)

or after the optim-run just like the results of the optim.-run or like OnTester(). In this case the modified values could be taken for the line in the otim.-list.

whroeder1
13641
whroeder1 2015.04.01 16:24  
  1. You aren't changing the externs, so there is no difference.
  2. Don't change externs. They are initialized once when the EA is loaded. If you change pairs, TFs, or broker changes other chart values, you go through a deinit/init cycle and your externals will be changed again (+1, +2... or *10 *100...).
Carl Schreiber
5960
Carl Schreiber 2015.04.01 19:39  

I know what you write is the normal case.

As there are (now b600+) two typed of variables: extern (can be changed) and input (cannot be changed) I got a slight hope that the changed variables are printed in the optim.-line.

I asked this first at the service desk but I got a strange answer ("input int somevar -variables cannot be defined in OnInit(). It causes compiler errors". It is correct but not what I asked).

This misunderstanding might be caused by a surprising lack of any edit tool at the service desk: no SRC-, no link-button and no other stuff to edit ones text :(

whroeder1
13641
whroeder1 2015.04.03 12:03  
gooly: This misunderstanding might be caused by a surprising lack of any edit tool at the service desk: no SRC-, no link-button and no other stuff to edit ones text :(
My service desk show the same buttons as this forum. Exactly like Get in touch with developers using Service Desk! - Traders' Forum
/
To add comments, please log in or register