Rajandran R Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, USDINR and 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. Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in)

Supertrend High-Low Breakout Strategy – Amibroker AFL code

1 min read

The Traditional Supertrend strategy is buy whenever the trailing stoploss breaks on the higher side and reverse to shorts when it breaks on the lower side. And the Buy or Sell Decision is taken on the close of the candle.

Supertrend High Low Breakout

[wp_ad_camp_5]

 
Now how to create a strategy where when the supertrend turns to buy mode and the reference high is marked at the time of supertrend turning to buy mode. But still the actual buy will come only if the high is taken out on the upper side. Similarly when the supertrend turns to sell mode and the reference low is marked at the time of supertrend turning to sell mode. But still the actual buy will come only if the low is taken out on the lower side. When the Reference High or Low is not broken yet then the old position(Long or Short) continues.

It is just a prototype strategy to demonstrate how such logical conditions can be incorporate in your strategy to bend the system the way you required.

Why Such a Strategy?
When there is a high volatility in the market and when your supertrend signals comes at huge spike then probably some of the cases you will end up catching the signal at the peak. Most of the Big Gapup and Gap down and then a sharp reversal without taking a newer high or newer lows in such a scenario you will be end up saving a few bucks in your strategy. However it has it own disadvantages too as it delays your trading position to take at a little higher price every time as it waits for reference high or low breakout.

Steps to Install

Download Supertrend High-Low Breakout – Amibroker AFL code
2)Unzip Supertrend High-Low Breakout.zip to local folder
3)Copy Supertrend High-Low Breakout.afl file to \\program files\\amibroker\\formula\\basic folder
5)Open Amibroker and Open a New Blank Chart
6)Goto Charts->Basic Charts and apply/drag-and-drop the Supertrend High-Low Breakout code into the blank chart
7)Bingo you are done. Now you will be able to see the Supertrend High-Low Breakout system with Buy and Sell signals.

Rajandran R Telecom Engineer turned Full-time Derivative Trader. Mostly Trading Nifty, Banknifty, USDINR and 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. Writing about Markets, Trading System Design, Market Sentiment, Trading Softwares & Trading Nuances since 2007 onwards. Author of Marketcalls.in)

[Live Coding Webinar] Build Your First Trading Bridge for…

In this course, you will be learning to build your own trading bridge using Python. This 60-minute session is perfect for traders, Python enthusiasts,...
Rajandran R
1 min read

[Webinar] Understanding and Mitigating Curve Fitting in System Trading

"Understanding and Mitigating Curve Fitting in System Trading"! This dynamic session aims to equip novice to intermediate traders, quantitative analysts, and financial engineers with...
Rajandran R
1 min read

P-Signal Strategy Long Only Strategy – Amibroker AFL Code

This tutorial provides an overview of the P-Signal reversal strategy, a quantitative trading strategy that utilizes statistical parameters and error functions to generate probabilistic...
Rajandran R
2 min read

17 Replies to “Supertrend High-Low Breakout Strategy – Amibroker AFL code”

  1. Dear Sir,
    Can you please provide AFL for MACD Histogram Divergence & Hidden Divergence (As shown in your Chart)

    Waiting for your reply.
    Vishnu dutt kaushik

  2. Dear Sir,

    Happy Dusshera.
    What are the parameters used by you in Supertrend, e.g. multiplier, period, trend mode etc.

    Sorry, i went through the AFL code, but am not familiar with AFL syntax, so could not figure out by myself.

    p.s. Yours is the only website in the world that talks about automation frankly and openly. Every one else is secretive and closed about this field.

    Thanks,
    Naren

    1. p.s. Yours is the only website in the world that talks about automation frankly and openly. Every one else is secretive and closed about this field.
      I appreciate this comment of Naren.
      I feel Rajendran is educating the retail investors in beating the big sharks of financial market.. Great work Raj.

  3. Dear Rajandran

    I’ve tried the code; Not able to get the indicators (arrow marks) on the chart. Is there any parameter that needs to be set?

    thanks,Tarak

  4. Rajandran Sir,

    I am use GCI MT4 live charts, i like formula – how to change (Amibroker) AFL code to (GCI MT4) .ex4 code, or how use for MT4 Chart – Supertrend High-Low Breakout
    I am wait for your kind advice, Thanking you

  5. Dear Rajandran

    I was trying supertrend. sometimes it shows a sell signal and then that disappears (in same candle)(i was using 3 min chart). how can we eliminate that?

    your website is really good)
    Thanks

  6. Hi Rajandran,

    I like this strategy very much and it’s my answer that looking for a solution to avoid trading when there’s no new HH,LH, LL or HL. However I’m newbie in Amibroker but I want to customize your AFL to suit my need. So I would really appreciated if you can guide me on these inquiries

    1. What if I want to manually adjust the number of bars to look back for previous high an low? where in your AFL should I go to and edit it?

    2. If I want to use “param” function for user input.

    Thank you so much in advance and looking forward to hearing from you.

      1. sir, how is possible high low in closing basis? there is meaningless if close in next close candle.I also request that if any member buy algostudio, your side provided some goods afl. thanks. without afl i cant do anything. thanks.

  7. Hi,

    Can Share the Afl for if stock move rise or fall 3% in a day.
    Buy Side if it cross it cross previous day low then buy
    Sell Side if it cross previous day high then sell

Leave a Reply

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