Showing Text Definition In Optimization For Switch Statement

I am optimizing and using a switch statement to test different market conditions. My code is shown below:

yestClose = Ref(Close,-1);

isMarketPosition = Optimize("Market Position", 3, 0, 3, 1);

switch (isMarketPosition)
{
	case 1: MP = yestClose == HHV(yestClose,10); break; //Yesterday was a 10-day high close
	case 2: MP = yestClose < HHV(yestClose,10) AND yestClose > LLV(yestClose,10); break;  //Yesterday was neither a 10-day high nor a 10-day low close
	case 3: MP = yestClose == LLV(yestClose,10); break;  //Yesterday was a 10-day low close
	default: MP = C>0; break;  //any day
}

When I optimize, the optimization column "Market Position" shows the values of 0, 1, 2, or 3. (As it should.) I am wondering if there is a way in the optimization report that it could show text instead...such as:

"All, High, Mid-range, Low" or something to that effect instead of "0,1,2,3".

Feels like it should be doable, but I can't get my head around how.

Thanks for any suggestions.

No, only numeric results in optimization columns. :frowning:

1 Like

@QEdges you can easily do this with a high-level CBT. Based on past discussions, I think you know how to do that with a switch statement and bo.AddCustomMetric().

4 Likes

Here below a possible alternative to easily identify rows that have values in a limiited range like in your example.

In Amibroker

  • [ AddRank column ], Select All, Copy, Paste to Excel

Then in Excel:

  • Apply a Color Scale (or Icon Set) to the desired column/s (Conditional Formatting)
2 Likes

@mradtke, I believe @QEdges refered to optimization table? Do you have example changing optimization table from numeric to text?

By "optimization report", I assume that @QEdges is referring to the report that appears in the Analysis window when you run an optimization, where each row is a one-line summary of the backtest for that variation. Assuming you have any flavor of CBT, you can simply do something like this:

 switch (isMarketPosition)
{
	case 1: mpName = "High"; break;
	case 2: mpName = "Mid-Range"; break;
	case 3: mpName = "Low"; break;
	default: mpName = "All"; break; 
}
bo.AddCustomMetric("Market Position Name", mpName);
4 Likes