Dear @Heisenberg,
Every new post of yours with new information.
Now it's three optimzation variables and triple loop to call 3 optimization variables' parameters.
You really know how to keep people busy.
There are a few mistakes:
You forgot to add full variable name to StaticVarGet("Equity_....
Then you should rather add underscore to all variable names.
As for
It's because StrFormat function has string length limit (it seems to be 1,000 characters).
You did not say (sounds familiar, doesn't it
) that you intend to output more than 14,000(!!!) equity curves side by side. So if one value has 7 characters then you end up with string length of around 100k characters + 14,000 column separators. So the length of the second string being inserted to AddRow's StrFormat function is simply getting cut by StrFormat early on.
As you can see here if opening the exported CSV file in Excel

If putting the final string variable outside of StrFormat then it is not cut.
As you can see here.

BTW, I changed Exploration Filter to lastbarinrange .... imagine if your symbol would have Barcount of 10,000 and code having 14,000 optimization steps... so you would end up with 10k * 14k = 140 million cells if outputting everything.
In addition I have reduced start and end of optimization in below update. Increase at your own risk.
/// @link https://forum.amibroker.com/t/help-with-staticvarget/19723/8
Portfolio = 1; // 1 = Portfolio, 0 = All Trades
SameBarExit = 0; // 1 = allow same bar exit, 0 = disallow
EntryTiming = 0; // 0 = Same Bar on Close, 1 = Next Bar at Open
ExitTiming = 0; // 0 = Same Bar on Close, 1 = Next Bar at Open
PosQty = 1;
Margin = 100;
target = Optimize("Target", 10, start1=5, end1=10, step1=1);
irsi = Optimize("RSI", 10, start2=5, end2=10, step2=1);
ima = Optimize("Mavg", 100, start3=10, end3=100, step3=20);
vola = 100 * ((StDev(log(C/Ref(C,-1)) * sqrt(252), 15)));
ratio = target/(vola+1e-9);
lev = IIf(ratio>1,1,ratio) * 100;
pctPosSize = lev/PosQty * 100/Margin;
pctPosSizeLast = LastValue(pctPosSize);
SetOption("InitialEquity",IIf(Portfolio,1000*1000,100*1000));
SetOption("CommissionMode",1);
SetOption("CommissionAmount",IIf(Portfolio, 0.00, 0));
SetOption("AllowSameBarExit", SameBarExit);
SetOption("MaxOpenPositions",IIf(Portfolio,PosQty,2500));
SetOption("AccountMargin",IIf(Portfolio,Margin,100));
SetOption("UsePrevBarEquityForPosSizing",IIf(EntryTiming==0,False,True));
SetOption("AllowPositionShrinking", True);
SetTradeDelays(EntryTiming,ExitTiming,EntryTiming,ExitTiming);
SetOption("ActivateStopsImmediately", IIf(ExitTiming==0,False,True));
SetPositionSize(IIf(Portfolio,pctPosSize,1),IIf(Portfolio,spsPercentOfEquity,spsShares));
RoundLotSize = IIf(Portfolio,1,1);
Buy = Sell = Short = Cover = 0;
AvgPrice = (H+L)/2;
BuyPrice = ShortPrice = IIf(EntryTiming==0,C,AvgPrice);
SellPrice = CoverPrice = IIf(ExitTiming==0,C,AvgPrice);
BUY = C>MA(C,ima) OR RSI(14) < irsi ;
SELL = C<MA(C,ima) ;
/// first run optimization
/// then run explore
/// (export result list to file)
/// @link https://forum.amibroker.com/t/help-with-staticvarget/19723/11
/// vrs 1.3 added by fxshrat
explore = Status( "action" ) == actionExplore;
indicator = Status( "action" ) == actionIndicator;
if ( explore OR indicator ) {
SetSortColumns(1);
SetOption("NoDefaultColumns", 1);
AddColumn(DateTime(), "Date", formatDateTime, -1, -1, 120);
str = "";
// iterating optimization min/max
for ( y = start3; y <= end3; y += step3 ) {
for ( z = start2; z <= end2; z += step2 ) {
for ( i = start1; i <= end1; i += step1 ) {
izy_str = "" + i +"_" + z +"_" + y;
modEq = StaticVarGet( "Equity_" + izy_str);
AddColumn( modEq, "modEq_" + izy_str, 1.3 );
psz = StaticVarGet( "ABpctPosSizeLast_" + izy_str);
str += StrFormat("%1.1f\t",psz);
//Plot( modEq, "modEq_"+i, colorRed );
}
}
}
AddRow(StrFormat("%s_pctPosSize:\t", Name()) + str);
Filter = Status("lastbarinrange");
//Filter = NOT IsNull(modEq);
}
//
if ( Status("actionex") == actionExOptimizeBacktest )
StaticVarSet("ABpctPosSizeLast_"+target +"_"+irsi +"_"+ima, pctPosSizeLast);
//
SetCustomBacktestProc( "", True );
if ( Status( "action" ) == actionPortfolio ) {
bo = GetBacktesterObject();
bo.Backtest();
StaticVarSet( "Equity_"+target +"_"+irsi +"_"+ima, bo.EquityArray() );
}