Rajandran R Creator of OpenAlgo - OpenSource Algo Trading framework for Indian Traders. Building GenAI Applications. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Building Algo Platforms, Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in

Bear Call Spread and Bear Put Spread – Amibroker AFL code

1 min read

What is Bear Call Spread?

Investopedia defines “A type of options strategy used when a decline in the price of the underlying asset is expected. It is achieved by selling call options at a specific strike price while also buying the same number of calls, but at a higher strike price. The maximum profit to be gained using this strategy is equal to the difference between the price paid for the long option and the amount collected on the short option.”

BCS

Bear Call Spread (6000CE-6400CE)
Bear Call Spread

[wp_ad_camp_5]

 

Visit here for Nifty Option Live Charts

What is Bear Put Spread?
A type of options strategy used when an option trader expects a decline in the price of the underlying asset. Bear Put Spread is achieved by purchasing put options at a specific strike price while also selling the same number of puts at a lower strike price. The maximum profit to be gained using this strategy is equal to the difference between the two strike prices, minus the net cost of the options.
BPS

Bear Put Spread(6400PE-6000PE)
Bear Put Spread

Procedure to Setup the Bear Call Spread and Bear Put Spread

1.Download Bear Call and Bear Put Spread.afl code to Amibroker/Formulas/Options Spread directory
and Unzip the file. Create Options Spread Directory if it doesn’t exist.
2.Open Amibroker->File->Open New Blank Chart
3.Now on the Left Pane goto Charts->Option Spread and drag and drop Bear Call Spread and Bear Put Spread to the blank chart.
4.Bingo! you got the Spread chart.
5.To Change the spread right click over the charts and goto Parameters where you have control to change the strike1 and strike2 prices as shown below

Bear Put Spread Settings
Bear Put Spread Settings

What Strategies are covered in the AFL Code?

1.Bear Call Spread – Neutral to Bearish Strategy.
2.Bear Put Spread – Bearish Strategy.

Prerequisite
Realtimedatafeed for Amibroker which Supports NSE Options.

Visit here to download Strangle and Straddle Option Spread – Amibroker AFL code

Rajandran R Creator of OpenAlgo - OpenSource Algo Trading framework for Indian Traders. Building GenAI Applications. Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, High Liquid Stock Derivatives. Trading the Markets Since 2006 onwards. Using Market Profile and Orderflow for more than a decade. Designed and published 100+ open source trading systems on various trading tools. Strongly believe that market understanding and robust trading frameworks are the key to the trading success. Building Algo Platforms, Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in

CUSUM Filter Strategy in AmiBroker AFL: A Practical Implementation

Detecting meaningful shifts in price trends while filtering out market noise is a challenge many traders face. Inspired by Jakub Polec’s blog, which applies...
Rajandran R
2 min read

Fisher Transform – Amibroker AFL Code

The Fisher Transform is a technical analysis indicator developed by John F. Ehlers, designed to identify potential turning points in the price movements of...
Rajandran R
2 min read

My Experience Converting SSL Hybrid from PineScript to Amibroker…

As a trader and coding enthusiast, I often find myself needing to translate trading indicators from one programming language to another. Recently, I embarked...
Rajandran R
8 min read

One Reply to “Bear Call Spread and Bear Put Spread – Amibroker…”

  1. Hi,
    Its a very helpful piece of code. I am trying to create alert when a certain level is hit in the code. But the alerts are not popping out. Here is the code.

    _SECTION_BEGIN(“Bear Call and Bear Put Spread”);
    SetChartOptions(0,chartShowArrows|chartShowDates);

    _N( Symbol1= ParamStr(“Sell Strike”, “BANKNIFTY05AUG2133700PE.NFO”) );

    SetForeign( Symbol1 );
    C1 = C;
    H1 = H;
    L1 = L;
    O1 = O;
    V1 = V;
    RestorePriceArrays();

    _N( Symbol2= ParamStr(“Buy Strike”, “BANKNIFTY05AUG2134300PE.NFO”) );

    SetForeign( Symbol2 );
    C2 = C;
    H2 = H;
    L2 = L;
    O2 = O;
    V2 = V;
    RestorePriceArrays();

    Color = ParamColor( “Color”, colorRed );
    Style = ParamStyle( “Style”, styleCandle, maskPrice );
    SlLevel = Param(“SL Level”, 0,0,10000);

    PlotOHLC( (1*O1-1*O2), (1*H1-1*H2), (1*L1-1*L2), (1*C1-1*C2), “(” + Symbol1 + ” – ” + Symbol2 + “) spread”, Color, style );

    _SECTION_END();

    SlAboutToHit = (GetRTDataForeign(“Last”, Symbol1) – GetRTDataForeign(“Last”, Symbol2)) > SlLevel;
    AlertIF( SlAboutToHit, “SOUND “, “SL Alert”, 15 );

    _N(Title = StrFormat(“(%s – %s) spread – {{INTERVAL}} {{DATE}} \n%s -\nOpen %g \nHi %g \nLo %g \nClose %g \n\n%s -\nOpen %g \nHi %g \nLo %g \nClose %g”, Symbol1, Symbol2, Symbol1, O1, H1, L1, C1, Symbol2, O2, H2, L2, C2));

    Can you please help me confirm if my code for the SlAboutToHit is correct or not?

    Thanks a ton in advalnce!

    Regards,
    Mithilesh

Leave a Reply

Get Notifications, Alerts on Market Updates, Trading Tools, Automation & More