FinancialChartのRSI(相対力指数)インジケータは、株価の動きの速さと大きさを測定するモメンタムオシレータです。資産の終値の上向きの動きを取引期間中の下向きの動きと比較して、株の強さまたは弱さを判断します。値は0〜100の間で変動します。プラスの変化が強い株の方が、マイナスの変化が強い株よりRSIが高くなります。
最新の評価益の大きさを最新の評価損と比較する際にRSIを応用することで、資産の買われ過ぎ/売られ過ぎの状況を判断できます。株は、RSIが70を超えると買われ過ぎ、30を下回ると売られ過ぎと見なされます。
次の図は、RSI(相対力指数)インジケータをチャートに追加し、期間を14に設定したときのFinancialChartを示しています。
次のコード例は、RSI(相対力指数)インジケータをFinancialChartに追加する方法を示します。この例では、BoxData.csモデルのデータとbox.jsonファイルを使用します。
BoxData.csクラスを[モデル]フォルダに追加します。
Model
BoxData.cs |
コードのコピー
|
---|---|
public class BoxData { private static List<FinanceData> _jsonData; public static List<FinanceData> GetDataFromJson() { if (_jsonData != null) { return _jsonData; } string path = HttpContext.Current.Server.MapPath("~/Content/box.json"); string jsonText = new StreamReader(path, System.Text.Encoding.Default).ReadToEnd(); JArray ja = (JArray)JsonConvert.DeserializeObject(jsonText); List<FinanceData> list = new List<FinanceData>(); foreach (var obj in ja) { string date = obj["date"].ToString(); // DateTime date = Convert.ToDateTime(obj["date"]); double high = Convert.ToDouble(obj["high"].ToString()); double low = Convert.ToDouble(obj["low"].ToString()); double open = Convert.ToDouble(obj["open"].ToString()); double close = Convert.ToDouble(obj["close"].ToString()); double volume = Convert.ToDouble(obj["volume"].ToString()); list.Add(new FinanceData { X = date, High = high, Low = low, Open = open, Close = close, Volume = volume }); } _jsonData = list; return list; } private static List<string> _annotationToolTips; public static List<string> GetAnnotationTooltips() { if (_annotationToolTips != null) { return _annotationToolTips; } _annotationToolTips = new List<string>{ "<b>Why the hot IPO market is cooling off?</b>", "<b>Tech IPO market healthy?</b>", "<b>Center for Sustainable Energy Leverages Box to Power California Clean Vehicle Rebate Project</b>" +"<br>Box today announced that the Center for Sustainable Energy, a nonprofit organization committed to accelerating the transition to a sustainable world powered by clean energy, is leveraging the Box platform to power a cloud-based document submission and review process as part of the Clean Vehicle Rebate Project.", "<b>Box to Present at the J.P. Morgan Technology, Media and Telecom Conference</b>"+ "<br>Box today announced that Aaron Levie, co-founder and CEO, will participate in the J.P. Morgan Technology, Media and Telecom Conference in Boston on Monday, May 18, 2015.", "<b>BD Receives FDA Clearance for a Novel Infusion Set with BD FlowSmart? Technology to Enhance the Use of Insulin Pumps</b>"+ "<br>Unique Side-Ported Catheter Designed to Offer Consistent Insulin Delivery and Fewer Flow Interruptions including Silent Occlusions Infusion Set Developed in Collaboration with JDRF and Helmsley Charitable ...", "<b>Wall Street tech debutant Box dismisses doubters</b>", "<b>BD Board Declares Dividend</b>"+ "<br>The Board of Directors of BD (Becton, Dickinson and Company) (NYSE: BDX) has declared a quarterly dividend of 60.0 cents per common share payable on June ...", "<b>Box Sets Date to Announce First Quarter Fiscal 2016 Financial Results</b>"+ "<br>Box today announced that it will report financial results for its first quarter which ended April 30, 2015, following the close of the market on Wednesday, June 10, 2015.", "<b>Making Money With Charles Payne: 05/21/15</b>", "<b>Best Buy to move sideways: Analyst</b>", "<b>Macquarie Upgrades Hercules Technology, Likes Dividend</b>"+ "<br>In a report published Tuesday, Macquarie analysts upgraded their rating on Hercules Technology Growth Capital, Inc. (NYSE: HTGX), with a price target of $14. The analysts believe that the company's dividend ...", "<b>The U.S. Department of Justice Selects Box to Enable Enterprise File Sharing</b>"+ "<br>Box today announced that it is working with the U.S. Department of Justice to deliver file sharing and information management to the agency’s workforce. After rigorous assessment, Box will receive an agency Authorization to Operate this week, allowing the DOJ to leverage the platform across all its component agencies.", "<b>Box Enables Improved Collaboration and Content Sharing at the ASPCA</b>"+ "<br>Box today announced that the ASPCAR , the first humane society established in North America, is bringing Box’s cloud content sharing and collaboration platform to its employees." }; return _annotationToolTips; } } |
また、box.jsonファイルをプロジェクトに追加し、次の内容をファイルに貼り付けます。
box.json
box.json |
コードのコピー
|
---|---|
[ { "date": "2015年01月23日", "open": 20.2, "high": 24.73, "low": 20.16, "close": 23.23, "volume": 42593223 }, { "date": "2015年01月26日", "open": 23.67, "high": 24.39, "low": 22.5, "close": 22.6, "volume": 8677164 }, { "date": "2015年01月27日", "open": 22, "high": 22.47, "low": 21.17, "close": 21.3, "volume": 3272512 }, { "date": "2015年01月28日", "open": 21.62, "high": 21.84, "low": 19.6, "close": 19.78, "volume": 5047364 }, { "date": "2015年01月29日", "open": 19.9, "high": 19.95, "low": 18.51, "close": 18.8, "volume": 3419482 }, { "date": "2015年01月30日", "open": 18.47, "high": 19.48, "low": 18.22, "close": 18.81, "volume": 2266439 }, { "date": "2015年02月02日", "open": 19.18, "high": 19.3, "low": 18.01, "close": 18.02, "volume": 2071168 }, { "date": "2015年02月03日", "open": 18.22, "high": 18.64, "low": 18.12, "close": 18.24, "volume": 1587435 }, { "date": "2015年02月04日", "open": 18.2, "high": 18.35, "low": 17, "close": 17.1, "volume": 2912224 }, { "date": "2015年02月05日", "open": 17.3, "high": 17.31, "low": 16.41, "close": 16.66, "volume": 2682187 }, { "date": "2015年02月06日", "open": 17.39, "high": 18.88, "low": 17.21, "close": 18.12, "volume": 3929164 }, { "date": "2015年02月08日", "open": 18.86, "high": 19.95, "low": 18.45, "close": 19.6, "volume": 3226650 }, { "date": "2015年02月10日", "open": 20.5, "high": 21, "low": 19.63, "close": 20.99, "volume": 2804409 }, { "date": "2015年02月11日", "open": 20.89, "high": 21, "low": 20.2, "close": 20.96, "volume": 1698365 }, { "date": "2015年02月12日", "open": 20.66, "high": 20.85, "low": 19.75, "close": 20.17, "volume": 1370320 }, { "date": "2015年02月13日", "open": 20.19, "high": 20.68, "low": 20, "close": 20.18, "volume": 711951 }, { "date": "2015年02月17日", "open": 19.5, "high": 20.1, "low": 18.8, "close": 19.05, "volume": 2093602 }, { "date": "2015年02月18日", "open": 18.31, "high": 18.5, "low": 17.96, "close": 18, "volume": 1849490 }, { "date": "2015年02月19日", "open": 18.33, "high": 19.25, "low": 17.91, "close": 18.96, "volume": 1311518 }, { "date": "2015年02月20日", "open": 18.68, "high": 19.3, "low": 18.65, "close": 18.85, "volume": 1001692 }, { "date": "2015年02月23日", "open": 18.8, "high": 18.89, "low": 18.11, "close": 18.21, "volume": 670087 }, { "date": "2015年02月24日", "open": 18.46, "high": 19, "low": 18.27, "close": 18.83, "volume": 759263 }, { "date": "2015年02月25日", "open": 18.83, "high": 19.48, "low": 18.47, "close": 18.67, "volume": 915580 }, { "date": "2015年02月26日", "open": 18.64, "high": 19.2, "low": 18.64, "close": 18.94, "volume": 461283 }, { "date": "2015年02月27日", "open": 18.8, "high": 19.12, "low": 18.55, "close": 18.66, "volume": 617199 }, { "date": "2015年03月02日", "open": 18.66, "high": 19.09, "low": 18.65, "close": 18.79, "volume": 519605 }, { "date": "2015年03月03日", "open": 18.79, "high": 19.21, "low": 18.45, "close": 18.59, "volume": 832415 }, { "date": "2015年03月04日", "open": 18.64, "high": 19.05, "low": 18.32, "close": 19, "volume": 539688 }, { "date": "2015年03月05日", "open": 19.2, "high": 19.2, "low": 18.8, "close": 19.14, "volume": 486149 }, { "date": "2015年03月06日", "open": 19.03, "high": 19.1, "low": 18.7, "close": 18.91, "volume": 685659 }, { "date": "2015年03月08日", "open": 18.98, "high": 20.15, "low": 18.96, "close": 19.4, "volume": 1321363 }, { "date": "2015年03月10日", "open": 19.3, "high": 19.8, "low": 18.85, "close": 19.64, "volume": 615743 }, { "date": "2015年03月11日", "open": 20.08, "high": 20.65, "low": 19.24, "close": 20.53, "volume": 2167167 }, { "date": "2015年03月12日", "open": 17.17, "high": 18.2, "low": 16.76, "close": 18.2, "volume": 6837638 }, { "date": "2015年03月13日", "open": 18.05, "high": 18.05, "low": 17.3, "close": 17.88, "volume": 1715629 }, { "date": "2015年03月16日", "open": 17.91, "high": 18, "low": 17.01, "close": 17.13, "volume": 1321313 }, { "date": "2015年03月17日", "open": 17.28, "high": 17.37, "low": 16.6, "close": 17.12, "volume": 1272242 }, { "date": "2015年03月18日", "open": 17.1, "high": 17.27, "low": 16.91, "close": 17.01, "volume": 530063 }, { "date": "2015年03月19日", "open": 17, "high": 17.28, "low": 17, "close": 17.06, "volume": 536427 }, { "date": "2015年03月20日", "open": 17.13, "high": 17.24, "low": 16.88, "close": 17.21, "volume": 1320237 }, { "date": "2015年03月23日", "open": 17.21, "high": 17.23, "low": 17.01, "close": 17.11, "volume": 509798 }, { "date": "2015年03月24日", "open": 17.02, "high": 17.18, "low": 16.82, "close": 17, "volume": 962149 }, { "date": "2015年03月25日", "open": 16.92, "high": 16.99, "low": 16.82, "close": 16.97, "volume": 565673 }, { "date": "2015年03月26日", "open": 16.83, "high": 17.56, "low": 16.83, "close": 17.54, "volume": 884523 }, { "date": "2015年03月27日", "open": 17.58, "high": 18.3, "low": 17.11, "close": 18.3, "volume": 705626 }, { "date": "2015年03月30日", "open": 18.5, "high": 19.4, "low": 18.4, "close": 19.05, "volume": 1151620 }, { "date": "2015年03月31日", "open": 19.08, "high": 20.58, "low": 18.4, "close": 19.75, "volume": 2020679 }, { "date": "2015年04月01日", "open": 19.69, "high": 19.69, "low": 18.55, "close": 18.65, "volume": 961078 }, { "date": "2015年04月02日", "open": 18.56, "high": 18.66, "low": 17.85, "close": 17.9, "volume": 884233 }, { "date": "2015年04月06日", "open": 17.78, "high": 17.94, "low": 17.51, "close": 17.66, "volume": 605252 }, { "date": "2015年04月07日", "open": 17.62, "high": 17.9, "low": 17.53, "close": 17.61, "volume": 591988 }, { "date": "2015年04月08日", "open": 17.64, "high": 17.85, "low": 17.32, "close": 17.36, "volume": 618855 }, { "date": "2015年04月08日", "open": 17.33, "high": 17.54, "low": 17.1, "close": 17.1, "volume": 761855 }, { "date": "2015年04月10日", "open": 17.08, "high": 17.36, "low": 17, "close": 17.05, "volume": 568373 }, { "date": "2015年04月13日", "open": 17.24, "high": 17.26, "low": 16.81, "close": 17.1, "volume": 667142 }, { "date": "2015年04月14日", "open": 17.1, "high": 17.89, "low": 17.02, "close": 17.52, "volume": 870138 }, { "date": "2015年04月15日", "open": 17.6, "high": 17.99, "low": 17.5, "close": 17.69, "volume": 530456 }, { "date": "2015年04月16日", "open": 17.95, "high": 18, "low": 17.6, "close": 17.82, "volume": 548730 }, { "date": "2015年04月17日", "open": 17.75, "high": 17.79, "low": 17.5, "close": 17.79, "volume": 446373 }, { "date": "2015年04月20日", "open": 17.63, "high": 17.98, "low": 17.52, "close": 17.93, "volume": 487017 }, { "date": "2015年04月21日", "open": 17.96, "high": 17.98, "low": 17.71, "close": 17.92, "volume": 320302 }, { "date": "2015年04月22日", "open": 17.88, "high": 18.33, "low": 17.57, "close": 18.29, "volume": 644812 }, { "date": "2015年04月23日", "open": 18.29, "high": 18.61, "low": 18.18, "close": 18.28, "volume": 563879 }, { "date": "2015年04月24日", "open": 18.5, "high": 18.5, "low": 17.61, "close": 17.75, "volume": 650762 }, { "date": "2015年04月27日", "open": 17.97, "high": 18.05, "low": 17.45, "close": 17.57, "volume": 437294 }, { "date": "2015年04月28日", "open": 17.65, "high": 17.79, "low": 17.39, "close": 17.5, "volume": 224519 }, { "date": "2015年04月29日", "open": 17.68, "high": 17.68, "low": 17.1, "close": 17.21, "volume": 495706 }, { "date": "2015年04月30日", "open": 17.22, "high": 17.3, "low": 17, "close": 17.11, "volume": 391040 }, { "date": "2015年05月01日", "open": 17.11, "high": 17.55, "low": 16.85, "close": 17.5, "volume": 563075 }, { "date": "2015年05月04日", "open": 17.56, "high": 17.85, "low": 17.3, "close": 17.4, "volume": 253138 }, { "date": "2015年05月05日", "open": 17.68, "high": 17.68, "low": 17.09, "close": 17.43, "volume": 290935 }, { "date": "2015年05月06日", "open": 17.48, "high": 17.48, "low": 17, "close": 17.04, "volume": 313662 }, { "date": "2015年05月07日", "open": 17.05, "high": 17.19, "low": 16.92, "close": 17.04, "volume": 360284 }, { "date": "2015年05月08日", "open": 17.13, "high": 17.21, "low": 16.91, "close": 17.1, "volume": 297653 }, { "date": "2015年05月11日", "open": 17.16, "high": 17.44, "low": 17.13, "close": 17.31, "volume": 268504 }, { "date": "2015年05月12日", "open": 17.28, "high": 17.44, "low": 16.99, "close": 17.24, "volume": 376961 }, { "date": "2015年05月13日", "open": 17.24, "high": 17.3, "low": 17.06, "close": 17.2, "volume": 244617 }, { "date": "2015年05月14日", "open": 17.24, "high": 17.25, "low": 17.02, "close": 17.08, "volume": 252526 }, { "date": "2015年05月15日", "open": 17.06, "high": 17.16, "low": 16.95, "close": 16.95, "volume": 274783 }, { "date": "2015年05月18日", "open": 16.95, "high": 17.01, "low": 16.76, "close": 16.87, "volume": 418513 }, { "date": "2015年05月19日", "open": 16.93, "high": 16.94, "low": 16.6, "close": 16.83, "volume": 367660 }, { "date": "2015年05月20日", "open": 16.8, "high": 16.9, "low": 16.65, "close": 16.86, "volume": 297914 }, { "date": "2015年05月21日", "open": 16.9, "high": 17.08, "low": 16.79, "close": 16.88, "volume": 229346 }, { "date": "2015年05月22日", "open": 16.9, "high": 17.05, "low": 16.85, "close": 17, "volume": 253279 }, { "date": "2015年05月26日", "open": 17.03, "high": 17.08, "low": 16.86, "close": 17.01, "volume": 212640 }, { "date": "2015年05月27日", "open": 17.01, "high": 17.99, "low": 16.87, "close": 17.75, "volume": 857109 }, { "date": "2015年05月28日", "open": 17.77, "high": 17.77, "low": 17.44, "close": 17.62, "volume": 338482 } ] |
C# |
コードのコピー
|
---|---|
// GET: /RSI/ public ActionResult Index() { var model = BoxData.GetDataFromJson(); return View(model); } |
Razor |
コードのコピー
|
---|---|
@using MVCFinancialChart.Models @model List<FinanceData> <script> // XYVデータをツールチップに表示するために使用する関数。 function tooltip(ht) { var date, content; if (!ht || !ht.item) { return ''; } date = ht.item.X ? ht.item.X : null; if (wijmo.isDate(date)) { date = wijmo.Globalize.formatDate(date, 'MM/dd/yy'); } content = '<b>' + ht.name + '</b><br/>' + 'Date: ' + date + '<br/>' + 'Y: ' + wijmo.Globalize.format(ht.y, 'n2'); if (ht.item.Volume) { content += '<br/>' + 'Volume: ' + wijmo.Globalize.format(ht.item.Volume, 'n0'); } return content; } function chartRendered(sender, args) { // メインチャートに一致するように指標チャートの最小/最大を設定します。 var indicatorChart = wijmo.Control.getControl('#indicator'), chart = wijmo.Control.getControl('#financeChart'); if (chart && indicatorChart) { indicatorChart.axisX.min = chart.axisX.actualMin; indicatorChart.axisX.max = chart.axisX.actualMax; } }; </script> @(Html.C1().FinancialChart() .Id("financeChart") .Height(400) .Width(1000) .Bind(Model) .BindingX("X") .Series(sers => { sers.Add().Binding("Close").Name("BOX").Visibility(C1.Web.Mvc.Chart.SeriesVisibility.Visible); }) .Tooltip(t => t.Content("tooltip")) .OnClientRendered("chartRendered") .Legend(C1.Web.Mvc.Chart.Position.Top) ) @(Html.C1().FinancialChart() .Id("indicator") .Height(200) .Width(1000) .Bind(Model) .BindingX("X") .Series(sers => { sers.AddRSI().Binding("Close").Period(14).Name("RSI").Style(svgb => svgb.Stroke("#ffa500 ")).Visibility(C1.Web.Mvc.Chart.SeriesVisibility.Visible); }) .Tooltip(t => t.Content("tooltip")) .OnClientRendered("chartRendered") .Legend(C1.Web.Mvc.Chart.Position.Bottom) ) |