1 Recent Bars = Last Trading Day on the EXCHANGE

My requirement is to create parameter within a BATCH file. It’s an OPTIONS database, therefore many options trade on some days while they don’t on other days. As such if I use 1 last bars or 1 last days it gives feed for the last traded bar or calendar day. But I wish to do the process only for last traded day on the exchange.
One way to do is through the From-To dates, but the same cannot be passed as parameter in a batch file.
Other way to put it as a filter checking the date with a REFERENCE symbol. I wish to know hot to code this as a condition.

Just a bit of WILD try. Am sure something is wrong in there from the logic angle:

bi = BarIndex();

Bardate = ValueWhen(bi=1,DateTime(),1);
RefNBardate = IIf(Name()=="NIFTY-II",Bardate,0);
RefBNBardate = IIf(Name()=="BANKNIFTY-II",Bardate,0);
BarDiffNS = DateTimeDiff( BarDate, RefNBardate ) ;
BarDiffBN = DateTimeDiff( RefNBardate, RefBNBardate ) ;
BarDiff = BarDiffNS - BarDiffBN;

Filter = 1;
//BarDiffNS = BarDiff;

AddColumn(BarDiffNS ,"BarDiffNS");
AddColumn(BarDiffBN ,"BarDiffNBN");
AddColumn(BarDiff ,"BarDiff");
```![Current Date Module|690x388](upload://xbNQyz6VS3jFv30qhio3WFq9iKH.jpg)