On popular demand, we have developed an Amibroker AFL for Intraday Open High Low strategy. In this strategy, positions are taken when Open=High or Open=Low for a given security in Intraday Timeframe. We have already posted an Excel sheet and Live signals for this system. Please check out the below links:
Intraday Open High Low Strategy- Live Signals
A Profitable Intraday Trading System: Excel Sheet
In the next section, we’ll go through an AFL and backtest report for this Trading System. Please visit Trading Tuitions Academy to learn AFL coding and create your own Trading systems.
AFL Overview
Paramter | Value |
Preferred Timeframe | Intraday 5 minute |
Indicators Used | None |
Buy Condition | Open=Low in Intraday Timeframe post 30 minutes of market open |
Short Condition | Open=High in Intraday Timeframe post 30 minutes of market open |
Sell Condition |
|
Cover Condition |
|
Stop Loss | 0.5% |
Targets | 2.5% |
Position Size | 50% of Equity |
Initial Equity | 200000 |
Brokerage | 100 per order |
Margin | 10% |
AFL Code
Download the AFL code from the below link:
Intraday Open High Low Trading System AFL
AFL Screenshot
Backtest Report
Paramter | Value |
Fixed Position Size | |
Initial Capital | 200000 |
Final Capital | 538807.42 |
Scrip Name | NSE Nifty, NSE BankNifty |
Backtest Period | 02-Jan-2015 to 26-Apr-2016 |
Timeframe | 5 Minutes |
Net Profit % | 169.40% |
Annual Return % | 111.15% |
Number of Trades | 130 |
Winning Trade % | 48.46% |
Average holding Period | 48.95 periods |
Max consecutive losses | 8 |
Max system % drawdown | -16.20% |
Max Trade % drawdown | -11.64% |
Download the detailed backtest report here.
Equity Curve
Additional Amibroker settings for backtesting
Goto Symbol–>Information, and specify the lot size and margin requirement. The below screenshot shows lot size of 75 and margin requirement of 10% for NSE Nifty:
Disclaimer:
All the AFL’s posted in this section are for learning purpose. Trading Tuitions does not necessarily own these AFL’s and we don’t have any intellectual property rights on them. We might copy useful AFL’s from public forums and post it in this section in a presentable format. The intent is not to copy anybody’s work but to share knowledge. If you find any misleading or non-reproducible content then please inform us at support@tradingtuitions.com
Dear Sir,
Thank you for sharing this excellent AFL.
I have an AFL with exploration function, when I explore it to my NSE futures watch-list, I get both current and past signals for every symbol. I would like to know how to get only the current (or the most recent) signals of every symbols in my watch-list. Kindly advise me what AFL command I should apply.
Thank you very much.
SIR, KINDLY EXPLAIN IN DETAIL AS HOW TO DO THE BACK TESTING.
THANKS
sir if you can modify for the screener
Hi Rahul,
Can you please let me know what modification you need?
What ia the purpose of C-lang coding You’ve posted above? And where can i use that coding? Kindly do the needful
Hi Poovi,
It is not C language, it is AFL (Amibroker Formula Language) which is used to create Trading strategies and systems. Read our Amibroker Tutorial series below:
https://tradingtuitions.com/category/categories/amibroker/tutorials/
This strategy and the corresponding result looks astonishing. Thanks for publishing the same.
It would be great if you can help me to understand this back testing result. I believe these 130 trades over a period of 16 months are incorrect. Why I feel this number is incorrect? When we start the trading day there are many long and short trade signals. We would take all the trades(let us assume). But out of these trades few of the signals get obsolete at the end of the day. E.g. On 29june16 there was a Short call in BPCL at 9:45 A.M because the Open and High price was same 1054.9. During the course of the day the counter went up above the Open price and the signal got closed.
Hence at the end of the day wherever the long and short signals are valid we are performing the back testing results. But we are not considering those trades which got executed and finally the stop loss got hit at the mid of the day. If we incorporate these cases results won’t be that rosy I believe. To backtest these trades you need to use 5 mins OHLC data instead of daily data. Then freeze all the signals generated till 9:45 A.M, that means first six 5mins candle.
Hope I have explained you all my thoughts.
I use a similar strategy but select stocks from the strongest sector to buy and weakest sector to sell out of all the signals generated.
Cheers !!
Hi Abhishek,
Thanks for your in-depth review. However, the strategy has been backtested on 5 Min data itself. And the example you mentioned would definitely trigger a Short signal at 9:45 but would be covered later hitting the stop loss.
Yes but the number of trades going by the backtesting results looks too low, there are good number of trades getting generated each day so going by that logic the number of trades as per backtesting report seems less.
He has run the script only on NSE Nifty, NSE BankNifty not all the stocks.
Great work..
But many times the entry price is not reached after 30 mins of market opening..
and in excell profit is calculated for those companies also..
what do you suggest for these conditions..?
Dear Admin & Abhishek,
I also have gone thru 100s off AFLs and whats common problem with us is like we check AFLs result on EOD and than apply the same in Intraday as we neednot trade overnight untill we get confidence in system and all times end up loosing money.
I have view and also tried I execute all trades in live and in backtesting ignoring 15 mins first and last from trading time.
Means while scanning it takes trades executed from 9.30 to 3.15 only.
This will give you exact idea of AFL and its result
Is it not possible to have such excell sheets for Futures
Hi Admin
you have indicated below extra condition in addition to the strategy signal in the AFL
High>=(sqrt(DayOpen)+0.0833)^2 FOR BUY &
Low<=(sqrt(DayOpen)-0.0833)^2 FOR SELL
Appreciate if could you explain bit more what is that extra condition and what exactly it checks.
Many Thanks
Hi Venkatesh,
This extra condition is to avoid whipsaws.
Will it possible for You to backtest this AFL and post the results for Nifty 50 Stocks. A backtest data of even 1 – 2 months would suffice.
Thanks .
I copy pasted this afl in my ami. I am not getting any buy sell signal. Please help me.
Hi,
I am looking for some volume based strategy. Like Todays volume is higher than average volume of last 5 days.
Best Regards,
Rajneesh Singh
Hi Rajneesh,
We are currently working on a volume based strategy. Will post it once its back-tested and ready.
Hi,
What is 0.0833 and how do you get to know this,
Thanks
I copypasted this afl and ran in 5 min chart. It is giving very wrong signals. Where can I send the screen shots of it you?
Hello sir , The way this strategey is plotted is it possible to plot camrillla strategy in ami broker
Hi, can you patch for this AFL to scan this at 9.30. I want to get signals after 15 min. Dont want to wait till 9.45
FirstTradeTime=094500;
SquareOffTime = 151500;
Just change this
this straetragy gives excellent result
Dear Admin,
Would be great if you can educate us significance / logic of the below formula derivation:
High>=(sqrt(DayOpen)+0.0833)^2 FOR BUY &
Low<=(sqrt(DayOpen)-0.0833)^2 FOR SELL
Hi Satish,
It is optimized formula to avoid whipsaws
On compounding how feasible is this
Hi Paras,
Yes, this strategy is feasible for compounding. However try to diversify on stocks, and don’t just stick to one or two.
Error 61 showing in row 28
_N(Title = StrFormat(“{{NAME}} – {{INTERVAL}} {{DATE}} Open %g, Hi %g, Lo %g, Close %g (%.1f%%) {{VALUES}}”, O, H, L, C ));
Hi Anu,
Please comment out this line, it doesn’t work in some versions of Amibroker
Thanks a million brother. Yet another beauty from you.
I am getting errors in Lines : 46 (Error 32), and Error 29 in 49, 50 and 52. Even it baffles me why I am getting these errors, while nothing wrong with the syntax. I am using 5.7 version. Would greatly help if you can let me know how I can overcome this one.
Thanks for all that you do. I am also looking to enrol in your AFL course, probably next month, quite interesting.
Cheers
GK
Hi Gopalkrishnan,
Fixed the AFL code and re-uploaded the same. Thanks for noticing this, and thanks a lot for your kind words.
Dear Admin
is this strategy of open high low is working good or not because i had traded in that and made a huge loss please help awaiting ur reply.
Hi Vijay,
Yes this is a profitable strategy on a long run. There may be few hiccups during sideways market but proper risk management can handle those