//=========================================================================================================== // Show MP //----------------------------------------------------------------------------------------------------------- protected void showMP(BarHistory bars, string mpFile) { Dictionary <int, string> markers = new Dictionary <int, string>(); string prevMp = ""; string[] lines = System.IO.File.ReadAllLines(mpFile); foreach (string line in lines) { // 1/3/17,R,,5,9,d // 3/31/17,P,d,6,5, // 3/29/18,C,,x,x, string[] columns = line.Split(','); if (columns.Length < 6) { continue; } var dateStr = columns[0].Trim(); var mp = columns[1].Trim(); if (mp == "") { continue; } // If mp is not changing, then don't do anything if (mp == prevMp) { continue; } // There is mp change, so try to get bar and save in the map DateTime d = DateTime.Parse(dateStr); int mpBar = bars.IndexOf(d, true); if (mpBar < 0) { continue; } markers[mpBar] = mp; prevMp = mp; } foreach (KeyValuePair <int, string> entry in markers) { string mp = entry.Value; int idx = entry.Key; if (mp == "R") { //DrawDot(idx, bars.Low[idx] * 0.98, Color.FromArgb(160, 0, 255, 0), 5); DrawBarAnnotation("⬤", idx, false, Color.FromArgb(180, 0, 255, 0), 14, true); } else if (mp == "C") { //DrawDot(idx, bars.Low[idx] * 0.98, Color.FromArgb(160, 255, 0, 0), 5); DrawBarAnnotation("⬤", idx, false, Color.FromArgb(200, 255, 0, 0), 14, true); } else { //DrawDot(idx, bars.Low[idx] * 0.98, Color.FromArgb(160, 255, 127, 80), 5); DrawBarAnnotation("⬤", idx, false, Color.FromArgb(200, 245, 176, 65), 14, true); } } DrawHeaderText("⬤ - Market Pulse"); }
//=========================================================================================================== // Show Woo //----------------------------------------------------------------------------------------------------------- protected void showWoo(BarHistory bars, string wooFile) { Dictionary <int, string> markers = new Dictionary <int, string>(); string prevWoo = ""; string[] lines = System.IO.File.ReadAllLines(wooFile); foreach (string line in lines) { // 3/14/17,WOO // 4/14/17, // 7/6/17,Correction string[] columns = line.Split(','); if (columns.Length < 2) { continue; } var dateStr = columns[0].Trim(); var woo = columns[1].Trim(); if (woo == "") { continue; } // If woo is not changing, then don't do anything if (woo == prevWoo) { continue; } // There is woo change, so try to get bar and save in the map DateTime d = DateTime.Parse(dateStr); int wooBar = bars.IndexOf(d, true); if (wooBar < 0) { continue; } markers[wooBar] = woo; prevWoo = woo; } foreach (KeyValuePair <int, string> entry in markers) { string woo = entry.Value; int idx = entry.Key; if (woo == "WOO") { DrawBarAnnotation("▲", entry.Key, false, Color.FromArgb(160, 0, 255, 0), 14, true); } else { DrawBarAnnotation("▲", entry.Key, false, Color.FromArgb(160, 255, 0, 0), 14, true); } } DrawHeaderText("▲ - WOO"); }
protected void showTradesOnIndexChart(BarHistory bars, string tradeFile) { string[] lines = System.IO.File.ReadAllLines(tradeFile); foreach (string line in lines) { // 1/2/18,3/12/18,ABMD,B1,105,closed,191.28,290.53,"20,084","30,506","10,421",52%,50,5.19% string[] columns = line.Split(','); //PrintDebug(line); var symbol = columns[2]; var label = columns[3]; if (label == "B1") { // Buy var buyDateStr = columns[0]; if (buyDateStr != "") { DateTime d = DateTime.Parse(buyDateStr); int buyBar = bars.IndexOf(d, true); if (buyBar > 0) { var gainPct = columns[11]; //DrawBarAnnotation2(symbol + "\n" + gainPct, buyBar, false); addTradeAnnotation(bars, buyBar, symbol + "\n" + gainPct, 2, 2); // Draw a short line in the bar in the middle double buyPrice = (bars.High[buyBar] + bars.Low[buyBar]) / 2; int nextBar = buyBar + 1; if (buyBar == bars.Count + bars.ExtendedBars - 1) { nextBar = buyBar; // Make sure the index is within the limit } DrawLine(buyBar - 1, buyPrice, nextBar, buyPrice, Color.Orange, 3); } } } } DrawAllTradeAnnotations(); }
//=========================================================================================================== // Show Trades //----------------------------------------------------------------------------------------------------------- protected void showTrades(BarHistory bars, string tradeFile) { ClearAllAnnotations(); if (bars.Symbol == this.settings.SP500 || bars.Symbol == this.settings.NASDAQ || bars.Symbol == "1EQUITY") { showTradesOnIndexChart(bars, tradeFile); return; } string[] lines = System.IO.File.ReadAllLines(tradeFile); foreach (string line in lines) { // 1/2/18,3/12/18,ABMD,B1,105,closed,191.28,290.53,"20,084","30,506","10,421",52%,50,5.19% string[] columns = line.Split(','); //PrintDebug(line); var symbol = columns[2]; if (symbol == bars.Symbol) { var label = columns[3]; // Buy var buyDateStr = columns[0]; if (buyDateStr != "") { DateTime d = DateTime.Parse(buyDateStr); int buyBar = bars.IndexOf(d, true); if (buyBar > 0) { double buyPrice = Double.Parse(columns[6]); DrawBarAnnotation2(label, buyBar, true); int nextBar = buyBar + 1; if (buyBar == bars.Count + bars.ExtendedBars - 1) { nextBar = buyBar; // Make sure the index is within the limit } DrawLine(buyBar - 1, buyPrice, nextBar, buyPrice, Color.Orange, 3); // If it is B1, then draw the pivot point and 25% target if (label == "B1") { var pivotPrice = Highest.Value(buyBar, bars.High, 26 * 5); var pivotBar = (int)bars.High.GetHighestBar(buyBar, 26 * 5); var targetPrice = pivotPrice * 1.25; DrawLine(pivotBar, pivotPrice, bars.Count - 1, pivotPrice, Color.Orange, 1); DrawLine(pivotBar, targetPrice, bars.Count - 1, targetPrice, Color.Orange, 1); // Find breakout day var breakoutBar = -1; for (int i = pivotBar + 1; i < bars.Count - 1; i++) { if (bars.High[i] > pivotPrice) { breakoutBar = i; break; } } if (breakoutBar != -1) { SetBackgroundColor(bars, breakoutBar, Color.FromArgb(15, Color.Blue)); var timeGoalBar = breakoutBar + 40; if (timeGoalBar < bars.Count) { SetBackgroundColor(bars, timeGoalBar, Color.FromArgb(15, Color.Blue)); } } } } } // Sell var sellDateStr = columns[1]; if (sellDateStr != "") { DateTime d = DateTime.Parse(sellDateStr); int sellBar = bars.IndexOf(d, true); WriteToDebugLog("sellDateStr = " + sellDateStr); WriteToDebugLog("d = " + d); WriteToDebugLog("sellBar = " + sellBar); if (sellBar > 0) { double sellPrice = Double.Parse(columns[7]); DrawBarAnnotation2(label, sellBar, false); int nextBar = sellBar + 1; if (sellBar == bars.Count + bars.ExtendedBars - 1) { nextBar = sellBar; // Make sure the index is within the limit } DrawLine(sellBar - 1, sellPrice, nextBar, sellPrice, Color.Brown, 3); } } } } DrawAllAnnotationsAtEnd(Color.FromArgb(255, 211, 84, 0), Color.Brown, 14); }