This page is out of date, click "Tipster Trendlines" at the top of the page.
The "free" version is no longer available. Go to the Tipster Trendlines 2.1 post for additional information.Trading from the chart - what a concept!
AFL code to trade from your Amibroker Chart
I've had many emails asking me for the code that I use to trade stocks from the Amibroker chart as seen in this chart trading example video post. I've decided to release the code since that is the spirit of the Internet I enjoy most. I was using separate files but to make this easier I've rolled them up, now there are only two files. Before you grab the files, please watch the quick video.
Make sure you test this yourself, all types of trades, Long, Short, at MKT, at LMT, at STP. And always make sure you double check the order entry in TWS before your transmit the order. I take NO responsibility if your a hammerhead and don't check your orders before you send transmit to the exchange.
- MessagePanelInclude.afl - put this file in your default include directory. This is usually /Amibroker/Include/
- TipsterTrendlines.afl - put this in your "custom" folder, or where ever you like, it will work from anywhere.
(BTW, donation button is on the right)
What it will do and won't do
- Use this code to place bracket orders with trend lines drawn right on the Amibroker chart.
- It does NOT allow you to use Amibroker to sell or cover, only place bracket orders.
- Lines should be called BS - Buy or Short, TA - Target, ST - Stop (case insensitive)
- Once you place the order and transmit, you need to manually adjust the target and stop inside TWS, the code does NOT do this for you once your order is placed.
- You must have Amibroker 5.0 or above for the coloured bar to appear at the top of the chart.
- Put the file "MessagePanelInclude.afl" in your include directory.
- Put the file "TipsterTrendlines.afl" in your custom directory
- Right click on the TipsterTrendlines" in the "Charts" sidebar and click "Insert" or "Insert Linked"
- You can run "Debugview" to see what the program is transmitting to TWS. Debugview is in your windows directory.
- You need to install IBController for Amibroker to communicate with TWS, it's available on the Amibroker website.
- Make sure you set up TWS API interface under "global" config, and set trusted IP to 127.0.0.1
- This code uses GetChartID and therefore might give you odd results if you open another chart with the same code and place trend lines with the same labels (BS, ST, TA). It might place an order for the wrong symbol, I have not tested this. To get around this either consider using the actual chart ID (available in the parameters window)
- There is no code to keep from placing multiple orders. If you hit "Buy" twice, you will place two orders, so be careful.
- The code also does not check for waiting or pending orders.
- This code works for stocks only, or other instruments with 2 decimal places. Forex uses 4 decimal places, so if you try Forex, you order is rounded, therefore do not use with Forex.
- In the future I may add additional functionality such as that listed above. If you have improvements on the code please let me know about the improvements.
- Check for pending or waiting order to prevent multiple orders from being transmitted
- Make display bar used as buttons (transmit, auto-trade on off, Long, Short, Close, Reverse, Cancel Order
- Drop down menus can also be added And lastly, if you like the code, please post a comment to this post.
Wow! Excellent job and thank you very much for sharing.
ReplyDeleteGreat effort and hats off for sharing the code !!!. I would love to test the next version of the afl code. Hope you make it available for free or a small charge.
ReplyDelete