Amibroker AFL code for Butterfly Spread:
You can use this AFL for Implementing Option Strategies in Amibroker.
Script:
_SECTION_BEGIN(“Butteryfly Spread”);
SetChartOptions(0,chartShowArrows|chartShowDates);
_N( Symbol1= ParamStr(“Buy 1 ATM Call/Put”, “NIFTY14MAR6300CE”) );
SetForeign( Symbol1 );
C1 = C;
H1 = H;
L1 = L;
O1 = O;
V1 = V;
RestorePriceArrays();
_N( Symbol2= ParamStr(“Sell 2 ATM Call/Put”, “NIFTY14MAR6400CE”) );
SetForeign( Symbol2 );
C2 = C;
H2 = H;
L2 = L;
O2 = O;
V2 = V;
RestorePriceArrays();
_N( Symbol3= ParamStr(“Buy 1 OTM Call/Put”, “NIFTY14MAR6500CE”) );
SetForeign( Symbol3 );
C3 = C;
H3 = H;
L3 = L;
O3 = O;
V3 = V;
RestorePriceArrays();
Color = ParamColor( “Color”, colorRed );
Style = ParamStyle( “Style”, styleLine, maskPrice );
PlotOHLC( (O1+O3)-(2*O2),(H1+H3)-(2*H2), (L1+L3)-(2*L2), (C1+C3)-(2*C2), “(“+Symbol1 + ” + “+Symbol3+ “- 2x” + Symbol2+”)”+ “spread”, Color, style );
_SECTION_END();