Im trying to create an indicator which gives out a sound alert at the first bar tick after a MA crossover.
When i write it, i have to "compile" it to finish it right?
Im using two variable moving averages (a slow one with MAperiod and typeint parameters 150, 4 and a fast one with 30, 4)
Ive coded a lot but when im compiling the indicator it always gives me an error.
Here's what i got so far:
#region Variables
// Wizard generated variables
private int myInput0 = 1; // Default setting for MyInput0
// User defined variables (add any user defined variables below)
#endregion
private bool soundOn = true; // on/off switch for audio alerts
private string alert1Sound = "long.wav"; //audio alert for Condition1
private string alert2Sound ="short.wav"; //audio alert for Condition2
private bool Condition1 = CrossAbove(MAV(30,30,4), MAV(150,150,4));//will be set to the conditions for alert1
private bool Condition2 = CrossBelow(MAV(30,30,4), MAV(150,150,4)); //will be set to the conditions for alert2
(Are the bool statements above well written? are they in the right space? I didnt know what to put in the MAV parameters since i only know 2 and it requires 3... the MAV im using is the NT standart)
/// <summary>
/// Called on each bar update event (incoming tick)
/// </summary>
protected override void OnBarUpdate()
{
if (Condition1 && soundOn && FirstTickOfBar) PlaySound(alert1Sound);
if (Condition2 && soundOn && FirstTickOfBar) PlaySound(alert2Sound);
}
#region Properties
[Browsable(false)] // this line prevents the data series from being displayed in the indicator properties dialog, do not remove
[XmlIgnore()] // this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
public DataSeries Plot0
{
get { return Values[0]; }
}
[Description("")]
[Category("Parameters")]
public int MyInput0
{
get { return myInput0; }
set { myInput0 = Math.Max(1, value); }
}
#endregion
}
[Description("what will help the user decide how to choose their entry")]
[Category("Parameters")]
public string LongSound (it gives me an error right here, saying something's wrong with this line)
{
get { return alert1Sound; } // this name matches that in the Variables section
set { alert1Sound = value; }
}
[Description("what will help the user decide how to choose their entry ")]
[Category("Parameters")]
class string ShortSound (and this line)
{
get { return alert2Sound; } // this name matches that in the Variables section
set { alert2Sound = value; }
}
}
You can cut out anything you find to be wrong or useless..
Thanks a lot to anyone who can give me a hand
Comment