Coding for trading.

Attila the trader

Active member
Messages
225
Likes
27
HI, About 1.5 years ago I asked, "how to back test without coding", found out that's its best to learn how to code, anyway now I'm pretty good at it, I'm decent with C++ and learning game development; I also know the basics of python,. I'm still a beginner though and want to know what should I learn to be able to do basic trading related things like, making indicators, testing strategies and analyzing and plotting data etc.. (basically trying to combine two things I like).
 
Hi Attila, this all depends on the platform you're using to view your charts
learning a programming language on its own is fine, but if you are using tradingview, you need to learn the subtleties pinescript. if you use amibroker, you have to learn the subtleties of afl (amibroker formula language) etc as they vastly all have their own built in repository of functions you can use.
you will find similarities for example AFL is based on C#
so if you want to learn to now code indicators and strategies etc you will need to choose a platform whose own code structure is most like the one you feel most comfortable with. There are those above, alternatively there are open source platforms such as quantconnect that accept multiple languages, i think python included
personally, i chose a platform of my choice, and learnt that language, rather than generics of C etc which is good, if you want to learn how to write hello world, but no good for the matter at hand.
hope that makes sens
 
If you are looking for a ready made option to use C # or similar in a package that already has options for backtesting then Multicharts is possible. It has two options for programming your own indicators using either C# or VB and a host of ready made ways to make use of the package. I am not in any way affiliated with them but they would be right at the top if I were looking to do what you are wanting.
 
Hi Attila, this all depends on the platform you're using to view your charts
learning a programming language on its own is fine, but if you are using tradingview, you need to learn the subtleties pinescript. if you use amibroker, you have to learn the subtleties of afl (amibroker formula language) etc as they vastly all have their own built in repository of functions you can use.
you will find similarities for example AFL is based on C#
so if you want to learn to now code indicators and strategies etc you will need to choose a platform whose own code structure is most like the one you feel most comfortable with. There are those above, alternatively there are open source platforms such as quantconnect that accept multiple languages, i think python included
personally, i chose a platform of my choice, and learnt that language, rather than generics of C etc which is good, if you want to learn how to write hello world, but no good for the matter at hand.
hope that makes sens
HI, for basic back testing (indicators and candle patters ) do you reckon pinescript is sufficient? because i already know it and its very simple
 
To play around and have some fun coding, it doesn´t matter which platform or language you use. If you want to actually develop something useful, look for a non-programming platform where you can add your own code. You cant use programming any more, markets are too efficient, changes frequently, it takes too long time to code.

Learn from Quantopian, who had to close since 10k+ users could not develop anything useful.
 
If you are good at programming with C++, you must look for an appropriate trading platform that uses C++ for structuring their code. It will be easier for you to develop indicators and analyze charts on that platform. However, if you gain enough confidence in Python, you can shift your platform accordingly to code new signals.
It is literally impossible to program algorithmic trading today, no matter how good programmer you are. The main reason is, you need frequently to adjust, and often develop a new set of strategies - there is no time to do this by programming.
 
HI, for basic back testing (indicators and candle patters ) do you reckon pinescript is sufficient? because i already know it and its very simple
This will all depend on your needs, but im sure its probably fine. it also has a pretty good user base in case you do have questions. you may need to move on however, depending on whether your needs become more complex
good luck with it though and dont listen to others just because they haven't made it through programming.
Its not the program or the code that makes an algorithm successful
 
HI, for basic back testing (indicators and candle patters ) do you reckon pinescript is sufficient? because i already know it and its very simple
I think yes. But you will still want to work-around the inherent limitations of the TradingView Strategy Tester (also likely impacts other softwares likes MT4, if their backtest is based only on OHLC bars instead of tickdata). The limitation is that the builtin Strategy Tester cannot determine what happened during mid-bar activity, it can only make assumptions on the open of the next bar - usually those assumptions are wrong!!

In Pinescript I've managed to work around this as follows. First, I disregard the built-in Strategy Tester completely. Then I just keep track of my own trade accounting with Pinescript variables (not too difficult) and I add a few stats I want such as MaxDD and Profit Factor.

Then since this is my own strategy, I know exactly where transactions would have occurred in price (or at least I can make a very educated guess)... so I just detect these scenarios in the chart and adjust for them as needed. All this data can be displayed in a table on the screen. The main benefit here is that I've utilized backtesting and created highly accurate results that I can trust.

PS: congrats on your GRIT in learning how to code. I learned the same way. It is very satisfying to be able to visualize something you want in this world - and now have a capability to go and build it yourself.
 
Last edited:
It is literally impossible to program algorithmic trading today, no matter how good programmer you are. The main reason is, you need frequently to adjust, and often develop a new set of strategies - there is no time to do this by programming.
what about back testing ?
 
This will all depend on your needs, but im sure its probably fine. it also has a pretty good user base in case you do have questions. you may need to move on however, depending on whether your needs become more complex
good luck with it though and dont listen to others just because they haven't made it through programming.
Its not the program or the code that makes an algorithm successful
alright, thanks man
 
Well to be fair, all-or-nothing thinking is too black-and-white here.

I think there are lots of valid use cases for backtesting. I use it myself in 2 different ways:
1) I backtest to determine if the algo logic has any potential at all ... a lot of ideas just stop here
2) I utilize the backtester to run out-of-sample forward testing ... I use this to determine if an algo is worthy to trade with real money

But I agree that basing live-trading off the raw backtest result is the wrong approach. Personally I will not trade anything live that cannot prove worthiness in out-of-sample forward testing. I've seen many algos where the backtest looks great but they completely fall apart in OOS forward testing.
 
what about back testing ?
When you have platforms where you can edit and back-test in one 200ms step as often as you want (1Station), then backtesting is not a problem, but using Cloud based setup having restrictions of 30seconds between backtests and long backtest times, this is obviously a no go, and mean strategy development is essentially impossible.

Backtesting is of cause mandatory, how would you else know how a strategy perform? As to using out-of-sample data, this depends of the strategy developed, if it was optimized randomly. There are many issues in this, and one need to pass the learning curve to operationally develop automated strategies. One thing for sure, you cannot pass the learning curve by programming any more, unless you have 5+ years to spend.

The real problem is the combination of tunnel sight, outdated platforms and forums keeping users in the past.
 
Last edited:
Top