Volume of the lowest value instrument?

So I have created an AFL with which it plots the price chart of lower of 2 values ( Banknifty 29800ce AND Banknifty 29800pe). Both are options.
So it will plot the lowest value of the above 2 instruments.

Now I also want the volume. I.e whichever price it is plotting, I also want the volume of that instrument.

here is the AFL I created for price.

symbol1 = ParamStr("instrument1","BANKNIFTYWK29800CE");
symbol2 = ParamStr("instrument2","BANKNIFTYWK29800PE");
open1 = Foreign(symbol1,"Open");
open2 = Foreign(symbol2,"Open");
high1 = Foreign(symbol1,"High");
high2 = Foreign(symbol2,"High");
low1 = Foreign(symbol1,"low");
low2 = Foreign(symbol2,"low");
close1 = Foreign(symbol1,"close");
close2 = Foreign(symbol2,"close");

Minopen = Min(Open1,Open2);
Minhigh = Min(high1,high2);
Minlow = Min(low1,low2);
Minclose = Min(close1,close2);

Plot(Minclose,"min",colorBlack,styleLine);

Please help

@Malibutown

Untested

vol1 = Foreign(symbol1, "Volume");
vol2 = Foreign(symbol2, "Volume"); 

rvol = iif(open1>open2, vol1, vol2);
symbol1 = ParamStr("instrument1","BANKNIFTYWK29800CE");
symbol2 = ParamStr("instrument2","BANKNIFTYWK29800PE");
symbol3 = ParamStr("instrument3","BANKNIFTYWK29900CE");
symbol4 = ParamStr("instrument4","BANKNIFTYWK29900PE");
symbol5 = ParamStr("instrument5","BANKNIFTYWK30000CE");
symbol6 = ParamStr("instrument6","BANKNIFTYWK30000PE");
symbol7 = ParamStr("instrument7","BANKNIFTYWK30100CE");
symbol8 = ParamStr("instrument8","BANKNIFTYWK30100PE");
symbol9 = ParamStr("instrument9","BANKNIFTYWK30200CE");
symbol10 = ParamStr("instrument10","BANKNIFTYWK30200PE");
symbol11 = ParamStr("instrument11","BANKNIFTYWK30300CE");
symbol12 = ParamStr("instrument12","BANKNIFTYWK30300PE");
symbol13 = ParamStr("instrument13","BANKNIFTYWK30400CE");
symbol14 = ParamStr("instrument14","BANKNIFTYWK30400PE");
symbol15 = ParamStr("instrument15","BANKNIFTYWK30500CE");
symbol16 = ParamStr("instrument16","BANKNIFTYWK30500PE");
open1 = Foreign(symbol1,"Open");
open2 = Foreign(symbol2,"Open");
high1 = Foreign(symbol1,"High");
high2 = Foreign(symbol2,"High");
low1 = Foreign(symbol1,"low");
low2 = Foreign(symbol2,"low");
close1 = Foreign(symbol1,"close");
close2 = Foreign(symbol2,"close");
open3 = Foreign(symbol3,"Open");
open4 = Foreign(symbol4,"Open");
high3 = Foreign(symbol3,"High");
high4 = Foreign(symbol4,"High");
low3 = Foreign(symbol3,"low");
low4 = Foreign(symbol4,"low");
close3 = Foreign(symbol3,"close");
close4 = Foreign(symbol4,"close");
open5 = Foreign(symbol5,"Open");
open6 = Foreign(symbol6,"Open");
high5 = Foreign(symbol5,"High");
high6 = Foreign(symbol6,"High");
low5 = Foreign(symbol5,"low");
low6 = Foreign(symbol6,"low");
close5 = Foreign(symbol5,"close");
close6 = Foreign(symbol6,"close");
open7 = Foreign(symbol7,"Open");
open8 = Foreign(symbol8,"Open");
high7 = Foreign(symbol7,"High");
high8 = Foreign(symbol8,"High");
low7 = Foreign(symbol7,"low");
low8 = Foreign(symbol8,"low");
close7 = Foreign(symbol7,"close");
close8 = Foreign(symbol8,"close");
Open9 = Foreign(symbol9,"Open");
Open10 = Foreign(symbol10,"Open");
High9 = Foreign(symbol9,"High");
High10 = Foreign(symbol10,"High");
Low9 = Foreign(symbol9,"low");
Low10 = Foreign(symbol10,"low");
Close9 = Foreign(symbol9,"close");
Close10 = Foreign(symbol10,"close");
Open11 = Foreign(symbol11,"Open");
Open12 = Foreign(symbol12,"Open");
High11 = Foreign(symbol11,"High");
High12 = Foreign(symbol12,"High");
Low11 = Foreign(symbol11,"low");
Low12 = Foreign(symbol12,"low");
Close11 = Foreign(symbol11,"close");
Close12 = Foreign(symbol12,"close");
Open13 = Foreign(symbol13,"Open");
Open14 = Foreign(symbol14,"Open");
High13 = Foreign(symbol13,"High");
High14 = Foreign(symbol14,"High");
Low13 = Foreign(symbol13,"low");
Low14 = Foreign(symbol14,"low");
Close13 = Foreign(symbol13,"close");
Close14 = Foreign(symbol14,"close");
Open15 = Foreign(symbol15,"Open");
Open16 = Foreign(symbol16,"Open");
High15 = Foreign(symbol15,"High");
High16 = Foreign(symbol16,"High");
Low15 = Foreign(symbol15,"low");
Low16 = Foreign(symbol16,"low");
Close15 = Foreign(symbol15,"close");
Close16 = Foreign(symbol16,"close");

Volume1= Foreign(symbol1,"volume");
Volume2=   Foreign(symbol2,"volume");
Volume3=   Foreign(symbol3,"volume");
Volume4=   Foreign(symbol4,"volume");
Volume5=   Foreign(symbol5,"volume");
Volume6=   Foreign(symbol6,"volume");
Volume7=   Foreign(symbol7,"volume");
Volume8=   Foreign(symbol8,"volume");
Volume9=   Foreign(symbol9,"volume");
Volume10=   Foreign(symbol10,"volume");
Volume11=   Foreign(symbol11,"volume");
Volume12=   Foreign(symbol12,"volume");
Volume13=   Foreign(symbol13,"volume");
Volume14=   Foreign(symbol14,"volume");
Volume15=   Foreign(symbol15,"volume");
Volume16=   Foreign(symbol16,"volume");

Volume12 = Volume1 + Volume2;
Volume34 = Volume3 + Volume4;
Volume56 = Volume5 + Volume6;
Volume78 = Volume7 + Volume8;
Volume910 = Volume9 + Volume10;
Volume1112 = Volume11 + Volume12;
Volume1314 = Volume13 + Volume14;
Volume1516 = Volume15 + Volume16;



open12 = open1+open2;
high12 = high1+high2;
low12 = low1+low2;
close12 = close1+close2;
open34 = open3+open4;
high34 = high3+high4;
low34 = low3+low4;
close34 = close3+close4;
open56= open5+open6;
high56 = high5+high6;
low56 = low5+low6;
close56 = close5+close6;
Open78 = Open7 + Open8;
High78 = High7 + High8;
Low78 = Low7 + Low8;
Close78 = Close7 + Close8;
Open910 = Open9 + Open10;
High910 = High9 + High10;
Low910 = Low9 + Low10;
Close910 = Close9 + Close10;
Open1112 = Open11 + Open12;
High1112 = High11 + High12;
Low1112 = Low11 + Low12;
Close1112 = Close11 + Close12;

Open1314 = Open13 + Open14;
High1314 = High13 + High14;
Low1314 = Low13 + Low14;
Close1314 = Close13 + Close14;

Open1516 = Open15 + Open16;
High1516 = High15 + High16;
Low1516 = Low15 + Low16;
Close1516 = Close15 + Close16;






Lopentriall = Min(Min(Open910,Open1112),Min(Open1314,Open1314));
Lopentrial = Min(Min(Open12,Open34),Min(Open56,Open78));
Lopenfinal = Min(Lopentriall,Lopentrial);

Lhightriall = Min(Min(high910,high1112),Min(high1314,high1314));
Lhightrial = Min(Min(high12,high34),Min(high56,high78));
Lhighfinal = Min(Lhightriall,Lhightrial);


Llowtriall = Min(Min(low910,low1112),Min(low1314,low1314));
Llowtrial = Min(Min(low12,low34),Min(low56,low78));
Llowfinal = Min(Llowtriall,Llowtrial);

Lclosetriall = Min(Min(close910,close1112),Min(close1314,close1314));
Lclosetrial = Min(Min(close12,close34),Min(close56,close78));
Lclosefinal = Min(Lclosetriall,Lclosetrial);

Plot(Lhighfinal,"Close",colorGreen,styleLine);
//Plot(Lclosefinal,"Close",colorBlack,styleLine);
Plot(Llowfinal,"Close",colorRed,styleLine);


grid_day = Day()!=Ref(Day(),-1); 
Plot(grid_day,"",colorLightGrey,styleHistogram|styleDots|styleNoLabel|styleOwnScale);
//Plot( Volume, _DEFAULT_NAME(), IIf( C > O, ParamColor("Up Color", colorGreen ), ParamColor("Down Color", colorRed ) ), ParamStyle( "Style", styleHistogram | styleThick, maskHistogram  ) );

//PlotOHLC(Lopenfinal,Lhighfinal,Llowfinal,Lclosefinal,"maincandle12",colorBlack);


//PlotOHLC(open12,high12,low12,close12,"Firstcandle12",colorBlack,styleLine);
//PlotOHLC(open34,high34,low34,close34,"Firstcandle34",colorRed,styleLine);
//PlotOHLC(open56,high56,low56,close56,"Firstcandle56",colorGreen,styleLine);
//PlotOHLC(open78,high78,low78,close78,"Firstcandle78",colorGreen,styleLine);
//PlotOHLC(open910,high910,low910,close910,"Firstcandle910",colorLightBlue,styleLine);

This is the original AFL I created. Want volume in it too

@Malibutown, I don't see a question here....

Do you understand the idea that I presented? Did it work in a simple test?

If it did not work as expected, what did you expect, and how are the results different from what you expected?

Good job on properly posting your code, but if you wrote it you should (hopefully) understand the idea I presented, and be able to expand on it.

2 Likes