I change from printf to watch.
Quote:
Displays the given text and up to 8 following bool, int, var, float, or string variables in the message window, or prints them to the log or diag.txt file in all modes. Optionally stops execution and changes to single step mode. Allows to quickly debug into functions and watch variable behavior.



Code:
// Machine learning ////////////////////////////
#include <profile.c>

function run()
{
	StartDate = 2010;
	EndDate = 2018;
	BarPeriod = 1440; // 1 day
	BarZone = WET; // Western European midnight
	Weekend = 1;	// don't merge Friday and Sunday bars
	asset("EUR/USD");
	
	NumTrainCycles = 2;
	if(TrainCycle == 1) set(RULES);
	else if(TrainCycle == 2) set(PARAMETERS);
  	else if(TrainCycle == 0) set(RULES|PARAMETERS); 

	if(Train) Hedge = 2;	// for training, allow long + short	
	LifeTime = 3;  		// one week
	MaxLong = MaxShort = -1;
	int nTr=optimize(50,0,100);
        Stop = optimize(1,1,50);

	if(adviseLong(PATTERN+FAST+2+RETURNS,0,
		priceHigh(2),priceLow(2),priceClose(2),
		priceHigh(1),priceLow(1),priceClose(1),
		priceHigh(1),priceLow(1),priceClose(1),
		priceHigh(0),priceLow(0),priceClose(0)) > nTr)
		enterLong();
	
	if(adviseShort() > nTr)
		enterShort();

  if (is(EXITRUN)){
    if (TrainCycle == 2)
      watch("nExit Cycle 2------------------");
    if (TrainCycle == 1)
      watch("nExit Cycle 1------------------");
    if (TrainCycle == 0)
      watch("nExit Cycle 0------------------");
  }

  if (is(FIRSTRUN)){
    if (TrainCycle == 2)
      watch("n----- Cycle 2------------------");
    if (TrainCycle == 1)
      watch("n----- Cycle 1------------------");
    if (TrainCycle == 0)
      watch("n----- Cycle 0------------------");
  }

}



and output is:


test compiling................
Rules: test 2010..2018

----- Cycle 1------------------

Exit Cycle 1------------------
Train EURUSD_L 37 patterns
Rules stored in test.c

No cycle 2???