What is the correct usage of the TradeVar[] variables for storing an indicator value for later use? I am running into problems using these variables in a portfolio strategy that trades more than one algorithm. In my usage below, I get the expected results if I comment out one of the algo calls in the algo loop. But if I run both algos, the TradeVars for algo1 all return 0, which is not the values assigned to them in the algo1() function.

Wondering if this could be a bug or if I am missing something obvious?

Thanks

Code:
void algo1()
{
...
TradeVar[0] = x
TradeVar[1] = y
...
enterLong();
...
enterShort();
}

void algo2()
{
...
TradeVar[0] = x
TradeVar[1] = y
enterLong();
...
enterShort();

}

function run()
{
...
while(algo(loop("algo1", "algo2")))
	{
		if(Algo == "algo1") algo1();
		if(Algo == "algo2") algo2();

	}	
	
	if(is(EXITRUN))
	{
		for(all_trades)
		{
			printf("\n%s, Value1: %f, Value2: %f", TradeAlgo, TradeVar[0], TradeVar[1]);
		}
	}
}



And an eample of the output - as you can see, the TradeVars for the algo1 trades always return 0:
Code:
algo2, Value1: 37.563797, Value2:: 1.118150
algo2, Value1: 28.984416, Value2:: 1.118747
algo1, Value1: 0.000000, Value2:: 0.000000
algo1, Value1: 0.000000, Value2:: 0.000000
algo2, Value1: 7.145730, Value2:: 1.116183
algo2, Value1: 6.539160, Value2:: 1.116329
algo2, Value1: 6.571875, Value2:: 1.116340
algo1, Value1: 0.000000, Value2:: 0.000000
algo2, Value1: 7.412091, Value2:: 1.116200


Last edited by boatman; 06/09/16 00:10.