Hello !
I have used KB for adding custom metrics but faced strange behaviour. I'm adding VIX and today's change in percent.
VixClose = Foreign( "VIX", "C" );
TimeFrameSet( inDaily );
VixClose = Ref(VixClose,-1);
TimeFrameRestore();
PrevClose=TimeFrameGetPrice( "C", inDaily, -1 );
daychng=100*(C-PrevClose)/PrevClose;
StaticVarSet( "Sdaychng", daychng);
StaticVarSet( "VIXC", VixClose);
SetCustomBacktestProc("");
if( Status("action") == actionPortfolio )
{
bo = GetBacktesterObject();
bo.Backtest(True);
for ( trade = bo.GetFirstTrade( ); trade; trade = bo.GetNextTrade( ) )
{
SdaychngVar = StaticVarGet( "Sdaychng" );
trade.AddCustomMetric( "Day Change", Lookup( SdaychngVar, trade.EntryDateTime ) );
symbolVIX = StaticVarGet("VIXC");
trade.AddCustomMetric( "Vix Close", Lookup( symbolVIX, trade.EntryDateTime ) );
}
// iterate through open positions
for ( trade = bo.GetFirstOpenPos( ); trade; trade = bo.GetNextOpenPos( ) )
{
symbolVIX = StaticVarGet("VIXC");
trade.AddCustomMetric( "Vix Close", Lookup( symbolVIX, trade.EntryDateTime ) );
SdaychngVar = StaticVarGet( "Sdaychng" );
trade.AddCustomMetric( "Day Change", Lookup( SdaychngVar, trade.EntryDateTime ) );
}
bo.ListTrades( );
}
VIX metric works as it should but in "Day Change" I always see "-1.#J" . I have googled "Amibroker -1.#J" but there is nothing about that.
When I plot daychng series , itt works fine so series are ok.
Any ideas ? Thank you all for support !