Menu
  • AFL2018
  • Training
  • Premium
  • Traders Cafe
  • Intraday signals
  • MCX Signals
  • Library

Marketcalls

Simply Intelligent Technical Analysis and Trading Strategies

  • Software
    • Amibroker
    • NinjaTrader 7
    • Ninjatrader 8
    • Option Action
    • Market Analyst
    • Metatrader
    • Python
    • Datafeed
  • Library
  • Markets
  • Commodities
  • Forex
  • Economy
    • Banking
  • Webinars
  • Trading Lessons
    • Algo Trading
    • Market Profile
    • Infographic
    • Video
You are here: Home / Amibroker / Supertrend Multi Timeframe Based Trading System – Amibroker AFL Code

Supertrend Multi Timeframe Based Trading System – Amibroker AFL Code

February 24, 2017 by Rajandran 23 Comments

Here is the first prototype from Marketcalls which demonstrates multi-timeframe based trading system which compares two timeframes (5min and hourly in this case) and takes a trade decision based on both the timeframes. To demonstrate with simple example we used supertrend on 5min timeframe and Hull RSI on the hourly timeframe to filter unwanted trading signals.

Trading Logic

Go long if Hourly HRSI is trending upwards and Supertrend turns to buy mode on 5min charts
Exit long if Supertrend turns to sell mode (i.e Trailing Stop hits on closing basis) on 5min charts

Go Short if Hourly HRSI is trending downwards and Supertrend turns to short mode on 5min charts
Exit Short if Supertrend turns to sell mode (i.e Training Stop hits on closing basis) on 5min charts

Bank Nifty Futures showing Supertrend Along with Hourly HRSI indicator as a filter

Download Supertrend with Multitimeframe Filter – Amibroker AFL Code

Here is the backtested results for Bank Nifty Futures (5min charts) Since SEP 2010 onwards with Brokerage + Other Transaction costs added as 0.02%
Max open position is taken based on 15% of the available capital.

Equity Curve

Drawdown

Download the Backtest Result

Multi Supertrend V3.0-20170224141735498

Related Readings and Observations

  • Supertrend V5.0 – Amibroker AFL CodeSupertrend V5.0 – Amibroker AFL Code In the new version of Supertrend thought of removing ATR factor to make the trading strategy independent of volatility factor. It is a simple long/short strategy fits for trading lower […]
  • Introduction to Backtesting a Trading System using AmibrokerIntroduction to Backtesting a Trading System using Amibroker Backtesting is a simple process which helps a trader to evaluate his trading ideas and provides information about how good the trading system performs on the given historical dataset. It […]
  • Supertrend V4.0  – Amibroker AFL CodeSupertrend V4.0 – Amibroker AFL Code Compared to Supertrend 3.0 with the new version two interesting features has been added. One is a simple EMA filter rule is added to Buy and Short Conditions and changes in the dashboard […]
  • ATR Volatility Long Only Trading SystemATR Volatility Long Only Trading System Yet another ATR Volatility based Long only Trading System. ATR Volatility system a mechanical strategy for higher time-frames Written by Tudor Marcelin - Art Invest. Just modified the […]
  • Supertrend Intraday Trading Strategy for High Volatile ScripsSupertrend Intraday Trading Strategy for High Volatile Scrips Supertrend Intraday Trading strategy will start trade the Supertrend only between 9:15a.m and 3:00:p.m and close any open position by 3:25p.m. The following code defines the time based rules.
  • Didi Index Long only Trading SystemDidi Index Long only Trading System Didi Index is a positional long only trading system constructed based on three exponential moving averages inspired from mql4 code Didi Index Indicator. Indicator developed by Brazilian […]

Filed Under: Amibroker Tagged With: AFL Code, Amibroker, Multitimeframe, SuperTrend, Trading System

About Rajandran

Rajandran is a Full time trader and founder of Marketcalls & Co-Founder of Traderscafe, trades mostly using discretionary Trading Concepts like Market Profile, Trading sentimental analysis, building timing models, algorithmic trading models. Instructs professional traders, full time traders & aspiring full time traders. Rajandran attended college in the Chennai where he earned a BE in Electronics and Communications. Rajandran has a broad understanding of trading softwares like Amibroker, Ninjatrader, Esignal, Metastock, Motivewave, Market Analyst(Optuma),Metatrader,Tradingivew,Python and understands individual needs of traders and investors utilizing a wide range of methodologies.

Comments

  1. Shiva says

    February 24, 2017 at 9:43 pm

    Is this the best intraday trading system. If ‘No’ then what is the best trading system you like the most.
    Is your back test only on long side?

    Reply
    • Rajandran says

      February 25, 2017 at 1:51 pm

      Its not a intraday trading system. For Intraday trading system visit https://www.marketcalls.in/lintra
      Backtest provided is for both long and short.

      Reply
  2. AJAY PARMAR says

    February 24, 2017 at 10:20 pm

    PARAMSETENGINE() shows error

    Reply
    • Rajandran says

      February 25, 2017 at 1:50 pm

      May be SPSO Optimizer is not installed in your machine. Either Install the SPSO optimizer or remove those three lines of code from your afl.

      OptimizerSetEngine(“spso”);
      OptimizerSetOption(“Runs”, 1 );
      OptimizerSetOption(“MaxEval”, 500 );

      Reply
      • Bhumit Bhuva says

        March 9, 2017 at 5:43 pm

        how to add this SPSO Optimizer?

        Reply
  3. Rajesh Kumar says

    February 24, 2017 at 10:32 pm

    HI,
    paramrSetEngine(“spso”);
    paramrSetOption(“Runs”, 1 );
    paramrSetOption(“MaxEval”, 500 );

    is giving error.

    i use licensed Ami 6.20.1

    Thanks.

    Reply
    • Rajandran says

      February 25, 2017 at 1:49 pm

      May be SPSO Optimizer is not installed in your machine. Either Install the SPSO optimizer or remove those three lines of code from your afl.

      Reply
  4. vijay says

    February 24, 2017 at 11:11 pm

    showing error in these lines

    paramrSetEngine(“spso”);
    paramrSetOption(“Runs”, 1 );
    paramrSetOption(“MaxEval”, 500 );

    Reply
  5. Dhaval says

    February 25, 2017 at 12:33 am

    Hi

    I have try to use the above-mentioned afl codes but got following error

    Multi Supertrend V3.0 :

    _N(Title = StrFormat(“{{NAME}} -- {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}”, O, H, L, C, SelectedValue( ROC( C, 1 ) ) ));

    paramrSetEngine(“spso”)
    ———————^
    File: ‘Formulas\Drag-drop\Multi Supertrend V3.0. 2.afi’, Ln:52, Col:23
    Error 30.
    Syntax error, identifier ‘paramrsetengine’ is undefined.

    Use ‘Edit Formula’ to correct error”

    Now what should I do to correctly apply these codes?

    Thanks and regards

    Reply
    • Rajandran says

      February 25, 2017 at 1:48 pm

      What Version you are using as SPSO is a optimizer engine plugin which released post 5.7 onwards. May be if you are using older codes you may need to
      remove the optimizer blocks i.e the below lines from the code and try out.

      OptimizerSetEngine(“spso”);
      OptimizerSetOption(“Runs”, 1 );
      OptimizerSetOption(“MaxEval”, 500 );

      Reply
  6. Bapirazu says

    February 25, 2017 at 2:12 pm

    Hi Rajandran,

    I appreciate you do provide Super trend afl code for every new version,
    but why dont you provide code for back testing and back testing setup.

    Could you please share us the link for Lintra and its backtesting code and setup

    Reply
    • Rajandran says

      February 25, 2017 at 2:43 pm

      All the AFL trading system which i provided here supports backtesting. And you can backtesting on your own.
      When comes to lintra its not open source but system is open to use https://www.marketcalls.in/lintra and also available as free addon for
      nimbledataprolite subscribers who subscribe via marketcalls https://www.marketcalls.in/premium/globaldatafeeds/nimbledatapropluslite

      For backtesting and learning about lintra try this webinar https://www.marketcalls.in/workshop/webinar-lintra-intraday-trading-system-system-performance.html

      Reply
  7. gopal says

    February 25, 2017 at 5:55 pm

    I want Supertrend formula in Excel, pls. guide how to do it

    Reply
  8. Ramesh says

    February 25, 2017 at 7:07 pm

    Thanks a lot.

    Reply
  9. ASH says

    February 25, 2017 at 7:59 pm

    Hi Rajandran,

    I am very big fan of you,to such kind give strategies and i have many time try to talk you but your team not touch you and I have also mail you.please check e-mail and answer me.

    Reply
  10. Bapirazu says

    February 26, 2017 at 12:23 pm

    Could some one explain the values of the below 2 lines

    Factor=param(“Factor”,3,1,4,1);

    Pd=param(“ATR Periods”,14,1,50,1);

    I understood 3 is multiplier and 14 is ATR
    but what about 1,4,1 and 1,50,1

    Reply
    • Rajandran says

      February 26, 2017 at 5:26 pm

      Those are values you can change the FActor and ATR from the external properties box.

      Reply
      • Mike says

        March 8, 2017 at 7:05 pm

        Hi Rajandran,

        I was wondering if you could help me with a bit of Amibroker formula please. In the following example I want to explore and find any stocks where “MyF()” condition is true if x is equal to 10,11,12,13,14,15,16 and so on. Perhaps I want to check 100 different periods.

        The code works fine and if MyF(10) is true then the explorer “DayDivG” column will show “10”, if MyF(11) is true then the explorer “DayDivG” column will show “11”, and so on.

        My Question is (if you have the time) is there an easier way to write the formula than having to use multiple OR expressions and IIF functions?

        If you could show an example I would greatly appreciate it.

        Many thanks for your great website and very helpful Amibroker lessons.

        ///////////////////////////////////////////////////////
        MDHist = MACD() -- Signal();

        function MyF(x)
        {
        PD = L < Ref(LLV(L,x),-1) AND Ref(L,-x) < Ref(L,-x + 1) AND Ref(L,-x) Ref(MDhist,-x) AND MDHist < 0 AND Ref(MDHist,-x) < 0;

        DivG = PD AND MDHU ;

        Return DivG;
        }

        Setup = MyF(10) OR MyF(11) OR MyF(12) OR Myf(13) OR Myf(14) OR MyF(15) OR MyF(16);

        AddColumn(IIf(MyF(10),10,IIf(MyF(11),11,IIf(MyF(12),12,IIf(MyF(13),13,
        IIf(MyF(14),14,IIf(MyF(15),15,IIf(MyF(16),16,0))))))),"#DivG");

        Filter = Setup;
        ///////////////////////////////////////////

        Reply
  11. Vikas says

    March 2, 2017 at 11:59 am

    Do you provide any AUM services for retail clients?? I am interested in investing with you…

    Reply
  12. Rajiv Kumar says

    March 5, 2017 at 8:27 pm

    How can the trading logic for LX (Long Exit) and SX (Short Exit) be same?

    Reply
  13. Mithoon says

    March 26, 2017 at 4:14 pm

    How do you backtest contractwise data on Amibroker in the absence of continuous data ,is there a way to stitch the data or is there anything else that can be done,please advice

    Reply
  14. Prady G says

    March 30, 2017 at 1:02 pm

    Hi Rajendran,

    Nice example of multi time frame code. Though it is working great, but I am unable to make the code working when I change the timeframe of supertrend, eg. I want to use the 1hr suprtrend in 5 mins chart. It is very very important to me and I am stuck to complete my strategy because of that. Will you please help me on this part ?
    I will be highly obliged if you can throw some light on this.

    Thanks & regards,
    Prady

    Reply
  15. Abhishek Nema says

    October 5, 2017 at 2:06 pm

    Dear All,

    Could anyone please help me out, “How can I put 15min Supertrend attach into 5min chart”.
    is there any same afl available ???

    With Regards
    Abhishek Nema

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Email Newsletter

Sign up to receive email updates on latest trading strategies , analysis & financial market updates

We Respect Your Privacy

Premium Access

Username:
Password:
Remember Me
Lost your password?

Tools For Traders

  • Marketcalls Android App
  • MCX Signals
  • Intraday Signals
  • International Commodities
  • OI Tracker
  • Participation OI
  • Your Broker
  • Market Sentiment Analysis

Amibroker Updates

Amibroker Technical Analysis and Automated Trading System Workshop – Chennai and Mumbai

March 6, 2018 By Rajandran 16 Comments

Onetimeframing Against Initial Balance – Intraday Trading Strategy Amibroker AFL Code

March 4, 2018 By Rajandran 1 Comment

[STA2018] Systematic Trading using Amibroker – Online Workshop

January 30, 2018 By Rajandran 13 Comments

Absolute Monthly and Yearly Profit/Loss Table – Amibroker AFL Code

January 18, 2018 By Rajandran 4 Comments

How to Integrate Tradingview Charts and Ideas with Amibroker

October 1, 2017 By Rajandran 13 Comments

  • Facebook
  • Google+
  • Linkedin
  • RSS
  • Twitter
  • YouTube

Metatrader Updates

MetaTrader 5 Demo Servers Now Available for BSE Currency Markets

March 20, 2018 By Rajandran 6 Comments

ChartIQ – WebTrader for MT4

December 4, 2017 By Rajandran 2 Comments

Metatrader 4 – Web Platform Overview

October 29, 2015 By Rajandran 8 Comments

William VIX FIX Indicator for Metatrader 4

May 16, 2015 By Rajandran 9 Comments

How to Install Custom MQL4 indicators in Metatrader

November 14, 2014 By Rajandran 5 Comments

Required US Government Disclaimer & CTFC Rule 4.41

​Futures trading contains substantial risk and is not suitable for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or lifestyle. Only consider risk capital that should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results. CTFC RULE 4.41 – HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN LIMITATIONS. UNLIKE AN ACTUAL PERFORMANCE RECORD, SIMULATED RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES HAVE NOT BEEN EXECUTED, THE RESULTS MAY HAVE UNDER-OR-OVER COMPENSATED FOR THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS SUCH AS LIQUIDITY. SIMULATED TRADING PROGRAMS IN GENERAL ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFIT OR LOSSES SIMILAR TO THOSE SHOWN. All trades, patterns, charts, systems, etc., discussed in this website or advertisement are for illustrative purposes only and not construed as specific advisory recommendations. All ideas and materials presented herein are for information and educational purposes only. No system or trading methodology has ever been developed that can guarantee profits or prevent losses. The testimonials and examples used herein are exceptional results which do not apply to average people and are not intended to represent or guarantee that anyone will achieve the same or similar results. Trades placed on the reliance of Trend Methods systems are taken at your own risk for your own account. This is not an offer to buy or sell futures interests.

About | Contact Us | Terms and Conditions | Privacy Policy | Support Policy | Disclaimer


© Copyright 2015 Marketcalls Financial Services Pvt Ltd · All Rights Reserved · And Our Sitemap · All Logos & Trademark Belongs To Their Respective Owners·

Data and information is provided for informational purposes only, and is not intended for trading purposes. Neither marketcalls.in website nor any of its promoters shall be liable for any errors or delays in the content, or for any actions taken in reliance thereon.