How to learn to code a "system" to backtest

Discussion in 'Strategy Building' started by jrlvnv, Jan 6, 2011.

  1. Thanks for the link, TradetoWin. You may have a point, but I feel that Excel has issues as follows:
    1) If you reference the wrong cell, it is easy to look into the future and the results will be wrong
    2) Not easy to make sure that the values are rounded to the nearest tick. This can be a problem in some cases like whether you are filled or not and also when you are on the edge of a rule being true or false

    In fact, I was an Excel user and started using Tradersstudio and found it to be easy as I had some basics of Excel.
    1) If you know Excel VBA, learning the TradersStudio language is easy.
    2) Another point is that the results of TradersStudio are exported as Excel file.

    So, that is why I feel that TradersStudio is a good option.
     
    #11     May 2, 2011
  2. jeffbeil

    jeffbeil

    Is there a reference site on how to help with backtesting on esignal? Also do you need Qlink to link esignal with excel?
     
    #12     May 4, 2011
  3. nathansz

    nathansz

    I read this topic about a week ago. At the time I had trading ideas I really wanted to backtest but no experience programming.

    In just a few days I got the premium data trial (6 months data) and Amibroker trial and learned how to code all of my trading ideas.

    All you have to do is write down what you want in pseudo code, and then find out how to code it bit by bit example:

    Buy when MACD Histogram ticks up from a new low, sell on the first MACD Histogram downtick.

    Google the code bit by bit and look at lots of other peoples work (no shortage).

    From 0 programming experience I had my favorite system coded and backtested into amibroker after about 4 hours self learning.
     
    #13     May 11, 2011
  4. Hi,

    http://www.smartquant.com/introduction/openquant_strategy.pdf

    The doc discusses C# code for Code for Breakout strategies; confirmation
    methods (e.g. 3 consecutive closes above a breakout point); oscillator strategies;
    moving average strategies; Gap closing strategies; Altucher strategies from Trade
    Like a Hedge Fund book; Chande strategy from the Beyond Technical Analysis book.

    Cheers,
    Anton
     
    #14     May 11, 2011
  5. That is interesting, nathansz. However, from what I have read from the forums that Amibroker requires strong programming skills, or am I wrong? Has it become easier for non-programmers or maybe you are a genius to be able to program a systme in one day? Can you please show a snapshot of your system?
     
    #15     May 18, 2011
  6. nathansz

    nathansz

    What sort of snapshot do you want? The system is now several pages of code and I dont really want to share it.

    I have no programming experience but I am pretty good with computers generally.

    When you first start in Amibroker it is a little daunting, but you just have to start small and build from there. The key for me was understanding the concept of how systems were put together in code.

    First write down what you want to do in english:

    For example I will make something up:

    Buy when price breaks above 6 week high on ascending volume

    Then identify the parts of your system description to turn to code:

    In this example:

    "price breaks above 6 week high"

    "Ascending volume"

    Then search for the code that equals your statement. In Amibroker I would do this by doing a search of the website, reading the code of other similar systems or looking through the list of terms in the code library.

    So looking for "price breaks above 6 week high" I find at the top of the list something called "Highest High Value" and Amibroker describes this as:

    "Calculates the highest value in the ARRAY over the preceding periods (periods includes the current day). HHV accepts periods parameter that can be constant as well as time-variant (array)."

    hhv( ARRAY, periods )

    ARRAY simply means, what data set do you want to find the value for?

    So in this case we would write:

    HHV(Close, 30)

    And this would give us the highest close of the last 6 weeks! Easy right? Now what you do is give this a name so you can refer to it later. Everytime you finish writing a statement you need to put a ; at the end also.

    HighestClose = HHV(Close, 30);

    Ok but we want to define a price break above that number in code. What we want to do, is look at yesterdays HighestClose number, and if todays close is higher than that number, Buy!

    It is simply written as:

    Ref(HighestClose, -1) < Close

    Ref(Array, periods) simply gives you the value for something, at a certain date/time. So Ref(HighestClose, -1) Will give you yesterdays value of HighestClose. So give this a name:

    HigherClose = Ref(HighestClose, -1) < Close;

    And we have the code for our original statement: "price breaks above 6 week high"

    I wont do the volume one here because this post is already way too long, but the last step in coding your system is to define your Buy. This is simply done as:

    Buy = HigherClose;

    In this case, Amibroker will buy whenever HigherClose is true.

    I am not saying that its easy, but if you are motivated and you start small, you can go from 0 programming to coding your own systems in a pretty short time frame. The resources out there are unlimited.
     
    #16     May 18, 2011
  7. nathansz

    nathansz

    I wrote a huge post and it didnt go through...

    What sort of snapshot do you want?

    If anyone needs help getting started let me know. Its easy if you start small.
     
    #17     May 19, 2011
  8. markd01

    markd01

    I concur with nathansz, to give AmiBroker a try. Main reason being huge user base with lots of examples all over the internet. You can simply Google for "AmiBroker + [your pseudocode]" and usually find code written by someone that you can reuse in your own system with minimal changes. Secondly, AmiBroker comes with AFL Code Wizard, which you may find useful to help you write code for your first basic system.

    Mark
     
    #18     May 25, 2011
  9. Thanks for your reply, nathansz. :) The snapshot was for your system screen and not the code. So the whole code which is several pages long now, was written in 4 hours! Amazing! :eek:

    You have explained the procedure very well and it is still hard to believe that you are not a programmer, maybe you can start a thread for the programming newbies on "how to start programming their own systems".
     
    #19     May 29, 2011
  10. That would be awesome.
     
    #20     May 29, 2011