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)

ZLEMA ATR Long Only Trading System – AFL code

1 min read

ZLEMA ATR Long only trading system is a mechanical strategy for higher time-frames. The trailing stop loss is quite adaptive and adjustible in the down trends to revise it stoploss downwards on its own and the buy or sell decision is taken only at the end of the candle. visit here to know more about Zero Lag EMA indicator

Nifty Spot Hourly Charts
Nifty Spot

Indications
1)The green line indicates trailing stop for longs
2)The Red line indicates trailing stop for shorts
3)The Green Arrow indicates longs
4)The Red Arrow indicates shorts

[wp_ad_camp_5]

 

Features
1)Trailing Stoploss Lines
2)Buy/Sell Signal Added
3)Magnified Market Price at the right top corner
4)Timeleft counter to idenfity the end of the candle
5)Non Repainting – Arrows will form only after the end of the candle. No arrows will disappear once the signal formed.

Recommended Timeframes
Preferably higher timeframes like 30min,hourly.etc. Perfectly suits for positional traders who intersted in Long and Exit strategies. And moreover it is a carryforward strategy and not a intra-day strategy though. But work pretty good in high volatile environment.

Backtest Results for Nifty Spot Since March 2009 to May 2014
Backtest Results
Tested with 2 lots of Nifty and with per leg brokerage/slippage of Rs100 included.

Equity Curve
Equity Curve

Drawdown
Drawdown

Profit Table
Profit Table

Steps to Install
1)Download ZLEMA ATR AFL code
2)Unzip ZLEMA ATR Trading System to local folder
3)Copy ZLEMA ATR.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 ZLEMA ATR Trading System code into the blank chart
7)Bingo you are done. Now you will be able to see the ZLEMA ATR Trading System indicator with Buy and Sell signals.

Compatibility
Amibroker 5.5 and above

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

16 Replies to “ZLEMA ATR Long Only Trading System – AFL code”

  1. Why this strategy is long onl?. Can’t we use the same for short and cover also?

    1. Yes you can use for shorting too. But if you are combining both long and shorts all together the risk is gonna increase a little bit. And shorts are not much favorable for this strategy as it makes 1/5th of the profits generated by shorts compared to the longs. All you are wasting your efforts, money, time to generate a little money by increasing your risk.

      1. Thanks rajendran. Got it.
        one more question. How is this strategy is different from original zl ema? Did u only added support for stop loss and other features around the base zl ema?

        1. ZL EMA is nothing but a just crossover between EMA and ZL-EMA whereas here ZLEMA ATR is a ATR based trailingstop included rest the coding explains better.

    1. Hi currently dont do freelancing for users requirements. I do code my own strategies. You can get it down with lots of freelancers available worldwide for converting a AFL code in MT4 code.

  2. Hi Rajandran,

    Thanks a lot for the system. One question is, if we use higher time frames like 4 hour, if the trend changes signal in the later part of the day, the new signal appears in next day morning by the time the market would have moved considerably, can we change the code to generate the signal at the closing time to take any trades..

    Example: System is buy mode and the market went down considerably by end of 3:30 PM, the sell signal will appear tomorrow and say a possible gap down with getting on late trades. Say, if we get the get the sell signal say close to 3:30, we can initiate the trade on the same day itself..

    Kindly request you to tell the modification of code..

    Much appreciated..

    Thanks

    Sai

      1. Hello Rajandran,

        Thanks for taking the time to give your inputs. I am a novice when it comes to programming and still learning TA, not really sure how to implement your suggestion.

        Also, i think i failed to explain my question properly. Say, the system is in Buy mode for the couple of days, say for 4 hr time frame

        Candle 1 (morning)–>Buy Mode | February 1st
        Candle 2 (noon)–> Buy Mode Continuation | February 1st
        Candle 3 (morning)–> Buy Mode Continuation | February 2nd

        Candle 4 (Noon)–> February 2nd| The market started going down (candle still forming) and during market closing hours it has crossed the stop loss. Now the market has closed.

        Next day morning when the market opened; immediately within a fraction of a second sell signal is appearing on Candle 4. & Candle 5 started forming… (Morning)–> February 3rd

        I mean the sell signal on candle 4 has no relation with candle 5 & so instead of the signal appearing during the next day morning i.e. february 3rd morning, is there a possibility of the sell signal appearing during the market closing time of february 2nd..

        I hope i was able to convey my thoughts clearly….

        In the recent blog post ” Autocorrelation and Stochastic Mean Reversion Trading”,

        http://www.marketcalls.in/amibroker/autocorrelation-stochastic-mean-reversion-trading.html

        a similar scenario was discussed.. Under Comments section, one viewer by the name

        “Thanveer” asked “Action needed only at market opening?”

        Your reply

        “”” Yes the system is designed accordingly since it is a EOD based strategy. You can either choose the days closing or at the next day open for your entry or exit. You can set the trade delay in the AFL code to 0,0,0,0 if you want to enter on the same day close to the market close.””

        My doubt is similar, how can we change the code to enter the trade on the same day or close to the market close.

        Your inputs are highly appreciated..

        Thanks

        Sai

        1. Hi,

          You can give a delay to the signals and can take a 1 or 2 bar of delay. But prepone the signals are not possible. It is like detecting/predicting the signals one bar earlier which is simply not possible.

          1. Hello Rajandran,

            Thanks for the inputs. Still with your permission, i want to probe further.. I will keep this simple,

            Say we are observing a 3 hr candle forming from 12:30 PM to 3:30 PM & the signal has been buy since past week.
            The 3 hr candle that is forming has is showing is continuously falling down and showing a big downtrend.
            Market Close at 3:30 P.M. & 3 hr candle also completed at 3:30 P.M

            Even though the candle is complete there is no Sell signal on this candle.. Only after the market opens next day, the Sell Signal is appearing on yesterday’s 3 hour candle.

            I mean, fundamentally nothing is changing on next day market opening because we already have a completed candle..

            Put another way, can we shave off the last few 2~3 minutes of the candle to say generate the signal at around 3:28 PM within the same day?

            Sorry that i am asking so many questions.. just trying to take your help..

            Thanks

            Sai

  3. Dear sir,
    ZLEMA ATR Long only , is best for Bullish market conditions. Can we have in the same way ZLEMA ATR Short only, another AFL, for Bearish Market conditions.

    Regards,

    1. Hi,
      Creating a strategy based on short only are really touch with math models. Once we did it will keep you posted here. As of now we havent done short only models. May be you can expect in the near term.

Leave a Reply

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