Matlab trading indicators

Posted: war21x3b Date: 14.07.2017

Updated 24 May Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:.

Technical analysis is the forecasting of future financial price movements based on an examination of past price movements. Most technical indicators require at least 1 variable argument. If these arguments are not supplied, default values are used. There is a bug in your calculation for the RSI similar as in the default Matlab function which you appear to have used as a basis for this one.

The RSI should be based on the previous value of the RSI, not just on the prices of a stock http: To solve the issue, the for loop should be replaced by:.

I believe there is a small bug in tsi subprogram i. So I added this line to remove it. That is correct, the function is suitable for 1 stock at a time. I will look into this and see what I can come up with, no guarantees. For the moment you can get around this issue by using a for loop. I know, not the fastest solution, but it works.

Just had a query regarding the indicators.

matlab trading indicators

If I read the functions correctly - they are suitable for only one column or one stock? Please see my other submission to the exchange located here: Do you have any code for the charts you display in the preview image? Would be great to plot indicators at the bottom of my chart like you do Kaufman, fractral, Jurik and Andrew's Pitchfork to this function? All inputs must be vertically oriented 2. All outputs are returned vertically oriented 3.

This code is intended to be used for hundreds or thousands of points of data. Normally you cannot use any of these functions for 1 single point. This function will require at least 1 more point of data for each of the hi, lo, and cl inputs than the maximum of the k or d inputs. At the moment I do not have access to Matlab in order to make this change but as soon as I do, I will add in your suggestion.

Nate, I want to thank you a lot for sharing your code because it works great and saved me a lot of time. Here you find a detailed explanation: An improvement could be a "method option" in the formula to choose one of both versions of RSI; one method with your original RSI version and a second one with the smoothed RSI version. Nate - I wanted to thank you for your sharing of your collection of trading based technical indicators.

But the results of indicators price,'t3',period,volfact are different from what you can get by using the same function in TA-Lib.

I'm glad you have been able to put my code to good use and thank you for sharing for your hard work. I use another indicator here that is fibonacci bands, i user your work to develop this indicador in matlab, and here is the code. Thank you for sharing your work.

Your efforts are greatly appreciated and I hope that others may find your work helpful. I wanted to share similar work with you and your followers in the hopes that some may find it complimentary and useful. As it isn't a file submission direct to Mathworks I really can't create my own thread. It is available in the repository of http: The issues have been fixed and the update should appear shortly. I have also added 2 more indicators. The example should have read: I have just added the KDJ Indicator as requested.

It should appear shortly depending on how long Matlab takes to approve my submission. This indicator was a little confusing. I'm not sure exactly which method is correct so I input 3 different methods. Simply uncomment whichever method you wish to use. I'll try my hand at the mex function, but unfortunately I don't have a whole lot of experience with them so no guarantees.

I do agree with you, this function is slow as an optimizer. I suggest pulling out the individual indicators that you are interested in and turn them into their own functions.

Then try to optimize those, that way you aren't bogged down by the 'Switch' statement. I want to use it in an optimization, but it is kind of slow. It would be wonderful if it can be into mex funtcion so the it will be much faster. Either increase the size of your input vector, or decrease the period. Thanks for the compliment! Peter - Yeah there are many calculations like that in my code where you could use one method or another to calculate ema or use sma over ema.

It is really a matter of opinion. Thank you for the rating!

Technical Analysis Examples - MATLAB & Simulink - MathWorks France

Noticed the stochastics delay is calculated using EMA, my TA program calculates it using SMA so there was a slight discrepancy. Do you know what the problem is? I'm knew to Matlab so having a hard time trying to decipher the code. SMA's and other stuff work fine. Cheers for the hard work. Sorry for the delay, but I have finally added the True Strength Index. Work has been crazy busy and this unfortunately was moved down on the priority list.

I would like to point out that I have included 2 methods for calculating the ema in the tsi. The first method is very similar to Mike's, and is based off of Wikipedia's interpretation of the ema. The second method is based off of Matlab's interpretation of the ema. To choose one or the other, simply comment whichever method you do not wish to use.

The default method is based off of Wikipedia. I will take at look at your code this weekend and hopefully have something put together by Sunday. Nate, I had some time so I coded the True Strength Index TSI. Probably not the most efficient code, and I don't know if it handles the NaN's properly, but basically it works with your program.

I quickly checked the output and it looks right. I decided to use Matlab's datvecmx function to calculate the year, month, and day rather than try to figure it out on my own. I originally thought that I could write a script to calculate dates faster than Matlab's built-in functions could, but at the moment I can't even calculate those values correctly, much less faster than Matlab.

I forgot about this problem. The problem arises because I don't evaluate leap years correctly. I'll try to fix it in the next day or two. I have also tried with smaller subsets of other market data and even used my fake market data constructed from random variables but the error was still there. You could try to run it with your own data as I suspect you will get that same error but if you want me to send you the actual values for dates, open, high, low, close prices I would need your email address.

Could you give me an example of how you are getting this error? You could email me your input that triggers the error, and I will see if I can reproduce it. Great code, easy to use, and Very well documented! Saved me a lot of time by not having to code this from scratch. Simply change this to a dummy value such as "val" , and the error will go away. Nate, I have come across a problem with the file while trying to estimate pivot points. The problem seems to be related to the code where you work out years, months and days from Matlab serial dates.

In particular I had issues with the following block of code:. I suggest you simply write a new ema code that includes the previous ema value and you should be set.

The following should do what you want,. I made some more investigation and I think tsmovavg based solution has a major drawback i.

Lets assume you have 10k bars and you calculate ema on it. Than a new bar comes and calculate again 10k would be very time costly - much easier to calculate just last bar.

But in this case this code will not work because instead of use x-1 data for initial value so last data point of 1st calculation of ema it will use some average values. The method that I used is the method that Matlab uses to calculate the ema in their own moving average function 'tsmovavg'.

This is not to say that that method is correct, but that is why I used it. It looks that there are at least 2 versions of code for EMA around i. EMA calculated with algorithm from this function and EMA calculated with this code. Added Volatility Ratio, Highest High Lowest Low. Fixed FSTO and SSTO error.

Choose your country to get translated content where available and see local events and offers. Based on your location, we recommend that you select: MathWorks is the leading developer of mathematical computing software for engineers and scientists. Log In Products Solutions Academia Support Community Events Contact Us How to Buy. Contact Us How to Buy Log In. Products Solutions Academia Support Community Events.

MATLAB Central Community Home MATLAB Answers File Exchange Cody Blogs Newsreader Link Exchange ThingSpeak Files Authors Tags Comments My File Exchange Submit About.

Technical Indicators version 1. Copyright c , Nate Jensen All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: The included indicators are: Comments and Ratings Zheng Zheng view profile.

Chart Technical Indicators - MATLAB & Simulink - MathWorks France

Tsz Shing Chow Tsz Shing Chow view profile. Hi guys, I have found some problems when I was using the codes. When I try to run the code in Matlab, it showed this "Not enough input arguments. Caspar Walhout Caspar Walhout view profile. Krzysztof Fajst Krzysztof Fajst view profile. Yona Yona view profile.

Plot the MACD Indicator - MATLAB & Simulink - MathWorks France

Cihan Ulas Cihan Ulas view profile. Could you check the SAR computation. It seems it has a different result than metastock.

Nate Jensen Nate Jensen view profile. Vamsi Vamsi view profile. Fernando Esteves Fernando Esteves view profile. Xie Ya Xie Ya view profile. I'm glad my code has worked out for you.

Fuad Fuad view profile. Let me look into this Ha and see what I can do for you. Thanks for the rating! Ray Lee Ray Lee view profile. Jean, Could you please rephrase; I'm not sure exactly what you mean. Hi, Any idea how to calculate the return of these rule please?

Thanks for the feedback Alejandro! I'm glad everything is working out for you. George Xu George Xu view profile. How to use the code on KDJ? Please, Say, I have tick data tick[] and like to has KDJ 9,2,3. Thanks, I did try, but get error.

Alejandro Leija Alejandro Leija view profile. Ruilong Ruilong view profile. Leonardo Hermoso Leonardo Hermoso view profile. Hi Mark, Thank you for sharing your work.

Mark Mark view profile. Jose Jose view profile. Nate, Thank you very much. Jose, Thank you for pointing this issue out! I will upload a fix tonight. I'm sorry about the error. Ha, I have just added the KDJ Indicator as requested. Arty Arty view profile. Peter Peter view profile. Hi Nate, I tried the t3 indicator and got an error message: Mike Mike view profile. Yeah I could probably put that in. Oh, I see you added these: Any plans to code the True Strength Index TSI?

The problem is fixed, and the new file should appear shortly. Bruno Pajusco Bruno Pajusco view profile. Bruno, Could you give me an example of how you are getting this error?

Mike, Thanks for the positive feedback! In particular I had issues with the following block of code: Krzysztof, I suggest you simply write a new ema code that includes the previous ema value and you should be set.

Hi, I made some more investigation and I think tsmovavg based solution has a major drawback i. Filter solution seems to be ok Krzysztof. Krzysztof, The method that I used is the method that Matlab uses to calculate the ema in their own moving average function 'tsmovavg'. I briefly compared it to Google's ema on their finance page and the results were the same. I would suggest to stick with what I have. Which one is correct?? Updates 24 May 1.

MATLAB Release MATLAB 7. Tags Add Tags analysis finance modeling technical indicators. Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB. Select Your Country Choose your country to get translated content where available and see local events and offers. Americas Canada English United States English. Explore Products MATLAB Simulink Student Software Hardware Support File Exchange. Try or Buy Downloads Trial Software Contact Sales Pricing and Licensing.

Learn to Use Documentation Tutorials Examples Videos and Webinars Training. Get Support Installation Help Answers Consulting License Center. About MathWorks Careers Newsroom Social Mission About MathWorks. MathWorks Accelerating the pace of engineering and science MathWorks is the leading developer of mathematical computing software for engineers and scientists.

Rating 4,1 stars - 519 reviews
inserted by FC2 system