Errors, bugs, questions - page 2310

 
ExpertRemove is not working correctly in Optimize mode.
input int Range = 0; // 1 .. 10

bool FuncInit()
{
  ExpertRemove();
  
  return(true);
}

int Count = 0;

void OnTick()
{
  static const bool Init = FuncInit();
  
  Count++;
}

double OnTester()
{
  return(Count);
}


Run Optimisation. You can see from the code that all passes should be terminated by ExpertRemove. But this doesn't happen:

Core 5  pass 8 tested with error "expert removed itself in global initialization function" in 0:00:00.312
Core 5  pass 9 returned result 331851.00 in 0:00:00.125
Core 4  pass 6 tested with error "expert removed itself in global initialization function" in 0:00:00.265
Core 4  pass 7 returned result 331851.00 in 0:00:00.140
Core 1  pass 0 tested with error "expert removed itself in global initialization function" in 0:00:00.312
Core 1  pass 1 returned result 331851.00 in 0:00:00.125
Core 3  pass 4 tested with error "expert removed itself in global initialization function" in 0:00:00.296
Core 3  pass 5 returned result 331851.00 in 0:00:00.156
Core 8  pass 2 tested with error "expert removed itself in global initialization function" in 0:00:00.265
Core 8  pass 3 returned result 331851.00 in 0:00:00.140
Tester  optimization finished, total passes 10
Statistics      optimization done in 0 minutes 01 seconds
Statistics      shortest pass 0:00:00.125, longest pass 0:00:00.156, average pass 0:00:00.137
Statistics      local 10 tasks (100%), remote 0 tasks (0%), cloud 0 tasks (0%)

Half of the passes have ignored ExpertRemove. Is it reproducible?


ZY This causes discrepancies between single passes and optimisations.

 
fxsaber:
typedef void (*FUNC)();
void f1() {};

void f2()
{
   f1();
}

void f2( FUNC g) 
{
   g();
}

This is essentially the same as a single function with a default parameter. this is usually how it's handled, so it's not a workaround or a crutch, it's a perfectly normal solution.

 
TheXpert:

In fact, it's the same as one function with a default parameter. That's usually how it's solved, so it's not a workaround or a crutch, but a perfectly normal solution.

The option of overloading is understandable. But it's not at all flexible to create such a thing for every function. Can't you make it nice in C++ too?

 
fxsaber:

The option of overloading is understandable. But it's not at all flexible to create such a thing for every function. Can't it be done nicely in C++ too?

I don't know, C++ is more flexible with constants, but I haven't worked with function pointers as default parameters

UPD g++ eats your code
 
TheXpert:

dunno, C++ is more flexible with constants, but I haven't worked with function pointers as default parameters

UPD g++ eats your code with flying colours

Thanks for the info!

 
fxsaber:

How do I achieve a default value for the input parameter of a function?

You can use python-style code

typedef void (*FUNC)();

void f0() {Print(__FUNCSIG__);};
void f1() {Print(__FUNCSIG__);};

void f2( FUNC g = NULL ) {
   if (g == NULL){g = f1;}
   
   g();
}


void OnStart()
{
   f2();
   f2(f0);
}
 
Sergey Dzyublik:

You can use python-style code

Thanks, I didn't know about NULL.

 

In the Tester report, when calculating the mathematical expectation of two collapsed positions by CloseBy, it is divided by two, instead of one. Hence we get wrong values in the report.


And such mishaps at CloseBy in the report


 

Привет

I rented this [product name Market has been deleted by moderator] for one me and I have not been able to change the settings, position number three 3 max

how to change the number of multiple buy and sell positions at the same time

Philip

 
foonet:

Discussion about Market products is prohibited on the forum sorry.
Discussion about Market products is prohibited on the forum sorry.