Experts: TrailingStop

 

TrailingStop:

An example of an Expert Advisor with a Trailing Stop implementation.

TrailingStop sl to priceopen

Author: Vladimir Karputov

 

Most likely, I do not understand the situation correctly.

Why does it open orders when changing EA parameters?

Or is it a "billet"?

 
sutrade:

Most likely, I do not understand the situation correctly.

Why does it open orders when changing EA parameters?

Or is it a "billet"?

This Expert Advisor is an example of implementing the TrailingStop function. Not for trading. And it opens POSITIONS after changing the parameters because: after changing the input parameters, the EA is reinitialised - the Init event takes place and the OnInit() function is triggered, in which the "FirstStart" flag is set to true - that is, the EA is set to the "First Start " state:

//+------------------------------------------------------------------+
//| Expert initialisation function|
//+------------------------------------------------------------------+
int OnInit()
  {
***
   FirstStart=true;
   return(INIT_SUCCEEDED);
  }