Matlab trade visualizations

Discussion in 'Automated Trading' started by knocks420, Jan 13, 2009.

  1. With tradestation and wealth-lab it is quite easy to review trades for a specific strategy and visually inspect the chart to double check that trades are placed as expected and the strategy is coded properly. I am relatively new to MatLab and was wondering what/how is the best way to do this? Example code would be kick a$$.
  2. Come on, I know some people use MatLab here! How do you debug your code and visually check your trade entries/exits??

  3. ej420


    first thing : Matlab NOT MatLab .

    The way I use matlab for trading is to just write my own code for everything.
  4. OK, so how do you determine if there are any errors in your code. I'm not talking about compiling errors, that your code is placing buys/sells in the appropriate location?
  5. Euler


    Program testing can be used to show the presence of bugs, but never to show their absence!

    Dijkstra, 1969
  6. nbeeyard


    The way to check you put properly orders can be reflected in your code if you consider that the datas come 1 by 1, like in real time (so use a for loop and for each new price, calculate the new moving average point,...).

    It's not specific to matlab anyway but it's true that you can use a lot of libraries for applying quickly yours strategies.
  7. The general consensus seems to be that, in fact, full confidence is placed in the ability to code correctly the first time and that no visual confirmation is done?

    I may not be the number 1 programmer but in my experience I have always had to visually confirm that trades are placed as I would expect on a chart. Even when using something as simple as EasyLanguage I have found errors visually that could only be confirmed by viewing where the trades have been placed despite the fact that the code, on initial review, seemed correct.
  8. Im not a matlab user, but what you could do is write the resulting entries/exits to a text file, and import this to a 3rd party product. Im using home-grown software for simulations, import those trades into Neoticker for visual confirmation and performance reports. Much easier than rolling my own charting and reporting.
  9. knocks420,

    Here's a couple more possibilities.

    This link discusses 3 ways of integrating MatLab with C#.

    Idea #1

    You could use the open source drawing tool ZedGraph as a basis to write your own charts, perhaps. That would take a lot of time, however.

    Idea #2

    Your post was intriguing because I'm releasing a tool called TickZOOM tomorrow that can integrate with MatLab. But noone tried it yet.

    TickZOOM is written in C# and has source code.

    It appears that if you follow the article above you can integrate into TickZOOM relatively easily to get tons of options:

    1. Make MatLab generate a .NET assembly.
    2. Wrap that assembly in a TickZoom Model object in C#.
    3. Run the TickZOOM engine which invokes the MatLab assembly.
    4. You get a chart with all the trades, plus all the rest of TickZOOM features.

    Features like running it in real time mode, replay mode, optimizing variables, or rolling it out to an execution server for full automation.

  10. Well the answer was easier then I had anticipated although the code needs work!:


    In my code I create an array called {pos} that captures buy, sell, short ( 1, 0, -1) I created a matrix and used changes in position to record relevant prices. Then fiddling with the plot tools, matlab will allow you to plot symbols which can be overlayed on the price chart.

    trade = zeros(length(pos),2);
    for c = 2:length(pos)
    if pos(c-1,1) ~= pos(c,1)
    if pos(c,1) == 1
    trade(c,1) = CVB(c+1,1);
    if pos(c,1) == -1
    trade(c,2) = CVB(c+1,1);

    I tried plotting candle charts with the Buy/Sell signals however the symbols disappeared anytime I zoomed in. Not sure why that happens?
    #10     Jan 19, 2009