I have a function that returns the var "AlgoForecast", which is then used to multiply with 0.65 to get a final var "Forecast" in the main run().

However, the multiplication seems to be wrong when doing so. The code is as follow:

Code
function tradeAlgo()
{
	var AlgoForecast = -12.34;
	printf("#\nAlgoForecast: %.2f", AlgoForecast);
	return AlgoForecast;
}

function run() 
{
	//Backtest configurations
	set(LOGFILE);
	TickTime = 500;
	StartDate = 1985;
	LookBack = 260;
	Capital = -1000000;
	BarPeriod = 1440;
	Fill = 3;
	Spread = Commission = 0;
	RollLong = RollShort = Slippage = Penalty = 0;
	
	var Forecast;
	Forecast = 0.65*tradeAlgo();
	
	printf("#\nForecast: %.2f", Forecast);
	
}


The log:
Code
[9: Tue 85-01-15 15:40] (170.81)
AlgoForecast: -12.34
Forecast: -7.80


From the code, the AlgoFunction returns -12.34, which is multiplied with 0.65, which should give -12.34*0.65 = -8.021. However, the log shows the final result is -7.80.

Last edited by vicknick; 11/24/24 08:32.