programming question

 

sorry for asking a simple question in this forum, where complex programming is discussed by experts as well or even mainly.


I tried to program a simple indicator which uses an alert when the current price level is x pips away from a given entry(or price) level

for example in the sense of:

Extern double E; //Entrylevel
Extern double distance; // distance from entry level

f((Bid - E)> Distance))
PlaySound("sound.wav");

or as a variation (USDCHF):

f((Bid - E)> 0.0005)) //distance replaced by number
PlaySound("sound.wav");

now
with this programming the alert reacts all the time, no matter what distance is entered?!

Should I use some function like "Point" or what is my (probably) basic mistake?


And another question: how can I program this alert (as soon as it works properly with the parameter "distance") to just sound once (triggered by a tick and then staying silent)

 

Replace

f((Bid - E)> Distance))
to

if(MathAbs(Bid - E)> Distance)

 
fxnew:

sorry for asking a simple question in this forum, where complex programming is discussed by experts as well or even mainly.


I tried to program a simple indicator which uses an alert when the current price level is x pips away from a given entry(or price) level

for example in the sense of:

Extern double E; //Entrylevel
Extern double distance; // distance from entry level

f((Bid - E)> Distance))
PlaySound("sound.wav");

or as a variation (USDCHF):

f((Bid - E)> 0.0005)) //distance replaced by number
PlaySound("sound.wav");

now
with this programming the alert reacts all the time, no matter what distance is entered?!

Should I use some function like "Point" or what is my (probably) basic mistake?


And another question: how can I program this alert (as soon as it works properly with the parameter "distance") to just sound once (triggered by a tick and then staying silent)

Hi,

Don't be shy to ask, I think we will all have or had a question one day.

Your programming seems to ne ok (if the 'f' means 'if'). Of course you can use Point if you want your distance to be express in pips:

if Distance = 5, you willhave to code: if(Bid - E > Distance*Point) Play...

The alert react all the time : yes of course, if price is above E of 5 pips or more but not when it is below. Right?

To have the sound only once, I use a flag: a boolean, lets say : bool alert1 = true;

then I set it to false after the Playsound command.

Don't forget to set it back to true, when it is (for example) below E, or whatever the requirement of your treatment.

Like that for example:

bool alert1 = true;

... (program lines)

if (Bid - E > Distance*Point)

{if (alert1)

{PlaySound("sound.wav");

alert1 = false;

}

}

else

alert1 = true;

Reason: