Help fixing sound and market depth on this Indicator
Created at 13 Sep 2016, 08:20
Help fixing sound and market depth on this Indicator
13 Sep 2016, 08:20
Can someone please help me fixing this 2 options
// ------- // PURPOSE // ------- // Alerts user when there is high volatility in the market over a period of seconds. // Userful signal when not looking at charts or when not at computer, configurable audible sound alerts for each currency. // Good for scalping. // Author: Paul Hayes // Date: 24/12/2015 // Version 1.5 // // Coding Guidlines: https://github.com/dotnet/corefx/wiki/Framework-Design-Guidelines-Digest // // Bug fix: display formatting issue. using System; using cAlgo.API; using cAlgo.API.Internals; using cAlgo.API.Indicators; namespace cAlgo { [Indicator(IsOverlay = true, TimeZone = TimeZones.UTC, AccessRights = AccessRights.None)] public class Alertas : Indicator { #region user defined parameters [Parameter("Alert ON", DefaultValue = true)] public bool AlertOn { get; set; } [Parameter("Sound ON", DefaultValue = true)] public bool PlaySound { get; set; } [Parameter("Volatility Pips", DefaultValue = 4, MaxValue = 20, MinValue = 1)] public int VolatilityPips { get; set; } [Parameter("Media File", DefaultValue = "C://windows//media//Alarm10")] public string MediaFile { get; set; } [Parameter("Display Position, 1-8", DefaultValue = 2, MinValue = 1, MaxValue = 3)] public int WarningPostion { get; set; } [Parameter("Warning Color", DefaultValue = "Red")] public string WarningColor { get; set; } [Parameter("Show Volatility", DefaultValue = true)] public bool ShowVolatility { get; set; } [Parameter("Show Spread", DefaultValue = true)] public bool ShowSpread { get; set; } [Parameter("Show Depth of Market", DefaultValue = true)] public bool ShowDepthOfMarket { get; set; } [Parameter("Spread Color", DefaultValue = "Yellow")] public string SpreadColor { get; set; } #endregion #region Private properties private MarketSeries mSeries; private StaticPosition position; private Colors warningTextColor; private Colors spreadTextColor; private bool errorOccured = false; private string lowerPosition = string.Empty; private MarketDepth marketDepth; #endregion const string errorMsg = "\n\n\n\n\n Scalpers Buddy Indicator: An error has occurred, view log events window for more information."; #region cTrader Events protected override void Initialize() { try { // Get the time-frame series of data mSeries = MarketData.GetSeries(Symbol, TimeFrame.Minute); warningTextColor = (Colors)Enum.Parse(typeof(Colors), WarningColor, true); spreadTextColor = (Colors)Enum.Parse(typeof(Colors), SpreadColor, true); if (ShowDepthOfMarket) { // Get Market Depth marketDepth = MarketData.GetMarketDepth(Symbol); // subscribe to event Updated marketDepth.Updated += MarketDepthUpdated; } } catch (Exception e) { errorOccured = true; Print("Scalpers Buddy: " + e.Message); } // position alert message on screen switch (WarningPostion) { case 1: position = StaticPosition.TopLeft; break; case 2: position = StaticPosition.TopCenter; break; case 3: position = StaticPosition.TopRight; break; case 4: position = StaticPosition.Right; lowerPosition = "\n\n"; break; case 5: position = StaticPosition.BottomRight; lowerPosition = "\n\n"; break; case 6: position = StaticPosition.BottomCenter; lowerPosition = "\n\n"; break; case 7: position = StaticPosition.BottomLeft; lowerPosition = "\n\n"; break; case 8: position = StaticPosition.Left; lowerPosition = "\n\n"; break; default: position = StaticPosition.TopLeft; break; } } public override void Calculate(int index) { if (errorOccured) { ChartObjects.DrawText("error-label", errorMsg, StaticPosition.TopCenter, Colors.Red); return; } // get the last highest price value double high = (mSeries.High.LastValue); // get the last lowest price value double low = (mSeries.Low.LastValue); // difference between high and low divided by the current instruments pip size = sudden movement in pips double pips = (high - low) / Symbol.PipSize; string pipsVolatility = "(Volatility: " + pips.ToString("0.00") + " pips)"; // display error message to screen. if (ShowVolatility) { ChartObjects.DrawText("volatilityMsg", pipsVolatility += lowerPosition, position, spreadTextColor); } // if pip movement > volatility setting if (Math.Ceiling(pips) > VolatilityPips) { if (AlertOn) { ChartObjects.DrawText("alertMsg", pipsVolatility, position, warningTextColor); } if (PlaySound) { if (MediaFile != string.Empty) Notifications.PlaySound(MediaFile); } } else { ChartObjects.RemoveObject("alertMsg"); } // if user wants to see the current bid/ask spread size, * feature separate from volatility alert. if (ShowSpread) { var spread = Math.Round(Symbol.Spread / Symbol.PipSize, 2); string s = string.Format("{0:N2}", spread); ChartObjects.DrawText("spreadMsg", "\nSpread: " + s, position, spreadTextColor); } } #endregion #region market depth private void MarketDepthUpdated() { double bidVolume = 0; double askVolume = 0; foreach (var entry in marketDepth.BidEntries) { double dVolume = Math.Round(entry.Volume / 1000000.0, 2); bidVolume += dVolume; } foreach (var entry in marketDepth.AskEntries) { double dVolume = Math.Round(entry.Volume / 1000000.0, 2); askVolume += dVolume; } ChartObjects.DrawText("Bid", "\n\n\nBuyers: " + bidVolume.ToString() + "m", position, Colors.DeepSkyBlue); ChartObjects.DrawText("ask", "\n\nSellers: " + askVolume.ToString() + "m", position, Colors.SeaGreen); } #endregion } }
I have tried adding the file to My Documents, but does not work,
Pepperstone market depth not working
ClickAlgo
14 Sep 2016, 07:17
Hi Serpico, the indicator can be found on the link below, please can you add your comments here so any bug reports can be centralised. I am onsure if the Market Depth feature works with Pepperstone. as for the sound, make you you have it turned on with your platform and you have set the correct path in the indicator to your media file.
/algos/indicators/show/705
@ClickAlgo