ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

Main Area and Open Discussion > General Software Discussion

Fractal Trading Indicator

<< < (2/3) > >>

Renegade:
The second screenshot there has the sound code in it. Can you attach it here and post a link to the relevant documentation?

It looks like it may already have the necessary functionality in it, and that only needs to be enabled.

You can also try using this in the spot where you want to play the sound.


--- Code: C# ---System.Media.SoundPlayer myPlayer = new System.Media.SoundPlayer();myPlayer.SoundLocation = @"c:\some-sound-file.wav";myPlayer.Play();
However, make certain to replace "c:\some-sound-file.wav" with the proper path to the WAV file that you want to play. It MUST be a WAV file though. You cannot use MP3s or anything else.

Niceperson:
Thanks for your quick reply.

I added the code lines. These are highlighted on the attached screenshot.

No sound.

The sound file used by me is good file because I can hear it when clicked directly.

Any help will be much appreciated.

Renegade:
Try copying the wave file to another location under "My Documents" then try that. (In case there's a permissions problem.)

Next, if that doesn't work, remove the code I had there before and insert this:


--- Code: C# ---PlaySound(@"C:\mySound.wav");
From: http://www.ninjatrader.com/support/helpGuides/nt7/index.html?playsound.htm

Fix the path there as well.

If you post the code itself rather than a screenshot, that makes it easier. (e.g. I'd like to see what's in the "using" directives.)

Niceperson:
The code is pasted below with the ' Using ' directives'. I have highlighted in RED the Play sound line code for easy reading.

The sound comes on each tick not on alert triangle. It is required only when the alert conditions are met.


-----------------------------------------------------------------------------------------------------------



--- Code: C# ---#region Using declarationsusing System;using System.Diagnostics;using System.Drawing;using System.Drawing.Drawing2D;using System.ComponentModel;using System.Xml.Serialization;using NinjaTrader.Cbi;using NinjaTrader.Data;using NinjaTrader.Gui.Chart;#endregion namespace NinjaTrader.Indicator{    [Description("")]    [Gui.Design.DisplayName("FractalPivot (TradeStation)")]    public class FractalPivot_TradeStation : Indicator    {        #region Variables                private int pLeftStrength = 2;                private int pRightStrength = 2;                private int pTickSeparation = 3;        #endregion                                         protected override void Initialize()        {                        Add(new Plot(new Pen(Color.Red,12), PlotStyle.TriangleDown, "Highs"));                                                          Add(new Plot(new Pen(Color.Blue,12), PlotStyle.TriangleUp, "Lows"));                                                            CalculateOnBarClose     = false;            Overlay                             = true;            PriceTypeSupported  = false;        }         protected override void OnBarUpdate()        {                        if(CurrentBar < Math.Max((pLeftStrength+pRightStrength)*3,15))                                return;                         if(pType == FractalPivot_TradeStation_Type.Both || pType == FractalPivot_TradeStation_Type.Highs) {                                int bar = (int)Pivot_EasyLanguage(1, 1, pLeftStrength, pRightStrength+1, pRightStrength).PivotBarRelative[0];                                                                if(bar>=0) Values[0].Set(pRightStrength, High[pRightStrength]+TickSize * pTickSeparation);                                                                PlaySound(@"C:\Program Files\NinjaTrader 7\sounds\Alert4.wav");                                                                                        }                        if(pType == FractalPivot_TradeStation_Type.Both || pType == FractalPivot_TradeStation_Type.Lows) {                                int bar = (int)Pivot_EasyLanguage(-1, 1, pLeftStrength, pRightStrength+1, pRightStrength).PivotBarRelative[0];                                                                if(bar>=0) Values[1].Set(pRightStrength, Low[pRightStrength]-TickSize * pTickSeparation);                                                        }        }

skwire:
@Niceperson: I added code tags around your code snippet for readability.
@Renegade: Line 47 was the red coloured line before I added the code tags.

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version