Is this Automated Trading Script still working?

Hello guys,
I searched across user AFL Library and found below the auto-trading script dated back to 2019 contributed by famous Barry Scarborough.

However, it looks like not working.

I would appreciate it if you can provide some help.

Specifically, what should i do to make this code working?
As Terence Ng suggested, i change the error into nerror. but it still not work.

What exactly is the error you get?
I used this AFL with some test strategies and worked for me. The problem i had is not all the trades on the chart were submitted to IB TWS.

Thanks for your response. Please see the below screenshot. It does not plot anything and only auto trade ParamToggle showed there. Also, when I explore, nothing happened. Do you have any change or setting for the code?


Hello c1001,

  1. You have to "Replace All" - "error"-String to "nerror"-String then this AFL will work
  2. Use "Scan" in Analysis and you will get results in any way the conditions will match
  3. This AFL is of course not copy & paste, you have to study it and develop your own interface/infrastructure

regards, Peter



Thank you so much. I will try tomorrow.

Thank you again! It works now! I replaced all error keywords and it did not work at the beginning because of some copy-paste format problems. After cleaned the format problem, it shows correct way.

//The symbol on the chart must agree with the symbol selected from this list before AutoTrading will connect to TWS > Blockquote

Does this mean the code only allows a single symbol auto trading?


Hello c1001,

Sure, again you have to study this code ... Symbols were defined here, you have change your content.

sTicker	= ParamList("Symbol to trade", "IBM,MSFT,IWM,QQQQ-SMART-STK,GLD-SMART-STK,FXP", 2);

sTicker will be used in every ib.function and ibc.function

regards, Peter

Hi Pietro,
Do you know any afl script that can auto trade a large amount of symbols from watchlist?

Hello c1001,

you will not find such a "script" ...

To develop a trading system is a complex procedure. It will not work with "copy & paste" especially on auto trading for your portfolio or intraday scalping. You need additional skills for portfolio-, money-, risk management, position sizing and suitable inticators special/dedicated for those symbols/tasks. AB is very strong in development and please do not forget any AFL from the library is published to teach us and has usually other main emphasis by these developers. You must learn coding and find/develop you own and special trading style.

Again you try to setup up a money machine, this will not work with "copy & paste". Everything you need to setup IB orderflow is detailed documented

To manage a large portfolio you have to substitude/replace "sTicker" by your symbols in any kind of looping. That task could be done by Watchlist "Scan" dump out to any hit list as kind of arrays or csv. Then read sequential these result structures and process your orders through any kind of a stateful response developed by you. You have to understand any "millimeter" of your sourcecode with any possible result/side effect in realtime.

Additional you have to learn technical analysis for any indicator construction, because every trading style and traded symbols need some other indication. A good starting point on this topic could be a IFTA membership and contact your local group. Howard Bandy does exellent work in discussing quantitative analysis .

You will lose your money without these skills ... auto trading will not work with "copy & paste".

regards, Peter


A very good advise with due concern.........

Hi rvdesh, sorry for not answering before. Yeah, the original code was created before Error was a function, so must be renamed. I also canceled all the Chartperiod and Market Hours restrictions, as my sistems runs also overnight and i define the timeframe.

All Pietro told you is correct. It's not easy to copy paste a complete AT System. And Portfolio AT systems are the toughest to program as they contain not just the system logic and the autotrading interface but the Portfolio and stocks assignation, position size, money management, etc.

This topic was automatically closed 100 days after the last reply. New replies are no longer allowed.