// ------------------------------------------- // ---- Notifications // ------------------------------------------- public void HandleEmailAlerts(State.Value value) { var keyName = "HKEY_CURRENT_USER\\ScreenerEmailNotificationsState"; var subkey = String.Format("{0}-{1}", value.GetKey(), this.TFrame); if (value.IsZero()) { Registry.SetValue(keyName, subkey, 0); } else { var candidate = (int)Registry.GetValue(keyName, subkey, 0); var from = "*****@*****.**"; var to = "*****@*****.**"; if ((value.Val > candidate && candidate >= 0) || (value.Val < candidate && candidate <= 0)) { Registry.SetValue(keyName, subkey, value.Val); var tradeType = value.GetTradeType().ToString(); var subject = String.Format("Trade oportunity: {0} {1} {2}/{3} - Punctuation: {4} ", value.Name, tradeType, value.Symbol, TFrame.AsString(), value.Val); Notifications.SendEmail(from, to, subject, ""); } } }
public void HandleSoundAlerts(State.Value value) { var keyName = "HKEY_CURRENT_USER\\ScreenerEmailNotificationsState"; var subkey = String.Format("{0}-SND", value.GetKey()); if (value.IsZero()) { Registry.SetValue(keyName, subkey, 0); } else { var obj = Registry.GetValue(keyName, subkey, null); Int32 candidate; if (obj == null) { candidate = 0; } else { candidate = (int)obj; } if ((value.Val > candidate && candidate >= 0) || (value.Val < candidate && candidate <= 0)) { Registry.SetValue(keyName, subkey, value.Val); Notifications.PlaySound(spaths[value.Name]); } } }
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 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); }
// ------------------------------------------- // ---- Notifications // ------------------------------------------- public void HandleEmailAlerts(State.Value value) { var keyName = "HKEY_CURRENT_USER\\ScreenerEmailNotificationsState"; var subkey = String.Format("{0}-EMAIL", value.GetKey()); if (value.IsZero()) { Registry.SetValue(keyName, subkey, 0); } else { var obj = Registry.GetValue(keyName, subkey, null); Int32 candidate; if (obj == null) { candidate = 0; } else { candidate = (int)obj; } var from = "*****@*****.**"; var to = "*****@*****.**"; if ((value.Val > candidate && candidate >= 0) || (value.Val < candidate && candidate <= 0)) { Registry.SetValue(keyName, subkey, value.Val); var tradeType = value.GetTradeType().ToString(); var tfStr = TimeFrameAsString(value.TimeFrame); var subject = String.Format("{0} trade oportunity on {1} {2} - Strategy: {3}, Points: {4} ", tradeType, tfStr, value.Symbol, value.Name, value.Val); Notifications.SendEmail(from, to, subject, ""); } } }