function call error

Posted By: steyr

function call error - 09/11/23 07:55

Hello everyone, I come from the MQL5 community, and I'm puzzled by this compiler error: Error 111 crash in run: run()

Something seems to be wrong with the call to StdDevFunc(), but I can't figure out what it might be. I would greatly appreciate your help.

Code

// Strategy template ///////////////////////

var ExtStdDevPeriod = 14; // Definition der Periodenlänge (können Sie anpassen)

function run() 
{
	var StdDevFunc(vars ,vars , var);
	
	
	BarPeriod = 60;
	set(PARAMETERS|LOGFILE);
	LookBack = 1000;
	if(Train) Detrend = TRADES;
	StartDate = 20130101;
	EndDate = 2023;
	NumWFOCycles = 10;
	
	vars Price = series(price());
        vars Trend = series(MovingAverage(Price,60,EMA));

	vars standardA = series(StdDevFunc(Price,Trend,0));
	
	
	plot("Trend",Trend,0,BLUE);
	plot("stddev",standardA,NEW,BLUE);
	PlotWidth = 800;
	PlotHeight1 = 300;
	
	

}

	var StdDevFunc(vars Preis,vars MAprice, var position)
	{
		 
		 var dTmp = 0.0;
		 var i;
		 for (i = 0; i < ExtStdDevPeriod; i++)
		 {
			  dTmp += pow(Preis[position - i] - MAprice[position], 2);
		 }
		 dTmp = sqrt(dTmp / ExtStdDevPeriod);
		 return dTmp;
	}



Posted By: izorro

Re: function call error - 09/11/23 10:29

The Troubleshooting Page has some good info.

You can use watch statement to debug and find which line might be causing the problem.
Posted By: AndrewAMD

Re: function call error - 09/11/23 12:24

That's not a compiler error, it compiled just fine. That's a runtime error.

Also, I don't understand why you put your function prototype for StdDevFunc() inside the run() body. Move it to prior. Or just move the actual function above it and remove the prototype.
Posted By: steyr

Re: function call error - 09/14/23 08:25

Thank you all!
© 2024 lite-C Forums