Custom Backtetsting

Is it Possible to use Portfolio Equity in Calculating an array?For Eg I have written the following code:

SetOption("InitialEquity" , 1000000);
NiftyClose = Foreign("$NIFTY-NSE" , "C" ) ;
MarginPerLot = (NiftyClose * LotSize) / 15 ;
TotalLots = round(Foreign("~~~Equity", "C" )/ MarginPerLot) ;

But Foreign("~~~Equity", "C" ) doesn't change and always remains as 1000000.How do I use Custom Backtester here?

Marginperlot can be defined in symbol properties and same with lot size. After that read these Position Sizing examples.

Marginperlot keeps on changing. It’s not a fixed number