public override void Calculate(int index) { _symboltime = MarketSeries.OpenTime[index]; _xbrindex = _xbrseries.GetIndexByDate(_symboltime); _xtiindex = _xtiseries.GetIndexByDate(_symboltime); var xbrtime = _xbrseries.OpenTime[_xbrindex]; var xtitime = _xtiseries.OpenTime[_xtiindex]; List <DateTime> timelist = new List <DateTime>(); timelist.Add(_symboltime); timelist.Add(xbrtime); timelist.Add(xtitime); _xbrindex = _xbrseries.GetIndexByDate(timelist.Min()); _xtiindex = _xtiseries.GetIndexByDate(timelist.Min()); double xbrclose = _xbrseries.Close[_xbrindex] / _xbrsymbol.PipSize; double xticlose = _xtiseries.Close[_xtiindex] / _xtisymbol.PipSize; double newclose = (xbrclose / xticlose) / (_xbrsymbol.PipSize * _xtisymbol.PipSize); Result[index] = newclose; double sum = 0.0; for (int i = index - AveragePeriods + 1; i <= index; i++) { sum += Result[i]; } Average[index] = sum / AveragePeriods; #region Chart BarsAgo = GetBarsAgo(index); ChartObjects.DrawText("barsago", "Cross_(" + BarsAgo.ToString() + ")", StaticPosition.TopLeft, _nocorel); #endregion }
//-------------------------------------- protected override void Initialize() { _marketDepth = MarketData.GetMarketDepth(Symbol); _marketDepth.Updated += MarketDepthUpdated; foreach (var entry in _marketDepth.BidEntries) { PreviousBidList.Add(new Previouslist { Preis = entry.Price, Volumen = entry.Volume }); } foreach (var entry in _marketDepth.AskEntries) { PreviousAskList.Add(new Previouslist { Preis = entry.Price, Volumen = entry.Volume }); } FilterM = Filter * 1000000; var Table = new StringBuilder(); Table.AppendLine("Bid\tTime\tMillion\t\tAsk\tTime\tMillion"); Table.AppendLine("(Buys)\tago\tUnits\t\t(Sells)\tago\tUnits"); Table.AppendLine("----------------------------------------------------------------------------------"); ChartObjects.DrawText("Header", Table.ToString(), StaticPosition.TopLeft, (Colors)Enum.Parse(typeof(Colors), TextColor, true)); Timer.Start(UpdateFrequency); }
private void drawCircle(Fractal fractal) { if (drawCircles) { ChartObjects.DrawText(getCircleLabel(fractal), circle, fractal.index, fractal.value, VerticalAlignment.Center, HorizontalAlignment.Center, Colors.Aqua); } Fractal previous = fractal.getPreviousOfSameSide(); if (previous != null) { foreach (Fractal badFractal in fractal.getBadFractals()) { if (drawCircles) { ChartObjects.RemoveObject(getCircleLabel(badFractal)); } if (!highlightBadFractals) { ChartObjects.RemoveObject(getArrowLabel(badFractal)); } if (highlightBadFractals) { ChartObjects.DrawText(getCircleLabel(badFractal), circle, badFractal.index, badFractal.value, VerticalAlignment.Center, HorizontalAlignment.Center, Colors.Red); } } } }
public override void Calculate(int index) { if (!IsRealTime) { return; } String output = ""; var rval = atr.Result.LastValue; double ratr; if (Symbol.PipSize == 0.0001) { ratr = Math.Round(rval * 10000, 1); } else if (Symbol.PipSize == 0.01) { ratr = Math.Round(rval * 100, 1); } else { ratr = 0; } output += string.Format("TP:\t{0}\n", ratr * 2); output += string.Format("SL:\t{0}\n", ratr * 4); output += string.Format("QTY:\t{0}", GetQuantity(ratr * 4)); ChartObjects.RemoveObject("scalpinginfo"); ChartObjects.DrawText("scalpinginfo", output, StaticPosition.TopLeft, Colors.DarkGreen); }
public override void Calculate(int index) { if (!IsLastBar) { return; } ChartObjects.DrawVerticalLine("vLine", index - Period, _colorLine); int maxIndex = index; double max = Source[index]; for (int i = index - Period; i <= index; i++) { if (max >= Source[i]) { continue; } max = Source[i]; maxIndex = i; } var text = "max " + max.ToString("0.0000"); var top = VerticalAlignment.Top; var center = HorizontalAlignment.Center; ChartObjects.DrawText("max", text, maxIndex, max + 0.0002, top, center, _colorText); ChartObjects.DrawLine("line", maxIndex, max, index, Source[index], _colorLine); }
public override void Calculate(int index) { if (_incorrectColors) { var errorColor = _random.Next(2) == 0 ? Colors.Red : Colors.White; ChartObjects.DrawText("Error", "Incorrect colors", StaticPosition.Center, errorColor); return; } var open = MarketSeries.Open[index]; var high = MarketSeries.High[index]; var low = MarketSeries.Low[index]; var close = MarketSeries.Close[index]; var MA = _ma.Result[index]; MaResult[index] = MA; if (MA < close) { color = open > close ? _AboveDownColor : _AboveUpColor; } if (MA >= close) { color = open > close ? _BelowDownColor : _BelowUpColor; } ChartObjects.DrawLine("candle" + index, index, open, index, close, color, CandleWidth, LineStyle.Solid); ChartObjects.DrawLine("line" + index, index, high, index, low, color, WickWidth, LineStyle.Solid); }
public override void Calculate(int index) { if (index < count - Historical_Bars) { return; } if (FastMA.Result[index] > SlowMA.Result[index] && FastMA.Result[index - 1] < SlowMA.Result[index - 1]) { ChartObjects.DrawText("BuySignal" + index, "▲", index, MarketSeries.Low[index] - ATR.Result[index], vAlign, hAlign, Colors.Green); if (SoundAlert) { Notifications.PlaySound(SoundFile); } } if (FastMA.Result[index] < SlowMA.Result[index] && FastMA.Result[index - 1] > SlowMA.Result[index - 1]) { ChartObjects.DrawText("SellSignal" + index, "▼", index, MarketSeries.High[index] + ATR.Result[index], vAlign, hAlign, Colors.Red); if (SoundAlert) { Notifications.PlaySound(SoundFile); } } }
/// <summary> /// Display pivot value at index position /// </summary> /// <param name="index"></param> private void DrawLabels(int index) { int xValue = index; double yValue = Math.Round(_p[index], Symbol.Digits); string objectName = string.Format("P {0}", yValue); ChartObjects.DrawText(objectName, objectName, xValue, yValue, VerticalAlignment.Top, HorizontalAlignment.Center, Colors.Blue); yValue = Math.Round(_r1[index], Symbol.Digits); objectName = string.Format("R1 {0}", yValue); ChartObjects.DrawText(objectName, objectName, xValue, yValue, VerticalAlignment.Top, HorizontalAlignment.Center, Colors.Green); yValue = Math.Round(_s1[index], Symbol.Digits); objectName = string.Format("S1 {0}", yValue); ChartObjects.DrawText(objectName, objectName, xValue, yValue, VerticalAlignment.Top, HorizontalAlignment.Center, Colors.Red); yValue = Math.Round(_r2[index], Symbol.Digits); objectName = string.Format("R2 {0}", yValue); ChartObjects.DrawText(objectName, objectName, xValue, yValue, VerticalAlignment.Top, HorizontalAlignment.Center, Colors.Green); yValue = Math.Round(_s2[index], Symbol.Digits); objectName = string.Format("S2 {0}", yValue); ChartObjects.DrawText(objectName, objectName, xValue, yValue, VerticalAlignment.Top, HorizontalAlignment.Center, Colors.Red); yValue = Math.Round(_r3[index], Symbol.Digits); objectName = string.Format("R3 {0}", yValue); ChartObjects.DrawText(objectName, objectName, xValue, yValue, VerticalAlignment.Top, HorizontalAlignment.Center, Colors.Green); yValue = Math.Round(_s3[index], Symbol.Digits); objectName = string.Format("S3 {0}", yValue); ChartObjects.DrawText(objectName, objectName, xValue, yValue, VerticalAlignment.Top, HorizontalAlignment.Center, Colors.Red); }
protected override void OnStart() { state = new State(TimeFrame.Daily); lseries = new Dictionary <TimeFrame, Dictionary <string, MarketSeries> >(); rseries = new Dictionary <TimeFrame, Dictionary <string, MarketSeries> >(); lmm50 = new Dictionary <TimeFrame, Dictionary <string, ExponentialMovingAverage> >(); lmm200 = new Dictionary <TimeFrame, Dictionary <string, WeightedMovingAverage> >(); rmm200 = new Dictionary <TimeFrame, Dictionary <string, WeightedMovingAverage> >(); lmacd = new Dictionary <TimeFrame, Dictionary <string, MacdCrossOver> >(); rmacd = new Dictionary <TimeFrame, Dictionary <string, MacdCrossOver> >(); spaths = new Dictionary <string, string>(3) { { "PB", "C:\\Users\\Andrey\\Music\\Sounds\\sms-alert-1.wav" }, { "MMX", "C:\\Users\\Andrey\\Music\\Sounds\\sms-alert-4.wav" }, { "VCN", "C:\\Users\\Andrey\\Music\\Sounds\\sms-alert-3.wav" } }; Print("Initializing screener local state."); foreach (var tf in GetAllRequiredTimeFrames()) { InitializeIndicators(tf); } Print("Initialization finished."); var output = state.Render(); ChartObjects.RemoveObject("screener"); ChartObjects.DrawText("screener", output, StaticPosition.TopLeft, Colors.Black); }
public override void Calculate(int index) { var indexDaily = LTF_Series.OpenTime.GetIndexByTime(MarketSeries.OpenTime.LastValue); Result[index] = RSI.Result[index]; if (Mac.Histogram[indexDaily] > Mac.Histogram[indexDaily - 1] && EMA.Result[indexDaily] > EMA.Result[indexDaily - 1]) { if (Result[index] < OverSold) { ChartObjects.DrawText("Buy_Signal" + index, Bullet, index, 30, vAlign, hAlign, Colors.Yellow); if (SoundAlert) { Notifications.PlaySound(SoundFile); } } } if (Mac.Histogram.Last(0) < Mac.Histogram.Last(1) && EMA.Result.Last(0) < EMA.Result.Last(1)) { if (Result[index] > OverBought) { ChartObjects.DrawText("Sell_Signal" + index, Bullet, index, 70, vAlign, hAlign, Colors.Red); if (SoundAlert) { Notifications.PlaySound(SoundFile); } } } ////////////////////////////////// }
private void ReDraw() { ChartObjects.RemoveAllObjects(); foreach (Alert alert in alerts) { if (MarketSeries.OpenTime.LastValue.AddMinutes(Period()) < alert.setup) { return; } if (!alert.inArgs) { continue; } Colors color; int periods = MarketSeries.OpenTime.Count - MarketSeries.OpenTime.GetIndexByTime(alert.setup); bool crossed = MarketSeries.Close.HasCrossedAbove(alert.price, periods) || MarketSeries.Close.HasCrossedBelow(alert.price, periods); bool near = Math.Abs(MarketSeries.Close.LastValue - alert.price) <= AlertDiapasone * Symbol.PipSize; if (near && Sound && alert.played > 0 && (alert.lastPlayed == null || DateTime.UtcNow.AddMinutes(-1) >= alert.lastPlayed)) { Notifications.PlaySound(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "Ring.wav")); alert.lastPlayed = DateTime.UtcNow; --alert.played; } if (Visual && (crossed || near)) { color = Colors.Red; } else { color = Colors.CornflowerBlue; } ChartObjects.DrawText(string.Format("alert_{0}", alert.price), string.Format("| {0}{1}", alert.price, near ? string.Format(" ({0})", Math.Round(Math.Abs(MarketSeries.Close.LastValue - alert.price) / Symbol.PipSize), 1) : ""), MarketSeries.OpenTime.Count + 1, alert.price, VerticalAlignment.Center, HorizontalAlignment.Right, color); if (ContignousType == 0) { for (int j = MarketSeries.Close.Count - 1; j > 0 && alert.index == 0; --j) { if (MarketSeries.Low[j] <= alert.price && MarketSeries.High[j] >= alert.price) { alert.index = j; } } } else { alert.index = 1; } if (alert.index != 0) { ChartObjects.DrawLine(string.Format("alert_{0}_l", alert.price), alert.index, alert.price, MarketSeries.OpenTime.Count + 1, alert.price, color, Thickness, LineStyle.Dots); } } }
public override void Calculate(int index) { if (_incorrectColors) { var errorColor = _random.Next(2) == 0 ? Colors.Red : Colors.White; ChartObjects.DrawText("Error", "Incorrect colors", StaticPosition.Center, errorColor); return; } var open = MarketSeries.Open[index]; var high = MarketSeries.High[index]; var low = MarketSeries.Low[index]; var close = MarketSeries.Close[index]; var haClose = (open + high + low + close) / 4; double haOpen; if (index > 0) { haOpen = (_haOpen[index - 1] + _haClose[index - 1]) / 2; } else { haOpen = (open + close) / 2; } _haOpen[index] = haOpen; _haClose[index] = haClose; var color = haOpen > haClose ? _downColor : _upColor; //Print("", haOpen, haClose, color); ChartObjects.DrawLine("upback" + index, index, high + BackHeight / 7, index, high + BackHeight / 2, color, BackWidth, LineStyle.Solid); ChartObjects.DrawLine("downback" + index, index, low - BackHeight / 7, index, low - BackHeight / 2, color, BackWidth, LineStyle.Solid); }
protected override void OnTick() { // Put your core logic here double will = 100 + Indicators.WilliamsPctR(wPeriod).Result.Last(0); double impact = 100000 * Indicators.TrueRange(MarketSeries).Result.Last(0); var text = "Impacto: " + impact.ToString(); text += "\nWilliamsR%: " + will.ToString() + "\n Timeframe: " + MarketSeries.TimeFrame.ToString(); ChartObjects.DrawText("", text, StaticPosition.TopLeft, Colors.White); if ((will < wLow) && (impact > trImpact)) { var result = ExecuteMarketOrder(TradeType.Buy, Symbol, InitialVolume, "bot", StopLoss, TakeProfit, 2, "comentario"); if (!result.IsSuccessful) { Print("error : {0}, {1}", result.Error, InitialVolume); } } if ((will > wHigh) && (impact > trImpact)) { var result = ExecuteMarketOrder(TradeType.Sell, Symbol, InitialVolume, "bot", StopLoss, TakeProfit, 2, "comentario"); if (!result.IsSuccessful) { Print("error : {0}, {1}", result.Error, InitialVolume); } } System.Threading.Thread.Sleep(2000); }
public void draw() { ChartObjects.RemoveAllObjects(); var hAlign = HorizontalAlignment.Left; var color = Colors.White; streakTime = (int)(Server.Time - startTime).TotalMinutes; var targetEquity = startingBalance + profit; ChartObjects.DrawText("text", "Equity: " + Account.Equity + "/" + targetEquity, MarketSeries.Close.Count - 1, Symbol.Bid, VerticalAlignment.Top, hAlign, color); ChartObjects.DrawText("text2", "Time (min): " + streakTime + "/" + streakTimeavg + " | Trades: " + streakTrades + "/" + streakTradesAvg, MarketSeries.Close.Count - 1, Symbol.Bid, VerticalAlignment.Bottom, hAlign, color); var netPosition = 0.0; foreach (Position pos in this.Positions) { if (pos.TradeType == TradeType.Buy) { netPosition += pos.Volume; } else { netPosition -= pos.Volume; } } var pips = ((targetEquity - Account.Equity) / (netPosition * Symbol.PipValue)) * Symbol.PipSize; ChartObjects.DrawHorizontalLine("TP", Symbol.Bid + pips, Colors.White, 2, LineStyle.Lines); }
private void Alert(int indexChanged) { Notifications.PlaySound(_soundFile); var text = string.Format("{0} {1:MM/dd/yyyy hh:mm:ss}", Symbol.Code, MarketSeries.OpenTime[indexChanged - 1]); ChartObjects.DrawText("obj", text, StaticPosition.TopLeft, Colors.Green); }
public override void Calculate(int index) { Result[index] = _mac.Result[index]; Average[index] = _mac.Average[index]; SignalOne = GetSigOne(index); if (SignalOne == "above") { SigOne_A[index] = _mac.Result[index]; } if (SignalOne == "below") { SigOne_B[index] = _mac.Result[index]; } SignalTwo = GetSigTwo(index); if (SignalTwo != null) { SigTwo[index] = _mac.Result[index]; } #region Chart BarsAgo = _mac.BarsAgo; Mark = GetMark(index).ToString("yyyy-MM-dd") + "-" + GetMark(index).ToString("HH"); ChartObjects.DrawText("barsago", "Cross_(" + BarsAgo.ToString() + ")", StaticPosition.TopLeft, _nocorel); ChartObjects.DrawText("mark", "\nMark_(" + Mark + ")", StaticPosition.TopLeft, _nocorel); #endregion }
private void DrawRemainingTime(TimeSpan remainingTimeToNews) { if (ShowTimeLeftToNews) { if (remainingTimeToNews > TimeSpan.Zero) { ChartObjects.DrawText("countdown1", "Time left to news: " + FormatTime(remainingTimeToNews), StaticPosition.Right); } else { ChartObjects.RemoveObject("countdown1"); } } if (ShowTimeLeftToPlaceOrders) { var remainingTimeToOrders = remainingTimeToNews - TimeSpan.FromSeconds(SecondsBefore); if (remainingTimeToOrders > TimeSpan.Zero) { ChartObjects.DrawText("countdown2", "Time left to place orders: " + FormatTime(remainingTimeToOrders), StaticPosition.TopRight); } else { ChartObjects.RemoveObject("countdown2"); } } }
public override void Calculate(int index) { if (index < 1) { // If first bar is first bar of the day set open if (MarketSeries.OpenTime[index].TimeOfDay == TimeSpan.Zero) { Open[index] = MarketSeries.Open[index]; } return; } DateTime openTime = MarketSeries.OpenTime[index]; DateTime lastOpenTime = MarketSeries.OpenTime[index - 1]; const string objectName = "messageNA"; if (!ApplicableTimeFrame(openTime, lastOpenTime)) { // Display message that timeframe is N/A const string text = "TimeFrame Not Applicable. Choose a lower Timeframe"; ChartObjects.DrawText(objectName, text, StaticPosition.TopLeft, Colors.Red); return; } // If TimeFrame chosen is applicable remove N/A message ChartObjects.RemoveObject(objectName); // Plot Daily Open and Close PlotDailyOpenClose(openTime, lastOpenTime, index); }
//----------------------------------------------------------------- public override void Calculate(int index) { string Code = " "+ Convert.ToString(Symbol.Code); string Ask = "\n "+ Convert.ToString(Symbol.Ask); string Bid = "\n\n "+ Convert.ToString(Symbol.Bid); string Spread = "\n\n\n "+ Convert.ToString(Convert.ToSingle(Symbol.Spread) * 10000); string Digits = "\n\n\n\n "+ Convert.ToString(Symbol.Digits); string PipSize = "\n\n\n\n\n "+ Convert.ToString(Symbol.PipSize); ChartObjects.DrawText("Labels", "Code:" + "\n" + "Ask:" + "\n" + "Bid:" + "\n" + "Spread:" + "\n" + "Digits:" + "\n" + "PipSize:" + "\n" , StaticPosition.TopLeft, Colors.Yellow); ChartObjects.DrawText("Code", Code, StaticPosition.TopLeft, Colors.LightBlue); ChartObjects.DrawText("Ask", Ask, StaticPosition.TopLeft, Colors.LightBlue); ChartObjects.DrawText("Bid", Bid, StaticPosition.TopLeft, Colors.LightBlue); ChartObjects.DrawText("Spread", Spread, StaticPosition.TopLeft, Colors.LightBlue); ChartObjects.DrawText("Digits", Digits, StaticPosition.TopLeft, Colors.LightBlue); ChartObjects.DrawText("PipSize", PipSize, StaticPosition.TopLeft, Colors.LightBlue); }
private void plotArrow(Fractal fractal) { String arrow = fractal.isHigher() ? arrowUp : arrowDown; Colors color = getArrowColor(fractal); ChartObjects.DrawText(getArrowLabel(fractal), arrow, fractal.index, getTextPosition(fractal, 0.9), VerticalAlignment.Center, HorizontalAlignment.Center, color); }
public override void Calculate(int index) { var text = ""; foreach (var pos in Positions) { if (pos.TradeType == TradeType.Buy) { text = text + pos.Quantity + " Lot " + pos.SymbolCode + " " + pos.TradeType + " " + pos.NetProfit + "\n"; } } var name = "Open buy"; double PL = Math.Round(Account.Equity - Account.Balance); text = "P&L " + PL + " Balance " + Math.Round(Account.Balance, 2) + " Equity " + Math.Round(Account.Equity, 2) + "\n" + text; var staticPos = StaticPosition.TopLeft; var color = Colors.DodgerBlue; ChartObjects.DrawText(name, text, staticPos, color); var text1 = ""; foreach (var pos in Positions) { if (pos.TradeType == TradeType.Sell) { text1 = text1 + pos.Quantity + " Lot " + pos.SymbolCode + " " + pos.TradeType + " " + pos.NetProfit + "\n"; } } name = "Open Sell"; staticPos = StaticPosition.TopRight; var color1 = Colors.Red; ChartObjects.DrawText(name, text1, staticPos, color1); }
private void check() { DateTime?writeTime = null; lock (lockObject) { if (File.Exists(getFName())) { writeTime = File.GetLastWriteTime(getFName()); } if (lastModified == null || lastModified < writeTime) { ChartObjects.RemoveAllObjects(); alerts.Clear(); if (!load() || !parse()) { ChartObjects.DrawText("AlertsErrorMessage", string.Format("Alerts\n{0}", lastError), StaticPosition.TopRight, Colors.Red); } else { if (lastModified == null) { save(); } } } lastModified = writeTime; } }
public override void Calculate(int index) { if (index == 0) { return; } bool dailyCondition = TimeFrame < TimeFrame.Hour12; if (dailyCondition) { calculateDailyPivots(index); } else { ChartObjects.DrawText("message", "Choose TF < H 12", StaticPosition.TopCenter, Colors.Red); } if (MarketSeries.OpenTime[index].DayOfWeek == DayOfWeek.Saturday || MarketSeries.OpenTime[index].DayOfWeek == DayOfWeek.Sunday) { // overwrite weekend values p[index] = double.NaN; r1[index] = double.NaN; r2[index] = double.NaN; r3[index] = double.NaN; s1[index] = double.NaN; s2[index] = double.NaN; s3[index] = double.NaN; } }
protected override void OnBar() { // PB Signals if (EnablePB) { foreach (var tf in ParseTimeFrames(PBTimeFrames)) { foreach (var sym in symbols) { var timing = CalculateMarketTiming(sym, tf); var val = GetPBSignal(sym, tf, timing); var value = new State.Value("PB", sym, tf, timing, val); state.Update(value); if (EnableEmailAlerts) { HandleEmailAlerts(value); } if (EnableSoundAlerts) { HandleSoundAlerts(value); } } } } // MMX Signals if (EnableMMX) { foreach (var tf in ParseTimeFrames(MMXTimeFrames)) { foreach (var sym in symbols) { var timing = CalculateMarketTiming(sym, tf); var val = GetMMXSignal(sym, tf, timing); var value = new State.Value("MMX", sym, tf, timing, val); state.Update(value); if (EnableEmailAlerts) { HandleEmailAlerts(value); } if (EnableSoundAlerts) { HandleSoundAlerts(value); } } } } var output = state.Render(); ChartObjects.RemoveObject("screener"); ChartObjects.DrawText("screener", output, StaticPosition.TopLeft, Colors.Black); }
protected override void Initialize() { // Summary YesterdayKeyLevels = Business.KeyLevels.GetYesterdaysKeyLevels(Account.BrokerName, Symbol.Code); if (YesterdayKeyLevels != null) { YesterdayKeyLevels.CalculateDaily(); // Write Summary string Summary = Symbol.Code.ToString() + ": Yesterday's (" + YesterdayKeyLevels.Date.ToShortDateString() + ") Open: " + YesterdayKeyLevels.Open.ToString() + ", Close: " + YesterdayKeyLevels.Close.ToString() + ", High: " + YesterdayKeyLevels.High.ToString() + ", Low: " + YesterdayKeyLevels.Low.ToString(); ChartObjects.DrawText("Previous", Summary, StaticPosition.BottomRight, Colors.Red); // Calculate ATR var ATRSeries = MarketData.GetSeries(TimeFrame.Daily); AverageTrueRange ATR = Indicators.AverageTrueRange(ATRSeries, 5, MovingAverageType.Simple); ChartObjects.DrawText("ATR", "ATR: " + ATR.Result.LastValue.ToString("0.##") + ", 15% ATR: " + (ATR.Result.LastValue * 0.15).ToString("0.##") + ",30% ATR: " + (ATR.Result.LastValue * 0.3).ToString("0.##") + "", StaticPosition.TopRight, Colors.Red); // DAILY // ChartObjects.DrawHorizontalLine("DailyHigh", YesterdayKeyLevels.High, Colors.Green, 1, LineStyle.LinesDots); // ChartObjects.DrawHorizontalLine("DailyLow", YesterdayKeyLevels.Low, Colors.Green, 1, LineStyle.LinesDots); // ChartObjects.DrawHorizontalLine("DailyCLose", YesterdayKeyLevels.Close, Colors.Green, 1, LineStyle.LinesDots); // Daily Levels P = ((YesterdayKeyLevels.High + YesterdayKeyLevels.Low + YesterdayKeyLevels.Close) / 3); R1 = ((2 * P) - YesterdayKeyLevels.Low); R2 = (P + YesterdayKeyLevels.High - YesterdayKeyLevels.Low); R3 = (YesterdayKeyLevels.High + 2 * (P - YesterdayKeyLevels.Low)); S1 = ((2 * P) - YesterdayKeyLevels.High); S2 = (P - YesterdayKeyLevels.High + YesterdayKeyLevels.Low); S3 = YesterdayKeyLevels.Low - 2 * (YesterdayKeyLevels.High - P); CBOL = ((YesterdayKeyLevels.High - YesterdayKeyLevels.Low) * 1.1 / 2 + YesterdayKeyLevels.Close); CBOS = YesterdayKeyLevels.Close - (YesterdayKeyLevels.High - YesterdayKeyLevels.Low) * 1.1 / 2; //WP = ((WeeklyHigh + WeeklyLow + WeeklyClose) / 3); //MP = ((MonthlyHigh + MonthlyLow + MonthlyClose) / 3); // WEEKLY // ChartObjects.DrawHorizontalLine("WeeklyHigh", WeeklyHigh, Colors.Green, 1, LineStyle.Lines); //ChartObjects.DrawHorizontalLine("WeeklyLow", WeeklyLow, Colors.Red, 1, LineStyle.Lines); // ChartObjects.DrawHorizontalLine("WeeklyClose", WeeklyClose, Colors.DeepSkyBlue, 1, LineStyle.LinesDots); // MONTHLY //ChartObjects.DrawHorizontalLine("MonthlyHigh", MonthlyHigh, Colors.Green, 3, LineStyle.Lines); //ChartObjects.DrawHorizontalLine("MonthlyLow", MonthlyLow, Colors.Red, 3, LineStyle.Lines); // ChartObjects.DrawHorizontalLine("MonthlyClose", MonthlyClose, Colors.DarkGray, 1, LineStyle.LinesDots); } }
private void GetMaxDrawDown() { peak = Math.Max(peak, Account.Balance); drawdown.Add((peak - Account.Balance) / peak * 100); drawdown.Sort(); mDrawdown = drawdown[drawdown.Count - 1]; ChartObjects.DrawText("show DD", "MaxDrawdown: " + Math.Round(mDrawdown, 2) + " Percent", corner_position); }
private void DisplaySpreadOnChart() { var spread = Math.Round(Symbol.Spread / Symbol.PipSize, 2); string text = string.Format("{0}", spread); ChartObjects.DrawText("Label", "Spread:", StaticPosition.TopLeft, Colors.Yellow); ChartObjects.DrawText("spread", "\t" + text, StaticPosition.TopLeft, Colors.White); }
public override void Calculate(int index) { DataSeries ds; double lowPrice = double.MaxValue; for (int i = 0; i < numBars; i++) { if (MarketSeries.Low.Last(i) < lowPrice) { lowPrice = MarketSeries.Low.Last(i); } } totalColor = Colors.White; int[,] values = new int[numBars, scores.Length + 1]; //MarketSeries currentSeries = MarketSeries. for (int bar = 0; bar < numBars; bar++) { for (int i = 0; i < timeframes.Length; i++) { ds = MarketData.GetSeries(timeframes[i]).Open; int convertedIndex = MarketData.GetSeries(timeframes[i]).OpenTime.GetIndexByTime(MarketData.GetSeries(this.TimeFrame).OpenTime[index - bar]); WMAsmall = Indicators.MovingAverage(ds, WMAsmallnum, MAType); WMAbig = Indicators.MovingAverage(ds, WMAbignum, MAType); if (WMAsmall.Result[convertedIndex] > WMAbig.Result[convertedIndex]) { values[bar, scores.Length] += scores[i]; values[bar, i] = scores[i]; totalColor = Colors.Green; } else { values[bar, scores.Length] -= scores[i]; values[bar, i] = -1 * scores[i]; totalColor = Colors.Red; } ChartObjects.DrawText("ScoreValue" + bar + "" + i, "■", index - bar, lowPrice - i * scale * Symbol.PipSize, VerticalAlignment.Bottom, HorizontalAlignment.Center, totalColor); if (bar == numBars - 1) { totalColor = getColor(values[0, i], false); ChartObjects.DrawText("Labels" + bar + "" + i, timeStrings[i], index + 1, lowPrice - i * scale * Symbol.PipSize, VerticalAlignment.Bottom, HorizontalAlignment.Center, totalColor); } if (i == timeframes.Length - 1) { totalColor = getColor(values[bar, scores.Length], true); ChartObjects.DrawText("FinalScoreValue" + bar + "" + i, "" + values[bar, scores.Length], index - bar, lowPrice - (i + 1) * scale * Symbol.PipSize, VerticalAlignment.Bottom, HorizontalAlignment.Center, totalColor); if (bar == numBars - 1) { totalColor = getColor(values[0, scores.Length], true); ChartObjects.DrawText("ScoreLabel" + bar + "" + i, "#", index + 1, lowPrice - (i + 1) * scale * Symbol.PipSize, VerticalAlignment.Bottom, HorizontalAlignment.Center, totalColor); } } } } }
/// <summary> /// Executes every tick. Put your core logic here. /// </summary> protected override void OnTick() { // Ticks are 100-ns intervals elapsed since January 1, 0001 at 00:00:00.000 in the Gregorian calendar. DateTime serverTime = Server.Time; using (NpgsqlCommand cmd = new NpgsqlCommand()) { cmd.Connection = dbConn; cmd.CommandText = "INSERT INTO " + dbSchema + "." + Symbol.Code + " (utc, tick, ask, bid, spread) VALUES (:utc, :tick, :ask, :bid, :spread)"; cmd.Parameters.AddWithValue(":utc", NpgsqlTypes.NpgsqlDbType.Timestamp, serverTime.ToString("yyyy-MM-dd HH:mm:ss.fff")); cmd.Parameters.AddWithValue(":tick", serverTime.Ticks); cmd.Parameters.AddWithValue(":ask", Symbol.Ask); cmd.Parameters.AddWithValue(":bid", Symbol.Bid); cmd.Parameters.AddWithValue(":spread", Symbol.Spread); cmd.ExecuteNonQuery(); } // // -- ON SCREEN DIAGNOSTICS -- // // Index of the last/newest bar on chart int barLast = MarketSeries.OpenTime.GetIndexByTime(MarketSeries.OpenTime.LastValue); ChartObjects.DrawText("barLast", (barLast).ToString(), barLast, MarketSeries.High.LastValue + 0.0001); // Diagnostic text ++diagTicks; if (diagTicks >= 4) { diagTicks = 0; } char ctick; switch (diagTicks) { case 0: ctick = '-'; break; case 1: ctick = '\\'; break; case 2: ctick = '|'; break; case 3: ctick = '/'; break; default: ctick = '.'; break; } string msg = diagTicks.ToString() + " " + ctick + Environment.NewLine; msg = msg + Symbol.Code + ">" + " Ask: " + Symbol.Ask.ToString("0.00000") + " Bid: " + Symbol.Bid.ToString("0.00000") + " Spread: " + Symbol.Spread.ToString("0.00000") + Environment.NewLine; ChartObjects.DrawText("diaginfo", msg, StaticPosition.TopLeft); }
protected override void OnBar() { foreach (var sym in symbols) { var timing = CalculateMarketTiming(sym); if (EnablePB) { var val = GetPBSignal(sym, timing); var value = new State.Value("PB", sym, timing, val); state.Update(value); if (EnableEmailAlerts) { HandleEmailAlerts(value); } if (EnableSoundAlerts) { HandleSoundAlerts(value); } } //if (EnableAcc) { // var val = GetAccSignal(sym, timing); // var value = new State.Value("ACC", sym, timing, val); // state.Update(value); // if (EnableEmailAlerts) { // HandleEmailAlerts(value); // } // if (EnableSoundAlerts) { // HandleSoundAlerts(value); // } //} //if (EnableVcn) { // var val = GetVcnSignal(sym, timing); // var value = new State.Value("VCN", sym, timing, val); // state.Update(value); // if (EnableEmailAlerts) { // HandleEmailAlerts(value); // } // if (EnableSoundAlerts) { // HandleSoundAlerts(value); // } //} } var output = state.Render(); ChartObjects.RemoveObject("screener"); ChartObjects.DrawText("screener", output, StaticPosition.TopLeft, Colors.Black); }