plot price of a call and a put and sum of both prices on chart

rvlv

Active Member
#1
HI coding experts

Please help for making this code in afl

we have 8500call and 8500 put.
I like to plot price of 8500call,say greenline
and plot 8500put price as red line
on amibroker chart.
also I like to plot sum of CLOSE prices of call and put on same chart as a yellow line.
symbol1=ce8500
symbol2 =pe8500
sum=symbol1 +symbol2

The sum is called a Gut.
thanks
 
#2
HI coding experts

Please help for making this code in afl

we have 8500call and 8500 put.
I like to plot price of 8500call,say greenline
and plot 8500put price as red line
on amibroker chart.
also I like to plot sum of CLOSE prices of call and put on same chart as a yellow line.
symbol1=ce8500
symbol2 =pe8500
sum=symbol1 +symbol2

The sum is called a Gut.
thanks
You are taking same strike price so it becomes a straddle selling.

Smart_trade
 

rvlv

Active Member
#3
smart trade
you are right.
if the prices can be plotted along with the sum of prices,one can go long or go short based on total price .
plot symbol1 close price
plot symbol2 close price
plot sum of both close prices on amibroker chart
is needed afl
the afl helps visual monitoring

thanks
 

sr114

Well-Known Member
#4
here is the afl. its meant for intraday but also can be used as eod

Code:
_SECTION_BEGIN("Background_Setting");
SetChartBkGradientFill( ParamColor("BgTop", colorBlack),
ParamColor("BgBottom", colorDarkGrey),ParamColor("TitleBack",colorGrey40)); 
SetChartBkColor(ParamColor("Outer Panel",colorPaleBlue));
SetChartOptions(0,chartShowArrows|chartShowDates);
_SECTION_END();

FirstScrip=ParamList("First Scrip", "NIFTY|BANKNIFTY|HINDUNILVR|LT|SBIN|TATASTEEL|TATA MOTORS|TCS" );
expiry1 = ParamList("Expiry1", "15JAN|15FEB|15MAR|15APR|15MAY|15JUN|15JUL" );
Strike1=Param("Strike1", 0,0,20000,1 );
type1 = ParamList("Type1", "CE|PE" );

SecondScrip=ParamList("Second Scrip", "NIFTY|BANKNIFTY|HINDUNILVR|LT|SBIN|TATASTEEL|TATA MOTORS|TCS" );
expiry2 = ParamList("Expiry2", "15JAN|15FEB|15MAR|15APR|15MAY|15JUN|15JUL" );
Strike2=Param("Strike2", 0,0,20000,1 );
type2 = ParamList("Type2", "CE|PE" );

Symbol1= FirstScrip+expiry1+Strike1+type1;
Symbol2= SecondScrip+expiry2+Strike2+type2;

_SECTION_BEGIN("Price_idx1");
Index1 = ParamStr("Index1", "NIFTY_CE"); // getting CE data in this name in rt mode	
idx1c=Foreign(Index1,"C");			// Here's the index
idx1o=Foreign(Index1,"o");
idx1h=Foreign(Index1,"h");
idx1l=Foreign(Index1,"l");
_SECTION_END();

_SECTION_BEGIN("Price_idx2");
Index2 = ParamStr("Index2", "NIFTY_PE"); // getting PE data in this name in rt mode	
idx2c=Foreign(Index2,"C");			
idx2o=Foreign(Index2,"o");
idx2h=Foreign(Index2,"h");
idx2l=Foreign(Index2,"l");
_SECTION_END();

af=idx1c+idx2c;


_SECTION_BEGIN("Price");

PlotOHLC( idx1o, idx1h, idx1l, idx1c, "(" + Index1+" ) ", colorblue, 64);
PlotOHLC( idx2o, idx2h, idx2l, idx2c, "(" +Index2 + ") ", colorGreen, 64);

PlotOHLC( idx1o+idx2o, idx1h+idx2h, idx1l+idx2l, idx1c+idx2c, "(" + Index1+" + "+Index2 + ") ", coloryellow, 64);

Title = EncodeColor(colorYellow) + "CE+PE \n" + EncodeColor(colorWhite)+ ""+Date() + " \n" + EncodeColor(colorGreen) +
EncodeColor(colorSkyblue) +symbol1+ "	,Close =	 "+ NumToStr(idx1c,1.2)+"\n"+
EncodeColor(colorSeaGreen) +symbol2+ "	,Close =	 "+ NumToStr(idx2c,1.2)+
EncodeColor(colorSkyblue) +"\nClose of 2 series =	 "+ NumToStr(af,1.2);


GraphXSpace=10;
_SECTION_END();
rgds
 
Last edited:

rvlv

Active Member
#5
SR114

THANKS for the code.
suppose i am getting prices of two symbols from nesttrader
or
suppose i get my data from masertrust
how to keep things simple and avoid ohlc thing.


suppose i need only the close price and sum of close prices,
i input symbols in parameters a call and a put
can you help me please to simplify-repair below code
--------------------------------------------------------------------
_SECTION_BEGIN("Price");//PLOT TWO SYMBOLS BY CASONI


SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

_SECTION_END();

p1 = ParamStr("Index","NSENifty");
Ind1 = Foreign(p1,"C",True);
Plot(Ind1,"\n("+P1+")",3,1|styleOwnScale);

p2 = ParamStr("STOCK","ACC");
Ind2 = Foreign(p2,"C",True);
Plot(Ind2,"\n("+P2+")",8,1|styleOwnScale);//6 BLUE

p3 = ParamStr("SUM","(ACC + NSENIFTY");
Ind3 = Foreign(p1,"C",True) +Foreign(p2,"C",True);
IND3 =IND1 +IND2 ;
Plot(Ind3," SUM -GUT",42,1|styleOwnScale);//6 BLUE 42 YELLOW
============================
All i need are 3 lines and visually proprtionally.
thanks
regards
 

sr114

Well-Known Member
#6
SR114

THANKS for the code.
suppose i am getting prices of two symbols from nesttrader
or
suppose i get my data from masertrust
how to keep things simple and avoid ohlc thing.


suppose i need only the close price and sum of close prices,
i input symbols in parameters a call and a put
can you help me please to simplify-repair below code
--------------------------------------------------------------------
_SECTION_BEGIN("Price");//PLOT TWO SYMBOLS BY CASONI


SetChartOptions(0,chartShowArrows|chartShowDates);
_N(Title = StrFormat("{{NAME}} - {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}", O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

_SECTION_END();

p1 = ParamStr("Index","NSENifty");
Ind1 = Foreign(p1,"C",True);
Plot(Ind1,"\n("+P1+")",3,1|styleOwnScale);

p2 = ParamStr("STOCK","ACC");
Ind2 = Foreign(p2,"C",True);
Plot(Ind2,"\n("+P2+")",8,1|styleOwnScale);//6 BLUE

p3 = ParamStr("SUM","(ACC + NSENIFTY");
Ind3 = Foreign(p1,"C",True) +Foreign(p2,"C",True);
IND3 =IND1 +IND2 ;
Plot(Ind3," SUM -GUT",42,1|styleOwnScale);//6 BLUE 42 YELLOW
============================
All i need are 3 lines and visually proprtionally.
thanks
regards

idx1c - close price of index1
idx2c - close price of index2

instead of PLOTOHLC - use PLOT function

Code:
PLOT(idx1c,"CLOSE Index1", colorred,styleline|styleOwnScale);
PLOT(idx2c,"CLOSE Index2", colorgreen,styleline|styleOwnScale);
gut=idx1c+idx2c;
Plot(gut,"GUT".coloryellow,styleline|styleOwnScale|stylethick);
rgds
 

Similar threads